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: "Class "MultipleAuthors\WP_Error" not found" #1971

Open
claudiulodro opened this issue Jan 9, 2025 · 1 comment
Open

Fatal error: "Class "MultipleAuthors\WP_Error" not found" #1971

claudiulodro opened this issue Jan 9, 2025 · 1 comment

Comments

@claudiulodro
Copy link

Expected Behavior

Current Behavior

The Plugin class is namespaced under the MultipleAuthors namespace. When the cache is flushed, if there is an error finding a co-author, a new WP_Error is returned. Since the WP_Error is not namespaced, the site crashes with a fatal error:

[09-Jan-2025 18:50:49 UTC] PHP Fatal error:  Uncaught Error: Class "MultipleAuthors\WP_Error" not found in /srv/htdocs/wp-content/plugins/publishpress-authors/src/core/Plugin.php:896
Stack trace:
#0 /wordpress/core/6.7.1/wp-includes/class-wp-hook.php(324): MultipleAuthors\Plugin->action_edited_term_taxonomy_flush_cache(475, 'author')
#1 /wordpress/core/6.7.1/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#2 /wordpress/core/6.7.1/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#3 /wordpress/core/6.7.1/wp-includes/taxonomy.php(4180): do_action('edited_term_tax...', 475, 'author')
#4 /wordpress/core/6.7.1/wp-includes/taxonomy.php(3578): _update_post_term_count(Array, Object(WP_Taxonomy))
#5 /wordpress/core/6.7.1/wp-includes/taxonomy.php(3550): wp_update_term_count_now(Array, Object(WP_Taxonomy))
#6 /wordpress/core/6.7.1/wp-includes/post.php(8082): wp_update_term_count(Array, 'author')
...

Possible Solution

Simple fix! :) Change that line to return new \WP_Error(...

Steps to Reproduce (for bugs)

In theory you can reproduce it by calling:

$tt_id = 12345; // Some author term ID that doesn't exist.
$plugin->action_edited_term_taxonomy_flush_cache( $tt_id, 'author' );

If you're trying to reproduce it on a live site and not just in code, it looks like you need to add this filter to trigger the flush

Context

When removing multi-authors from posts, clients were reporting that the Save crashed with an "Updating failed" error and authors did not get removed.

Screen Shot 2025-01-09 at 1 00 41 PM

Your Environment

  • Version used: 4.7.3
  • Browser Name and version: n/a
  • Operating System and version (desktop or mobile): n/a
  • Link to your project: n/a
@stevejburge
Copy link
Member

Thanks for reporting this in detail, @claudiulodro. We'll take a close look

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

No branches or pull requests

2 participants