Footnotes block completely breaks Block Editor causing page to be uneditable #53970
Labels
[Block] Footnotes
Affects the Footnotes Block
[Status] Duplicate
Used to indicate that a current issue matches an existing one and can be closed
[Type] Bug
An existing feature does not function as intended
Description
I added a Footnotes block to my page and added a couple of Footnotes.
I then deleted the Footnotes block as I wanted to see if I was still able to add Footnotes (using the More option on the Block Toolbar). To my surprise, it automatically re-added the Footnotes block to the bottom of my page.
I then clicked the 'back' icon within the Footnotes block, next to the newly inserted (blank) footnote, went back to where the Footnote was inserted and removed it.
The Block Editor then completely broke and I am now unable to edit this page. If I try to edit the page, I'm shown the standard WordPress Critical Error message. If I try to view the page in the browser, no content displays. With Debug turned on, I'm shown a Fatal Error. (see below)
If I try to edit the page I get this Fatal Error:
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks/footnotes.php:37 Stack trace: #0 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/class-wp-block.php(258): render_block_core_footnotes(Array, '', Object(WP_Block)) #1 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks.php(1133): WP_Block->render() #2 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks.php(1171): render_block(Array) #3 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/class-wp-hook.php(310): do_blocks('<!-- wp:heading...') #4 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/plugin.php(205): WP_Hook->apply_filters('<!-- wp:heading...', Array) #5 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1864): apply_filters('the_content', '<!-- wp:heading...') #6 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/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)) #7 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/rest-api/class-wp-rest-server.php(1188): WP_REST_Posts_Controller->get_item(Object(WP_REST_Request)) #8 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/rest-api/class-wp-rest-server.php(1035): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/pages/(?...', Array, NULL) #9 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/rest-api.php(545): WP_REST_Server->dispatch(Object(WP_REST_Request)) #10 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/rest-api.php(2911): rest_do_request(Object(WP_REST_Request)) #11 [internal function]: rest_preload_api_request(Array, '/wp/v2/pages/29...') #12 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/block-editor.php(743): array_reduce(Array, 'rest_preload_ap...', Array) #13 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-admin/edit-form-blocks.php(77): block_editor_rest_api_preload(Array, Object(WP_Block_Editor_Context)) #14 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-admin/post.php(187): require('/Users/anthonyh...') #15 {main} thrown in /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks/footnotes.php on line 37
With debug turned on, I'm shown this Fatal Error when trying to view the page in the browser: (it's worth noting that I didn't save the page after removing the Footnotes Block, so the auto-save has completely stopped the previously saved page content from showing)
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks/footnotes.php:37 Stack trace: #0 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/class-wp-block.php(258): render_block_core_footnotes(Array, '', Object(WP_Block)) #1 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks.php(1133): WP_Block->render() #2 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks.php(1171): render_block(Array) #3 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/class-wp-hook.php(310): do_blocks('<!-- wp:heading...') #4 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/plugin.php(205): WP_Hook->apply_filters('<!-- wp:heading...', Array) #5 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/post-template.php(256): apply_filters('the_content', '<!-- wp:heading...') #6 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-content/themes/twentytwentyone/template-parts/content/content-page.php(29): the_content() #7 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/template.php(787): require('/Users/anthonyh...') #8 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/template.php(720): load_template('/Users/anthonyh...', false, Array) #9 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/general-template.php(206): locate_template(Array, true, false, Array) #10 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-content/themes/twentytwentyone-child/page.php(14): get_template_part('template-parts/...') #11 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/template-loader.php(106): include('/Users/anthonyh...') #12 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-blog-header.php(19): require_once('/Users/anthonyh...') #13 /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/index.php(17): require('/Users/anthonyh...') #14 {main} thrown in /Users/anthonyhortin/Documents/sites/your-wordpress-site.com/wp-includes/blocks/footnotes.php on line 37
Looking in the database, this is the content from the last saved page (2023-08-27 20:25:08)
There also appears to be two saved revisions dated after the above page. This is the first one (2023-08-27 20:25:08):
This is the second one (2023-08-27 20:32:15):
This page is now completely broken within the Block Editor and I'm not able to edit it. The only way I've been able to get my content back is by copying the content directly from the database, creating a new page, and manually copying the block content back into the page via Code Editor mode.
Step-by-step reproduction instructions
See above
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: