bobbingwide / fizzie

Fizzie theme - a Full Site Editing theme using Gutenberg blocks
9 stars 1 forks source link

Replace `core/query-loop` with `core/post-template` to avoid Warnings in the Site Editor #73

Closed bobbingwide closed 1 year ago

bobbingwide commented 2 years ago

This is not actually an issue with the Fizzie theme.

It's a problem that occurs when using the Site Editor when updating any theme and site contents that were created using earlier versions of Gutenberg.

I'm also getting a number of Warnings in the Site Editor.

Warning: Block core/query-loop has been renamed to Post Template. core/query-loop will be supported until WordPress version 5.9. in C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat\wordpress-5.8\index.php on line 123

Explanation

These messages occur during admin_enqueue_scripts. The stack trace below shows the post that contains the query-loop block but it's not immediately obvious why the post that contains this content is being processed to find its excerpt, nor which post it is. It's all to do with some logic I can't fully explain inside gutenberg_initialize_editor() involving $preload_data, which is then enqueued inline for use by wp.apiFetch.

$preload_data = array_reduce(
        $preload_paths,
        'rest_preload_api_request',
        array()
    ); 

Workaround

C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php(285:2) bw_trace_error_handler(2) 334 2 2022-01-06T08:36:42+00:00 1.900843 0.000660 cf=admin_enqueue_scripts,the_content 39989 115 72 12582912/14680064 256M F=621 err Array

[0] => (integer) 512
[1] => (string) "User Warning: Block core/query-loop has been renamed to Post Template. core/query-loop will be supported until WordPress version 5.9."
[2] => (string) "C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat\wordpress-5.8\index.php"
[3] => (integer) 123
  1. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\libs\bwtrace.php:108 0
  2. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:292 0
  3. bw_trace_error_handler(512,Block core/query-loop has been renamed to Post Template. core/query-loop will be supported until WordPress version 5.9.,C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat\wordpress-5.8\index.php,123) C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:0 4
  4. trigger_error(Block core/query-loop has been renamed to Post Template. core/query-loop will be supported until WordPress version 5.9.,512) C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat\wordpress-5.8\index.php:123 2
  5. gutenberg_render_legacy_query_loop_block(array,,object) C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat.php:132 3
  6. {closure}(array,,object) C:\apache\htdocs\wp55\wp-includes\class-wp-block.php:255 3
  7. render C:\apache\htdocs\wp55\wp-includes\class-wp-block.php:241 0
  8. render C:\apache\htdocs\wp55\wp-includes\blocks.php:883 0
  9. render_block(array) C:\apache\htdocs\wp55\wp-includes\blocks.php:921 1
  10. do_blocks(

    In this example we use the Query block to display some posts with both their content and excerpts, side by side.

) C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:307 1 10. apply_filters(

In this example we use the Query block to display some posts with both their content and excerpts, side by side.

,array) C:\apache\htdocs\wp55\wp-includes\plugin.php:189 2 11. apply_filters(the_content,

In this example we use the Query block to display some posts with both their content and excerpts, side by side.

) C:\apache\htdocs\wp55\wp-includes\rest-api\endpoints\class-wp-rest-posts-controller.php:1811 2 12. prepare_item_for_response(object,object) C:\apache\htdocs\wp55\wp-includes\rest-api\endpoints\class-wp-rest-posts-controller.php:377 2 13. get_items(object) C:\apache\htdocs\wp55\wp-includes\rest-api\class-wp-rest-server.php:1141 1 14. respond_to_request(object,/wp/v2/posts,array,unsupported) C:\apache\htdocs\wp55\wp-includes\rest-api\class-wp-rest-server.php:988 4 15. dispatch(object) C:\apache\htdocs\wp55\wp-includes\rest-api.php:511 1 16. rest_do_request(object) C:\apache\htdocs\wp55\wp-includes\rest-api.php:2860 1 17. rest_preload_api_request(array,/wp/v2/posts?context=edit) C:\apache\htdocs\wp55\wp-includes\rest-api.php:0 2 18. array_reduce(array,rest_preload_api_request,array) C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\editor-settings.php:76 3 19. gutenberg_initialize_editor(edit_site_editor,edit-site,array) C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\full-site-editing\edit-site-page.php:164 3 20. gutenberg_edit_site_init(appearance_page_gutenberg-edit-site) C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:307 1 21. apply_filters(unsupported,array) C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:331 2 22. do_action(array) C:\apache\htdocs\wp55\wp-includes\plugin.php:474 1 23. do_action(admin_enqueue_scripts,appearance_page_gutenberg-edit-site) C:\apache\htdocs\wp55\wp-admin\admin-header.php:118 2 24. require_once(C:\apache\htdocs\wp55\wp-admin\admin-header.php) C:\apache\htdocs\wp55\wp-admin\admin.php:239 1 25. require_once(C:\apache\htdocs\wp55\wp-admin\admin.php) C:\apache\htdocs\wp55\wp-admin\themes.php:10 1 _Originally posted by @bobbingwide in https://github.com/bobbingwide/fizzie/issues/72#issuecomment-1006388053_
bobbingwide commented 1 year ago

Fixed in changes for #70 ?