[wp-trac] [WordPress Trac] #55705: Safeguarding has_blocks() Against Fatal Errors
WordPress Trac
noreply at wordpress.org
Mon May 9 20:36:46 UTC 2022
#55705: Safeguarding has_blocks() Against Fatal Errors
-------------------------+-----------------------------
Reporter: Howdy_McGee | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
The `has_blocks()` has type conversion at the end function call:
`return false !== strpos( (string) $post, '<!-- wp:' );`
Where `$post` is the **passed parameter**. While this should be a WP_Post,
or type that returns a WP_Post, the function should not throw a Fatal
Error if `$post` is an object by the end of the call.
I think this should be revised to soft-error out if whatever parameter is
passed cannot be converted to a string. For example, if a WP_Error is
given, the system Fatal Errors. If the function's `get_post()` call
returns false, the function continues to try to string convert the passed
parameter and could throw a Fatal Error.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55705>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list