Skip to content

Bug Fix: Prevent invalid query args from causing php errors & a limitless query


11 February 2021

23:59:19 GMT+0000

Passing a query string like http://vip-go-dev.lndo.site/?name[]=test will cause the below php error:

PHP Warning: trim() expects parameter 1 to be string, array given in /app/wp/wp-includes/class-wp-query.php on line 779

Because WordPress interprets these sorts of query strings as single post or single page queries – it will end up with a main query that looks like the SQL query below – which is notably limitless:

SELECT wp_posts.*
FROM wp_posts
WHERE 1=1
AND wp_posts.post_type = 'post'
ORDER BY wp_posts.post_date DESC

This is a stopgap while awaiting the resolution of the following core ticket:

https://core.trac.wordpress.org/ticket/17737

https://github.com/Automattic/vip-go-mu-plugins/pull/1981