[wp-trac] [WordPress Trac] #17559: Deprecated query_string doesn't support array arguments

WordPress Trac wp-trac at lists.automattic.com
Wed May 25 22:39:14 UTC 2011


#17559: Deprecated query_string doesn't support array arguments
--------------------------+-------------------
 Reporter:  nacin         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  3.1.4
Component:  Query         |    Version:
 Severity:  critical      |   Keywords:
--------------------------+-------------------
 In [17999/trunk/wp-admin/includes/post.php] we now send along the
 post_status as an array.

 However, if any plugin is hooking into query_string, then the array
 disappears, due to the `is_scalar()` check in WP::build_query_string() --

 {{{
         function build_query_string() {
                 $this->query_string = '';
                 $this->query_string = http_build_query($this->query_vars);
                 foreach ( (array) array_keys($this->query_vars) as $wpvar)
 {
                         if ( '' != $this->query_vars[$wpvar] ) {
                                 $this->query_string .=
 (strlen($this->query_string) < 1) ? '' : '&';
                                 if ( !is_scalar($this->query_vars[$wpvar])
 ) // Discard non-scalars.
                                         continue;
                                 $this->query_string .= $wpvar . '=' .
 rawurlencode($this->query_vars[$wpvar]);
                         }
                 }

                 // query_string filter deprecated.  Use request filter
 instead.
                 if ( has_filter('query_string') ) {  // Don't bother
 filtering and parsing if no plugins are hooked in.
                         $this->query_string =
 apply_filters('query_string', $this->query_string);
                         parse_str($this->query_string, $this->query_vars);

                 }
         }
 }}}

 A solution would be to instead build $this->query_string with
 http_build_query(). However, we want RFC 1936, rather than 1738
 (rawurlencode vs urlencode). In PHP 5.3.x-dev, http_build_query() can
 accept an enc_type, but that doesn't help us.

 Our own _http_build_query() does have an encoding parameter, but it's just
 true/false. We could perhaps overload that -- possibly by leveraging the
 same constants as PHP does in 5.3.x -- to support raw url encoding.

 This is marked for 3.1.4 since our array in 3.1.3 ended up getting unset
 whenever query_string was used, which then sets post_status to
 future/private/publish/draft but not inherit, thus zeroing out the
 attachments page.

 For 3.1.4, I suggest we move from the array callback back to the comma-
 delimited string form. That would mean reverting [18047] (optionally) and
 doing an implode of $states in [17999/trunk/wp-admin/includes/post.php].

 For 3.2, we need to look at the other solutions proposed.

 For 3.3 I'd like to start reporting deprecated filters.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17559>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list