Support Forum
Support › MB User Meta › PHP Notice: Trying to get property 'id' of non-objectResolved
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.
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.
That fixes the error.
Thanks!
Experienced the same issue here.
The website was super slow on the Ajax Requests from MB Blocks.
I applied the correction mentioned in DuplicatedFields.php
and also in UserFields.php (line 37).
After this the website was normal again.
Will this patch be on the next update?
I want to be sure that those 2 modifications won't be overwritten next time with the plugin update.
Thanks
Hi Pascal,
Thank you for your feedback.
I've informed the development team to fix this issue. It will be included in the next update.