[wp-trac] [WordPress Trac] #63028: PHP Warning caused by media.php and formatting.php
WordPress Trac
noreply at wordpress.org
Thu Feb 27 08:00:00 UTC 2025
#63028: PHP Warning caused by media.php and formatting.php
-------------------------------+------------------------------
Reporter: isrgrajan | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 6.7.2
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Comment (by dd32):
Replying to [comment:3 isrgrajan]:
> To simulate the condition where an attachmentâs post parent is an array
Doing so is completely incorrect, and not something that WordPress should
be supporting, IMHO.
There's only so much WordPress can do to protect developers from
themselves.
Ideally the `WP_Post::post_parent` field would have int validation on the
values that can be set, but unfortunately PHP doesn't really support that
in a way that WordPress can use for back-compat.
> If it's an array, it triggers PHP warnings and risks unpredictable
behaviour, compromising site stability.
Exactly. A developer should expect unpredictable result, including PHP
Warnings and Fatal errors, by setting data to values outside of the
expected types.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63028#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list