@@ -11,77 +11,77 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_DMS_4_8_0_event_subtotals extends EE_Data_Migration_Script_Stage_Table |
13 | 13 | { |
14 | - public function __construct() |
|
15 | - { |
|
16 | - global $wpdb; |
|
17 | - $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
18 | - $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
19 | - $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
|
20 | - parent::__construct(); |
|
21 | - } |
|
22 | - protected function _migrate_old_row($line_item_row) |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
26 | - $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | - $new_line_item_data = array( |
|
28 | - 'LIN_code' => 'event-' . $event_id, |
|
29 | - 'TXN_ID' => $line_item_row['TXN_ID'], |
|
30 | - 'LIN_name' => __('Event', 'event_espresso'), |
|
31 | - 'LIN_desc' => $line_item_row['LIN_desc'], |
|
32 | - 'LIN_unit_price' => $line_item_row['LIN_unit_price'], |
|
33 | - 'LIN_percent' => $line_item_row['LIN_percent'], |
|
34 | - 'LIN_is_taxable' => $line_item_row['LIN_is_taxable'], |
|
35 | - 'LIN_order' => $line_item_row['LIN_order'], |
|
36 | - 'LIN_total' => $line_item_row['LIN_total'], |
|
37 | - 'LIN_quantity' => $line_item_row['LIN_quantity'], |
|
38 | - 'LIN_parent' => $line_item_row['LIN_ID'], |
|
39 | - 'LIN_type' => 'sub-total', |
|
40 | - 'OBJ_type' => 'Event', |
|
41 | - 'OBJ_ID' => $event_id, |
|
42 | - ); |
|
43 | - $new_line_item_datatypes = array( |
|
44 | - '%s',// LIN_code |
|
45 | - '%d',// TXN_ID |
|
46 | - '%s',// LIN_name |
|
47 | - '%s',// LIN_desc |
|
48 | - '%f',// LIN_unit_price |
|
49 | - '%f',// LIN_percent |
|
50 | - '%d',// LIN_is_taxable |
|
51 | - '%d',// LIN_order |
|
52 | - '%f',// LIN_total |
|
53 | - '%d',// LIN_quantity |
|
54 | - '%d',// LIN_parent |
|
55 | - '%s',// LIN_type |
|
56 | - '%s',// OBJ_type |
|
57 | - '%d',// OBJ_ID |
|
58 | - ); |
|
59 | - // insert the new event subtotal line item, pointing to this line item |
|
60 | - $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
|
61 | - if (! $success) { |
|
62 | - $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
|
63 | - } |
|
64 | - $new_line_item_id = $wpdb->insert_id; |
|
65 | - $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id); |
|
66 | - $query = $wpdb->prepare( |
|
67 | - "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
68 | - $new_line_item_id, |
|
69 | - $line_item_row['LIN_ID'], |
|
70 | - $new_line_item_id |
|
71 | - ); |
|
72 | - $success = $wpdb->query($query); |
|
73 | - if ($success === false) { |
|
74 | - $this->add_error( |
|
75 | - sprintf( |
|
76 | - __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'), |
|
77 | - $new_line_item_id, |
|
78 | - $line_item_row['LIN_ID'], |
|
79 | - $wpdb->last_error, |
|
80 | - $query, |
|
81 | - $success |
|
82 | - ) |
|
83 | - ); |
|
84 | - } |
|
85 | - return 1; |
|
86 | - } |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + global $wpdb; |
|
17 | + $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
18 | + $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
19 | + $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
|
20 | + parent::__construct(); |
|
21 | + } |
|
22 | + protected function _migrate_old_row($line_item_row) |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
26 | + $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | + $new_line_item_data = array( |
|
28 | + 'LIN_code' => 'event-' . $event_id, |
|
29 | + 'TXN_ID' => $line_item_row['TXN_ID'], |
|
30 | + 'LIN_name' => __('Event', 'event_espresso'), |
|
31 | + 'LIN_desc' => $line_item_row['LIN_desc'], |
|
32 | + 'LIN_unit_price' => $line_item_row['LIN_unit_price'], |
|
33 | + 'LIN_percent' => $line_item_row['LIN_percent'], |
|
34 | + 'LIN_is_taxable' => $line_item_row['LIN_is_taxable'], |
|
35 | + 'LIN_order' => $line_item_row['LIN_order'], |
|
36 | + 'LIN_total' => $line_item_row['LIN_total'], |
|
37 | + 'LIN_quantity' => $line_item_row['LIN_quantity'], |
|
38 | + 'LIN_parent' => $line_item_row['LIN_ID'], |
|
39 | + 'LIN_type' => 'sub-total', |
|
40 | + 'OBJ_type' => 'Event', |
|
41 | + 'OBJ_ID' => $event_id, |
|
42 | + ); |
|
43 | + $new_line_item_datatypes = array( |
|
44 | + '%s',// LIN_code |
|
45 | + '%d',// TXN_ID |
|
46 | + '%s',// LIN_name |
|
47 | + '%s',// LIN_desc |
|
48 | + '%f',// LIN_unit_price |
|
49 | + '%f',// LIN_percent |
|
50 | + '%d',// LIN_is_taxable |
|
51 | + '%d',// LIN_order |
|
52 | + '%f',// LIN_total |
|
53 | + '%d',// LIN_quantity |
|
54 | + '%d',// LIN_parent |
|
55 | + '%s',// LIN_type |
|
56 | + '%s',// OBJ_type |
|
57 | + '%d',// OBJ_ID |
|
58 | + ); |
|
59 | + // insert the new event subtotal line item, pointing to this line item |
|
60 | + $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
|
61 | + if (! $success) { |
|
62 | + $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
|
63 | + } |
|
64 | + $new_line_item_id = $wpdb->insert_id; |
|
65 | + $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id); |
|
66 | + $query = $wpdb->prepare( |
|
67 | + "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
68 | + $new_line_item_id, |
|
69 | + $line_item_row['LIN_ID'], |
|
70 | + $new_line_item_id |
|
71 | + ); |
|
72 | + $success = $wpdb->query($query); |
|
73 | + if ($success === false) { |
|
74 | + $this->add_error( |
|
75 | + sprintf( |
|
76 | + __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'), |
|
77 | + $new_line_item_id, |
|
78 | + $line_item_row['LIN_ID'], |
|
79 | + $wpdb->last_error, |
|
80 | + $query, |
|
81 | + $success |
|
82 | + ) |
|
83 | + ); |
|
84 | + } |
|
85 | + return 1; |
|
86 | + } |
|
87 | 87 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct() |
15 | 15 | { |
16 | 16 | global $wpdb; |
17 | - $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
17 | + $this->_old_table = $wpdb->prefix.'esp_line_item'; |
|
18 | 18 | $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
19 | 19 | $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
20 | 20 | parent::__construct(); |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $wpdb; |
25 | 25 | // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
26 | - $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
26 | + $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM '.$wpdb->prefix.'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | 27 | $new_line_item_data = array( |
28 | - 'LIN_code' => 'event-' . $event_id, |
|
28 | + 'LIN_code' => 'event-'.$event_id, |
|
29 | 29 | 'TXN_ID' => $line_item_row['TXN_ID'], |
30 | 30 | 'LIN_name' => __('Event', 'event_espresso'), |
31 | 31 | 'LIN_desc' => $line_item_row['LIN_desc'], |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | 'OBJ_ID' => $event_id, |
42 | 42 | ); |
43 | 43 | $new_line_item_datatypes = array( |
44 | - '%s',// LIN_code |
|
45 | - '%d',// TXN_ID |
|
46 | - '%s',// LIN_name |
|
47 | - '%s',// LIN_desc |
|
48 | - '%f',// LIN_unit_price |
|
49 | - '%f',// LIN_percent |
|
50 | - '%d',// LIN_is_taxable |
|
51 | - '%d',// LIN_order |
|
52 | - '%f',// LIN_total |
|
53 | - '%d',// LIN_quantity |
|
54 | - '%d',// LIN_parent |
|
55 | - '%s',// LIN_type |
|
56 | - '%s',// OBJ_type |
|
57 | - '%d',// OBJ_ID |
|
44 | + '%s', // LIN_code |
|
45 | + '%d', // TXN_ID |
|
46 | + '%s', // LIN_name |
|
47 | + '%s', // LIN_desc |
|
48 | + '%f', // LIN_unit_price |
|
49 | + '%f', // LIN_percent |
|
50 | + '%d', // LIN_is_taxable |
|
51 | + '%d', // LIN_order |
|
52 | + '%f', // LIN_total |
|
53 | + '%d', // LIN_quantity |
|
54 | + '%d', // LIN_parent |
|
55 | + '%s', // LIN_type |
|
56 | + '%s', // OBJ_type |
|
57 | + '%d', // OBJ_ID |
|
58 | 58 | ); |
59 | 59 | // insert the new event subtotal line item, pointing to this line item |
60 | 60 | $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
61 | - if (! $success) { |
|
61 | + if ( ! $success) { |
|
62 | 62 | $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
63 | 63 | } |
64 | 64 | $new_line_item_id = $wpdb->insert_id; |
@@ -13,53 +13,53 @@ |
||
13 | 13 | class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage |
14 | 14 | { |
15 | 15 | |
16 | - protected $_line_item_table_name; |
|
16 | + protected $_line_item_table_name; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Just initializes the status of the migration |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | - $this->_pretty_name = __('Pre-tax total line items', 'event_espresso'); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
19 | + /** |
|
20 | + * Just initializes the status of the migration |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | + $this->_pretty_name = __('Pre-tax total line items', 'event_espresso'); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Counts the records to migrate; the public version may cache it |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - protected function _count_records_to_migrate() |
|
37 | - { |
|
38 | - return 1; |
|
39 | - } |
|
32 | + /** |
|
33 | + * Counts the records to migrate; the public version may cache it |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + protected function _count_records_to_migrate() |
|
37 | + { |
|
38 | + return 1; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
45 | - * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
46 | - * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
47 | - * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
48 | - * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
49 | - * @param int $num_items_to_migrate |
|
50 | - * @return int number of items ACTUALLY migrated |
|
51 | - */ |
|
52 | - protected function _migration_step($num_items_to_migrate = 50) |
|
53 | - { |
|
54 | - global $wpdb; |
|
55 | - $rows_updated = $wpdb->update( |
|
56 | - $this->_line_item_table_name, |
|
57 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | - array( 'LIN_code' => 'tickets' ), |
|
59 | - array( '%s' ), |
|
60 | - array( '%s' ) |
|
61 | - ); |
|
62 | - $this->set_completed(); |
|
63 | - return 1; |
|
64 | - } |
|
43 | + /** |
|
44 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
45 | + * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
46 | + * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
47 | + * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
48 | + * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
49 | + * @param int $num_items_to_migrate |
|
50 | + * @return int number of items ACTUALLY migrated |
|
51 | + */ |
|
52 | + protected function _migration_step($num_items_to_migrate = 50) |
|
53 | + { |
|
54 | + global $wpdb; |
|
55 | + $rows_updated = $wpdb->update( |
|
56 | + $this->_line_item_table_name, |
|
57 | + array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | + array( 'LIN_code' => 'tickets' ), |
|
59 | + array( '%s' ), |
|
60 | + array( '%s' ) |
|
61 | + ); |
|
62 | + $this->set_completed(); |
|
63 | + return 1; |
|
64 | + } |
|
65 | 65 | } |
@@ -54,10 +54,10 @@ |
||
54 | 54 | global $wpdb; |
55 | 55 | $rows_updated = $wpdb->update( |
56 | 56 | $this->_line_item_table_name, |
57 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | - array( 'LIN_code' => 'tickets' ), |
|
59 | - array( '%s' ), |
|
60 | - array( '%s' ) |
|
57 | + array('LIN_code' => 'pre-tax-subtotal'), |
|
58 | + array('LIN_code' => 'tickets'), |
|
59 | + array('%s'), |
|
60 | + array('%s') |
|
61 | 61 | ); |
62 | 62 | $this->set_completed(); |
63 | 63 | return 1; |
@@ -8,49 +8,49 @@ |
||
8 | 8 | |
9 | 9 | class EE_DMS_4_2_0_datetime_fields extends EE_Data_Migration_Script_Stage_Table |
10 | 10 | { |
11 | - public function __construct() |
|
12 | - { |
|
13 | - global $wpdb; |
|
14 | - $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
|
15 | - $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
16 | - parent::__construct(); |
|
17 | - } |
|
11 | + public function __construct() |
|
12 | + { |
|
13 | + global $wpdb; |
|
14 | + $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
|
15 | + $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
16 | + parent::__construct(); |
|
17 | + } |
|
18 | 18 | |
19 | - protected function _migrate_old_row($old_row) |
|
20 | - { |
|
21 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
22 | - // QSG_order equal to this question's QST_order |
|
23 | - global $wpdb; |
|
19 | + protected function _migrate_old_row($old_row) |
|
20 | + { |
|
21 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
22 | + // QSG_order equal to this question's QST_order |
|
23 | + global $wpdb; |
|
24 | 24 | |
25 | - $updated = $wpdb->update( |
|
26 | - $this->_old_table, |
|
27 | - array( |
|
28 | - 'DTT_name' => '', |
|
29 | - 'DTT_description' => '', |
|
30 | - ), |
|
31 | - array( |
|
32 | - 'DTT_ID' => $old_row['DTT_ID'], |
|
33 | - ), |
|
34 | - array( |
|
35 | - '%s',// DTT_name, |
|
36 | - '%s',// DTT_description |
|
37 | - ), |
|
38 | - array( |
|
39 | - '%d',// DTT_ID |
|
40 | - ) |
|
41 | - ); |
|
42 | - if (false === $updated) { |
|
43 | - $this->add_error( |
|
44 | - sprintf( |
|
45 | - __( |
|
46 | - "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d", |
|
47 | - 'event_espresso' |
|
48 | - ), |
|
49 | - $this->_old_table, |
|
50 | - $old_row['QST_ID'] |
|
51 | - ) |
|
52 | - ); |
|
53 | - } |
|
54 | - // nothing to map really |
|
55 | - } |
|
25 | + $updated = $wpdb->update( |
|
26 | + $this->_old_table, |
|
27 | + array( |
|
28 | + 'DTT_name' => '', |
|
29 | + 'DTT_description' => '', |
|
30 | + ), |
|
31 | + array( |
|
32 | + 'DTT_ID' => $old_row['DTT_ID'], |
|
33 | + ), |
|
34 | + array( |
|
35 | + '%s',// DTT_name, |
|
36 | + '%s',// DTT_description |
|
37 | + ), |
|
38 | + array( |
|
39 | + '%d',// DTT_ID |
|
40 | + ) |
|
41 | + ); |
|
42 | + if (false === $updated) { |
|
43 | + $this->add_error( |
|
44 | + sprintf( |
|
45 | + __( |
|
46 | + "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d", |
|
47 | + 'event_espresso' |
|
48 | + ), |
|
49 | + $this->_old_table, |
|
50 | + $old_row['QST_ID'] |
|
51 | + ) |
|
52 | + ); |
|
53 | + } |
|
54 | + // nothing to map really |
|
55 | + } |
|
56 | 56 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | global $wpdb; |
14 | 14 | $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
15 | - $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
15 | + $this->_old_table = $wpdb->prefix."esp_datetime"; |
|
16 | 16 | parent::__construct(); |
17 | 17 | } |
18 | 18 | |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | 'DTT_ID' => $old_row['DTT_ID'], |
33 | 33 | ), |
34 | 34 | array( |
35 | - '%s',// DTT_name, |
|
36 | - '%s',// DTT_description |
|
35 | + '%s', // DTT_name, |
|
36 | + '%s', // DTT_description |
|
37 | 37 | ), |
38 | 38 | array( |
39 | - '%d',// DTT_ID |
|
39 | + '%d', // DTT_ID |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | if (false === $updated) { |
@@ -6,42 +6,42 @@ |
||
6 | 6 | |
7 | 7 | class EE_DMS_4_2_0_question_group_questions extends EE_Data_Migration_Script_Stage_Table |
8 | 8 | { |
9 | - private $_qgq_table; |
|
10 | - public function __construct() |
|
11 | - { |
|
12 | - global $wpdb; |
|
13 | - $this->_pretty_name = __("Question Group Questions", "event_espresso"); |
|
14 | - $this->_old_table = $wpdb->prefix."esp_question"; |
|
15 | - $this->_qgq_table = $wpdb->prefix."esp_question_group_question"; |
|
16 | - parent::__construct(); |
|
17 | - } |
|
18 | - protected function _migrate_old_row($old_row) |
|
19 | - { |
|
20 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
21 | - // QSG_order equal to this question's QST_order |
|
22 | - global $wpdb; |
|
23 | - $updated = $wpdb->update( |
|
24 | - $this->_qgq_table, |
|
25 | - array('QGQ_order'=>$old_row['QST_order']), |
|
26 | - array('QST_ID'=>$old_row['QST_ID']), |
|
27 | - array('%d',// QGQ_order |
|
28 | - ), |
|
29 | - array('%d',// QST_ID |
|
30 | - ) |
|
31 | - ); |
|
32 | - if (false === $updated) { |
|
33 | - $this->add_error( |
|
34 | - sprintf( |
|
35 | - __( |
|
36 | - "Error in updating table %s setting QGQ_order = %d where QST_ID = %d", |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - $this->_qgq_table, |
|
40 | - $old_row['QST_order'], |
|
41 | - $old_row['QST_ID'] |
|
42 | - ) |
|
43 | - ); |
|
44 | - } |
|
45 | - // nothing to map really |
|
46 | - } |
|
9 | + private $_qgq_table; |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | + global $wpdb; |
|
13 | + $this->_pretty_name = __("Question Group Questions", "event_espresso"); |
|
14 | + $this->_old_table = $wpdb->prefix."esp_question"; |
|
15 | + $this->_qgq_table = $wpdb->prefix."esp_question_group_question"; |
|
16 | + parent::__construct(); |
|
17 | + } |
|
18 | + protected function _migrate_old_row($old_row) |
|
19 | + { |
|
20 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
21 | + // QSG_order equal to this question's QST_order |
|
22 | + global $wpdb; |
|
23 | + $updated = $wpdb->update( |
|
24 | + $this->_qgq_table, |
|
25 | + array('QGQ_order'=>$old_row['QST_order']), |
|
26 | + array('QST_ID'=>$old_row['QST_ID']), |
|
27 | + array('%d',// QGQ_order |
|
28 | + ), |
|
29 | + array('%d',// QST_ID |
|
30 | + ) |
|
31 | + ); |
|
32 | + if (false === $updated) { |
|
33 | + $this->add_error( |
|
34 | + sprintf( |
|
35 | + __( |
|
36 | + "Error in updating table %s setting QGQ_order = %d where QST_ID = %d", |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + $this->_qgq_table, |
|
40 | + $old_row['QST_order'], |
|
41 | + $old_row['QST_ID'] |
|
42 | + ) |
|
43 | + ); |
|
44 | + } |
|
45 | + // nothing to map really |
|
46 | + } |
|
47 | 47 | } |
@@ -24,9 +24,9 @@ |
||
24 | 24 | $this->_qgq_table, |
25 | 25 | array('QGQ_order'=>$old_row['QST_order']), |
26 | 26 | array('QST_ID'=>$old_row['QST_ID']), |
27 | - array('%d',// QGQ_order |
|
27 | + array('%d', // QGQ_order |
|
28 | 28 | ), |
29 | - array('%d',// QST_ID |
|
29 | + array('%d', // QST_ID |
|
30 | 30 | ) |
31 | 31 | ); |
32 | 32 | if (false === $updated) { |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | // unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | // instead of construction, because it only gets constructed on first page load |
11 | 11 | // (all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
|
12 | +$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
|
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | 15 | $matches = array(); |
16 | 16 | preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
65 | 65 | // echo "$version_string can be migrated from"; |
66 | 66 | return true; |
67 | - } elseif (! $version_string) { |
|
67 | + } elseif ( ! $version_string) { |
|
68 | 68 | // echo "no version string provided: $version_string"; |
69 | 69 | // no version string provided... this must be pre 4.3 |
70 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | 71 | } else { |
72 | 72 | // echo "$version_string doesnt apply"; |
73 | 73 | return false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function schema_changes_before_migration() |
83 | 83 | { |
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
84 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
85 | 85 | $now_in_mysql = current_time('mysql', true); |
86 | 86 | $table_name = 'esp_answer'; |
87 | 87 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | { |
725 | 725 | foreach ($tables_to_check as $table_name) { |
726 | 726 | $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
727 | - if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
727 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
728 | 728 | && $this->_get_table_analysis()->tableExists($table_name) |
729 | 729 | ) { |
730 | 730 | maybe_convert_table_to_utf8mb4($table_name); |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | - // echo "$version_string can be migrated from"; |
|
66 | - return true; |
|
67 | - } elseif (! $version_string) { |
|
68 | - // echo "no version string provided: $version_string"; |
|
69 | - // no version string provided... this must be pre 4.3 |
|
70 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
72 | - // echo "$version_string doesnt apply"; |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | + // echo "$version_string can be migrated from"; |
|
66 | + return true; |
|
67 | + } elseif (! $version_string) { |
|
68 | + // echo "no version string provided: $version_string"; |
|
69 | + // no version string provided... this must be pre 4.3 |
|
70 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | + // echo "$version_string doesnt apply"; |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $now_in_mysql = current_time('mysql', true); |
|
86 | - $table_name = 'esp_answer'; |
|
87 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $now_in_mysql = current_time('mysql', true); |
|
86 | + $table_name = 'esp_answer'; |
|
87 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | REG_ID int(10) unsigned NOT NULL, |
89 | 89 | QST_ID int(10) unsigned NOT NULL, |
90 | 90 | ANS_value text NOT NULL, |
91 | 91 | PRIMARY KEY (ANS_ID), |
92 | 92 | KEY REG_ID (REG_ID), |
93 | 93 | KEY QST_ID (QST_ID)"; |
94 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,29 +139,29 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - // note: although this table is no longer in use, |
|
153 | - // it hasn't been removed because then queries to the model will have errors. |
|
154 | - // but you should expect this table and its corresponding model to be removed in |
|
155 | - // the next few months |
|
156 | - $table_name = 'esp_currency_payment_method'; |
|
157 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + // note: although this table is no longer in use, |
|
153 | + // it hasn't been removed because then queries to the model will have errors. |
|
154 | + // but you should expect this table and its corresponding model to be removed in |
|
155 | + // the next few months |
|
156 | + $table_name = 'esp_currency_payment_method'; |
|
157 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
158 | 158 | CUR_code varchar(6) NOT NULL, |
159 | 159 | PMD_ID int(11) NOT NULL, |
160 | 160 | PRIMARY KEY (CPM_ID), |
161 | 161 | KEY PMD_ID (PMD_ID)"; |
162 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | - $table_name = 'esp_datetime'; |
|
164 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
162 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
163 | + $table_name = 'esp_datetime'; |
|
164 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
166 | 166 | DTT_name varchar(255) NOT NULL DEFAULT '', |
167 | 167 | DTT_description text NOT NULL, |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | KEY DTT_EVT_start (DTT_EVT_start), |
179 | 179 | KEY EVT_ID (EVT_ID), |
180 | 180 | KEY DTT_is_primary (DTT_is_primary)"; |
181 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | - $table_name = "esp_datetime_ticket"; |
|
183 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
182 | + $table_name = "esp_datetime_ticket"; |
|
183 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
184 | 184 | DTT_ID int(10) unsigned NOT NULL, |
185 | 185 | TKT_ID int(10) unsigned NOT NULL, |
186 | 186 | PRIMARY KEY (DTK_ID), |
187 | 187 | KEY DTT_ID (DTT_ID), |
188 | 188 | KEY TKT_ID (TKT_ID)"; |
189 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | - $table_name = 'esp_event_message_template'; |
|
191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
189 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
190 | + $table_name = 'esp_event_message_template'; |
|
191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
194 | 194 | PRIMARY KEY (EMT_ID), |
195 | 195 | KEY EVT_ID (EVT_ID), |
196 | 196 | KEY GRP_ID (GRP_ID)"; |
197 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_event_meta'; |
|
199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_event_meta'; |
|
199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,34 +211,34 @@ discard block |
||
211 | 211 | EVT_donations tinyint(1) NULL, |
212 | 212 | PRIMARY KEY (EVTM_ID), |
213 | 213 | KEY EVT_ID (EVT_ID)"; |
214 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | - $table_name = 'esp_event_question_group'; |
|
216 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
214 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
215 | + $table_name = 'esp_event_question_group'; |
|
216 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | 217 | EVT_ID bigint(20) unsigned NOT NULL, |
218 | 218 | QSG_ID int(10) unsigned NOT NULL, |
219 | 219 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
220 | 220 | PRIMARY KEY (EQG_ID), |
221 | 221 | KEY EVT_ID (EVT_ID), |
222 | 222 | KEY QSG_ID (QSG_ID)"; |
223 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_event_venue'; |
|
225 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_event_venue'; |
|
225 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | EVT_ID bigint(20) unsigned NOT NULL, |
227 | 227 | VNU_ID bigint(20) unsigned NOT NULL, |
228 | 228 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
229 | 229 | PRIMARY KEY (EVV_ID)"; |
230 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | - $table_name = 'esp_extra_meta'; |
|
232 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
230 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
231 | + $table_name = 'esp_extra_meta'; |
|
232 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
233 | 233 | OBJ_ID int(11) DEFAULT NULL, |
234 | 234 | EXM_type varchar(45) DEFAULT NULL, |
235 | 235 | EXM_key varchar(45) DEFAULT NULL, |
236 | 236 | EXM_value text, |
237 | 237 | PRIMARY KEY (EXM_ID), |
238 | 238 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
239 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | - $table_name = 'esp_extra_join'; |
|
241 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
239 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
240 | + $table_name = 'esp_extra_join'; |
|
241 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
242 | 242 | EXJ_first_model_id varchar(6) NOT NULL, |
243 | 243 | EXJ_first_model_name varchar(20) NOT NULL, |
244 | 244 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -246,9 +246,9 @@ discard block |
||
246 | 246 | PRIMARY KEY (EXJ_ID), |
247 | 247 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
248 | 248 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
249 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | - $table_name = 'esp_line_item'; |
|
251 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
249 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
250 | + $table_name = 'esp_line_item'; |
|
251 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
252 | 252 | LIN_code varchar(245) NOT NULL DEFAULT '', |
253 | 253 | TXN_ID int(11) DEFAULT NULL, |
254 | 254 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
270 | 270 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
271 | 271 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
272 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
273 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
274 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | - $table_name = 'esp_log'; |
|
276 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
272 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
273 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
274 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
275 | + $table_name = 'esp_log'; |
|
276 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
277 | 277 | LOG_time datetime DEFAULT NULL, |
278 | 278 | OBJ_ID varchar(45) DEFAULT NULL, |
279 | 279 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -284,12 +284,12 @@ discard block |
||
284 | 284 | KEY LOG_time (LOG_time), |
285 | 285 | KEY OBJ (OBJ_type,OBJ_ID), |
286 | 286 | KEY LOG_type (LOG_type)"; |
287 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | - $table_name = 'esp_message'; |
|
289 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
290 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
291 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
292 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
287 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
288 | + $table_name = 'esp_message'; |
|
289 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
290 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
291 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
292 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
293 | 293 | GRP_ID int(10) unsigned NULL, |
294 | 294 | MSG_token varchar(255) NULL, |
295 | 295 | TXN_ID int(10) unsigned NULL, |
@@ -321,18 +321,18 @@ discard block |
||
321 | 321 | KEY STS_ID (STS_ID), |
322 | 322 | KEY MSG_created (MSG_created), |
323 | 323 | KEY MSG_modified (MSG_modified)"; |
324 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
325 | - $table_name = 'esp_message_template'; |
|
326 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
324 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
325 | + $table_name = 'esp_message_template'; |
|
326 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
327 | 327 | GRP_ID int(10) unsigned NOT NULL, |
328 | 328 | MTP_context varchar(50) NOT NULL, |
329 | 329 | MTP_template_field varchar(30) NOT NULL, |
330 | 330 | MTP_content text NOT NULL, |
331 | 331 | PRIMARY KEY (MTP_ID), |
332 | 332 | KEY GRP_ID (GRP_ID)"; |
333 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | - $table_name = 'esp_message_template_group'; |
|
335 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
334 | + $table_name = 'esp_message_template_group'; |
|
335 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
336 | 336 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
337 | 337 | MTP_name varchar(245) NOT NULL DEFAULT '', |
338 | 338 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -344,9 +344,9 @@ discard block |
||
344 | 344 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
345 | 345 | PRIMARY KEY (GRP_ID), |
346 | 346 | KEY MTP_user_id (MTP_user_id)"; |
347 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
348 | - $table_name = 'esp_payment'; |
|
349 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
347 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
348 | + $table_name = 'esp_payment'; |
|
349 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
350 | 350 | TXN_ID int(10) unsigned DEFAULT NULL, |
351 | 351 | STS_ID varchar(3) DEFAULT NULL, |
352 | 352 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | PRIMARY KEY (PAY_ID), |
364 | 364 | KEY PAY_timestamp (PAY_timestamp), |
365 | 365 | KEY TXN_ID (TXN_ID)"; |
366 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
367 | - $table_name = 'esp_payment_method'; |
|
368 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
366 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
367 | + $table_name = 'esp_payment_method'; |
|
368 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
369 | 369 | PMD_type varchar(124) DEFAULT NULL, |
370 | 370 | PMD_name varchar(255) DEFAULT NULL, |
371 | 371 | PMD_desc text, |
@@ -381,24 +381,24 @@ discard block |
||
381 | 381 | PRIMARY KEY (PMD_ID), |
382 | 382 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
383 | 383 | KEY PMD_type (PMD_type)"; |
384 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
385 | - $table_name = "esp_ticket_price"; |
|
386 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
384 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
385 | + $table_name = "esp_ticket_price"; |
|
386 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | 387 | TKT_ID int(10) unsigned NOT NULL, |
388 | 388 | PRC_ID int(10) unsigned NOT NULL, |
389 | 389 | PRIMARY KEY (TKP_ID), |
390 | 390 | KEY TKT_ID (TKT_ID), |
391 | 391 | KEY PRC_ID (PRC_ID)"; |
392 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
393 | - $table_name = "esp_ticket_template"; |
|
394 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
392 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
393 | + $table_name = "esp_ticket_template"; |
|
394 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
395 | 395 | TTM_name varchar(45) NOT NULL, |
396 | 396 | TTM_description text, |
397 | 397 | TTM_file varchar(45), |
398 | 398 | PRIMARY KEY (TTM_ID)"; |
399 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | - $table_name = 'esp_question'; |
|
401 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
399 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
400 | + $table_name = 'esp_question'; |
|
401 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
402 | 402 | QST_display_text text NOT NULL, |
403 | 403 | QST_admin_label varchar(255) NOT NULL, |
404 | 404 | QST_system varchar(25) DEFAULT NULL, |
@@ -412,18 +412,18 @@ discard block |
||
412 | 412 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
413 | 413 | PRIMARY KEY (QST_ID), |
414 | 414 | KEY QST_order (QST_order)'; |
415 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | - $table_name = 'esp_question_group_question'; |
|
417 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
415 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | + $table_name = 'esp_question_group_question'; |
|
417 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
418 | 418 | QSG_ID int(10) unsigned NOT NULL, |
419 | 419 | QST_ID int(10) unsigned NOT NULL, |
420 | 420 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
421 | 421 | PRIMARY KEY (QGQ_ID), |
422 | 422 | KEY QST_ID (QST_ID), |
423 | 423 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
424 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | - $table_name = 'esp_question_option'; |
|
426 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
424 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
425 | + $table_name = 'esp_question_option'; |
|
426 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
427 | 427 | QSO_value varchar(255) NOT NULL, |
428 | 428 | QSO_desc text NOT NULL, |
429 | 429 | QST_ID int(10) unsigned NOT NULL, |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | PRIMARY KEY (QSO_ID), |
434 | 434 | KEY QST_ID (QST_ID), |
435 | 435 | KEY QSO_order (QSO_order)"; |
436 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
437 | - $table_name = 'esp_registration'; |
|
438 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
436 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
437 | + $table_name = 'esp_registration'; |
|
438 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
439 | 439 | EVT_ID bigint(20) unsigned NOT NULL, |
440 | 440 | ATT_ID bigint(20) unsigned NOT NULL, |
441 | 441 | TXN_ID int(10) unsigned NOT NULL, |
@@ -459,18 +459,18 @@ discard block |
||
459 | 459 | KEY TKT_ID (TKT_ID), |
460 | 460 | KEY EVT_ID (EVT_ID), |
461 | 461 | KEY STS_ID (STS_ID)"; |
462 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
463 | - $table_name = 'esp_registration_payment'; |
|
464 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
462 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
463 | + $table_name = 'esp_registration_payment'; |
|
464 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
465 | 465 | REG_ID int(10) unsigned NOT NULL, |
466 | 466 | PAY_ID int(10) unsigned NULL, |
467 | 467 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
468 | 468 | PRIMARY KEY (RPY_ID), |
469 | 469 | KEY REG_ID (REG_ID), |
470 | 470 | KEY PAY_ID (PAY_ID)"; |
471 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
472 | - $table_name = 'esp_state'; |
|
473 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
471 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
472 | + $table_name = 'esp_state'; |
|
473 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
474 | 474 | CNT_ISO varchar(2) NOT NULL, |
475 | 475 | STA_abbrev varchar(24) NOT NULL, |
476 | 476 | STA_name varchar(100) NOT NULL, |
@@ -478,9 +478,9 @@ discard block |
||
478 | 478 | PRIMARY KEY (STA_ID), |
479 | 479 | KEY STA_abbrev (STA_abbrev), |
480 | 480 | KEY CNT_ISO (CNT_ISO)"; |
481 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
482 | - $table_name = 'esp_status'; |
|
483 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
481 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
482 | + $table_name = 'esp_status'; |
|
483 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
484 | 484 | STS_code varchar(45) NOT NULL, |
485 | 485 | STS_type varchar(45) NOT NULL, |
486 | 486 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -488,9 +488,9 @@ discard block |
||
488 | 488 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
489 | 489 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
490 | 490 | KEY STS_type (STS_type)"; |
491 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
492 | - $table_name = 'esp_transaction'; |
|
493 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
492 | + $table_name = 'esp_transaction'; |
|
493 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
494 | 494 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
495 | 495 | TXN_total decimal(12,3) DEFAULT '0.00', |
496 | 496 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | PRIMARY KEY (TXN_ID), |
503 | 503 | KEY TXN_timestamp (TXN_timestamp), |
504 | 504 | KEY STS_ID (STS_ID)"; |
505 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
506 | - $table_name = 'esp_venue_meta'; |
|
507 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
505 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
506 | + $table_name = 'esp_venue_meta'; |
|
507 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
508 | 508 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
509 | 509 | VNU_address varchar(255) DEFAULT NULL, |
510 | 510 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -523,10 +523,10 @@ discard block |
||
523 | 523 | KEY VNU_ID (VNU_ID), |
524 | 524 | KEY STA_ID (STA_ID), |
525 | 525 | KEY CNT_ISO (CNT_ISO)"; |
526 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
527 | - // modified tables |
|
528 | - $table_name = "esp_price"; |
|
529 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
526 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
527 | + // modified tables |
|
528 | + $table_name = "esp_price"; |
|
529 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
530 | 530 | PRT_ID tinyint(3) unsigned NOT NULL, |
531 | 531 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
532 | 532 | PRC_name varchar(245) NOT NULL, |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | PRC_parent int(10) unsigned DEFAULT 0, |
540 | 540 | PRIMARY KEY (PRC_ID), |
541 | 541 | KEY PRT_ID (PRT_ID)"; |
542 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
543 | - $table_name = "esp_price_type"; |
|
544 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
542 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
543 | + $table_name = "esp_price_type"; |
|
544 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
545 | 545 | PRT_name varchar(45) NOT NULL, |
546 | 546 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
547 | 547 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
551 | 551 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
552 | 552 | PRIMARY KEY (PRT_ID)"; |
553 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
554 | - $table_name = "esp_ticket"; |
|
555 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
553 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
554 | + $table_name = "esp_ticket"; |
|
555 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
556 | 556 | TTM_ID int(10) unsigned NOT NULL, |
557 | 557 | TKT_name varchar(245) NOT NULL DEFAULT '', |
558 | 558 | TKT_description text NOT NULL, |
@@ -575,9 +575,9 @@ discard block |
||
575 | 575 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
576 | 576 | PRIMARY KEY (TKT_ID), |
577 | 577 | KEY TKT_start_date (TKT_start_date)"; |
578 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
579 | - $table_name = 'esp_question_group'; |
|
580 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
578 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
579 | + $table_name = 'esp_question_group'; |
|
580 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
581 | 581 | QSG_name varchar(255) NOT NULL, |
582 | 582 | QSG_identifier varchar(100) NOT NULL, |
583 | 583 | QSG_desc text NULL, |
@@ -590,145 +590,145 @@ discard block |
||
590 | 590 | PRIMARY KEY (QSG_ID), |
591 | 591 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
592 | 592 | KEY QSG_order (QSG_order)'; |
593 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
594 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
595 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
596 | - // (because many need to convert old string states to foreign keys into the states table) |
|
597 | - $script_4_1_defaults->insert_default_states(); |
|
598 | - $script_4_1_defaults->insert_default_countries(); |
|
599 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
600 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
601 | - $script_4_5_defaults->insert_default_price_types(); |
|
602 | - $script_4_5_defaults->insert_default_prices(); |
|
603 | - $script_4_5_defaults->insert_default_tickets(); |
|
604 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
605 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
606 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
607 | - $script_4_6_defaults->insert_default_currencies(); |
|
608 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
609 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
610 | - $script_4_8_defaults->verify_new_countries(); |
|
611 | - $script_4_8_defaults->verify_new_currencies(); |
|
612 | - $this->verify_db_collations(); |
|
613 | - $this->verify_db_collations_again(); |
|
614 | - return true; |
|
615 | - } |
|
593 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
594 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
595 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
596 | + // (because many need to convert old string states to foreign keys into the states table) |
|
597 | + $script_4_1_defaults->insert_default_states(); |
|
598 | + $script_4_1_defaults->insert_default_countries(); |
|
599 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
600 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
601 | + $script_4_5_defaults->insert_default_price_types(); |
|
602 | + $script_4_5_defaults->insert_default_prices(); |
|
603 | + $script_4_5_defaults->insert_default_tickets(); |
|
604 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
605 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
606 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
607 | + $script_4_6_defaults->insert_default_currencies(); |
|
608 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
609 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
610 | + $script_4_8_defaults->verify_new_countries(); |
|
611 | + $script_4_8_defaults->verify_new_currencies(); |
|
612 | + $this->verify_db_collations(); |
|
613 | + $this->verify_db_collations_again(); |
|
614 | + return true; |
|
615 | + } |
|
616 | 616 | |
617 | 617 | |
618 | 618 | |
619 | - /** |
|
620 | - * @return boolean |
|
621 | - */ |
|
622 | - public function schema_changes_after_migration() |
|
623 | - { |
|
624 | - return true; |
|
625 | - } |
|
619 | + /** |
|
620 | + * @return boolean |
|
621 | + */ |
|
622 | + public function schema_changes_after_migration() |
|
623 | + { |
|
624 | + return true; |
|
625 | + } |
|
626 | 626 | |
627 | 627 | |
628 | 628 | |
629 | - public function migration_page_hooks() |
|
630 | - { |
|
631 | - } |
|
629 | + public function migration_page_hooks() |
|
630 | + { |
|
631 | + } |
|
632 | 632 | |
633 | 633 | |
634 | 634 | |
635 | - /** |
|
636 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
637 | - * |
|
638 | - * @return void |
|
639 | - */ |
|
640 | - public function verify_db_collations() |
|
641 | - { |
|
642 | - global $wpdb; |
|
643 | - // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
644 | - if ('utf8mb4' !== $wpdb->charset |
|
645 | - || get_option('ee_verified_db_collations', false)) { |
|
646 | - return; |
|
647 | - } |
|
648 | - // grab tables from each model |
|
649 | - $tables_to_check = array(); |
|
650 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
651 | - if (method_exists($model_name, 'instance')) { |
|
652 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
653 | - if ($model_obj instanceof EEM_Base) { |
|
654 | - foreach ($model_obj->get_tables() as $table) { |
|
655 | - if (strpos($table->get_table_name(), 'esp_') |
|
656 | - && (is_main_site()// for main tables, verify global tables |
|
657 | - || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
658 | - ) |
|
659 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
660 | - ) { |
|
661 | - $tables_to_check[] = $table->get_table_name(); |
|
662 | - } |
|
663 | - } |
|
664 | - } |
|
665 | - } |
|
666 | - } |
|
667 | - // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
668 | - // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
669 | - // of hard-coding this |
|
670 | - $addon_tables = array( |
|
671 | - // mailchimp |
|
672 | - 'esp_event_mailchimp_list_group', |
|
673 | - 'esp_event_question_mailchimp_field', |
|
674 | - // multisite |
|
675 | - 'esp_blog_meta', |
|
676 | - // people |
|
677 | - 'esp_people_to_post', |
|
678 | - // promotions |
|
679 | - 'esp_promotion', |
|
680 | - 'esp_promotion_object', |
|
681 | - ); |
|
682 | - foreach ($addon_tables as $table_name) { |
|
683 | - $tables_to_check[] = $table_name; |
|
684 | - } |
|
685 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
686 | - // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
687 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
688 | - // seeing how this ran with the fix from 10435, no need to check again |
|
689 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
690 | - } |
|
635 | + /** |
|
636 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
637 | + * |
|
638 | + * @return void |
|
639 | + */ |
|
640 | + public function verify_db_collations() |
|
641 | + { |
|
642 | + global $wpdb; |
|
643 | + // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
644 | + if ('utf8mb4' !== $wpdb->charset |
|
645 | + || get_option('ee_verified_db_collations', false)) { |
|
646 | + return; |
|
647 | + } |
|
648 | + // grab tables from each model |
|
649 | + $tables_to_check = array(); |
|
650 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
651 | + if (method_exists($model_name, 'instance')) { |
|
652 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
653 | + if ($model_obj instanceof EEM_Base) { |
|
654 | + foreach ($model_obj->get_tables() as $table) { |
|
655 | + if (strpos($table->get_table_name(), 'esp_') |
|
656 | + && (is_main_site()// for main tables, verify global tables |
|
657 | + || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up) |
|
658 | + ) |
|
659 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
660 | + ) { |
|
661 | + $tables_to_check[] = $table->get_table_name(); |
|
662 | + } |
|
663 | + } |
|
664 | + } |
|
665 | + } |
|
666 | + } |
|
667 | + // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
668 | + // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
669 | + // of hard-coding this |
|
670 | + $addon_tables = array( |
|
671 | + // mailchimp |
|
672 | + 'esp_event_mailchimp_list_group', |
|
673 | + 'esp_event_question_mailchimp_field', |
|
674 | + // multisite |
|
675 | + 'esp_blog_meta', |
|
676 | + // people |
|
677 | + 'esp_people_to_post', |
|
678 | + // promotions |
|
679 | + 'esp_promotion', |
|
680 | + 'esp_promotion_object', |
|
681 | + ); |
|
682 | + foreach ($addon_tables as $table_name) { |
|
683 | + $tables_to_check[] = $table_name; |
|
684 | + } |
|
685 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
686 | + // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
687 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
688 | + // seeing how this ran with the fix from 10435, no need to check again |
|
689 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
690 | + } |
|
691 | 691 | |
692 | 692 | |
693 | 693 | |
694 | - /** |
|
695 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
696 | - * which meant some DB collations might not have been updated |
|
697 | - * @return void |
|
698 | - */ |
|
699 | - public function verify_db_collations_again() |
|
700 | - { |
|
701 | - global $wpdb; |
|
702 | - // double-check we haven't already done this or that the DB doesn't support it |
|
703 | - // compare to how WordPress' upgrade_430() function does this check |
|
704 | - if ('utf8mb4' !== $wpdb->charset |
|
705 | - || get_option('ee_verified_db_collations_again', false)) { |
|
706 | - return; |
|
707 | - } |
|
708 | - $tables_to_check = array( |
|
709 | - 'esp_attendee_meta', |
|
710 | - 'esp_message' |
|
711 | - ); |
|
712 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
713 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
714 | - } |
|
694 | + /** |
|
695 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
696 | + * which meant some DB collations might not have been updated |
|
697 | + * @return void |
|
698 | + */ |
|
699 | + public function verify_db_collations_again() |
|
700 | + { |
|
701 | + global $wpdb; |
|
702 | + // double-check we haven't already done this or that the DB doesn't support it |
|
703 | + // compare to how WordPress' upgrade_430() function does this check |
|
704 | + if ('utf8mb4' !== $wpdb->charset |
|
705 | + || get_option('ee_verified_db_collations_again', false)) { |
|
706 | + return; |
|
707 | + } |
|
708 | + $tables_to_check = array( |
|
709 | + 'esp_attendee_meta', |
|
710 | + 'esp_message' |
|
711 | + ); |
|
712 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
713 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
714 | + } |
|
715 | 715 | |
716 | 716 | |
717 | 717 | |
718 | - /** |
|
719 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
720 | - * @param $tables_to_check |
|
721 | - * @return boolean true if logic ran, false if it didn't |
|
722 | - */ |
|
723 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
724 | - { |
|
725 | - foreach ($tables_to_check as $table_name) { |
|
726 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
727 | - if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
728 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
729 | - ) { |
|
730 | - maybe_convert_table_to_utf8mb4($table_name); |
|
731 | - } |
|
732 | - } |
|
733 | - } |
|
718 | + /** |
|
719 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
720 | + * @param $tables_to_check |
|
721 | + * @return boolean true if logic ran, false if it didn't |
|
722 | + */ |
|
723 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
724 | + { |
|
725 | + foreach ($tables_to_check as $table_name) { |
|
726 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
727 | + if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
728 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
729 | + ) { |
|
730 | + maybe_convert_table_to_utf8mb4($table_name); |
|
731 | + } |
|
732 | + } |
|
733 | + } |
|
734 | 734 | } |
@@ -37,103 +37,103 @@ |
||
37 | 37 | */ |
38 | 38 | abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base |
39 | 39 | { |
40 | - /** |
|
41 | - * The migration script this is a stage of |
|
42 | - * |
|
43 | - * @var EE_Data_Migration_Script_Base |
|
44 | - */ |
|
45 | - protected $_migration_script; |
|
40 | + /** |
|
41 | + * The migration script this is a stage of |
|
42 | + * |
|
43 | + * @var EE_Data_Migration_Script_Base |
|
44 | + */ |
|
45 | + protected $_migration_script; |
|
46 | 46 | |
47 | - /** |
|
48 | - * This should eb called to essentially 'finalize' construction of the stage. |
|
49 | - * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is |
|
50 | - * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to |
|
51 | - * |
|
52 | - * @param EE_Data_Migration_Script_Base $migration_script |
|
53 | - */ |
|
54 | - public function _construct_finalize($migration_script) |
|
55 | - { |
|
56 | - $this->_migration_script = $migration_script; |
|
57 | - } |
|
47 | + /** |
|
48 | + * This should eb called to essentially 'finalize' construction of the stage. |
|
49 | + * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is |
|
50 | + * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to |
|
51 | + * |
|
52 | + * @param EE_Data_Migration_Script_Base $migration_script |
|
53 | + */ |
|
54 | + public function _construct_finalize($migration_script) |
|
55 | + { |
|
56 | + $this->_migration_script = $migration_script; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here, |
|
61 | - * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children |
|
62 | - * needs to catch exceptions and decide what's a fatal error and what isn't. |
|
63 | - * |
|
64 | - * @param int $num_items_to_migrate |
|
65 | - * @return int |
|
66 | - */ |
|
67 | - public function migration_step($num_items_to_migrate = 50) |
|
68 | - { |
|
69 | - // before we run the migration step, we want ot take note of warnings that get outputted |
|
70 | - ob_start(); |
|
71 | - $items_migrated = $this->_migration_step($num_items_to_migrate); |
|
72 | - $output = ob_get_contents(); |
|
73 | - ob_end_clean(); |
|
74 | - if ($output) { |
|
75 | - $this->add_error($output); |
|
76 | - } |
|
77 | - $this->_records_migrated += $items_migrated; |
|
78 | - return $items_migrated; |
|
79 | - } |
|
59 | + /** |
|
60 | + * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here, |
|
61 | + * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children |
|
62 | + * needs to catch exceptions and decide what's a fatal error and what isn't. |
|
63 | + * |
|
64 | + * @param int $num_items_to_migrate |
|
65 | + * @return int |
|
66 | + */ |
|
67 | + public function migration_step($num_items_to_migrate = 50) |
|
68 | + { |
|
69 | + // before we run the migration step, we want ot take note of warnings that get outputted |
|
70 | + ob_start(); |
|
71 | + $items_migrated = $this->_migration_step($num_items_to_migrate); |
|
72 | + $output = ob_get_contents(); |
|
73 | + ob_end_clean(); |
|
74 | + if ($output) { |
|
75 | + $this->add_error($output); |
|
76 | + } |
|
77 | + $this->_records_migrated += $items_migrated; |
|
78 | + return $items_migrated; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
84 | - * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
85 | - * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
86 | - * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
87 | - * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
88 | - * very least we MUST report/return 50 items migrated) |
|
89 | - * |
|
90 | - * @param int $num_items_to_migrate |
|
91 | - * @return int number of items ACTUALLY migrated |
|
92 | - */ |
|
93 | - abstract protected function _migration_step($num_items_to_migrate = 50); |
|
82 | + /** |
|
83 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
84 | + * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
85 | + * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
86 | + * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
87 | + * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
88 | + * very least we MUST report/return 50 items migrated) |
|
89 | + * |
|
90 | + * @param int $num_items_to_migrate |
|
91 | + * @return int number of items ACTUALLY migrated |
|
92 | + */ |
|
93 | + abstract protected function _migration_step($num_items_to_migrate = 50); |
|
94 | 94 | |
95 | - /** |
|
96 | - * Counts the records that have been migrated so far |
|
97 | - * |
|
98 | - * @return int |
|
99 | - */ |
|
100 | - public function count_records_migrated() |
|
101 | - { |
|
102 | - return $this->_records_migrated; |
|
103 | - } |
|
95 | + /** |
|
96 | + * Counts the records that have been migrated so far |
|
97 | + * |
|
98 | + * @return int |
|
99 | + */ |
|
100 | + public function count_records_migrated() |
|
101 | + { |
|
102 | + return $this->_records_migrated; |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * returns an array of strings describing errors |
|
107 | - * |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function get_errors() |
|
111 | - { |
|
112 | - return $this->_errors; |
|
113 | - } |
|
105 | + /** |
|
106 | + * returns an array of strings describing errors |
|
107 | + * |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function get_errors() |
|
111 | + { |
|
112 | + return $this->_errors; |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
118 | - * to have been made from the properties_as_array() function. |
|
119 | - * |
|
120 | - * @param array $array_of_properties like what's produced from properties_as_array() method |
|
121 | - */ |
|
122 | - public function instantiate_from_array_of_properties($array_of_properties) |
|
123 | - { |
|
124 | - unset($array_of_properties['class']); |
|
125 | - foreach ($array_of_properties as $property_name => $property_value) { |
|
126 | - $this->{$property_name} = $property_value; |
|
127 | - } |
|
128 | - } |
|
116 | + /** |
|
117 | + * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
118 | + * to have been made from the properties_as_array() function. |
|
119 | + * |
|
120 | + * @param array $array_of_properties like what's produced from properties_as_array() method |
|
121 | + */ |
|
122 | + public function instantiate_from_array_of_properties($array_of_properties) |
|
123 | + { |
|
124 | + unset($array_of_properties['class']); |
|
125 | + foreach ($array_of_properties as $property_name => $property_value) { |
|
126 | + $this->{$property_name} = $property_value; |
|
127 | + } |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * Gets the script this is a stage of |
|
132 | - * |
|
133 | - * @return EE_Data_Migration_Script_Base |
|
134 | - */ |
|
135 | - protected function get_migration_script() |
|
136 | - { |
|
137 | - return $this->_migration_script; |
|
138 | - } |
|
130 | + /** |
|
131 | + * Gets the script this is a stage of |
|
132 | + * |
|
133 | + * @return EE_Data_Migration_Script_Base |
|
134 | + */ |
|
135 | + protected function get_migration_script() |
|
136 | + { |
|
137 | + return $this->_migration_script; |
|
138 | + } |
|
139 | 139 | } |
@@ -13,59 +13,59 @@ |
||
13 | 13 | class EE_DMS_4_3_0_event_message_templates extends EE_Data_Migration_Script_Stage_Table |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * This property will hold the table name for event_message_templates |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - private $_emt_table; |
|
16 | + /** |
|
17 | + * This property will hold the table name for event_message_templates |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + private $_emt_table; |
|
21 | 21 | |
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - global $wpdb; |
|
26 | - $this->_pretty_name = __('Event Message Templates', 'event_espresso'); |
|
27 | - $this->_old_table = $wpdb->prefix."esp_message_template_group"; |
|
28 | - $this->_emt_table = $wpdb->prefix."esp_event_message_template"; |
|
29 | - parent::__construct(); |
|
30 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + global $wpdb; |
|
26 | + $this->_pretty_name = __('Event Message Templates', 'event_espresso'); |
|
27 | + $this->_old_table = $wpdb->prefix."esp_message_template_group"; |
|
28 | + $this->_emt_table = $wpdb->prefix."esp_event_message_template"; |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - protected function _migrate_old_row($old_row) |
|
35 | - { |
|
36 | - // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups ) |
|
37 | - global $wpdb; |
|
38 | - if ($old_row['EVT_ID'] > 0) { |
|
39 | - // let's get the EVT for this id so we can update the custom name on the old row. |
|
40 | - $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
34 | + protected function _migrate_old_row($old_row) |
|
35 | + { |
|
36 | + // foreach row that has an evt_id ..let's create an equivalent entry in the new event_messages_template table to link the message template to the event (since EVT_ID is no longer referenced in esp_message_template_groups ) |
|
37 | + global $wpdb; |
|
38 | + if ($old_row['EVT_ID'] > 0) { |
|
39 | + // let's get the EVT for this id so we can update the custom name on the old row. |
|
40 | + $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
41 | 41 | |
42 | - // update name |
|
43 | - $updated = $wpdb->update( |
|
44 | - $this->_old_table, |
|
45 | - array( |
|
46 | - 'MTP_name' =>$event_name |
|
47 | - ), |
|
48 | - array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
49 | - array( '%s' ), |
|
50 | - array( '%d' ) |
|
51 | - ); |
|
42 | + // update name |
|
43 | + $updated = $wpdb->update( |
|
44 | + $this->_old_table, |
|
45 | + array( |
|
46 | + 'MTP_name' =>$event_name |
|
47 | + ), |
|
48 | + array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
49 | + array( '%s' ), |
|
50 | + array( '%d' ) |
|
51 | + ); |
|
52 | 52 | |
53 | - $inserted = $wpdb->insert( |
|
54 | - $this->_emt_table, |
|
55 | - array( |
|
56 | - 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
57 | - 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
58 | - ), |
|
59 | - array( '%d', '%d' ) |
|
60 | - ); |
|
53 | + $inserted = $wpdb->insert( |
|
54 | + $this->_emt_table, |
|
55 | + array( |
|
56 | + 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
57 | + 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
58 | + ), |
|
59 | + array( '%d', '%d' ) |
|
60 | + ); |
|
61 | 61 | |
62 | - if (false === $updated) { |
|
63 | - $this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
64 | - } |
|
62 | + if (false === $updated) { |
|
63 | + $this->add_error(sprintf(__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
64 | + } |
|
65 | 65 | |
66 | - if (false === $inserted) { |
|
67 | - $this->add_error(sprintf(__("Error in inserting a row into setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID'])); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
66 | + if (false === $inserted) { |
|
67 | + $this->add_error(sprintf(__("Error in inserting a row into setting EVT_ID = %d and GRP_ID = %d", "event_espresso"), $this->_emt_table, $old_row['EVT_ID'], $old_row['GRP_ID'])); |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | global $wpdb; |
38 | 38 | if ($old_row['EVT_ID'] > 0) { |
39 | 39 | // let's get the EVT for this id so we can update the custom name on the old row. |
40 | - $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
40 | + $event_name = 'Custom Template for '.$wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
41 | 41 | |
42 | 42 | // update name |
43 | 43 | $updated = $wpdb->update( |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | array( |
46 | 46 | 'MTP_name' =>$event_name |
47 | 47 | ), |
48 | - array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
49 | - array( '%s' ), |
|
50 | - array( '%d' ) |
|
48 | + array('GRP_ID' => (int) $old_row['GRP_ID']), |
|
49 | + array('%s'), |
|
50 | + array('%d') |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | $inserted = $wpdb->insert( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'EVT_ID' => (int) $old_row['EVT_ID'], |
57 | 57 | 'GRP_ID' => (int) $old_row['GRP_ID'], |
58 | 58 | ), |
59 | - array( '%d', '%d' ) |
|
59 | + array('%d', '%d') |
|
60 | 60 | ); |
61 | 61 | |
62 | 62 | if (false === $updated) { |
@@ -7,39 +7,39 @@ |
||
7 | 7 | |
8 | 8 | class EE_DMS_4_3_0_question_option_order extends EE_Data_Migration_Script_Stage_Table |
9 | 9 | { |
10 | - public function __construct() |
|
11 | - { |
|
12 | - global $wpdb; |
|
13 | - $this->_pretty_name = __("Question Options", "event_espresso"); |
|
14 | - $this->_old_table = $wpdb->prefix."esp_question_option"; |
|
15 | - parent::__construct(); |
|
16 | - } |
|
17 | - protected function _migrate_old_row($old_row) |
|
18 | - { |
|
19 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
20 | - // QSG_order equal to this question's QST_order |
|
21 | - global $wpdb; |
|
22 | - $updated = $wpdb->update( |
|
23 | - $this->_old_table, |
|
24 | - array('QSO_order'=>$old_row['QSO_ID']), |
|
25 | - array('QSO_ID'=>$old_row['QSO_ID']), |
|
26 | - array('%d',// QSO_order |
|
27 | - ), |
|
28 | - array('%d',// QSO_ID |
|
29 | - ) |
|
30 | - ); |
|
31 | - if (false === $updated) { |
|
32 | - $this->add_error( |
|
33 | - sprintf( |
|
34 | - __( |
|
35 | - "Error in updating table %s setting QSO_order = %d where QSO_ID = %d", |
|
36 | - 'event_espresso' |
|
37 | - ), |
|
38 | - $this->_old_table, |
|
39 | - $old_row['QSO_ID'], |
|
40 | - $old_row['QSO_ID'] |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
44 | - } |
|
10 | + public function __construct() |
|
11 | + { |
|
12 | + global $wpdb; |
|
13 | + $this->_pretty_name = __("Question Options", "event_espresso"); |
|
14 | + $this->_old_table = $wpdb->prefix."esp_question_option"; |
|
15 | + parent::__construct(); |
|
16 | + } |
|
17 | + protected function _migrate_old_row($old_row) |
|
18 | + { |
|
19 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
20 | + // QSG_order equal to this question's QST_order |
|
21 | + global $wpdb; |
|
22 | + $updated = $wpdb->update( |
|
23 | + $this->_old_table, |
|
24 | + array('QSO_order'=>$old_row['QSO_ID']), |
|
25 | + array('QSO_ID'=>$old_row['QSO_ID']), |
|
26 | + array('%d',// QSO_order |
|
27 | + ), |
|
28 | + array('%d',// QSO_ID |
|
29 | + ) |
|
30 | + ); |
|
31 | + if (false === $updated) { |
|
32 | + $this->add_error( |
|
33 | + sprintf( |
|
34 | + __( |
|
35 | + "Error in updating table %s setting QSO_order = %d where QSO_ID = %d", |
|
36 | + 'event_espresso' |
|
37 | + ), |
|
38 | + $this->_old_table, |
|
39 | + $old_row['QSO_ID'], |
|
40 | + $old_row['QSO_ID'] |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
@@ -23,9 +23,9 @@ |
||
23 | 23 | $this->_old_table, |
24 | 24 | array('QSO_order'=>$old_row['QSO_ID']), |
25 | 25 | array('QSO_ID'=>$old_row['QSO_ID']), |
26 | - array('%d',// QSO_order |
|
26 | + array('%d', // QSO_order |
|
27 | 27 | ), |
28 | - array('%d',// QSO_ID |
|
28 | + array('%d', // QSO_ID |
|
29 | 29 | ) |
30 | 30 | ); |
31 | 31 | if (false === $updated) { |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | print( |
345 | 345 | apply_filters( |
346 | 346 | 'FHEE__EE_Front_Controller__header_meta_tag', |
347 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
347 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n" |
|
348 | 348 | ) |
349 | 349 | ); |
350 | 350 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | print( |
361 | 361 | apply_filters( |
362 | 362 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
363 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
363 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | { |
414 | 414 | static $shown_already = false; |
415 | 415 | do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
416 | - if (! $shown_already |
|
416 | + if ( ! $shown_already |
|
417 | 417 | && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
418 | 418 | && is_main_query() |
419 | 419 | && ! is_feed() |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | ) { |
423 | 423 | echo EE_Error::get_notices(); |
424 | 424 | $shown_already = true; |
425 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
425 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
426 | 426 | } |
427 | 427 | do_action('AHEE__EE_Front_Controller__display_errors__end'); |
428 | 428 | } |
@@ -26,467 +26,467 @@ |
||
26 | 26 | final class EE_Front_Controller |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @var string $_template_path |
|
31 | - */ |
|
32 | - private $_template_path; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var string $_template |
|
36 | - */ |
|
37 | - private $_template; |
|
38 | - |
|
39 | - /** |
|
40 | - * @type EE_Registry $Registry |
|
41 | - */ |
|
42 | - protected $Registry; |
|
43 | - |
|
44 | - /** |
|
45 | - * @type EE_Request_Handler $Request_Handler |
|
46 | - */ |
|
47 | - protected $Request_Handler; |
|
48 | - |
|
49 | - /** |
|
50 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | - */ |
|
52 | - protected $Module_Request_Router; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * class constructor |
|
57 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @param \EE_Registry $Registry |
|
61 | - * @param \EE_Request_Handler $Request_Handler |
|
62 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | - */ |
|
64 | - public function __construct( |
|
65 | - EE_Registry $Registry, |
|
66 | - EE_Request_Handler $Request_Handler, |
|
67 | - EE_Module_Request_Router $Module_Request_Router |
|
68 | - ) { |
|
69 | - $this->Registry = $Registry; |
|
70 | - $this->Request_Handler = $Request_Handler; |
|
71 | - $this->Module_Request_Router = $Module_Request_Router; |
|
72 | - // load other resources and begin to actually run shortcodes and modules |
|
73 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
74 | - // analyse the incoming WP request |
|
75 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
76 | - // process request with module factory |
|
77 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
78 | - // before headers sent |
|
79 | - add_action('wp', array($this, 'wp'), 5); |
|
80 | - // primarily used to process any content shortcodes |
|
81 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
82 | - // header |
|
83 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
84 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
85 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
86 | - // display errors |
|
87 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
88 | - // the content |
|
89 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
90 | - // exclude our private cpt comments |
|
91 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
92 | - // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
93 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
94 | - // action hook EE |
|
95 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return EE_Request_Handler |
|
101 | - */ |
|
102 | - public function Request_Handler() |
|
103 | - { |
|
104 | - return $this->Request_Handler; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return EE_Module_Request_Router |
|
110 | - */ |
|
111 | - public function Module_Request_Router() |
|
112 | - { |
|
113 | - return $this->Module_Request_Router; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @return LegacyShortcodesManager |
|
119 | - */ |
|
120 | - public function getLegacyShortcodesManager() |
|
121 | - { |
|
122 | - return EE_Config::getLegacyShortcodesManager(); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
130 | - /** |
|
131 | - * filter_wp_comments |
|
132 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
133 | - * widgets/queries done on frontend |
|
134 | - * |
|
135 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
136 | - * @return array array of comment clauses with modifications. |
|
137 | - * @throws InvalidArgumentException |
|
138 | - * @throws InvalidDataTypeException |
|
139 | - * @throws InvalidInterfaceException |
|
140 | - */ |
|
141 | - public function filter_wp_comments($clauses) |
|
142 | - { |
|
143 | - global $wpdb; |
|
144 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
145 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
146 | - $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
147 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
148 | - ); |
|
149 | - $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
150 | - foreach ($cpts as $cpt => $details) { |
|
151 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
152 | - } |
|
153 | - } |
|
154 | - return $clauses; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
160 | - * |
|
161 | - * @param string $url incoming url |
|
162 | - * @return string final assembled url |
|
163 | - */ |
|
164 | - public function maybe_force_admin_ajax_ssl($url) |
|
165 | - { |
|
166 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
167 | - $url = str_replace('http://', 'https://', $url); |
|
168 | - } |
|
169 | - return $url; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
182 | - * default priority init phases have run |
|
183 | - * |
|
184 | - * @access public |
|
185 | - * @return void |
|
186 | - */ |
|
187 | - public function wp_loaded() |
|
188 | - { |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
196 | - /** |
|
197 | - * _get_request |
|
198 | - * |
|
199 | - * @access public |
|
200 | - * @param WP $WP |
|
201 | - * @return void |
|
202 | - */ |
|
203 | - public function get_request(WP $WP) |
|
204 | - { |
|
205 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
206 | - $this->Request_Handler->parse_request($WP); |
|
207 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
213 | - * |
|
214 | - * @access public |
|
215 | - * @param WP_Query $WP_Query |
|
216 | - * @return void |
|
217 | - */ |
|
218 | - public function pre_get_posts($WP_Query) |
|
219 | - { |
|
220 | - // only load Module_Request_Router if this is the main query |
|
221 | - if ($this->Module_Request_Router instanceof EE_Module_Request_Router |
|
222 | - && $WP_Query->is_main_query() |
|
223 | - ) { |
|
224 | - // cycle thru module routes |
|
225 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
226 | - // determine module and method for route |
|
227 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
228 | - if ($module instanceof EED_Module) { |
|
229 | - // get registered view for route |
|
230 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
231 | - // grab module name |
|
232 | - $module_name = $module->module_name(); |
|
233 | - // map the module to the module objects |
|
234 | - $this->Registry->modules->{$module_name} = $module; |
|
235 | - } |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - |
|
244 | - /*********************************************** WP HOOK ***********************************************/ |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * wp - basically last chance to do stuff before headers sent |
|
249 | - * |
|
250 | - * @access public |
|
251 | - * @return void |
|
252 | - */ |
|
253 | - public function wp() |
|
254 | - { |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - |
|
259 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * callback for the "template_redirect" hook point |
|
264 | - * checks sidebars for EE widgets |
|
265 | - * loads resources and assets accordingly |
|
266 | - * |
|
267 | - * @return void |
|
268 | - */ |
|
269 | - public function templateRedirect() |
|
270 | - { |
|
271 | - global $wp_query; |
|
272 | - if (empty($wp_query->posts)) { |
|
273 | - return; |
|
274 | - } |
|
275 | - // if we already know this is an espresso page, then load assets |
|
276 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
277 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
278 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
279 | - if ($load_assets) { |
|
280 | - add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
281 | - add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - /** |
|
287 | - * builds list of active widgets then scans active sidebars looking for them |
|
288 | - * returns true is an EE widget is found in an active sidebar |
|
289 | - * Please Note: this does NOT mean that the sidebar or widget |
|
290 | - * is actually in use in a given template, as that is unfortunately not known |
|
291 | - * until a sidebar and it's widgets are actually loaded |
|
292 | - * |
|
293 | - * @return boolean |
|
294 | - */ |
|
295 | - private function espresso_widgets_in_active_sidebars() |
|
296 | - { |
|
297 | - $espresso_widgets = array(); |
|
298 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
299 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
300 | - if (is_active_widget(false, false, $id_base)) { |
|
301 | - $espresso_widgets[] = $id_base; |
|
302 | - } |
|
303 | - } |
|
304 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
305 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
306 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
307 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
308 | - foreach ($espresso_widgets as $espresso_widget) { |
|
309 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
310 | - return true; |
|
311 | - } |
|
312 | - } |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
316 | - return false; |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * header_meta_tag |
|
322 | - * |
|
323 | - * @access public |
|
324 | - * @return void |
|
325 | - */ |
|
326 | - public function header_meta_tag() |
|
327 | - { |
|
328 | - print( |
|
329 | - apply_filters( |
|
330 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
331 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
332 | - ) |
|
333 | - ); |
|
334 | - |
|
335 | - // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
336 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
337 | - // also exclude all critical pages from indexing |
|
338 | - if (( |
|
339 | - is_tax('espresso_event_type') |
|
340 | - && get_option('blog_public') !== '0' |
|
341 | - ) |
|
342 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
343 | - ) { |
|
344 | - print( |
|
345 | - apply_filters( |
|
346 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
347 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
348 | - ) |
|
349 | - ); |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * wp_print_scripts |
|
356 | - * |
|
357 | - * @return void |
|
358 | - */ |
|
359 | - public function wp_print_scripts() |
|
360 | - { |
|
361 | - global $post; |
|
362 | - if (isset($post->EE_Event) |
|
363 | - && $post->EE_Event instanceof EE_Event |
|
364 | - && get_post_type() === 'espresso_events' |
|
365 | - && is_singular() |
|
366 | - ) { |
|
367 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - public function enqueueStyle() |
|
373 | - { |
|
374 | - wp_enqueue_style('espresso_default'); |
|
375 | - wp_enqueue_style('espresso_custom_css'); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
381 | - |
|
382 | - |
|
383 | - public function enqueueScripts() |
|
384 | - { |
|
385 | - wp_enqueue_script('espresso_core'); |
|
386 | - } |
|
387 | - |
|
388 | - |
|
389 | - /** |
|
390 | - * display_errors |
|
391 | - * |
|
392 | - * @access public |
|
393 | - * @return void |
|
394 | - * @throws DomainException |
|
395 | - */ |
|
396 | - public function display_errors() |
|
397 | - { |
|
398 | - static $shown_already = false; |
|
399 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
400 | - if (! $shown_already |
|
401 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
402 | - && is_main_query() |
|
403 | - && ! is_feed() |
|
404 | - && in_the_loop() |
|
405 | - && did_action('wp_head') |
|
406 | - && $this->Request_Handler->is_espresso_page() |
|
407 | - ) { |
|
408 | - echo EE_Error::get_notices(); |
|
409 | - $shown_already = true; |
|
410 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
411 | - } |
|
412 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - |
|
418 | - |
|
419 | - /*********************************************** UTILITIES ***********************************************/ |
|
420 | - /** |
|
421 | - * template_include |
|
422 | - * |
|
423 | - * @access public |
|
424 | - * @param string $template_include_path |
|
425 | - * @return string |
|
426 | - */ |
|
427 | - public function template_include($template_include_path = null) |
|
428 | - { |
|
429 | - if ($this->Request_Handler->is_espresso_page()) { |
|
430 | - $this->_template_path = ! empty($this->_template_path) |
|
431 | - ? basename($this->_template_path) |
|
432 | - : basename( |
|
433 | - $template_include_path |
|
434 | - ); |
|
435 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
436 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
437 | - $this->_template = basename($this->_template_path); |
|
438 | - return $this->_template_path; |
|
439 | - } |
|
440 | - return $template_include_path; |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * get_selected_template |
|
446 | - * |
|
447 | - * @access public |
|
448 | - * @param bool $with_path |
|
449 | - * @return string |
|
450 | - */ |
|
451 | - public function get_selected_template($with_path = false) |
|
452 | - { |
|
453 | - return $with_path ? $this->_template_path : $this->_template; |
|
454 | - } |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * @deprecated 4.9.26 |
|
459 | - * @param string $shortcode_class |
|
460 | - * @param \WP $wp |
|
461 | - */ |
|
462 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
463 | - { |
|
464 | - \EE_Error::doing_it_wrong( |
|
465 | - __METHOD__, |
|
466 | - __( |
|
467 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
468 | - 'event_espresso' |
|
469 | - ), |
|
470 | - '4.9.26' |
|
471 | - ); |
|
472 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - /** |
|
477 | - * @return void |
|
478 | - * @deprecated 4.9.57.p |
|
479 | - */ |
|
480 | - public function loadPersistentAdminNoticeManager() |
|
481 | - { |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * @return void |
|
487 | - * @deprecated 4.9.64.p |
|
488 | - */ |
|
489 | - public function employ_CPT_Strategy() |
|
490 | - { |
|
491 | - } |
|
29 | + /** |
|
30 | + * @var string $_template_path |
|
31 | + */ |
|
32 | + private $_template_path; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var string $_template |
|
36 | + */ |
|
37 | + private $_template; |
|
38 | + |
|
39 | + /** |
|
40 | + * @type EE_Registry $Registry |
|
41 | + */ |
|
42 | + protected $Registry; |
|
43 | + |
|
44 | + /** |
|
45 | + * @type EE_Request_Handler $Request_Handler |
|
46 | + */ |
|
47 | + protected $Request_Handler; |
|
48 | + |
|
49 | + /** |
|
50 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
51 | + */ |
|
52 | + protected $Module_Request_Router; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * class constructor |
|
57 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @param \EE_Registry $Registry |
|
61 | + * @param \EE_Request_Handler $Request_Handler |
|
62 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
63 | + */ |
|
64 | + public function __construct( |
|
65 | + EE_Registry $Registry, |
|
66 | + EE_Request_Handler $Request_Handler, |
|
67 | + EE_Module_Request_Router $Module_Request_Router |
|
68 | + ) { |
|
69 | + $this->Registry = $Registry; |
|
70 | + $this->Request_Handler = $Request_Handler; |
|
71 | + $this->Module_Request_Router = $Module_Request_Router; |
|
72 | + // load other resources and begin to actually run shortcodes and modules |
|
73 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
74 | + // analyse the incoming WP request |
|
75 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
76 | + // process request with module factory |
|
77 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
78 | + // before headers sent |
|
79 | + add_action('wp', array($this, 'wp'), 5); |
|
80 | + // primarily used to process any content shortcodes |
|
81 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
82 | + // header |
|
83 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
84 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
85 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
86 | + // display errors |
|
87 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
88 | + // the content |
|
89 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
90 | + // exclude our private cpt comments |
|
91 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
92 | + // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
93 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
94 | + // action hook EE |
|
95 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return EE_Request_Handler |
|
101 | + */ |
|
102 | + public function Request_Handler() |
|
103 | + { |
|
104 | + return $this->Request_Handler; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return EE_Module_Request_Router |
|
110 | + */ |
|
111 | + public function Module_Request_Router() |
|
112 | + { |
|
113 | + return $this->Module_Request_Router; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @return LegacyShortcodesManager |
|
119 | + */ |
|
120 | + public function getLegacyShortcodesManager() |
|
121 | + { |
|
122 | + return EE_Config::getLegacyShortcodesManager(); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
130 | + /** |
|
131 | + * filter_wp_comments |
|
132 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
133 | + * widgets/queries done on frontend |
|
134 | + * |
|
135 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
136 | + * @return array array of comment clauses with modifications. |
|
137 | + * @throws InvalidArgumentException |
|
138 | + * @throws InvalidDataTypeException |
|
139 | + * @throws InvalidInterfaceException |
|
140 | + */ |
|
141 | + public function filter_wp_comments($clauses) |
|
142 | + { |
|
143 | + global $wpdb; |
|
144 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
145 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
146 | + $custom_post_types = LoaderFactory::getLoader()->getShared( |
|
147 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
148 | + ); |
|
149 | + $cpts = $custom_post_types->getPrivateCustomPostTypes(); |
|
150 | + foreach ($cpts as $cpt => $details) { |
|
151 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
152 | + } |
|
153 | + } |
|
154 | + return $clauses; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
160 | + * |
|
161 | + * @param string $url incoming url |
|
162 | + * @return string final assembled url |
|
163 | + */ |
|
164 | + public function maybe_force_admin_ajax_ssl($url) |
|
165 | + { |
|
166 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
167 | + $url = str_replace('http://', 'https://', $url); |
|
168 | + } |
|
169 | + return $url; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
182 | + * default priority init phases have run |
|
183 | + * |
|
184 | + * @access public |
|
185 | + * @return void |
|
186 | + */ |
|
187 | + public function wp_loaded() |
|
188 | + { |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
196 | + /** |
|
197 | + * _get_request |
|
198 | + * |
|
199 | + * @access public |
|
200 | + * @param WP $WP |
|
201 | + * @return void |
|
202 | + */ |
|
203 | + public function get_request(WP $WP) |
|
204 | + { |
|
205 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
206 | + $this->Request_Handler->parse_request($WP); |
|
207 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
213 | + * |
|
214 | + * @access public |
|
215 | + * @param WP_Query $WP_Query |
|
216 | + * @return void |
|
217 | + */ |
|
218 | + public function pre_get_posts($WP_Query) |
|
219 | + { |
|
220 | + // only load Module_Request_Router if this is the main query |
|
221 | + if ($this->Module_Request_Router instanceof EE_Module_Request_Router |
|
222 | + && $WP_Query->is_main_query() |
|
223 | + ) { |
|
224 | + // cycle thru module routes |
|
225 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
226 | + // determine module and method for route |
|
227 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
228 | + if ($module instanceof EED_Module) { |
|
229 | + // get registered view for route |
|
230 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
231 | + // grab module name |
|
232 | + $module_name = $module->module_name(); |
|
233 | + // map the module to the module objects |
|
234 | + $this->Registry->modules->{$module_name} = $module; |
|
235 | + } |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + |
|
244 | + /*********************************************** WP HOOK ***********************************************/ |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * wp - basically last chance to do stuff before headers sent |
|
249 | + * |
|
250 | + * @access public |
|
251 | + * @return void |
|
252 | + */ |
|
253 | + public function wp() |
|
254 | + { |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + |
|
259 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * callback for the "template_redirect" hook point |
|
264 | + * checks sidebars for EE widgets |
|
265 | + * loads resources and assets accordingly |
|
266 | + * |
|
267 | + * @return void |
|
268 | + */ |
|
269 | + public function templateRedirect() |
|
270 | + { |
|
271 | + global $wp_query; |
|
272 | + if (empty($wp_query->posts)) { |
|
273 | + return; |
|
274 | + } |
|
275 | + // if we already know this is an espresso page, then load assets |
|
276 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
277 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
278 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
279 | + if ($load_assets) { |
|
280 | + add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10); |
|
281 | + add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10); |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + /** |
|
287 | + * builds list of active widgets then scans active sidebars looking for them |
|
288 | + * returns true is an EE widget is found in an active sidebar |
|
289 | + * Please Note: this does NOT mean that the sidebar or widget |
|
290 | + * is actually in use in a given template, as that is unfortunately not known |
|
291 | + * until a sidebar and it's widgets are actually loaded |
|
292 | + * |
|
293 | + * @return boolean |
|
294 | + */ |
|
295 | + private function espresso_widgets_in_active_sidebars() |
|
296 | + { |
|
297 | + $espresso_widgets = array(); |
|
298 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
299 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
300 | + if (is_active_widget(false, false, $id_base)) { |
|
301 | + $espresso_widgets[] = $id_base; |
|
302 | + } |
|
303 | + } |
|
304 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
305 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
306 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
307 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
308 | + foreach ($espresso_widgets as $espresso_widget) { |
|
309 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
310 | + return true; |
|
311 | + } |
|
312 | + } |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | + return false; |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * header_meta_tag |
|
322 | + * |
|
323 | + * @access public |
|
324 | + * @return void |
|
325 | + */ |
|
326 | + public function header_meta_tag() |
|
327 | + { |
|
328 | + print( |
|
329 | + apply_filters( |
|
330 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
331 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n" |
|
332 | + ) |
|
333 | + ); |
|
334 | + |
|
335 | + // let's exclude all event type taxonomy term archive pages from search engine indexing |
|
336 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
337 | + // also exclude all critical pages from indexing |
|
338 | + if (( |
|
339 | + is_tax('espresso_event_type') |
|
340 | + && get_option('blog_public') !== '0' |
|
341 | + ) |
|
342 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
343 | + ) { |
|
344 | + print( |
|
345 | + apply_filters( |
|
346 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
347 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
348 | + ) |
|
349 | + ); |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * wp_print_scripts |
|
356 | + * |
|
357 | + * @return void |
|
358 | + */ |
|
359 | + public function wp_print_scripts() |
|
360 | + { |
|
361 | + global $post; |
|
362 | + if (isset($post->EE_Event) |
|
363 | + && $post->EE_Event instanceof EE_Event |
|
364 | + && get_post_type() === 'espresso_events' |
|
365 | + && is_singular() |
|
366 | + ) { |
|
367 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + public function enqueueStyle() |
|
373 | + { |
|
374 | + wp_enqueue_style('espresso_default'); |
|
375 | + wp_enqueue_style('espresso_custom_css'); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
381 | + |
|
382 | + |
|
383 | + public function enqueueScripts() |
|
384 | + { |
|
385 | + wp_enqueue_script('espresso_core'); |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + /** |
|
390 | + * display_errors |
|
391 | + * |
|
392 | + * @access public |
|
393 | + * @return void |
|
394 | + * @throws DomainException |
|
395 | + */ |
|
396 | + public function display_errors() |
|
397 | + { |
|
398 | + static $shown_already = false; |
|
399 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
400 | + if (! $shown_already |
|
401 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
402 | + && is_main_query() |
|
403 | + && ! is_feed() |
|
404 | + && in_the_loop() |
|
405 | + && did_action('wp_head') |
|
406 | + && $this->Request_Handler->is_espresso_page() |
|
407 | + ) { |
|
408 | + echo EE_Error::get_notices(); |
|
409 | + $shown_already = true; |
|
410 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
411 | + } |
|
412 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + |
|
418 | + |
|
419 | + /*********************************************** UTILITIES ***********************************************/ |
|
420 | + /** |
|
421 | + * template_include |
|
422 | + * |
|
423 | + * @access public |
|
424 | + * @param string $template_include_path |
|
425 | + * @return string |
|
426 | + */ |
|
427 | + public function template_include($template_include_path = null) |
|
428 | + { |
|
429 | + if ($this->Request_Handler->is_espresso_page()) { |
|
430 | + $this->_template_path = ! empty($this->_template_path) |
|
431 | + ? basename($this->_template_path) |
|
432 | + : basename( |
|
433 | + $template_include_path |
|
434 | + ); |
|
435 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
436 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
437 | + $this->_template = basename($this->_template_path); |
|
438 | + return $this->_template_path; |
|
439 | + } |
|
440 | + return $template_include_path; |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * get_selected_template |
|
446 | + * |
|
447 | + * @access public |
|
448 | + * @param bool $with_path |
|
449 | + * @return string |
|
450 | + */ |
|
451 | + public function get_selected_template($with_path = false) |
|
452 | + { |
|
453 | + return $with_path ? $this->_template_path : $this->_template; |
|
454 | + } |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * @deprecated 4.9.26 |
|
459 | + * @param string $shortcode_class |
|
460 | + * @param \WP $wp |
|
461 | + */ |
|
462 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
463 | + { |
|
464 | + \EE_Error::doing_it_wrong( |
|
465 | + __METHOD__, |
|
466 | + __( |
|
467 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
468 | + 'event_espresso' |
|
469 | + ), |
|
470 | + '4.9.26' |
|
471 | + ); |
|
472 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + /** |
|
477 | + * @return void |
|
478 | + * @deprecated 4.9.57.p |
|
479 | + */ |
|
480 | + public function loadPersistentAdminNoticeManager() |
|
481 | + { |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * @return void |
|
487 | + * @deprecated 4.9.64.p |
|
488 | + */ |
|
489 | + public function employ_CPT_Strategy() |
|
490 | + { |
|
491 | + } |
|
492 | 492 | } |