[wp-trac] [WordPress Trac] #10659: wp_getPages fails on PHP5 with no page count parameter

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 20 03:39:08 UTC 2009


#10659: wp_getPages fails on PHP5 with no page count parameter
--------------------------+-------------------------------------------------
 Reporter:  redsweater    |       Owner:  josephscott
     Type:  defect (bug)  |      Status:  new        
 Priority:  normal        |   Milestone:  Unassigned 
Component:  XML-RPC       |     Version:             
 Severity:  normal        |    Keywords:             
--------------------------+-------------------------------------------------
 Apparently there is a difference in the way php4 and php5 behave when it
 comes to missing XMLRPC parameters. In php4, the existing behavior of
 wp_getPages works well, causing a default page count of 10 to be used if
 the:

 $num_pages      = (int) $args[3];

 line evaluates to a $num_pages that fails the test "isset()".

 In PHP 5, if the client provides no 4th argument ($args[3]), then the
 evaluation fails abruptly with a console-written error about 3 being a bad
 index.

 To fix this, I am providing a patch that is more deliberately defensive
 against a missing 4th parameter. If the 4th parameter doesn't exist, the
 default value of 10 pages is used. Otherwise, it is read and respected.

 It might be worth evaluating other XMLRPC methods that have "optional"
 method arguments, to make sure they behave as expected under PHP 5.

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


More information about the wp-trac mailing list