Commit Graph

95 Commits

Author SHA1 Message Date
Gary Pendergast
56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


Built from https://develop.svn.wordpress.org/trunk@43571


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
Peter Wilson
90f1ac17ec Cron: Add hooks and a function to allow hijacking cron implementation.
This allows sites with a large cron option or a custom cron implementation to hijack the cron option to store cron data using custom functionality.

`wp_get_scheduled_event()` is new function to retrieve the event object for a given event based on the hook name, arguments and timestamp. If no timestamp is specified the next occurence is returned.

Preflight filters are added to all functions that read from or modify the cron option: `pre_schedule_event`, `pre_reschedule_event`, `pre_unschedule_event`, `pre_clear_scheduled_hook`, `pre_unschedule_hook`, `pre_get_scheduled_event` and `pre_next_scheduled`.

Additionally, the post scheduling hooks `next_scheduled` and `get_schedule` to allow plugins to modify an event after retrieving it from WordPress.

Props rmccue, DavidAnderson, ethitter, peterwilsoncc.
Fixes #32656.


Built from https://develop.svn.wordpress.org/trunk@43540


git-svn-id: http://core.svn.wordpress.org/trunk@43369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-07-27 02:23:25 +00:00
Peter Wilson
2e43234f3f Cron API: Return meaningful values from cron functions.
Return values added to Cron API functions to indicate outcome:

* `wp_schedule_single_event()`, `wp_schedule_event()`, `wp_reschedule_event()` and `wp_unschedule_event()`: boolean indicating success or failure,
* `wp_clear_scheduled_hook()`: integer indicating number of jobs cleared (zero or more), `false` if one or more jobs fail to clear,
* `wp_unschedule_hook()`: integer indicating number of jobs cleared (zero or more), `false` if the jobs fail to clear,
* `spawn_cron()`: boolean indicating whether job spawned,
* `wp_cron()`: integer indicating number of jobs spawned (zero or more), `false` if one or more jobs fail to spawned,
* `_set_cron_array()`: boolean outcome of `update_option()`.

Props evansolomon, jrf, peterwilsoncc, pento for code review.
Fixes #21072.


Built from https://develop.svn.wordpress.org/trunk@43050


git-svn-id: http://core.svn.wordpress.org/trunk@42879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-01 02:05:23 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
John Blackbourn
850532fb01 Cron API: Improvements to docblocks for the event scheduling functions.
See #42505

Built from https://develop.svn.wordpress.org/trunk@42216


git-svn-id: http://core.svn.wordpress.org/trunk@42045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-22 15:16:47 +00:00
Drew Jaynes
b13aa27cf4 Docs: Use third-person singular verbs in the summaries for wp_unschedule_hook() and wp_clear_scheduled_hook().
See #41017.

Built from https://develop.svn.wordpress.org/trunk@40970


git-svn-id: http://core.svn.wordpress.org/trunk@40820 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-30 04:54:41 +00:00
Sergey Biryukov
641a4b643f Cron API: Introduce wp_unschedule_hook() to clear all events attached to a hook.
This complements `wp_clear_scheduled_hook()`, which only clears events attached with specific arguments.

Props arena, mordauk, jrf.
Fixes #18997.
Built from https://develop.svn.wordpress.org/trunk@40965


git-svn-id: http://core.svn.wordpress.org/trunk@40815 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-30 00:22:44 +00:00
Scott Taylor
76926fa763 Cron: clarify descriptions for Cron API functions.
Props johnbillion.
Fixes #37769.

Built from https://develop.svn.wordpress.org/trunk@38357


git-svn-id: http://core.svn.wordpress.org/trunk@38298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 09:22:30 +00:00
Sergey Biryukov
18601e4b5a Docs: In wp_schedule_single_event(), add a note about scheduling an event to occur within 10 minutes of another event with the same action hook.
Props medariox.
Fixes #37455.
Built from https://develop.svn.wordpress.org/trunk@38148


git-svn-id: http://core.svn.wordpress.org/trunk@38089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-25 12:23:30 +00:00
Sergey Biryukov
139387b7e5 Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core.
Props metodiew.
Fixes #36495.
Built from https://develop.svn.wordpress.org/trunk@37985


