Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught Error: Class 'YahnisElsts\PluginUpdateChecker\v5p1\DebugBar\Panel' not found #543

Open
daigo75 opened this issue Oct 20, 2023 · 11 comments

Comments

@daigo75
Copy link

daigo75 commented Oct 20, 2023

I came across the error on two sites that were running the Query Monitor plugin. I couldn't reproduce the error on my development servers, but I was able to fetched the call stack from the sites:

Fatal error: Uncaught Error: Class 'YahnisElsts\PluginUpdateChecker\v5p1\DebugBar\Panel' not found in /var/www/clients/client1/web2/web/wp-content/plugins/wc-aelia-foundation-classes/src/vendor/yahniselsts/plugin-update-checker/Puc/v5p1/DebugBar/PluginPanel.php on line 8
Call stack:
include() wp-content/plugins/wc-aelia-foundation-classes/src/vendor/yahnis-elsts/plugin-updatechecker/Puc/v5p1/Autoloader.php:80
YahnisElsts\P\v\Autoloader::autoload() spl_autoload_call() wp-content/plugins/wc-aelia-foundation-classes/src/vendor/yahnis-elsts/plugin-updatechecker/Puc/v5p1/DebugBar/Extension.php:40
YahnisElsts\P\v\D\Extension::addDebugBarPanel() wp-includes/class-wp-hook.php:310
WP_Hook::apply_filters() wp-includes/plugin.php:205
apply_filters() wp-content/plugins/query-monitor/classes/debug_bar.php:53
Debug_Bar::init_panels() wp-content/plugins/query-monitor/classes/debug_bar.php:18
Debug_Bar::__construct() wp-content/plugins/query-monitor/collectors/debug_bar.php:77
register_qm_collectors_debug_bar() wp-includes/class-wp-hook.php:310
WP_Hook::apply_filters() wp-includes/class-wp-hook.php:334
WP_Hook::do_action() wp-includes/plugin.php:517
do_action() wp-settings.php:632
require_once() wp-config.php:176
require_once() wp-load.php:50
require_once() wp-admin/admin.php:34
require_once() wp-admin/index.php:10

The "wc-aelia-foundation-classes" is my plugin, which loads the library. It's not doing anything in this scenario phase, it just looks like the events triggered by the Query Monitor are intercepted by the update checker, which can't find one of the classes, for some reason.

@YahnisElsts
Copy link
Owner

YahnisElsts commented Oct 20, 2023

It looks like Query Monitor attempts to emulate the Debug Bar plugin when that plugin isn't active. PUC has limited Debug Bar integration, so under certain conditions, it adds a callback to the debug_bar_panels filter that QM calls here:
Debug_Bar::init_panels() wp-content/plugins/query-monitor/classes/debug_bar.php:53

During that, PUC tries to load some classes related to the Debug Bar. Which apparently doesn't work because the Debug_Bar_Panel class doesn't exist. I think this probably happens because QM autoloads its version of Debug_Bar_Panel, and PUC specifically disables autoloading for the relevant class_exists() check.

However, I can't figure out what scenario could actually lead to that chain of events. You need a situation where the Debug_Bar class already exists but Debug_Bar_Panel does not. Maybe something else makes QM load Debug_Bar earlier than usual? Do any of the other plugins on those sites use Debug Bar? Their tabs might also show up in QM.

@daigo75
Copy link
Author

daigo75 commented Oct 20, 2023

Unfortunately, I don't have any other information about the issue. The affected sites, both of which threw the error between yesterday and today, belong to clients, but I don't have access to them, due to data protection policies. Neither client is tech savvy, nor do they have a person who can provide technical details, therefore we're still at a preliminary investigation level, at least until someone can provide more details about the conditions that cause the issue.

YahnisElsts added a commit that referenced this issue Oct 20, 2023
…ing a fatal error in the unusual situation where `Debug_Bar` exists and `Debug_Bar_Panel` does not.

This should never happen with the Debug Bar plugin itself. However, it's apparently possible if Query Monitor is involved. See #543
@YahnisElsts
Copy link
Owner

Well, I have an idea about how the error can be avoided, but I don't have a way to verify if it will actually work since I can't reproduce the error. And if you don't have access to the sites, you might not be able to verify the fix either.

If you'd like to try it anyway, switch from version 5.1 of PUC to what's currently in the master branch.

@daigo75
Copy link
Author

daigo75 commented Oct 20, 2023

I would be happy to try the master branch, but I wasn't able to reproduce the error myself, either. Due to that, there's no way of knowing if the fix will work.

I will ask the clients if they could grant access to a staging site for testing. If they agree, I will report back here. If not, I will have to wait until I get the chance to run the test.

@JiveDig
Copy link

JiveDig commented Oct 20, 2023

Noting I hit the same error this morning. Deactivated Query Monitor via WP-CLI so I could access the Dashboard.

CleanShot 2023-10-20 at 12 10 12@2x

@daigo75
Copy link
Author

daigo75 commented Oct 27, 2023

@YahnisElsts Just a quick update. Another user reported the same error. Unfortunately, I couldn't get access to a staging site (they are all very strict with the access), so I couldn't test the proposed fix. If there's going to be a new version coming soon, please let me know and I will update my plugins too.

@YahnisElsts
Copy link
Owner

I could create a new release pretty easily, but I'm a bit reluctant to do that when I don't know if the fix actually works.

@JiveDig
Copy link

JiveDig commented Oct 27, 2023

@YahnisElsts What's the best way to test (if I hit it again)? Do I run the develop branch, or just change that line manually in my plugin on the site with issues?

@YahnisElsts
Copy link
Owner

I think either would work. Changing the line yourself might be slightly safer because the repository could (at some point) include other, unrelated changes.

@daigo75
Copy link
Author

daigo75 commented Nov 8, 2023

@YahnisElsts I prepared a build of my plugin that includes the proposed changes, then asked some of my customers to try it on their sites. After installing the update, the error went away. It reappeared shortly after, due to the presence of another plugin (Admin Menu Editor Pro) which includes the "old", unpatched version of the Plugin Update Checker library, but that is a further confirmation that the patched version works.

@YahnisElsts
Copy link
Owner

All right, I've made a new release, version 5.3. I will also update Admin Menu Editor Pro sometime this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants