Verified Commit 4f378557 authored by Erick Hitter's avatar Erick Hitter
Browse files

Make clear what the different post statuses are used for

parent cfc5de3e
......@@ -13,7 +13,7 @@ class Cron_Options_CPT extends Singleton {
const LOCK = 'create-jobs';
const POST_TYPE = 'a8c_cron_ctrl_events';
const POST_STATUS = 'inherit';
const POST_STATUS_PENDING = 'inherit';
const POST_STATUS_COMPLETED = 'trash';
private $posts_to_clean = array();
......@@ -74,7 +74,7 @@ class Cron_Options_CPT extends Singleton {
do {
$jobs_posts = $this->get_jobs( array(
'post_type' => self::POST_TYPE,
'post_status' => self::POST_STATUS,
'post_status' => self::POST_STATUS_PENDING,
'suppress_filters' => false,
'posts_per_page' => 100,
'paged' => $page,
......@@ -177,7 +177,7 @@ class Cron_Options_CPT extends Singleton {
'post_date' => date( 'Y-m-d H:i:s', $event['timestamp'] ),
'post_date_gmt' => date( 'Y-m-d H:i:s', $event['timestamp'] ),
'post_type' => self::POST_TYPE,
'post_status' => self::POST_STATUS,
'post_status' => self::POST_STATUS_PENDING,
);
$this->create_job( $job_post );
......@@ -223,7 +223,7 @@ class Cron_Options_CPT extends Singleton {
private function job_exists( $timestamp, $action, $instance, $return_id = false ) {
global $wpdb;
$exists = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s AND post_status = %s LIMIT 1;", $this->event_name( $timestamp, $action, $instance ), self::POST_TYPE, self::POST_STATUS ) );
$exists = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s AND post_type = %s AND post_status = %s LIMIT 1;", $this->event_name( $timestamp, $action, $instance ), self::POST_TYPE, self::POST_STATUS_PENDING ) );
if ( $return_id ) {
return empty( $exists ) ? 0 : (int) array_shift( $exists );
......
......@@ -34,7 +34,7 @@ class Utils {
static function get_events_from_post_objects() {
$events = get_posts( array(
'post_type' => \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_TYPE,
'post_status' => \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_STATUS,
'post_status' => \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_STATUS_PENDING,
'posts_per_page' => 10,
'orderby' => 'date',
'order' => 'ASC',
......
......@@ -28,7 +28,7 @@ class Cron_Options_CPT_Tests extends \WP_UnitTestCase {
$event = \Automattic\WP\Cron_Control\Tests\Utils::create_test_event();
$post_name = sprintf( '%s-%s-%s', $event['timestamp'], md5( $event['action'] ), md5( maybe_serialize( $event['args'] ) ) );
$entry = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND post_name = %s LIMIT 1", \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_TYPE, \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_STATUS, $post_name ) );
$entry = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND post_name = %s LIMIT 1", \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_TYPE, \Automattic\WP\Cron_Control\Cron_Options_CPT::POST_STATUS_PENDING, $post_name ) );
$this->assertEquals( count( $entry ), 1 );
......
Supports Markdown
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