[wp-trac] [WordPress Trac] #52995: Undefined `$post_ID` variable in `edit-form-blocks.php`
WordPress Trac
noreply at wordpress.org
Tue May 18 22:26:47 UTC 2021
#52995: Undefined `$post_ID` variable in `edit-form-blocks.php`
------------------------------+-----------------------------
Reporter: ravipatel | Owner: SergeyBiryukov
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 5.8
Component: Editor | Version: 5.0
Severity: normal | Resolution:
Keywords: has-patch commit | Focuses:
------------------------------+-----------------------------
Changes (by SergeyBiryukov):
* keywords: has-patch => has-patch commit
Comment:
It looks like the issue comes from [source:tags/5.7.2/src/wp-
admin/post.php?marks=199#L191 this line] in `wp-admin/post.php`:
{{{
$post = get_post( $post_id, OBJECT, 'edit' );
}}}
The `ID`, `post_parent`, and `menu_order` properties of the `WP_Post`
class are documented as integers, so I thought it would be a safe
assumption to always treat them as such. However, that is not the case
when `get_post()` is called with an `edit`, `attribute`, or `js` context,
because all values are run through `esc_attr()` or `esc_js()` in that
case, and these properties are unexpectedly converted to strings.
I believe we should fix that and make the type of these properties
consistent in all contexts, that should also help avoid similar issues
elsewhere in the future. See [attachment:"52995.diff"].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52995#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list