Make WordPress Core

Opened 9 months ago

Last modified 9 months ago

#59103 new defect (bug)

Gutenberg 16.4 Footnotes Critical Bug on PHP 8.0

Reported by: orangeavocad0's profile orangeavocad0 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version: 6.3
Component: Editor Keywords: needs-patch php80
Focuses: php-compatibility Cc:

Description

I am currently using WordPress version 6.3, PHP 8.0.

There is no issue initially when creating a post with the footnotes block, and is able to publish the post.

After a while, when trying to edit the same post again, I will see the critical error as such as seen in the attachment.

PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /wordpress/plugins/gutenberg/16.4.0/build/block-library/blocks/footnotes.php:37 Stack trace: #0 /wordpress/core/6.3/wp-includes/class-wp-block.php(258): gutenberg_render_block_core_footnotes(Array, '', Object(WP_Block)) #1 /wordpress/core/6.3/wp-includes/blocks.php(1133): WP_Block->render() #2 /wordpress/core/6.3/wp-includes/blocks.php(1171): render_block(Array) #3 /wordpress/core/6.3/wp-includes/class-wp-hook.php(310): do_blocks('<!-- wp:rank-ma...') #4 /wordpress/core/6.3/wp-includes/plugin.php(205): WP_Hook->apply_filters('<!-- wp:rank-ma...', Array) #5 /wordpress/core/6.3/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php(1864): apply_filters('the_content', '<!-- wp:rank-ma...') #6 /wordpress/core/6.3/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 /wordpress/core/6.3/wp-includes/rest-api/class-wp-rest-server.php(1188): WP_REST_Posts_Controller->get_item(Object(WP_REST_Request)) #8 /wordpress/core/6.3/wp-includes/rest-api/class-wp-rest-server.php(1035): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/posts/(?...', Array, NULL) #9 /wordpress/core/6.3/wp-includes/rest-api.php(545): WP_REST_Server->dispatch(Object(WP_REST_Request)) #10 /wordpress/core/6.3/wp-includes/rest-api.php(2911): rest_do_request(Object(WP_REST_Request)) #11 [internal function]: rest_preload_api_request(Array, '/wp/v2/posts/57...') #12 /wordpress/core/6.3/wp-includes/block-editor.php(743): array_reduce(Array, 'rest_preload_ap...', Array) #13 /wordpress/core/6.3/wp-admin/edit-form-blocks.php(77): block_editor_rest_api_preload(Array, Object(WP_Block_Editor_Context)) #14 /wordpress/core/6.3/wp-admin/post.php(187): require('/wordpress/core...') #15 {main} thrown in /wordpress/plugins/gutenberg/16.4.0/build/block-library/blocks/footnotes.php on line 37	

Attachments (1)

Screenshot 2023-08-14 at 11.58.02 PM.png (95.8 KB) - added by orangeavocad0 9 months ago.

Download all attachments as: .zip

Change History (9)

This ticket was mentioned in Slack in #core-editor by nekojonez. View the logs.


9 months ago

#2 follow-up: @ramonopoly
9 months ago

Are there any steps to reproduce this?

I tried using 6.3 on PHP 8.0 but couldn't.

Even so, I've added a bit of defensive code to the footnotes block in https://github.com/WordPress/gutenberg/pull/53660 just in case.

Edit: And Gutenberg 16.4 :)

Last edited 9 months ago by ramonopoly (previous) (diff)

#3 in reply to: ↑ 2 @orangeavocad0
9 months ago

Replying to ramonopoly:

Are there any steps to reproduce this?

I tried using 6.3 on PHP 8.0 but couldn't.

Even so, I've added a bit of defensive code to the footnotes block in https://github.com/WordPress/gutenberg/pull/53660 just in case.

Edit: And Gutenberg 16.4 :)

I tried but sometimes the bug happens, sometimes it doesn't. Not very sure what is the trigger for this fatal error.

Actually when it occurred for my site, the Happiness Engineer thought that it was plugin conflict but after doing some testing, there isn't any plugin conflict.

I clearly see the fatal error in the site logs about the footnotes. :)

One thing to highlight is that downgrading to PHP 7.4 reduced the fatal error to a warning but it still caused other errors in the editor. Additionally, even though it was just a warning, the footnotes is not rendering in page. For example, see this post - https://blog.pastething.com/2023/08/09/economics-navigate-automated-world/#universal-basic-income-a-beacon-of-hope-or-just-a-mirage

I think the site log I posted earlier is the best I can provide for now :(

#4 @ramonopoly
9 months ago

Thanks for the quick reply @orangeavocad0

I think I might have found a way to reproduce:

https://github.com/WordPress/gutenberg/pull/53660#issuecomment-1678407868

#5 @chaplin89
9 months ago

Hello. Same problem here. WP 6.3 with PHP 8.1.

 Fatal error: Uncaught Error: count(): Argument #1 ($value) must be of type Countable|array, null given
in /home/customer/www/mywebsite/public_html/wp-includes/blocks/footnotes.php on line 37

#6 @johanneswilm
9 months ago

I assume the problem is fixed if one upgrades to Gutenberg 16.5.0? How does one then manually fix footnotes in existing posts?

#7 @SergeyBiryukov
9 months ago

  • Component changed from Post Formats to Editor
  • Focuses php-compatibility added
  • Keywords php80 added

#8 @ramonopoly
9 months ago

I assume the problem is fixed if one upgrades to Gutenberg 16.5.0? How does one then manually fix footnotes in existing posts?

Testing a fix over here: https://github.com/WordPress/gutenberg/pull/53713

In the meantime you could either go into the database in wp_postmeta itself and escape the quotations, or use a filter similar to the one in the above PR.

Note: See TracTickets for help on using tickets.