[wp-trac] [WordPress Trac] #54815: Warning found in post-thumbnail-template.php on PHP 8.0.14

WordPress Trac noreply at wordpress.org
Fri Jan 14 03:30:48 UTC 2022

#54815: Warning found in post-thumbnail-template.php on PHP 8.0.14
 Reporter:  SierraTR      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.9
Component:  General       |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:

Comment (by costdev):

 The warning occurs in other PHP versions as well. See
 .preg-match-errors preg_match].


 The regex in question:


 It's simply missing a trailing `/`.


 "Why are we only finding this out now?"

 No tests hit the condition on Line 198. See
 includes/post-thumbnail-template.php 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


 To trigger the warning (+hint for unit tests):

 1. Switch to Twenty Twenty-One.
 2. Create a page and add a Featured Image.
 3. Add this to `page.php`:


 if ( have_posts() ) : while ( have_posts() ) : the_post();
 endwhile; endif;

 4. Load the page.
 5. You should see this warning:

  Warning: preg_match(): No ending delimiter '/' found in /wp-includes
 /post-thumbnail-template.php on line 198

Ticket URL: <https://core.trac.wordpress.org/ticket/54815#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list