Open bobbingwide opened 1 year ago
Having disabled the block's code I found I needed to rename several blocks created as oik-testimonials/acf-field
to acf-field/acf-field
.
During the update I didn't notice that I needed to change the name
attribute as well.
Where I had
<!-- wp:acf-field/acf-field {"name":"oik-testimonials/acf-field","
data":{"acf-field-name":"text_area","_acf-field-name":"field_645f589a88304"},"mode":"preview"} /-->
the name
attribute should have been "acf-field/acf-field".
This user error, made using the code editor, caused ACF PRO to produce a Fatal error when attempting to edit the post.
[11-Jul-2023 11:45:12 UTC] PHP Warning: Trying to access array offset on value of type bool in C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\pro\blocks.php on line 556
[11-Jul-2023 11:45:12 UTC] PHP Fatal error: Uncaught TypeError: key(): Argument #1 ($array) must be of type array, null given in C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\includes\local-meta.php:81
Stack trace:
#0 C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\includes\local-meta.php(81): key(NULL)
#1 C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\includes\local-meta.php(53): ACF_Local_Meta->is_request(NULL)
#2 C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\includes\local-meta.php(240): ACF_Local_Meta->add(NULL, NULL, true)
#3 C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\pro\blocks.php(556): acf_setup_meta(NULL, NULL, true)
#4 C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\pro\blocks.php(502): acf_rendered_block(Array, '', true, 173, Object(WP_Block))
#5 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(258): acf_render_block_callback(Array, '', Object(WP_Block))
#6 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(244): WP_Block->render()
#7 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(244): WP_Block->render()
#8 C:\apache\htdocs\wp55\wp-includes\blocks.php(1072): WP_Block->render()
#9 C:\apache\htdocs\wp55\wp-includes\blocks.php(1110): render_block(Array)
#10 C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php(308): do_blocks('<!-- wp:paragra...')
#11 C:\apache\htdocs\wp55\wp-includes\plugin.php(205): WP_Hook->apply_filters('<!-- wp:paragra...', Array)
#12 C:\apache\htdocs\wp55\wp-includes\rest-api\endpoints\class-wp-rest-posts-controller.php(1860): apply_filters('the_content', '<!-- wp:paragra...')
#13 C:\apache\htdocs\wp55\wp-includes\rest-api\endpoints\class-wp-rest-posts-controller.php(569): WP_REST_Posts_Controller->prepare_item_for_response(Object(WP_Post), Object(WP_REST_Request))
#14 C:\apache\htdocs\wp55\wp-includes\rest-api\class-wp-rest-server.php(1181): WP_REST_Posts_Controller->get_item(Object(WP_REST_Request))
#15 C:\apache\htdocs\wp55\wp-includes\rest-api\class-wp-rest-server.php(1028): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/oik_test...', Array, NULL)
#16 C:\apache\htdocs\wp55\wp-includes\rest-api.php(535): WP_REST_Server->dispatch(Object(WP_REST_Request))
#17 C:\apache\htdocs\wp55\wp-includes\rest-api.php(2889): rest_do_request(Object(WP_REST_Request))
#18 [internal function]: rest_preload_api_request(Array, '/wp/v2/oik_test...')
#19 C:\apache\htdocs\wp55\wp-includes\block-editor.php(634): array_reduce(Array, 'rest_preload_ap...', Array)
#20 C:\apache\htdocs\wp55\wp-admin\edit-form-blocks.php(77): block_editor_rest_api_preload(Array, Object(WP_Block_Editor_Context))
#21 C:\apache\htdocs\wp55\wp-admin\post.php(187): require('C:\\apache\\htdoc...')
#22 {main}
thrown in C:\apache\htdocs\wordpress\wp-content\plugins\advanced-custom-fields-pro\includes\local-meta.php on line 81
The logic in acf_prepare_block()
, called from line 555, can return false
if there's no block name or there's no block type with the given name. ACF PRO doesn't check for this and subsequently fatals within acf_setup_meta()
.
Note: The problem occurs when editing the post after a successful Update in both Code and Visual editor modes.
Now that the acf-field-block plugin has been developed it's time to disable the generic field block logic in oik-testimonials.
Part of the reasoning is in https://github.com/bobbingwide/oik-testimonials/issues/7#issuecomment-1630590520