git-svn-id: http://core.svn.wordpress.org/trunk@37926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-06 12:40:29 +00:00
Drew Jaynes
da78aeffe9 Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files.
Applying these specially-crafted `@see` tags allows the Code Reference parser to recognize and link these elements as actions and filters.

See #36921.

Built from https://develop.svn.wordpress.org/trunk@37542


git-svn-id: http://core.svn.wordpress.org/trunk@37510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 18:59:27 +00:00
Drew Jaynes
9cb5247392 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

Built from https://develop.svn.wordpress.org/trunk@37518


git-svn-id: http://core.svn.wordpress.org/trunk@37486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:50:28 +00:00
Drew Jaynes
f52a8cb1fa Docs: Remove/replace invalid inline @link tags in DocBlocks in wp-includes/*.
Fixes #36910.

Built from https://develop.svn.wordpress.org/trunk@37487


git-svn-id: http://core.svn.wordpress.org/trunk@37455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 17:39:28 +00:00
Drew Jaynes
383b9a44de Docs: Adjust formatting for an added-parameter changelog entry in the hook doc for the cron_request filter.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@36299


git-svn-id: http://core.svn.wordpress.org/trunk@36266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-14 17:30:28 +00:00
Eric Lewis
7733ed2ddc Cron: Add the cron lock timestamp to the 'cron_request' filter arguments.
Fixes #31307

Built from https://develop.svn.wordpress.org/trunk@36228


git-svn-id: http://core.svn.wordpress.org/trunk@36195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-08 23:54:26 +00:00
Drew Jaynes
df0c1aa0ed Docs: Add a missing notation for the $gmt_time parameter in the DocBlock for spawn_cron().
See #32246.

Built from https://develop.svn.wordpress.org/trunk@36022


git-svn-id: http://core.svn.wordpress.org/trunk@35987 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-19 08:20:27 +00:00
Scott Taylor
2f167faeb2 Cron: In spawn_cron(), when using ALTERNATE_WP_CRON, return early for any non-GET, instead of naively checking ! empty( $_POST ).
Props johnbillion, markoheijnen.
Fixes #27447.

Built from https://develop.svn.wordpress.org/trunk@34576


git-svn-id: http://core.svn.wordpress.org/trunk@34540 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-26 04:51:26 +00:00
Sergey Biryukov
d9b7d915c2 Document @return value for wp_unschedule_event().
See #33475.
Built from https://develop.svn.wordpress.org/trunk@34044


git-svn-id: http://core.svn.wordpress.org/trunk@34012 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-11 11:35:24 +00:00
Scott Taylor
c1bb5b5ce3 After [33843], update the location of some files in This filter is documented in docs
Props dimadin.
See #33413.

Built from https://develop.svn.wordpress.org/trunk@33954


git-svn-id: http://core.svn.wordpress.org/trunk@33923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-08 22:17:26 +00:00
Dion Hulse
580ca68e26 Cron: Reject events when the provided $timestamp is not a valid timestamp.
Invalid timestamps were previously accepted by the scheduling functions but would never be run due to our implementation which caused the cron option to forever contain the events.
This rejects such events which most likely only occur due to developer error.

Props utkarshpatel, wonderboymusic, SergeyBiryukov.
See #33423, Fixes #33475

Built from https://develop.svn.wordpress.org/trunk@33936


git-svn-id: http://core.svn.wordpress.org/trunk@33905 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-07 02:39:23 +00:00
Drew Jaynes
4c37f68b79 Fix inline documentation syntax in wp_xmlrpc_server.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@32591


git-svn-id: http://core.svn.wordpress.org/trunk@32561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-25 06:25:25 +00:00
Dominik Schilling
64fc7294b6 Use HTTPS URLs for codex.wordpress.org.
see #27115.
Built from https://develop.svn.wordpress.org/trunk@32116


git-svn-id: http://core.svn.wordpress.org/trunk@32095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-12 21:29:32 +00:00
Scott Taylor
e619abda6e Improve various @param docs for src/wp-includes/*.
See #30224.

Built from https://develop.svn.wordpress.org/trunk@30681


git-svn-id: http://core.svn.wordpress.org/trunk@30671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-01 01:34:24 +00:00
Drew Jaynes
273396fe1e Ensure inline code is markdown-escaped as such, and that code snippets in descriptions are properly indented.
Affects DocBlocks for the following core elements:
* Backtick-escapes a `<link>` tag in a parameter description for the `embed_oembed_discover` hook
* Inline code fixes in the summary and return description for `WP_List_Table::get_table_classes()`
* Removes HTML markup from the summary for `WP_List_Table::display_rows_or_placeholder()`
* Backtick-escapes a `<tr>` tag in a parameter description for `WP_Users_List_Table::single_row()`
* Converts non-DocBlocks into multi-line comments in `WP_Dependencies::do_items()`
* Removes HTML markup from the summary for the `comment_form_top` hook.
* Inline code and snippet fixes in the description for `wp_get_schedules()`

Props rarst for the initial patch.
See #30473.

Built from https://develop.svn.wordpress.org/trunk@30537


git-svn-id: http://core.svn.wordpress.org/trunk@30526 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-24 04:58:22 +00:00
Scott Taylor
ea679e358e wp_schedule_single_event() should not prevent scheduling a future duplicate event. It should only reject an event as a duplicate if there is already a similar event scheduled within 10 minutes of the given timestamp.
Adds unit tests, fixes existing cron test.

Props tellyworth.

See [9181], #6966.
Fixes #28213.

Built from https://develop.svn.wordpress.org/trunk@29939


git-svn-id: http://core.svn.wordpress.org/trunk@29690 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-17 19:17:18 +00:00
Sergey Biryukov
f1ab373378 Skip ALTERNATE_WP_CRON redirect when performing XML-RPC requests.
props markoheijnen.
fixes #27447.
Built from https://develop.svn.wordpress.org/trunk@29732


git-svn-id: http://core.svn.wordpress.org/trunk@29506 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-11 14:02:15 +00:00
Sergey Biryukov
7753c3ff05 Avoid an undefined index notice in wp_reschedule_event().
props paulschreiber.
fixes #29077.
Built from https://develop.svn.wordpress.org/trunk@29349


git-svn-id: http://core.svn.wordpress.org/trunk@29126 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-01 20:57:16 +00:00
John Blackbourn
9e85d070a8 Remove SSL verification by default for requests to wp-cron.php. Props sivel, rhurling. Fixes #12609.
Built from https://develop.svn.wordpress.org/trunk@28781


git-svn-id: http://core.svn.wordpress.org/trunk@28594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-19 22:53:19 +00:00
Dion Hulse
bb9dd73d53 Cron: Fix a case where a cache inconsistency can cause wp_clear_scheduled_hook() to enter an infinite loop. This unravels the function from using other cron api functions to looping over the cron array directly. See #25773
Built from https://develop.svn.wordpress.org/trunk@26782


git-svn-id: http://core.svn.wordpress.org/trunk@26669 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-07 09:13:11 +00:00
Dominik Schilling
596bbe36a9 Cron Request: Fix incorrect use of add_query_arg() arguments.
props datafeedrcom, dimadin.
see [26267].
fixes #26218.
Built from https://develop.svn.wordpress.org/trunk@26365


git-svn-id: http://core.svn.wordpress.org/trunk@26266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-24 21:49:09 +00:00
Drew Jaynes
812e66d61d Inline documentation for hooks in wp-includes/cron.php.
Props tmtoy for the initial patch.
Fixes #25475.

Built from https://develop.svn.wordpress.org/trunk@26267


git-svn-id: http://core.svn.wordpress.org/trunk@26173 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-19 05:01:11 +00:00
Ryan Boren
15a06a35ab Use wp_unslash() instead of stripslashes() and stripslashes_deep(). Use wp_slash() instead of add_magic_quotes().
see #WP21767


git-svn-id: http://core.svn.wordpress.org/trunk@23591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-03 16:30:38 +00:00
Ryan Boren
43a7e695e9 Revert 23416, 23419, 23445 except for wp_reset_vars() changes. We are going a different direction with the slashing cleanup, so resetting to a clean slate. see #21767
git-svn-id: http://core.svn.wordpress.org/trunk@23554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-01 16:28:40 +00:00
Ryan Boren
cc5ed3a485 Change all core API to expect unslashed rather than slashed arguments.
The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now.

Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet.

Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed.

Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary.

Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core.

Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests.

Plugins should use wp_unslash() on data being passed to core API.

Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer.

Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data.

Remove many no longer necessary calls to $wpdb->escape() and esc_sql().

In wp_get_referer() and wp_get_original_referer(), return unslashed data.

Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget.

Switch several queries over to prepare().

Expect something to break.

Props alexkingorg
see #21767


git-svn-id: http://core.svn.wordpress.org/trunk@23416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-14 22:51:06 +00:00
Andrew Nacin
557d9313a7 Introduce constants to allow for easier expression of time periods in seconds. Adds MINUTE_IN_SECONDS, HOUR_IN_SECONDS, DAY_IN_SECONDS, WEEK_IN_SECONDS, YEAR_IN_SECONDS. props nbachiyski, SergeyBiryukov. fixes #20987.
git-svn-id: http://core.svn.wordpress.org/trunk@21996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-25 05:26:19 +00:00
Andrew Nacin
b45c550376 Use $gmt_time rather than $local_time in cron, since it uses GMT/UTC and not a local timestamp. see #14391.
git-svn-id: http://core.svn.wordpress.org/trunk@21954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-23 16:57:21 +00:00
ryan
95cfdf2fd6 Introduce cron_request filter. Props ikailo. fixes #13449
git-svn-id: http://core.svn.wordpress.org/trunk@21293 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-20 15:15:22 +00:00
ryan
15c7c9095b Use site_url() to construct the cron url. Props SergeyBiryukov. see #13449
git-svn-id: http://svn.automattic.com/wordpress/trunk@19922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-14 17:53:35 +00:00
ryan
2f915b5320 Use microtime() for cron locks. fixes #19700
git-svn-id: http://svn.automattic.com/wordpress/trunk@19722 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-09 19:02:31 +00:00
ryan
07ff8b216b Use one space, not two, after trailing punctuation. fixes #19537
git-svn-id: http://svn.automattic.com/wordpress/trunk@19593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-12-13 23:45:31 +00:00
ryan
5ebcc1d3ea Improve cron locking. Avoid multiple cron processes looping over the same events. fixes #17462
git-svn-id: http://svn.automattic.com/wordpress/trunk@18659 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-09 19:59:44 +00:00
nacin
844636bf1c Don't show extra .0 in _deprecated_argument calls. They should appear in @since docs though.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-12-15 11:27:38 +00:00
scribu
3b5707c4be Add note about wp_next_scheduled() in wp_schedule_event(). See #14668
git-svn-id: http://svn.automattic.com/wordpress/trunk@16690 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-12-02 16:27:16 +00:00
nacin
d0b26b2d43 Kill check_server_timer(). fixes #15602.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-11-29 05:16:24 +00:00
ryan
a2ec5bfafa Introduce schedule_event filter. fixes #15146
git-svn-id: http://svn.automattic.com/wordpress/trunk@15837 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-10-18 20:50:35 +00:00
dd32
a14d289755 Alot more tabs. Props jacobsantos & Viper007bond. See #14147
git-svn-id: http://svn.automattic.com/wordpress/trunk@15355 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-06-30 00:05:18 +00:00
ryan
039b8aa6e5 Don't suppress errors when including cron if WP_DEBUG. Props sivel. fixes #11507
git-svn-id: http://svn.automattic.com/wordpress/trunk@14414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-05-03 21:46:19 +00:00
westi
ff7831207c Updates and improvements to _depreceated_argument. See #11386 props nacin.
git-svn-id: http://svn.automattic.com/wordpress/trunk@12584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-12-30 16:23:39 +00:00
westi
47a7b1b003 Fix typo in _deprecated_argument() and start using _deprecated_argument() in wp-includes files. See #11386 props nacin.
git-svn-id: http://svn.automattic.com/wordpress/trunk@12537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-12-24 11:12:04 +00:00
westi
53dfdc063b Fix wp_clear_scheduled_hook() so that it function prototype matches the other cron functions.
Include backwards compatibility code so that plugins that used the old way still work.
Fixes #10468.

git-svn-id: http://svn.automattic.com/wordpress/trunk@12462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-12-19 11:47:16 +00:00