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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #40460
    Steven KwokSteven Kwok
    Participant

    Dear 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 upstream

    Any ideas on how to resolve it? Thanks!

    #40465
    PeterPeter
    Moderator

    Hello 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.

    #40491
    Steven KwokSteven Kwok
    Participant

    Hi 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 );
    }
    #40498
    PeterPeter
    Moderator

    Hello,

    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.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.