← All changes
|
vendor/woocommerce/action-scheduler/classes/schema/ActionScheduler_StoreSchema.php
+21
-9
1.2.1
→
trunk
View file →
| @@ -13,18 +13,25 @@ | ||
| 13 | 13 | const GROUPS_TABLE = 'actionscheduler_groups'; |
| 14 | 14 | const DEFAULT_DATE = '0000-00-00 00:00:00'; |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * @var int Increment this value to trigger a schema update. | |
| 17 | + * Schema version. | |
| 18 | + * | |
| 19 | + * Increment this value to trigger a schema update. | |
| 20 | + * | |
| 21 | + * @var int | |
| 18 | 22 | */ |
| 19 | 23 | protected $schema_version = 7; |
| 20 | 24 | |
| 25 | + /** | |
| 26 | + * Construct. | |
| 27 | + */ | |
| 21 | 28 | public function __construct() { |
| 22 | - $this->tables = [ | |
| 29 | + $this->tables = array( | |
| 23 | 30 | self::ACTIONS_TABLE, |
| 24 | 31 | self::CLAIMS_TABLE, |
| 25 | 32 | self::GROUPS_TABLE, |
| 26 | - ]; | |
| 33 | + ); | |
| 27 | 34 | } |
| 28 | 35 | |
| 29 | 36 | /** |
| 30 | 37 | * Performs additional setup work required to support this schema. |
| @@ -32,19 +39,26 @@ | ||
| 32 | 39 | public function init() { |
| 33 | 40 | add_action( 'action_scheduler_before_schema_update', array( $this, 'update_schema_5_0' ), 10, 2 ); |
| 34 | 41 | } |
| 35 | 42 | |
| 43 | + /** | |
| 44 | + * Get table definition. | |
| 45 | + * | |
| 46 | + * @param string $table Table name. | |
| 47 | + */ | |
| 36 | 48 | protected function get_table_definition( $table ) { |
| 37 | 49 | global $wpdb; |
| 38 | - $table_name = $wpdb->$table; | |
| 39 | - $charset_collate = $wpdb->get_charset_collate(); | |
| 50 | + $table_name = $wpdb->$table; | |
| 51 | + $charset_collate = $wpdb->get_charset_collate(); | |
| 52 | + $default_date = self::DEFAULT_DATE; | |
| 53 | + // phpcs:ignore Squiz.PHP.CommentedOutCode | |
| 40 | 54 | $max_index_length = 191; // @see wp_get_db_schema() |
| 55 | + | |
| 41 | 56 | $hook_status_scheduled_date_gmt_max_index_length = $max_index_length - 20 - 8; // - status, - scheduled_date_gmt |
| 42 | - $default_date = self::DEFAULT_DATE; | |
| 57 | + | |
| 43 | 58 | switch ( $table ) { |
| 44 | 59 | |
| 45 | 60 | case self::ACTIONS_TABLE: |
| 46 | - | |
| 47 | 61 | return "CREATE TABLE {$table_name} ( |
| 48 | 62 | action_id bigint(20) unsigned NOT NULL auto_increment, |
| 49 | 63 | hook varchar(191) NOT NULL, |
| 50 | 64 | status varchar(20) NOT NULL, |
| @@ -69,9 +83,8 @@ | ||
| 69 | 83 | KEY `claim_id_status_scheduled_date_gmt` (`claim_id`, `status`, `scheduled_date_gmt`) |
| 70 | 84 | ) $charset_collate"; |
| 71 | 85 | |
| 72 | 86 | case self::CLAIMS_TABLE: |
| 73 | - | |
| 74 | 87 | return "CREATE TABLE {$table_name} ( |
| 75 | 88 | claim_id bigint(20) unsigned NOT NULL auto_increment, |
| 76 | 89 | date_created_gmt datetime NULL default '{$default_date}', |
| 77 | 90 | PRIMARY KEY (claim_id), |
| @@ -78,9 +91,8 @@ | ||
| 78 | 91 | KEY date_created_gmt (date_created_gmt) |
| 79 | 92 | ) $charset_collate"; |
| 80 | 93 | |
| 81 | 94 | case self::GROUPS_TABLE: |
| 82 | - | |
| 83 | 95 | return "CREATE TABLE {$table_name} ( |
| 84 | 96 | group_id bigint(20) unsigned NOT NULL auto_increment, |
| 85 | 97 | slug varchar(255) NOT NULL, |
| 86 | 98 | PRIMARY KEY (group_id), |