#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)
Change History (9)
#2
@
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.
#3
@
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?
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 ourbp-core-wpabstraction.php
file, but I do think this would be a bad idea.