Opened 4 months ago
Closed 3 months ago
#23425 closed defect (bug) (duplicate)
PHP warning in WP_Query::get_posts() when url includes ?page[]
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 1.5.1 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
To reproduce:
- Install WordPress (I cloned from https://github.com/WordPress/WordPress, @ [23391])
- Go to http://example.com/?page[]
Stack trace:
Warning: trim() expects parameter 1 to be string, array given in /var/www/projects/wordpress/wp-includes/query.php on line 2024
Stack trace:
- {main}() /var/www/projects/wordpress/index.php:0
- require() /var/www/projects/wordpress/index.php:17
- wp() /var/www/projects/wordpress/wp-blog-header.php:14
- WP->main() /var/www/projects/wordpress/wp-includes/functions.php:779
- WP->query_posts() /var/www/projects/wordpress/wp-includes/class-wp.php:549
- WP_Query->query() /var/www/projects/wordpress/wp-includes/class-wp.php:485
- WP_Query->get_posts() /var/www/projects/wordpress/wp-includes/query.php:2972
- trim() /var/www/projects/wordpress/wp-includes/query.php:2024
Looks like the query var "page" needs sanitizing / casting to string, either with the trim() on line 2024 or before.
Change History (4)
Is there any practical reason to use that URL format in a real project? IMO handling this for a use-case that wouldn't exist in practice is unnecessary overhead.
also related #23416
comment:4
SergeyBiryukov — 3 months ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
- Version changed from trunk to 1.5.1
Note: See
TracTickets for help on using
tickets.

Very similar, not sure if it's worth adding a new ticket. Adding ?s[] to the URL gives an error in the same method:
There may be other parameters that need sanitising too.