Repository navigation
Conversation
…`exclude`. The `exclude` argument of `wp_list_pages()` was sanitized with `preg_replace()` and split with `explode()`, which caused a fatal `TypeError` on PHP 8 when an array of page IDs was passed. It is now parsed with `wp_parse_id_list()`, so both an array of IDs and the existing comma-separated string are accepted. The `wp_list_pages_excludes` filter continues to receive an array of numeric strings. The `exclude` and `include` arguments are now documented as `int[]`, matching `get_pages()`, to which they are passed through. The `include` argument was previously documented as an array but described as a comma-separated list. See #66052.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Test ReportTicket: https://core.trac.wordpress.org/ticket/66052 Environment
Steps to Test
Test Results
The PR is complete, maintains backward compatibility, and is ready for commit. Props therssoftware. AI Disclosure: In accordance with the WordPress AI policy, I disclose that generative AI (Google Antigravity) was used in testing and drafting this test report. All test steps and assertions were run and verified in the local development environment. |
Trac ticket: https://core.trac.wordpress.org/ticket/66052
wp_list_pages()cleaned itsexcludeargument withpreg_replace()and then split it withexplode(). Both functions expect a string, so passing an array of page IDs caused a fatalTypeErroron PHP 8:Passing an array is a reasonable thing to do:
get_pages(), which receives these arguments, accepts arrays. Theincludeargument ofwp_list_pages()is also already documented as an array.Changes
excludeis now parsed withwp_parse_id_list(), so it accepts an array of IDs (integers or numeric strings) as well as the existing comma-separated string.wp_list_pages_excludesfilter still receives an array of numeric strings, as before. A@phpstan-param numeric-string[]tag now documents this.excludedefault changes from''toarray().excludeandincludeare now documented asint[]to matchget_pages().includewas typed asarraybut described as a comma-separated list. Added a@since 7.2.0note.Testing
New PHPUnit tests in
tests/phpunit/tests/post/wpListPages.php:excludeaccepts an array of IDs, as integers or as numeric strings.includeaccepts an array of IDs, as integers or as numeric strings.wp_list_pages_excludesfilter still receives numeric strings when given a comma-separated string with extra spaces.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.