Opened 7 years ago
Last modified 4 weeks ago
#43159 new enhancement
Introduce helper function for XMLRPC checks
Reported by: | NathanAtmoz | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Bootstrap/Load | Keywords: | has-patch |
Focuses: | Cc: |
Description
Similar to #25669, it would be nice if there was a helper function for checking if WordPress is doing a XML-RPC request.
Attachments (3)
Change History (8)
#2
in reply to:
↑ 1
;
follow-up:
↓ 3
@
7 years ago
@birgire: Thanks for looking at the patch.
Replying to birgire:
- I don't think we should add
wp_doing_xmlrpc()
in that line inwp-cron.php
, because that file can be requested directly, (see e.g. withinspawn_cron()
here ) and thenwp_doing_xmlrpc()
wouldn't be defined and resulting in a PHP error. Some users rely on Unix Cron instead, requesting that file from there.
I don't see wp_doing_xmlrpc()
in wp-cron.php
in the patch? Am I missing something?
- I found an extra
defined( 'XMLRPC_REQUEST' )
check inspawn_cron()
(src), but I noticed thatdefined( 'DOING_AJAX' )
anddefined( 'DOING_CRON' )
have not been replaced. Most likely a reason for that, but we could look further into that.
I originally didn't use wp_doing_xmlrpc()
here because the other constants hadn't been replaced. But this function is loaded really early, and the only place it's called in core is hooked to init
.
#3
in reply to:
↑ 2
@
7 years ago
Replying to NathanAtmoz:
I don't see
wp_doing_xmlrpc()
inwp-cron.php
in the patch? Am I missing something?
This part was meant to be a general note why it wasn't replaced in wp-cron.php
, sorry that wasn't made more clear ;-)
I also checked in the tests/
directory and didn't find any use of XMLRPC_REQUEST
there.
Thanks for the patch @NathanAtmoz
I'm not sure what the consensus is regarding
wp_doing_xmlrpc()
but we now havewp_doing_ajax()
since 4.7 andwp_doing_cron()
since 4.8. So it would seem logical to introduce it. Also the discussion in #25669 doesn't seems to be against such a function, if I understand it correctly.I reviewed 43159.diff and here are some notes:
wp_doing_xmlrpc()
in that line inwp-cron.php
, because that file can be requested directly, (see e.g. withinspawn_cron()
here ) and thenwp_doing_xmlrpc()
wouldn't be defined and resulting in a PHP error. Some users rely on Unix Cron instead, requesting that file from there.|| defined( 'DOING_AJAX' )
check inis_admin_bar_showing()
. I think that removal must have been accidental and should be reverted.defined( 'XMLRPC_REQUEST' )
check inspawn_cron()
(src), but I noticed thatdefined( 'DOING_AJAX' )
anddefined( 'DOING_CRON' )
have not been replaced. Most likely a reason for that, but we could look further into that.defined( 'XMLRPC_REQUEST' )
check in_publish_post_hook()
(src), that seems to be a valid replacement forwp_doing_xmlrpc()
.