Opened 12 years ago
Closed 10 years ago
#27447 closed defect (bug) (fixed)
'XML-RPC server accepts POST requests only.' returned by xml-rpc.php while doing_wp_cron.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | 3.8.1 |
| Component: | XML-RPC | Keywords: | has-patch |
| Focuses: | Cc: |
Description
While using ALTERNATE_WP_CRON, there is a redirect to a modified url including doing_wp_cron whenever a cron must be performed.
A condition prevents the redirection from happening on POST, but when an xmlrpc is posted, the guard (!empty($_POST)) fails to prevent the redirection because the content does not get parsed into $_POST.
In cron.php, spawn_cron, I propose replacing
function spawn_cron( $gmt_time = 0 ) {
...
if ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ) {
if ( !empty($_POST) || defined('DOING_AJAX') )
return;
by
function spawn_cron( $gmt_time = 0 ) {
...
if ( defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON ) {
if ( 'POST' == $_SERVER['REQUEST_METHOD'] || defined('DOING_AJAX') )
return;
Attachments (3)
Change History (13)
#2
@
11 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 29732:
#3
@
11 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
I think switching to SERVER_METHOD is probably a bit better here. $_POST is fine when we want to be naïve, but this case shows we need to expect that people will sometimes use raw POST data. php://input isn't re-readable until PHP 5.6 and that's overkill anyway. If we're receiving POST data, then it has to be a POST method. (The reverse isn't true: you can still receive query variables that get parsed into $_GET in a POST request.)
Checking XMLRPC_REQUEST is fine, but we should probably do a direct method check instead.
#4
@
11 years ago
Agreed on changing this, but I'd probably just make it filterable instead. The REST API sets XMLRPC_REQUEST right now for compatibility, but I could see that disappearing in the future.
#5
@
11 years ago
- Keywords has-patch added
Totally forgot about raw POST data. Included a new patch that fixes it and includes a filter.
#6
@
11 years ago
If we switch to 'POST' != $_SERVER['REQUEST_METHOD'], do we still need the other checks and the filter?
#7
@
11 years ago
- Keywords needs-docs added
- Milestone changed from 4.1 to Future Release
I think we should explicitly check for a GET method here to also avoid doing redirects with methods such as PUT, DELETE, etc.
Patch attached.
Sorry for the late response. I'm unsure why you would have seen it. Added a check when using XML-RPC which would also prevent issues when using JSON REST API.
Moving to 4.1.