Plugin Conflict Causing Critical Error
-
Hi, I have an oddball critical error I’m hoping you can help me with. Here’s the rundown:
I’m rebuilding a massive site with multiple departments contributing content. To provide some degree of sanity managing the thousands of attachments, I registered a taxonomy named ‘folder’ for pages (other post types are using different filing methods that will not work for pages). Each page is assigned a term from this taxonomy, and the term’s slug (sanitized, natch) serves as an uploads directory subfolder name.
This custom path is set by a function that hooks into the upload_dir filter.
A few weeks ago after a Smush update the pages (only) started experiencing critical errors if you try to open them in WP Admin to edit them. The information from the error log:
PHP Fatal error: Uncaught Error: Cannot use object of type WP_Error as array in /nas/content/live/mysite/wp-content/plugins/my-plugin/inc/common-media.php:319\n Stack trace:\n#0 /nas/content/live/mysite/wp-content/plugins/my-plugin/inc/common-media.php(279): my_pluginset_page_subdir(8)\n#1 /nas/content/live/mysite/wp-includes/class-wp-hook.php(307): my_pluginset_upload_dir(Array)\n#2 /nas/content/live/mysite/wp-includes/plugin.php(191): WP_Hook->apply_filters(Array, Array)\n#3 /nas/content/live/mysite/wp-includes/functions.php(2362): apply_filters('upload_dir', Array)\n#4 /nas/content/live/mysite/wp-includes/functions.php(2297): wp_upload_dir(NULL, false)\n#5 /nas/content/live/mysite/wp-content/plugins/wp-smushit/core/class-helper.php(62): wp_get_upload_dir()\n#6 /nas/content/live/mysite/wp-content/plugins/wp-smushit/core/class-core.php(222): Smush\\Core\\Helper::logger()\n#7 /nas/content/live/mysite/wp-includes/class-wp-hook.php(307): Smush\\Core\\Core->load_libs('')\n#8 /nas/content/live/mysite/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)\n#9 /nas/content/live/mysite/wp-includes/plugin.php(476): WP_Hook->do_action(Array)\n#10 /nas/content/live/mysite/wp-settings.php(461): do_action('plugins_loaded')\n#11 /nas/content/live/mysite/wp-config.php(128): require_once('/nas/content/li...')\n#12 /nas/content/live/mysite/wp-load.php(50): require_once('/nas/content/li...')\n#13 /nas/content/live/mysite/wp-admin/admin.php(34): require_once('/nas/content/li...')\n#14 /nas/content/live/mysite/wp-admin/post.php(12): require_once('/nas/content/li...')\n#15 {main}\n thrown in /nas/content/live/mysite/wp-content/plugins/my-plugin/inc/common-media.php on line 319, referer: https://mysite.wpengine.com/wp-admin/edit.php?post_type=page
The line of code leading to the error is:
$folders = wp_get_post_terms( $post_id, ‘folder’ );
Instead of returning the term information, this is now returning:
O:8:”WP_Error”:3:{s:6:”errors”;a:1:{s:16:”invalid_taxonomy”;a:1:{i:0;s:17:”Invalid taxonomy.”;}}s:10:”error_data”;a:0:{}s:18:”, referer: https://[site-redacted]/wp-admin/post.php?post=9645&action=edit&lang=en
I added error handling by making sure the $folders value is an array before working with it, but I need to fix the underlying problem that I can no longer retrieve the terms for the folder taxonomy.
Deactivating Smush fixes the problem immediately. I wish I could remember if this started after updates in June or July, but I truly do not remember. My code had been in place since last November, and we have had no problems until the summer updates of Smush.
Any help you can provide will be greatly appreciated. I love Smush and would prefer to keep it on the site.
- The topic ‘Plugin Conflict Causing Critical Error’ is closed to new replies.