Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#28024 closed defect (bug) (worksforme)

WordPress doesn't honor array query vars

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.1
Component: Query Keywords:
Focuses: Cc:


Since r4753, we're discarding arrays from the query vars. This makes the query_vars filter useless in the event one is hoping to let WP parse and retrieve array variables passed in e.g. a form related to a custom post type.

Was there any good reason to do this, or was it simply premature and overzealous sanitization?

Change History (5)

#1 follow-up: @wonderboymusic
10 years ago

  • Keywords reporter-feedback close added

Where is this not working?

add_filter( 'query_vars', function ( $vars ) {
	$vars[] = 'denis';
	return $vars;
} );

add_action( 'template_redirect', function () {
	var_dump( get_query_var( 'denis' ) );
} );

Navigate to:


array(2) {
  string(3) "foo"
  string(3) "bar"

pre_get_posts also works with arrays...

#2 in reply to: ↑ 1 @Denis-de-Bernardy
10 years ago

Replying to wonderboymusic:

Where is this not working?

add_action('template_redirect', function () {
    global $wp;

Can't recall which WP function I needed that relied on query_string, but that was the issue.

#3 @Denis-de-Bernardy
10 years ago

  • Keywords reporter-feedback close removed

#4 @helen
10 years ago

  • Version changed from trunk to 2.1

#5 @chriscct7
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Can't replicate. No further reports in 2 years. Closing as worksforme. Reopen if someone can reproduce this

Note: See TracTickets for help on using tickets.