Skip to:
Content

BuddyPress.org

Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#8414 closed defect (bug) (fixed)

Tools > "Repair site tracking site icons" generates PHP Fatal error when not on Multisite

Reported by: slaFFik Owned by: slaffik
Milestone: 7.1.0 Priority: normal
Severity: normal Version: 7.0.0
Component: Blogs Keywords: has-patch commit
Cc:

Description

If you open Tools > BuddyPress page in /wp-admin/tools.php?page=bp-tools and try to run "Repair site tracking site icons/blog avatars synchronization." operation while NOT being on WP Multisite - the action will generate a fatal error:

PHP Fatal error:  Uncaught Error: Call to undefined function get_sites() in trunk\wp-content\plugins\buddypress\src\bp-core\admin\bp-core-admin-tools.php:337
Stack trace:
#0 trunk\wp-content\plugins\buddypress\src\bp-core\admin\bp-core-admin-tools.php(83): bp_admin_repair_blog_site_icons()
#1 trunk\wp-includes\class-wp-hook.php(287): bp_admin_repair_handler()
#2 trunk\wp-includes\class-wp-hook.php(311): WP_Hook->apply_filters()
#3 trunk\wp-includes\plugin.php(484): WP_Hook->do_action()
#4 trunk\wp-admin\includes\menu.php(155): do_action()
#5 trunk\wp-admin\menu.php(327): require_once('C:\\OpenServer\\d...')
#6 trunk\wp-admin\admin.php(158): require('C:\\OpenServer\\d...')
#7 trunk\wp-admin\tools.php(40): require_once('C:\\OpenServer\\d...')
#8 {main}
  thrown in trunk\wp-content\plugins\buddypress\src\bp-core\admin\bp-core-admin-tools.php on line 337

It looks like this was introduced in BP 7 (see #8384).

Multisite-related operation "Repopulate site tracking records." works fine because it uses a function bp_blogs_record_existing_blogs() which does all the proper is_multisite() checks.
And bp_admin_repair_blog_site_icons() used in a failing operation calls get_sites() directly without safety checks first.

Attachments (2)

8414.patch​ (872 bytes) - added by slaFFik 6 months ago.
8414.1.patch​ (1.2 KB) - added by slaFFik 6 months ago.

Download all attachments as: .zip

Change History (9)

@slaFFik
6 months ago

#1 @slaFFik
6 months ago

  • Keywords has-patch added

I've attached a patch that implements the easiest solution to this problem - on non-MS site display a "Failed" message, similar to bp_admin_repair_blog_records() function.
We could add get_sites() function into our bp-core-wpabstraction.php file, but I do think this would be a bad idea.

#2 @imath
6 months ago

  • Milestone changed from Awaiting Review to 7.1.0

Thanks for catching this issue and for the patch @slaFFik πŸ‘Œ. I believe we should only include this tool for Multisite configs.

Last edited 6 months ago by imath (previous) (diff)

#3 @slaFFik
6 months ago

In this case, I suggest to leave the improvement I made in the 1st patch, but also hide the checkbox completely if not on Multisite. So direct call to a function will return an expected array with a "Failed" text, but by default, the checkbox won't be displayed on the Tools page at all on a regular WP installation. Sounds good?

@slaFFik
6 months ago

#4 @imath
6 months ago

  • Keywords commit added

Sounds good πŸ‘Œ Let’s have this in πŸ˜‰

This ticket was mentioned in ​Slack in #buddypress by imath. ​View the logs.


6 months ago

#6 @slaffik
6 months ago

  • Owner set to slaffik
  • Resolution set to fixed
  • Status changed from new to closed

In 12826:

Tools: add WP MultiSite checks for "Repair site tracking site icons" operation

On regular sites checking and running the "Repair site tracking site icons" operation on the Tools > BuddyPress page generates a fatal error due to the get_sites() function usage, which is MultiSite specific. So, hide the operation on non-multisite and properly return an error when ran directly.

Fixes #8414 (Trunk)

#7 @slaffik
6 months ago

In 12827:

Tools: add WP MultiSite checks for "Repair site tracking site icons" operation

On regular sites checking and running the "Repair site tracking site icons" operation on the Tools > BuddyPress page generates a fatal error due to the get_sites() function usage, which is MultiSite specific. So, hide the operation on non-multisite and properly return an error when ran directly.

See #8414 (Branch 7.0)

Note: See TracTickets for help on using tickets.