Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#8414 closed defect (bug) (fixed)

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

Reported by: slaffik's profile slaFFik Owned by: slaffik's profile 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 4 years ago.
8414.1.patch​ (1.2 KB) - added by slaFFik 4 years ago.

Download all attachments as: .zip

Change History (9)

@slaFFik
4 years ago

#1 @slaFFik
4 years 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
4 years 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 4 years ago by imath (previous) (diff)

#3 @slaFFik
4 years 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
4 years ago

#4 @imath
4 years ago

  • Keywords commit added

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

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


4 years ago

#6 @slaffik
4 years 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
4 years 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.