[wp-trac] [WordPress Trac] #31521: wp_title if archive of year w/o permalink fires php notice in locale.php
WordPress Trac
noreply at wordpress.org
Thu Nov 11 16:27:59 UTC 2021
#31521: wp_title if archive of year w/o permalink fires php notice in locale.php
-------------------------------------------------+-------------------------
Reporter: michelwppi | Owner:
| hellofromTonya
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.9
Component: General | Version: 4.1.1
Severity: normal | Resolution: fixed
Keywords: good-first-bug has-patch has- | Focuses: template
screenshots has-unit-tests commit |
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"52136" 52136]:
{{{
#!CommitTicketReference repository="" revision="52136"
Template: Fix "undefined index: 00" when archive month query is empty in
`wp_title()`.
When `m` query_tag has a valid year, i.e. `?m=2021`, and there are posts
for that year, `substr()` returns a `false` on PHP 5.6 and an empty string
on PHP 7.0+. Passing either of those values to `$wp_locale->get_month()`
results in a PHP notice on PHP 5.6 to PHP 7.4 and a PHP Warning on PHP
8.0+.
Why? The `$month` lookup table has zeroized keys from '01' to '12'. A
empty value is passed to `zeroise()` returns `'00'` which is directly
passed as a key in the month property. That key does not exist.
While `$wp_locale->get_month()` would benefit from guarding/validation,
this fix ensures a falsey value is not passed as a month.
Tests are added including a test that fails with this fix not applied.
Follow-up to [801], [35294], [35624].
Props antpb, audrasjb, costdev, davidmosterd, drewapicture, herregroen,
hellofromTonya, michelwppi, sergeybiryukov.
Fixes #31521.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31521#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list