Opened 23 months ago
Closed 23 months ago
#54815 closed defect (bug) (fixed)
Warning found in post-thumbnail-template.php on PHP 8.0.14
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.9 | Priority: | high |
Severity: | normal | Version: | 5.9 |
Component: | Media | Keywords: | has-patch dev-feedback fixed-major |
Focuses: | Cc: |
Description
Warning thrown when displaying post category page that includes thumbnail images.
WP 5.9 RC2 PHP 8.0.14, not browser-specific, not theme-specific
Warning: preg_match(): No ending delimiter '/' found in ..../wp-includes/post-thumbnail-template.php on line 198
Attachments (1)
Change History (14)
#2
@
23 months ago
- Summary changed from post-thumbnail-template.php to Warning found in post-thumbnail-template.php on PHP 8.0.14
#3
@
23 months ago
The warning occurs in other PHP versions as well. See preg_match.
The regex in question:
'/(^|&)loading='
It's simply missing a trailing /
.
"Why are we only finding this out now?"
No tests hit the condition on Line 198. See the report (this is subject to change, of course). As a result, the faulty preg_match()
is never triggered and so the warning is not thrown.
This is why tests should at least achieve line coverage for all new code.
To trigger the warning (+hint for unit tests):
- Switch to Twenty Twenty-One.
- Create a page and add a Featured Image.
- Add this to
page.php
:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); get_the_post_thumbnail( get_the_ID(), 'post-thumbnail', 'does_not_contain_loading=true' ); endwhile; endif;
- Load the page.
- You should see this warning:
Warning: preg_match(): No ending delimiter '/' found in /wp-includes/post-thumbnail-template.php on line 198
#6
@
23 months ago
- Component changed from General to Media
- Owner set to audrasjb
- Priority changed from normal to high
- Status changed from new to assigned
You're right, I'm seeing this now and this is a high priority, thanks @costdev.
The issue was introduced in [52065].
The proposed patch fixes the issue.
Self-assigning for commit asap in 5.9.
This ticket was mentioned in PR #2160 on WordPress/wordpress-develop by audrasjb.
23 months ago
#7
Trac ticket: https://core.trac.wordpress.org/ticket/54815
#9
@
23 months ago
- Keywords dev-feedback fixed-major added; commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for backport.
We'll need a second committer sign-off before backporting this change to 5.9.
Pinging @adamsilverstein and/or @flixos90 for second sign-off as they worked on [52065].
23 months ago
#10
Committed in https://core.trac.wordpress.org/changeset/52574
Assigning to milestone 5.9 for further investigation.