Commit 45d9895d authored by Erick Hitter's avatar Erick Hitter

Port more of WP-CLI skeleton so we get a nice readme, which can include the minimum PHP version

parent be7a50ed
composer.lock
vendor
.DS_Store
Thumbs.db
wp-cli.local.yml
node_modules/
*.sql
*.tar.gz
*.zip
module.exports = function( grunt ) {
'use strict';
var banner = '/**\n * <%= pkg.homepage %>\n * Copyright (c) <%= grunt.template.today("yyyy") %>\n * This file is generated automatically. Do not edit.\n */\n';
// Project configuration
grunt.initConfig( {
pkg: grunt.file.readJSON( 'package.json' ),
addtextdomain: {
options: {
textdomain: 'automattic-cron-control',
},
update_all_domains: {
options: {
updateDomains: true
},
src: [ '*.php', '**/*.php', '!node_modules/**', '!php-tests/**', '!bin/**' ]
}
},
wp_readme_to_markdown: {
your_target: {
files: {
'README.md': 'readme.txt'
}
},
},
makepot: {
target: {
options: {
domainPath: '/languages',
mainFile: 'cron-control.php',
potFilename: 'cron-control.pot',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
},
type: 'wp-plugin',
updateTimestamp: true
}
}
},
} );
grunt.loadNpmTasks( 'grunt-wp-i18n' );
grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' );
grunt.registerTask( 'i18n', ['addtextdomain', 'makepot'] );
grunt.registerTask( 'readme', ['wp_readme_to_markdown'] );
grunt.util.linefeed = '\n';
};
Cron Control
============
# Cron Control #
**Contributors:** automattic, ethitter
**Tags:** support, user
**Requires at least:** 4.4
**Tested up to:** 4.9
**Requires PHP:** 7.0
**Stable tag:** 0.1.0
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
Execute WordPress cron events in parallel, using a custom post type for event storage.
Execute WordPress cron events in parallel, with custom event storage for high-volume cron.
Using REST API endpoints (requires WordPress 4.4+), an event queue is produced and events are triggered.
## Description ##
## PHP Compatibility
Execute WordPress cron events in parallel, with custom event storage for high-volume cron.
Cron Control requires PHP 7 or greater to be able to catch fatal errors triggered by event callbacks. PHP 7 is also required to define arrays in constants (such as for adding "Internal Events").
Using REST API endpoints (requires WordPress 4.4+), or a Golang daemon, an event queue is produced and events are triggered.
## Event Concurrency
## Installation ##
In some circumstances, multiple events with the same action can safely run in parallel. This is usually not the case, largely due to Core's alloptions, but sometimes an event is written in a way that we can support concurrent executions.
1. Define `WP_CRON_CONTROL_SECRET` in `wp-config.php`
1. Upload the `cron-control` directory to the `/wp-content/mu-plugins/` directory
1. Create a file at `/wp-content/mu-plugins/cron-control.php` to load `/wp-content/mu-plugins/cron-control/cron-control.php`
To allow concurrency for your event, and to specify the level of concurrency, please hook the `a8c_cron_control_concurrent_event_whitelist` filter as in the following example:
## Frequently Asked Questions ##
``` php
add_filter( 'a8c_cron_control_concurrent_event_whitelist', function( $wh ) {
$wh['my_custom_event'] = 2;
### Why is PHP 7 required? ###
return $wh;
} );
```
To be able to catch fatal errors triggered by event callbacks, and define arrays in constants (such as for adding "Internal Events"), PHP 7 is necessary.
## Adding Internal Events
### Adding Internal Events ###
**This should be done sparingly as "Internal Events" bypass certain locks and limits built into the plugin.** Overuse will lead to unexpected resource usage, and likely resource exhaustion.
In `wp-config.php` or a similarly-early and appropriate place, define `CRON_CONTROL_ADDITIONAL_INTERNAL_EVENTS` as an array of arrays like:
```php
```
define( 'CRON_CONTROL_ADDITIONAL_INTERNAL_EVENTS', array(
array(
'schedule' => 'hourly',
'action' => 'do_a_thing',
'callback' => '__return_true',
),
array(
'schedule' => 'hourly',
'action' => 'do_a_thing',
'callback' => '__return_true',
),
) );
```
Due to the early loading (to limit additions), the `action` and `callback` generally can't directly reference any Core, plugin, or theme code. Since WordPress uses actions to trigger cron, class methods can be referenced, so long as the class name is not dynamically referenced. For example:
```php
```
define( 'CRON_CONTROL_ADDITIONAL_INTERNAL_EVENTS', array(
array(
'schedule' => 'hourly',
'action' => 'do_a_thing',
'callback' => array( 'Some_Class', 'some_method' ),
),
array(
'schedule' => 'hourly',
'action' => 'do_a_thing',
'callback' => array( 'Some_Class', 'some_method' ),
),
) );
```
Take care to reference the full namespace when appropriate.
### Increasing Event Concurrency ###
In some circumstances, multiple events with the same action can safely run in parallel. This is usually not the case, largely due to Core's alloptions, but sometimes an event is written in a way that we can support concurrent executions.
To allow concurrency for your event, and to specify the level of concurrency, please hook the `a8c_cron_control_concurrent_event_whitelist` filter as in the following example:
```
add_filter( 'a8c_cron_control_concurrent_event_whitelist', function( $wh ) {
$wh['my_custom_event'] = 2;
return $wh;
} );
```
## Changelog ##
### 1.5 ###
* Convert from custom post type to custom table with proper indices
### 1.0 ###
* Initial release
{
"name": "automattic/cron-control",
"description": "Execute WordPress cron events in parallel, with custom event storage for high-volume cron.",
"license": "GPL-2.0",
"require": {
"php": ">=7.0.0"
},
"require-dev": {
"wp-cli/wp-cli": "*"
}
}
{
"name": "cron-control",
"version": "1.5.0",
"main": "Gruntfile.js",
"author": "Automatic",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-wp-i18n": "~0.5.0",
"grunt-wp-readme-to-markdown": "~1.0.0"
}
}
=== Cron Control ===
Contributors: automattic, ethitter
Tags: support, user
Requires at least: 4.4
Tested up to: 4.9
Requires PHP: 7.0
Stable tag: 0.1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Execute WordPress cron events in parallel, with custom event storage for high-volume cron.
== Description ==
Execute WordPress cron events in parallel, with custom event storage for high-volume cron.
Using REST API endpoints (requires WordPress 4.4+), or a Golang daemon, an event queue is produced and events are triggered.
== Installation ==
1. Define `WP_CRON_CONTROL_SECRET` in `wp-config.php`
1. Upload the `cron-control` directory to the `/wp-content/mu-plugins/` directory
1. Create a file at `/wp-content/mu-plugins/cron-control.php` to load `/wp-content/mu-plugins/cron-control/cron-control.php`
== Frequently Asked Questions ==
= Why is PHP 7 required? =
To be able to catch fatal errors triggered by event callbacks, and define arrays in constants (such as for adding "Internal Events"), PHP 7 is necessary.
= Adding Internal Events =
**This should be done sparingly as "Internal Events" bypass certain locks and limits built into the plugin.** Overuse will lead to unexpected resource usage, and likely resource exhaustion.
In `wp-config.php` or a similarly-early and appropriate place, define `CRON_CONTROL_ADDITIONAL_INTERNAL_EVENTS` as an array of arrays like:
```
define( 'CRON_CONTROL_ADDITIONAL_INTERNAL_EVENTS', array(
array(
'schedule' => 'hourly',
'action' => 'do_a_thing',
'callback' => '__return_true',
),
) );
```
Due to the early loading (to limit additions), the `action` and `callback` generally can't directly reference any Core, plugin, or theme code. Since WordPress uses actions to trigger cron, class methods can be referenced, so long as the class name is not dynamically referenced. For example:
```
define( 'CRON_CONTROL_ADDITIONAL_INTERNAL_EVENTS', array(
array(
'schedule' => 'hourly',
'action' => 'do_a_thing',
'callback' => array( 'Some_Class', 'some_method' ),
),
) );
```
Take care to reference the full namespace when appropriate.
= Increasing Event Concurrency =
In some circumstances, multiple events with the same action can safely run in parallel. This is usually not the case, largely due to Core's alloptions, but sometimes an event is written in a way that we can support concurrent executions.
To allow concurrency for your event, and to specify the level of concurrency, please hook the `a8c_cron_control_concurrent_event_whitelist` filter as in the following example:
```
add_filter( 'a8c_cron_control_concurrent_event_whitelist', function( $wh ) {
$wh['my_custom_event'] = 2;
return $wh;
} );
```
== Changelog ==
= 1.5 =
* Convert from custom post type to custom table with proper indices
= 1.0 =
* Initial release
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment