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_LoggerSchema.php
jetformbuilder / vendor / woocommerce / action-scheduler / classes / schema Last commit date
ActionScheduler_LoggerSchema.php 1 year ago ActionScheduler_StoreSchema.php 1 month ago
ActionScheduler_LoggerSchema.php
102 lines
1 <?php
2
3 /**
4 * Class ActionScheduler_LoggerSchema
5 *
6 * @codeCoverageIgnore
7 *
8 * Creates a custom table for storing action logs
9 */
10 class ActionScheduler_LoggerSchema extends ActionScheduler_Abstract_Schema {
11 const LOG_TABLE = 'actionscheduler_logs';
12
13 /**
14 * Schema version.
15 *
16 * Increment this value to trigger a schema update.
17 *
18 * @var int
19 */
20 protected $schema_version = 3;
21
22 /**
23 * Construct.
24 */
25 public function __construct() {
26 $this->tables = array(
27 self::LOG_TABLE,
28 );
29 }
30
31 /**
32 * Performs additional setup work required to support this schema.
33 */
34 public function init() {
35 add_action( 'action_scheduler_before_schema_update', array( $this, 'update_schema_3_0' ), 10, 2 );
36 }
37
38 /**
39 * Get table definition.
40 *
41 * @param string $table Table name.
42 */
43 protected function get_table_definition( $table ) {
44 global $wpdb;
45 $table_name = $wpdb->$table;
46 $charset_collate = $wpdb->get_charset_collate();
47 switch ( $table ) {
48
49 case self::LOG_TABLE:
50 $default_date = ActionScheduler_StoreSchema::DEFAULT_DATE;
51 return "CREATE TABLE $table_name (
52 log_id bigint(20) unsigned NOT NULL auto_increment,
53 action_id bigint(20) unsigned NOT NULL,
54 message text NOT NULL,
55 log_date_gmt datetime NULL default '{$default_date}',
56 log_date_local datetime NULL default '{$default_date}',
57 PRIMARY KEY (log_id),
58 KEY action_id (action_id),
59 KEY log_date_gmt (log_date_gmt)
60 ) $charset_collate";
61
62 default:
63 return '';
64 }
65 }
66
67 /**
68 * Update the logs table schema, allowing datetime fields to be NULL.
69 *
70 * This is needed because the NOT NULL constraint causes a conflict with some versions of MySQL
71 * configured with sql_mode=NO_ZERO_DATE, which can for instance lead to tables not being created.
72 *
73 * Most other schema updates happen via ActionScheduler_Abstract_Schema::update_table(), however
74 * that method relies on dbDelta() and this change is not possible when using that function.
75 *
76 * @param string $table Name of table being updated.
77 * @param string $db_version The existing schema version of the table.
78 */
79 public function update_schema_3_0( $table, $db_version ) {
80 global $wpdb;
81
82 if ( 'actionscheduler_logs' !== $table || version_compare( $db_version, '3', '>=' ) ) {
83 return;
84 }
85
86 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
87 $table_name = $wpdb->prefix . 'actionscheduler_logs';
88 $table_list = $wpdb->get_col( "SHOW TABLES LIKE '{$table_name}'" );
89 $default_date = ActionScheduler_StoreSchema::DEFAULT_DATE;
90
91 if ( ! empty( $table_list ) ) {
92 $query = "
93 ALTER TABLE {$table_name}
94 MODIFY COLUMN log_date_gmt datetime NULL default '{$default_date}',
95 MODIFY COLUMN log_date_local datetime NULL default '{$default_date}'
96 ";
97 $wpdb->query( $query ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
98 }
99 // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
100 }
101 }
102