Custom Fields
Re-Envisioned
Support MB User Meta PHP Notice: Trying to get property ‘id’ of non-object

  • Creator
    Topic
  • #18947
    Resolved Drake Cooper
    Participant

    Hi,
    I’m creating Gutenberg blocks using MB Blocks and Builder. Whenever I click on a block to edit it, I get this PHP error in the log. It only happens when MB User Meta or MB User Profile is enabled.

    [09-Apr-2020 19:05:09 UTC] PHP Notice:  Trying to get property 'id' of non-object in /var/www/wordpress.stock2/public/content/plugins/meta-box-aio/vendor/meta-box/mb-user-meta/src/DuplicatedFields.php on line 31
    [09-Apr-2020 19:05:09 UTC] PHP Stack trace:
    [09-Apr-2020 19:05:09 UTC] PHP   1. {main}() /var/www/wordpress.stock2/public/wp/wp-admin/admin-ajax.php:0
    [09-Apr-2020 19:05:09 UTC] PHP   2. do_action() /var/www/wordpress.stock2/public/wp/wp-admin/admin-ajax.php:175
    [09-Apr-2020 19:05:09 UTC] PHP   3. WP_Hook->do_action() /var/www/wordpress.stock2/public/wp/wp-includes/plugin.php:478
    [09-Apr-2020 19:05:09 UTC] PHP   4. WP_Hook->apply_filters() /var/www/wordpress.stock2/public/wp/wp-includes/class-wp-hook.php:311
    [09-Apr-2020 19:05:09 UTC] PHP   5. MBBlocks\MetaBox->fetch() /var/www/wordpress.stock2/public/wp/wp-includes/class-wp-hook.php:287
    [09-Apr-2020 19:05:09 UTC] PHP   6. MBBlocks\MetaBox->show() /var/www/wordpress.stock2/public/content/plugins/meta-box-aio/vendor/meta-box/mb-blocks/src/MetaBox.php:87
    [09-Apr-2020 19:05:09 UTC] PHP   7. RWMB_Field::call() /var/www/wordpress.stock2/public/content/plugins/meta-box/inc/meta-box.php:259
    [09-Apr-2020 19:05:09 UTC] PHP   8. RWMB_Field::show() /var/www/wordpress.stock2/public/content/plugins/meta-box/inc/field.php:593
    [09-Apr-2020 19:05:09 UTC] PHP   9. RWMB_Field::filter() /var/www/wordpress.stock2/public/content/plugins/meta-box/inc/field.php:71
    [09-Apr-2020 19:05:09 UTC] PHP  10. apply_filters_ref_array() /var/www/wordpress.stock2/public/content/plugins/meta-box/inc/field.php:628
    [09-Apr-2020 19:05:09 UTC] PHP  11. WP_Hook->apply_filters() /var/www/wordpress.stock2/public/wp/wp-includes/plugin.php:249
    [09-Apr-2020 19:05:09 UTC] PHP  12. MBUM\DuplicatedFields->remove_field() /var/www/wordpress.stock2/public/wp/wp-includes/class-wp-hook.php:289
    

    Using Firefox 75, WP 5.4, MetaBox 5.2.8, MetaBox AIO 1.11.2.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #18958
    Long Nguyen
    Moderator

    Hi Drake,

    Something goes wrong with the function get_current_screen() and it does not return a screen object which always has the property id.

    Please try to edit the file /wp-content/plugins/metabox-meta-box-aio/vendor/meta-box/mb-user-meta/src/DuplicatedFields.php and check the object $screen on line 31, the code should be

    $screen = get_current_screen();
    if( ! is_object( $screen ) ) {
        return $html;
    }

    Then clear the log and edit the block again. Let me know how it goes.

    #18975
    Drake Cooper
    Participant

    That fixes the error.
    Thanks!

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