WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 3 years ago

Last modified 13 months ago

#13449 closed enhancement (fixed)

Filter Cron URL

Reported by: ikailo Owned by: westi
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.4.1
Component: Cron API Keywords: has-patch early
Focuses: Cc:

Description

This patch allows developers to modify the URL for a spawned cron process. Needed when 'siteurl' is not actually the URL where wp-cron.php exists.

Attachments (3)

filter_wp_cron.diff (565 bytes) - added by ikailo 5 years ago.
13449.patch (761 bytes) - added by SergeyBiryukov 3 years ago.
13449.diff (887 bytes) - added by ryan 3 years ago.

Download all attachments as: .zip

Change History (21)

@ikailo5 years ago

comment:1 @nacin5 years ago

  • Keywords reporter-feedback close added; wp_cron cron hook filter removed
  • Milestone changed from 3.0 to Future Release

There's already a filter you can use in wp_remote_post. What's the use case for filtering the cron URL? I imagine it's narrow -- I'd suggest you just stick you using the filter already available.

comment:2 @ikailo5 years ago

  • Version 3.0 deleted

The case:

In a particular site's configuration,'siteurl' is set to http://domain.com, and 'home' is 'http://domain.com/subdirectory/'. A particular plugin requires that all postbacks be sent with the subdirectory value intact. Hence, we must modify the Cron URL to reflect the home value instead of the siteurl.

Other similar hooks already exist and can be used for such a purpose: admin_url, trackback_url, plugins_url, login_url, logout_url, register, wp_admin

I did not find any filters in wp_remote_post that would allow the same simplicity as these other hooks. If one does exist, cold you please point me to it?

comment:3 @nacin5 years ago

  • Keywords reporter-feedback close removed

I stand corrected, I thought for sure you could filter the URL of an HTTP request, but now I can't find one.

comment:4 @ikailo5 years ago

  • Keywords has-patch added

comment:5 @ikailo5 years ago

  • Cc john@… added

comment:6 @westi3 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from Future Release to 3.4

We should probably switch this code to use get_site_url and then we gain filtering of the url using the site_url filter for free.

Seems like a simple enhancement we could include in 3.4

@SergeyBiryukov3 years ago

comment:7 @SergeyBiryukov3 years ago

  • Keywords has-patch added; needs-patch removed

comment:8 @ryan3 years ago

History: [8529] and [8537].

I was wondering if there was a reason this isn't already site_url(). There doesn't seem to be any. This will also make it easier on those who need to use SERVER_ADDR in the cron url.

Last edited 3 years ago by ryan (previous) (diff)

comment:9 @ryan3 years ago

Tweaking the timeout for the wp_remote_post() request and passing a Host header are also sometimes needed. Perhaps specific filters for filtering the cron url and request args would be best here after all.

comment:10 @ryan3 years ago

In [19922]:

Use site_url() to construct the cron url. Props SergeyBiryukov. see #13449

@ryan3 years ago

comment:11 @ryan3 years ago

cron_request filter for url and args.

comment:12 @markjaquith3 years ago

Is the 'key' array member never used?

comment:13 @ryan3 years ago

I threw it in there as a means to make it easier to generate a keyed url.

comment:14 @ryan3 years ago

  • Milestone changed from 3.4 to Future Release

comment:15 @batmoo3 years ago

  • Cc batmoo@… added

comment:16 @ryan3 years ago

  • Keywords early added
  • Milestone changed from Future Release to 3.5
  • Version set to 3.4.1

comment:17 @ryan3 years ago

  • Resolution set to fixed
  • Status changed from new to closed

In [21293]:

Introduce cron_request filter. Props ikailo. fixes #13449

comment:18 @ircbot13 months ago

This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.

Note: See TracTickets for help on using tickets.