Make WordPress Core

Opened 7 years ago

Last modified 4 weeks ago

#43159 new enhancement

Introduce helper function for XMLRPC checks

Reported by: nathanatmoz's profile 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)

43159.diff (2.3 KB) - added by NathanAtmoz 7 years ago.
43159.2.diff (4.1 KB) - added by NathanAtmoz 7 years ago.
43159.3.diff (4.4 KB) - added by NathanAtmoz 4 weeks ago.

Download all attachments as: .zip

Change History (8)

@NathanAtmoz
7 years ago

#1 follow-up: @birgire
7 years ago

  • Keywords has-patch added

Thanks for the patch @NathanAtmoz

I'm not sure what the consensus is regarding wp_doing_xmlrpc() but we now have wp_doing_ajax() since 4.7 and wp_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:

  • I don't think we should add wp_doing_xmlrpc() in that line in wp-cron.php, because that file can be requested directly, (see e.g. within spawn_cron() here ) and then wp_doing_xmlrpc() wouldn't be defined and resulting in a PHP error. Some users rely on Unix Cron instead, requesting that file from there.
  • It removes the || defined( 'DOING_AJAX' ) check in is_admin_bar_showing(). I think that removal must have been accidental and should be reverted.
  • I found an extra defined( 'XMLRPC_REQUEST' ) check in spawn_cron() (src), but I noticed that defined( 'DOING_AJAX' ) and defined( 'DOING_CRON' ) have not been replaced. Most likely a reason for that, but we could look further into that.
  • I also found an extra defined( 'XMLRPC_REQUEST' ) check in _publish_post_hook() (src), that seems to be a valid replacement for wp_doing_xmlrpc().
Version 2, edited 7 years ago by birgire (previous) (next) (diff)

#2 in reply to: ↑ 1 ; follow-up: @NathanAtmoz
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 in wp-cron.php, because that file can be requested directly, (see e.g. within spawn_cron() here ) and then wp_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 in spawn_cron() (src), but I noticed that defined( 'DOING_AJAX' ) and defined( '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.

@NathanAtmoz
7 years ago

#3 in reply to: ↑ 2 @birgire
7 years ago

Replying to NathanAtmoz:

I don't see wp_doing_xmlrpc() in wp-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.

#4 @jorbin
8 weeks ago

  • Keywords needs-refresh added

Patch no longer applies cleanly. I would support getting this in if someone wants to refresh the patch.

@NathanAtmoz
4 weeks ago

#5 @NathanAtmoz
4 weeks ago

  • Keywords needs-refresh removed

Patch refreshed

Note: See TracTickets for help on using tickets.