[wp-trac] [WordPress Trac] #52826: New wp_getimagesize() causing unexpected failures
WordPress Trac
noreply at wordpress.org
Tue Mar 23 19:43:32 UTC 2021
#52826: New wp_getimagesize() causing unexpected failures
-------------------------------------+------------------------
Reporter: terriann | Owner: whyisjake
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 5.7.1
Component: Media | Version: 5.7
Severity: critical | Resolution:
Keywords: has-patch needs-refresh | Focuses:
-------------------------------------+------------------------
Comment (by terriann):
I've submitted a new patch, based on SVN trunk's current status, which
includes the change that was already committed: attachment:52826.4.diff. I
believe this new change addresses many of the concerns here.
This solution moves away from using an `is_null()` check to determine
whether to pass the second parameter to PHP's native `getimagesize()`. A
colleague pointed out that `func_num_args()` could also be used to see if
the second parameter is explicitly provided.
It looks like there is a precedent in core for using `func_num_args()` for
both backward compatibility and shimming. Examples:
[https://core.trac.wordpress.org/browser/tags/5.7/src/wp-
includes/option.php#L92 /wp-includes/option.php:92] and
[https://core.trac.wordpress.org/browser/tags/5.7/src/wp-includes/class-
wp-rewrite.php#L1787 /wp-includes/class-wp-rewrite.php:1787]
Because the second parameter is a reference, my understanding is that it
''shouldn't'' need to be initialized in advance of calling
`wp_getimagesize( $file, $info )` much like how one wouldn't typically
initilize `$matches` before calling `preg_match( $pattern, $subject,
$matches )`.
The change in this new patch would support calling `getimagesize()` with
the same parameter count it had been called with in WordPress 5.6.2 and
earlier.
I've tested this in the environment where we first detected the issue,
which streams the files from the uploads directory in the manner
@rinatkhaziev described. Images that were not storing attachment metadata
for width and height after the 5.7 upgrades are now storing width, height
and correctly parsing relevant EXIF data for title, caption, etc.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52826#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list