#10659 closed defect (bug) (fixed)
wp_getPages fails if WP_DEBUG is set, and no page count parameter provided
Reported by: | redsweater | Owned by: | westi |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | 2.8 |
Component: | XML-RPC | Keywords: | |
Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (7)
#1
@
15 years ago
- Summary changed from wp_getPages fails on PHP5 with no page count parameter to wp_getPages failsif WP_DEBUG is set, and no page count parameter provided
#2
@
15 years ago
- Summary changed from wp_getPages failsif WP_DEBUG is set, and no page count parameter provided to wp_getPages fails if WP_DEBUG is set, and no page count parameter provided
#3
@
15 years ago
- Owner changed from josephscott to westi
- Status changed from new to reviewing
This explains the fun I had testing #10244 this morning.
UPDATE: I think I was confused into thinking this is a PHP4 vs. PHP5 issue, but instead I think it's a question of whether WP_DEBUG is set to true or not.
When WP_DEBUG is true, sensitive array accesses in WordPress cause errors to be written, and thus foil the XML response.
Should these sensitive array accesses be guarded (as the patch provides for in this case), so that XMLRPC operates correctly in WP_DEBUG mode?
If so, I have another case and patch to submit.