Latest plugin update throws fatal error

Support › Meta Box AIO › Latest plugin update throws fatal error

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #50200
    FabianFabian
    Participant

    Hello,

    The latest MB AIO update causes this fatal error on a client site:

    [STDERR] PHP Fatal error: Uncaught TypeError: RWMB_Helpers_String::sanitize_id(): Argument #1 ($id) must be of type string, null given, called in /home/xxx/public_html/wp-content/plugins/meta-box-aio/vendor/meta-box/meta-box/inc/meta-box.php on line 327 and defined in /home/xxx/public_html/wp-content/plugins/meta-box-aio/vendor/meta-box/meta-box/inc/helpers/string.php:23

    #50203
    PeterPeter
    Moderator

    Hello Fabian,

    Thank you for reaching out.

    This is a very weird issue. It looks like a field group (meta box) on the site is registered with null id. For example:

    add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
        $meta_boxes[] = [
            'title'      => 'Event details',
            'post_types' => 'post',
            'id'         => null, // this causes the error
            'fields'     => [
                ...
            ],
        ];
    
        return $meta_boxes;
    } );
    

    Can you please recheck all the field groups registered on the site if one has null ID?

    #50204
    FabianFabian
    Participant

    Hi Peter,

    Thanks for looking into this. Yes, I can confirm there is a field group which explicitly defines 'id' => null (no idea how that happened). Correcting it now would probably break the site though. Since things were working fine still up until the last update, I suppose the new version has tightened the signature for sanitize_id(). I realize that this code is technically invalid, since individual field IDs are required. But Meta Box becoming fatal after an update would still warrant better defensive handling I think.

    #50209
    PeterPeter
    Moderator

    Hello,

    Thanks for your feedback.

    I will inform the development team to improve the code to prevent the fatal error from happening again. Let me know if you have any questions.

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