Hi @ansibansi,
Thanks for reporting this. Could you share the steps to reproduce the issue? If you have an error log, that would also be helpful.
Thanks,
Phi
I’m still in the process finding out what went wrong. I just got a message from my wp that editing a cpt caused this error (removed url specifric data), so its happening post_edit:
Ein Fehler vom Typ E_ERROR wurde in der Zeile 662 der Datei httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php verursacht. Fehlermeldung: Uncaught Error: Object of class WP_Error could not be converted to string in httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php:662
Stack trace:
#0 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(662): sprintf()
#1 [internal function]: MetaFieldBlock\MBFields->MetaFieldBlock\{closure}()
#2 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(657): array_map()
#3 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(321): MetaFieldBlock\MBFields->format_field_taxonomy()
#4 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(300): MetaFieldBlock\MBFields->render_mb_field()
#5 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(223): MetaFieldBlock\MBFields->render_field()
#6 httpdocs/wp-includes/class-wp-hook.php(324): MetaFieldBlock\MBFields->format_value_for_rest()
#7 httpdocs/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#8 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(198): apply_filters()
#9 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(151): MetaFieldBlock\MBFields->normalize_group_value()
#10 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(137): MetaFieldBlock\MBFields->normalize_value()
#11 httpdocs/wp-content/plugins/display-a-meta-field-as-block/includes/mb-fields.php(108): MetaFieldBlock\MBFields->get_rest_values()
#12 httpdocs/wp-includes/rest-api/endpoints/class-wp-rest-controller.php(439): MetaFieldBlock\MBFields->get_rest_field()
#13 httpdocs/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(2098): WP_REST_Controller->add_additional_fields_to_object()
#14 httpdocs/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(655): WP_REST_Posts_Controller->prepare_item_for_response()
#15 httpdocs/wp-includes/rest-api/class-wp-rest-server.php(1292): WP_REST_Posts_Controller->get_item()
#16 httpdocs/wp-includes/rest-api/class-wp-rest-server.php(1125): WP_REST_Server->respond_to_request()
#17 httpdocs/wp-includes/rest-api.php(586): WP_REST_Server->dispatch()
#18 httpdocs/wp-includes/rest-api.php(2973): rest_do_request()
#19 [internal function]: rest_preload_api_request()
#20 httpdocs/wp-includes/block-editor.php(754): array_reduce()
#21 httpdocs/wp-admin/edit-form-blocks.php(114): block_editor_rest_api_preload()
#22 httpdocs/wp-admin/post.php(187): require('/var/www/vhosts...')
#23 {main}
thrown
I have then checked my hooks, disabled them temporarily and they didnt have an influence. Tinkered a bit with trying to catch the error but replacing term with term_object did solve the problem without me understanding why.
Shared Hosting, no further error log :/
-
This reply was modified 10 months, 2 weeks ago by
ansibansi.
@ansibansi Thank you for the details. What is the version of MFB on your site?
@ansibansi It’s a weird issue. get_term returns a valid WP_Term object, while get_term_link returns a WP_Error with the same term_id. Is there any change the term is not publicly queryalbe? I couldn’t reproduce it on my end, but I’ll keep trying. If I still can’t, I’ll go with your fix and use term_object in the next version.
Thats what I thought: Weird.
Doesnt really make sense from my pov, too. Especially in the backend. I am currently looking into my plugin code to see what could have happened the issue, I have a hook for post_type_link, that appends a query arg, but I would have expected to see my plugin in the trace then.
@ansibansi According to the official documentation for get_term_link we should always check the result of this function in case the term does not exist. So I will make sure to do that.
If you find anything interesting about the issue, feel free to share it with me.