PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.1
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / vendor / woocommerce / action-scheduler / classes / schema / ActionScheduler_StoreSchema.php
jetformbuilder / vendor / woocommerce / action-scheduler / classes / schema Last commit date
ActionScheduler_LoggerSchema.php 1 year ago ActionScheduler_StoreSchema.php 1 month ago
ActionScheduler_StoreSchema.php
146 lines
1 <?php
2
3 /**
4 * Class ActionScheduler_StoreSchema
5 *
6 * @codeCoverageIgnore
7 *
8 * Creates custom tables for storing scheduled actions
9 */
10 class ActionScheduler_StoreSchema extends ActionScheduler_Abstract_Schema {
11 const ACTIONS_TABLE = 'actionscheduler_actions';
12 const CLAIMS_TABLE = 'actionscheduler_claims';
13 const GROUPS_TABLE = 'actionscheduler_groups';
14 const DEFAULT_DATE = '0000-00-00 00:00:00';
15
16 /**
17 * Schema version.
18 *
19 * Increment this value to trigger a schema update.
20 *
21 * @var int
22 */
23 protected $schema_version = 8;
24
25 /**
26 * Construct.
27 */
28 public function __construct() {
29 $this->tables = array(
30 self::ACTIONS_TABLE,
31 self::CLAIMS_TABLE,
32 self::GROUPS_TABLE,
33 );
34 }
35
36 /**
37 * Performs additional setup work required to support this schema.
38 */
39 public function init() {
40 add_action( 'action_scheduler_before_schema_update', array( $this, 'update_schema_5_0' ), 10, 2 );
41 }
42
43 /**
44 * Get table definition.
45 *
46 * @param string $table Table name.
47 */
48 protected function get_table_definition( $table ) {
49 global $wpdb;
50 $table_name = $wpdb->$table;
51 $charset_collate = $wpdb->get_charset_collate();
52 $default_date = self::DEFAULT_DATE;
53 // phpcs:ignore Squiz.PHP.CommentedOutCode
54 $max_index_length = 191; // @see wp_get_db_schema()
55
56 $hook_status_scheduled_date_gmt_max_index_length = $max_index_length - 20 - 8; // - status, - scheduled_date_gmt
57
58 switch ( $table ) {
59
60 case self::ACTIONS_TABLE:
61 return "CREATE TABLE {$table_name} (
62 action_id bigint(20) unsigned NOT NULL auto_increment,
63 hook varchar(191) NOT NULL,
64 status varchar(20) NOT NULL,
65 scheduled_date_gmt datetime NULL default '{$default_date}',
66 scheduled_date_local datetime NULL default '{$default_date}',
67 priority tinyint unsigned NOT NULL default '10',
68 args varchar($max_index_length),
69 schedule longtext,
70 group_id bigint(20) unsigned NOT NULL default '0',
71 attempts int(11) NOT NULL default '0',
72 last_attempt_gmt datetime NULL default '{$default_date}',
73 last_attempt_local datetime NULL default '{$default_date}',
74 claim_id bigint(20) unsigned NOT NULL default '0',
75 extended_args varchar(8000) DEFAULT NULL,
76 PRIMARY KEY (action_id),
77 KEY hook_status_scheduled_date_gmt (hook($hook_status_scheduled_date_gmt_max_index_length), status, scheduled_date_gmt),
78 KEY status_scheduled_date_gmt (status, scheduled_date_gmt),
79 KEY scheduled_date_gmt (scheduled_date_gmt),
80 KEY args (args($max_index_length)),
81 KEY group_id (group_id),
82 KEY last_attempt_gmt (last_attempt_gmt),
83 KEY `claim_id_status_priority_scheduled_date_gmt` (`claim_id`,`status`,`priority`,`scheduled_date_gmt`),
84 KEY `status_last_attempt_gmt` (`status`,`last_attempt_gmt`),
85 KEY `status_claim_id` (`status`,`claim_id`)
86 ) $charset_collate";
87
88 case self::CLAIMS_TABLE:
89 return "CREATE TABLE {$table_name} (
90 claim_id bigint(20) unsigned NOT NULL auto_increment,
91 date_created_gmt datetime NULL default '{$default_date}',
92 PRIMARY KEY (claim_id),
93 KEY date_created_gmt (date_created_gmt)
94 ) $charset_collate";
95
96 case self::GROUPS_TABLE:
97 return "CREATE TABLE {$table_name} (
98 group_id bigint(20) unsigned NOT NULL auto_increment,
99 slug varchar(255) NOT NULL,
100 PRIMARY KEY (group_id),
101 KEY slug (slug($max_index_length))
102 ) $charset_collate";
103
104 default:
105 return '';
106 }
107 }
108
109 /**
110 * Update the actions table schema, allowing datetime fields to be NULL.
111 *
112 * This is needed because the NOT NULL constraint causes a conflict with some versions of MySQL
113 * configured with sql_mode=NO_ZERO_DATE, which can for instance lead to tables not being created.
114 *
115 * Most other schema updates happen via ActionScheduler_Abstract_Schema::update_table(), however
116 * that method relies on dbDelta() and this change is not possible when using that function.
117 *
118 * @param string $table Name of table being updated.
119 * @param string $db_version The existing schema version of the table.
120 */
121 public function update_schema_5_0( $table, $db_version ) {
122 global $wpdb;
123
124 if ( 'actionscheduler_actions' !== $table || version_compare( $db_version, '5', '>=' ) ) {
125 return;
126 }
127
128 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
129 $table_name = $wpdb->prefix . 'actionscheduler_actions';
130 $table_list = $wpdb->get_col( "SHOW TABLES LIKE '{$table_name}'" );
131 $default_date = self::DEFAULT_DATE;
132
133 if ( ! empty( $table_list ) ) {
134 $query = "
135 ALTER TABLE {$table_name}
136 MODIFY COLUMN scheduled_date_gmt datetime NULL default '{$default_date}',
137 MODIFY COLUMN scheduled_date_local datetime NULL default '{$default_date}',
138 MODIFY COLUMN last_attempt_gmt datetime NULL default '{$default_date}',
139 MODIFY COLUMN last_attempt_local datetime NULL default '{$default_date}'
140 ";
141 $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
142 }
143 // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
144 }
145 }
146