[wp-trac] [WordPress Trac] #9044: http_build_query: third arg not added until PHP v. 5.1.2

WordPress Trac wp-trac at lists.automattic.com
Wed Feb 4 18:42:58 GMT 2009


#9044: http_build_query: third arg not added until PHP v. 5.1.2
--------------------------+-------------------------------------------------
 Reporter:  mediafetish   |       Owner:                                      
     Type:  defect (bug)  |      Status:  new                                 
 Priority:  normal        |   Milestone:  2.7.1                               
Component:  HTTP          |     Version:  2.7                                 
 Severity:  normal        |    Keywords:  http_build_query, bug, http, plugins
--------------------------+-------------------------------------------------
 In wp-includes/compat.php:
 {{{
 // Added in PHP 5.0

 if (!function_exists('http_build_query')) {
         function http_build_query($data, $prefix=null, $sep=null) {
                 return _http_build_query($data, $prefix, $sep);
         }
 }
 }}}
 But according to: http://us2.php.net/http_build_query

 The third argument wasn't added until PHP Version 5.1.2

 This caused my install to fail when trying to use the automatic plugin
 upgrade function. In research, I found several occurrences of others
 fighting with this error:
 {{{
 Warning: http_build_query() expects at most 2 parameters, 3 given in
 /stor/ezines/htdocs/wp-includes/http.php on line 248
 }}}
 Line 248 has:
 {{{
 $r['body'] = http_build_query($r['body'], null, '&');
 }}}
 I believe this should call _http_build_query:
 {{{
 $r['body'] = _http_build_query($r['body'], null, '&');
 }}}
 Which fixed my installation.

 I'm not sure if this is accurate but I also believe that the logic in
 compat.php to test for the function http_build_query should also test for
 php version... something like:

 {{{
 if (!function_exists('http_build_query') || version_compare(PHP_VERSION,
 '5.1.2') === -1 ) {
         if(function_exists('http_build_query')) {
                 override_function('http_build_query',
                                                         '$data,
 $prefix=null, $sep=null',
                                                         'return
 _http_build_query($data, $prefix, $sep);');
         }else{
                 function http_build_query($data, $prefix=null, $sep=null)
 {
                         return _http_build_query($data, $prefix, $sep);
                 }
         }
 }
 }}}
 But that requires APD functions to override the native function so I don't
 know if that's the best approach or if it's even necessary since http.php
 was the only file I could find that called http_build_query directly. I'll
 leave that up to the gurus I guess ;)

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


More information about the wp-trac mailing list