MB Custom Post Type causes PHP Fatal error after upgrading to PHP 8.0
Support › MB Custom Post Type › MB Custom Post Type causes PHP Fatal error after upgrading to PHP 8.0
- This topic has 3 replies, 2 voices, and was last updated 2 years, 2 months ago by
Peter.
-
AuthorPosts
-
February 9, 2023 at 9:09 AM #40460
Steven Kwok
ParticipantDear support team,
As my hosting provider automatically upgraded my plan to PHP 8.0, I cannot access my dashboard.
I tried to deactivate all my plugins and activate them one by one to figure out which one causes the issue. I found that when I only activate the MB Custom Post Type plugin, this issue occurs. Related PHP logs are as follows:
PHP message: PHP Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /www/site/public/wp-includes/media.php:3721
Stack trace:
#0 /www/site/public/wp-includes/media.php(3721): strpos(Array, 'attachment:')
#1 /www/site/public/wp-admin/menu.php(71): get_taxonomies_for_attachments('objects')
#2 /www/site/public/wp-admin/admin.php(158): require('/www/jewelrytal...')
#3 /www/site/public/wp-admin/index.php(10): require_once('/www/jewelrytal...')
#4 {main}
thrown in /www/site/public/wp-includes/media.php on line 3721" while reading response header from upstreamAny ideas on how to resolve it? Thanks!
February 9, 2023 at 10:14 PM #40465Peter
ModeratorHello Steven,
Please try to deactivate all plugins except Meta Box and MB extensions, switch to a standard theme of WordPress and check this issue again. If the issue persists, please copy your site to a staging site then share the credentials to this contact form https://metabox.io/contact/, I will take a closer look.
February 11, 2023 at 9:06 PM #40491Steven Kwok
ParticipantHi Peter,
Thanks for your reply.
Yes, I tried to deactivate all plugins except the Meta Box base and MB Custom Post Type plugins. This issue persists.
As the error.log shows (I pasted the snippet below):
PHP message: PHP Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in /www/site/public/wp-includes/media.php:3721 Stack trace: #0 /www/site/public/wp-includes/media.php(3721): strpos(Array, 'attachment:') #1 /www/site/public/wp-admin/menu.php(71): get_taxonomies_for_attachments('objects') #2 /www/site/public/wp-admin/admin.php(158): require('/www/site...') #3 /www/site/public/wp-admin/index.php(10): require_once('/www/site...') #4 {main} thrown in /www/site/public/wp-includes/media.php on line 3721" while reading response header from upstream
The first argument of the strpos function receives an array which may be unacceptable in PHP 8.0. So tried to add the code before the strpos function in the media.php file. Then the warning message does not show again.
if( gettype( $object_type ) == 'array' ){ $object_type = implode( "", $object_type ); }
February 13, 2023 at 7:16 AM #40498Peter
ModeratorHello,
Thanks for sharing the solution.
Instead of modifying the source code of WordPress directly, please try to go to the admin area > Dashboard > Updates > Update WordPress to the latest version 6.1.1 or re-install it.
Let me know how it goes.
-
AuthorPosts
- You must be logged in to reply to this topic.