[wp-trac] [WordPress Trac] #55705: Safeguarding has_blocks() Against Fatal Errors

WordPress Trac noreply at wordpress.org
Wed May 11 10:06:29 UTC 2022


#55705: Safeguarding has_blocks() Against Fatal Errors
-------------------------------------------------+-------------------------
 Reporter:  Howdy_McGee                          |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  6.1
Component:  Editor                               |     Version:  5.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing has-testing-info                       |
-------------------------------------------------+-------------------------
Changes (by costdev):

 * keywords:   => has-patch has-unit-tests needs-testing has-testing-info


Comment:

 === Reproduction/Testing steps

 1. Download
 [https://core.trac.wordpress.org/attachment/ticket/55705/has_blocks.zip
 has_blocks.zip].
 2. Navigate to `Plugins > Add New > Upload Plugin`.
 3. Select `has_blocks.zip`, upload and activate.
 4. 🐞 There should be an admin notice:
 {{{
 A Fatal Error occurred: Object of class stdClass could not be converted to
 string.
 }}}
 5. Apply patch
 [https://core.trac.wordpress.org/attachment/ticket/55705/55705.diff
 55705.diff].
 6. Refresh the page.
 7. ✅ There should be an admin notice and a `_doing_it_wrong()` notice:
 {{{
 Admin notice:
 A Fatal Error did not occur.

 _doing_it_wrong() notice:
 Notice: Function has_blocks was called incorrectly.
 $post is not a valid post.
 Please see Debugging in WordPress for more information.
 (This message was added in version 6.1.0.) in /wp-includes/functions.php
 on line <number>
 }}}

 === Clean up
   - Deactivate and delete the "`has_blocks()` Fatal Error" plugin.
   - Revert the patch.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55705#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list