wordpress-develop/tests/phpunit/tests/general
Tonya Mork 06dc5e170f 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52136 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-11 16:27:44 +00:00
..
paginateLinks.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
template_CheckedSelectedHelper.php Code Modernization: Rename the readonly() function to wp_readonly(). 2021-08-09 17:19:21 +00:00
template.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
wpError.php Build/Test Tools: Implement use of the void solution. 2021-08-07 10:29:41 +00:00
wpGetArchives.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
wpGetDocumentTitle.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
wpResourceHints.php Coding Standards: Add visibility to methods in tests/phpunit/tests/. 2021-11-04 15:22:47 +00:00
wpTitle.php Template: Fix "undefined index: 00" when archive month query is empty in wp_title(). 2021-11-11 16:27:44 +00:00