@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | { |
25 | 25 | global $wpdb; |
26 | 26 | $this->_pretty_name = esc_html__('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"; |
|
27 | + $this->_old_table = $wpdb->prefix."esp_message_template_group"; |
|
28 | + $this->_emt_table = $wpdb->prefix."esp_event_message_template"; |
|
29 | 29 | parent::__construct(); |
30 | 30 | } |
31 | 31 | |
@@ -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) { |
@@ -12,59 +12,59 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_DMS_4_3_0_event_message_templates extends EE_Data_Migration_Script_Stage_Table |
14 | 14 | { |
15 | - /** |
|
16 | - * This property will hold the table name for event_message_templates |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - private $_emt_table; |
|
15 | + /** |
|
16 | + * This property will hold the table name for event_message_templates |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + private $_emt_table; |
|
20 | 20 | |
21 | 21 | |
22 | - public function __construct() |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - $this->_pretty_name = esc_html__('Event Message Templates', 'event_espresso'); |
|
26 | - $this->_old_table = $wpdb->prefix . "esp_message_template_group"; |
|
27 | - $this->_emt_table = $wpdb->prefix . "esp_event_message_template"; |
|
28 | - parent::__construct(); |
|
29 | - } |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + $this->_pretty_name = esc_html__('Event Message Templates', 'event_espresso'); |
|
26 | + $this->_old_table = $wpdb->prefix . "esp_message_template_group"; |
|
27 | + $this->_emt_table = $wpdb->prefix . "esp_event_message_template"; |
|
28 | + parent::__construct(); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | 32 | |
33 | - protected function _migrate_old_row($old_row) |
|
34 | - { |
|
35 | - // 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 ) |
|
36 | - global $wpdb; |
|
37 | - if ($old_row['EVT_ID'] > 0) { |
|
38 | - // let's get the EVT for this id so we can update the custom name on the old row. |
|
39 | - $event_name = 'Custom Template for ' . $wpdb->get_var($wpdb->prepare("SELECT post_title from $wpdb->posts WHERE ID = %d", absint($old_row['EVT_ID']))); |
|
33 | + protected function _migrate_old_row($old_row) |
|
34 | + { |
|
35 | + // 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 ) |
|
36 | + global $wpdb; |
|
37 | + if ($old_row['EVT_ID'] > 0) { |
|
38 | + // let's get the EVT for this id so we can update the custom name on the old row. |
|
39 | + $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 | 40 | |
41 | - // update name |
|
42 | - $updated = $wpdb->update( |
|
43 | - $this->_old_table, |
|
44 | - array( |
|
45 | - 'MTP_name' => $event_name |
|
46 | - ), |
|
47 | - array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
48 | - array( '%s' ), |
|
49 | - array( '%d' ) |
|
50 | - ); |
|
41 | + // update name |
|
42 | + $updated = $wpdb->update( |
|
43 | + $this->_old_table, |
|
44 | + array( |
|
45 | + 'MTP_name' => $event_name |
|
46 | + ), |
|
47 | + array( 'GRP_ID' => (int) $old_row['GRP_ID'] ), |
|
48 | + array( '%s' ), |
|
49 | + array( '%d' ) |
|
50 | + ); |
|
51 | 51 | |
52 | - $inserted = $wpdb->insert( |
|
53 | - $this->_emt_table, |
|
54 | - array( |
|
55 | - 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
56 | - 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
57 | - ), |
|
58 | - array( '%d', '%d' ) |
|
59 | - ); |
|
52 | + $inserted = $wpdb->insert( |
|
53 | + $this->_emt_table, |
|
54 | + array( |
|
55 | + 'EVT_ID' => (int) $old_row['EVT_ID'], |
|
56 | + 'GRP_ID' => (int) $old_row['GRP_ID'], |
|
57 | + ), |
|
58 | + array( '%d', '%d' ) |
|
59 | + ); |
|
60 | 60 | |
61 | - if (false === $updated) { |
|
62 | - $this->add_error(sprintf(esc_html__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
63 | - } |
|
61 | + if (false === $updated) { |
|
62 | + $this->add_error(sprintf(esc_html__("Error in updating the row in %s setting 'MTP_name = %s", 'event_espresso'), $this->_old_table, $event_name)); |
|
63 | + } |
|
64 | 64 | |
65 | - if (false === $inserted) { |
|
66 | - $this->add_error(sprintf(esc_html__("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'])); |
|
67 | - } |
|
68 | - } |
|
69 | - } |
|
65 | + if (false === $inserted) { |
|
66 | + $this->add_error(sprintf(esc_html__("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'])); |
|
67 | + } |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |
@@ -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 = esc_html__("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 | - esc_html__( |
|
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 = esc_html__("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 | + esc_html__( |
|
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 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | { |
12 | 12 | global $wpdb; |
13 | 13 | $this->_pretty_name = esc_html__("Question Options", "event_espresso"); |
14 | - $this->_old_table = $wpdb->prefix . "esp_question_option"; |
|
14 | + $this->_old_table = $wpdb->prefix."esp_question_option"; |
|
15 | 15 | parent::__construct(); |
16 | 16 | } |
17 | 17 | protected function _migrate_old_row($old_row) |
@@ -23,9 +23,9 @@ discard block |
||
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) { |
@@ -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 = esc_html__('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' => esc_html__('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 | - esc_html__('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 = esc_html__('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' => esc_html__('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 | + esc_html__('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 = esc_html__('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' => esc_html__('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; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function __construct() |
23 | 23 | { |
24 | 24 | global $wpdb; |
25 | - $this->_line_item_table_name = $wpdb->prefix . "esp_line_item"; |
|
25 | + $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | 26 | $this->_pretty_name = esc_html__('Pre-tax total line items', 'event_espresso'); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -54,10 +54,10 @@ discard block |
||
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; |
@@ -12,53 +12,53 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage |
14 | 14 | { |
15 | - protected $_line_item_table_name; |
|
15 | + protected $_line_item_table_name; |
|
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Just initializes the status of the migration |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - global $wpdb; |
|
24 | - $this->_line_item_table_name = $wpdb->prefix . "esp_line_item"; |
|
25 | - $this->_pretty_name = esc_html__('Pre-tax total line items', 'event_espresso'); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Just initializes the status of the migration |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + global $wpdb; |
|
24 | + $this->_line_item_table_name = $wpdb->prefix . "esp_line_item"; |
|
25 | + $this->_pretty_name = esc_html__('Pre-tax total line items', 'event_espresso'); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * Counts the records to migrate; the public version may cache it |
|
33 | - * @return int |
|
34 | - */ |
|
35 | - protected function _count_records_to_migrate() |
|
36 | - { |
|
37 | - return 1; |
|
38 | - } |
|
31 | + /** |
|
32 | + * Counts the records to migrate; the public version may cache it |
|
33 | + * @return int |
|
34 | + */ |
|
35 | + protected function _count_records_to_migrate() |
|
36 | + { |
|
37 | + return 1; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
44 | - * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
45 | - * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
46 | - * 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, |
|
47 | - * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
48 | - * @param int $num_items_to_migrate |
|
49 | - * @return int number of items ACTUALLY migrated |
|
50 | - */ |
|
51 | - protected function _migration_step($num_items_to_migrate = 50) |
|
52 | - { |
|
53 | - global $wpdb; |
|
54 | - $rows_updated = $wpdb->update( |
|
55 | - $this->_line_item_table_name, |
|
56 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
57 | - array( 'LIN_code' => 'tickets' ), |
|
58 | - array( '%s' ), |
|
59 | - array( '%s' ) |
|
60 | - ); |
|
61 | - $this->set_completed(); |
|
62 | - return 1; |
|
63 | - } |
|
42 | + /** |
|
43 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
44 | + * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
45 | + * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
46 | + * 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, |
|
47 | + * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
48 | + * @param int $num_items_to_migrate |
|
49 | + * @return int number of items ACTUALLY migrated |
|
50 | + */ |
|
51 | + protected function _migration_step($num_items_to_migrate = 50) |
|
52 | + { |
|
53 | + global $wpdb; |
|
54 | + $rows_updated = $wpdb->update( |
|
55 | + $this->_line_item_table_name, |
|
56 | + array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
57 | + array( 'LIN_code' => 'tickets' ), |
|
58 | + array( '%s' ), |
|
59 | + array( '%s' ) |
|
60 | + ); |
|
61 | + $this->set_completed(); |
|
62 | + return 1; |
|
63 | + } |
|
64 | 64 | } |
@@ -16,15 +16,13 @@ discard block |
||
16 | 16 | 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', esc_html__('Flag indicating question is only for primary attendees','event_espresso'), false, false) |
17 | 17 | ) |
18 | 18 | ); |
19 | - |
|
20 | - |
|
21 | 19 | * |
22 | 20 | */ |
23 | 21 | class EE_DMS_4_1_0_event_question_group extends EE_Data_Migration_Script_Stage_Table |
24 | 22 | { |
25 | - private $_new_table; |
|
26 | - public function _migrate_old_row($old_row) |
|
27 | - { |
|
23 | + private $_new_table; |
|
24 | + public function _migrate_old_row($old_row) |
|
25 | + { |
|
28 | 26 | // $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $this->_new_transaction_table); |
29 | 27 | // if ( ! $txn_id ){ |
30 | 28 | // $this->add_error(sprintf(esc_html__("Could not find the transaction for the 3.1 attendee %d from row %s", "event_espresso"),$old_row['id'],$this->_json_encode($old_row))); |
@@ -34,8 +32,8 @@ discard block |
||
34 | 32 | // $new_line_items = $this->_insert_new_line_items($txn,$old_row); |
35 | 33 | // $this->get_migration_script()->set_mapping($this->_old_table,$old_row['id'],$this->_new_line_table,$new_line_items); |
36 | 34 | |
37 | - $this->_insert_new_event_question_groups($old_row); |
|
38 | - } |
|
35 | + $this->_insert_new_event_question_groups($old_row); |
|
36 | + } |
|
39 | 37 | // function _migration_step($num_items=50){ |
40 | 38 | // global $wpdb; |
41 | 39 | // $start_at_record = $this->count_records_migrated(); |
@@ -55,109 +53,109 @@ discard block |
||
55 | 53 | // $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
56 | 54 | // return $count; |
57 | 55 | // } |
58 | - public function __construct() |
|
59 | - { |
|
60 | - global $wpdb; |
|
61 | - $this->_old_table = $wpdb->prefix . "events_detail"; |
|
62 | - $this->_extra_where_sql = 'WHERE event_status!="D"'; |
|
63 | - $this->_new_table = $wpdb->prefix . "esp_event_question_group"; |
|
64 | - $this->_pretty_name = esc_html__("Question Groups in each Event", "event_espresso"); |
|
65 | - parent::__construct(); |
|
66 | - } |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + global $wpdb; |
|
59 | + $this->_old_table = $wpdb->prefix . "events_detail"; |
|
60 | + $this->_extra_where_sql = 'WHERE event_status!="D"'; |
|
61 | + $this->_new_table = $wpdb->prefix . "esp_event_question_group"; |
|
62 | + $this->_pretty_name = esc_html__("Question Groups in each Event", "event_espresso"); |
|
63 | + parent::__construct(); |
|
64 | + } |
|
67 | 65 | |
68 | - /** |
|
69 | - * Attempts to insert a new question group inthe new format given an old one |
|
70 | - * @global type $wpdb |
|
71 | - * @param array $old_event |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - private function _insert_new_event_question_groups($old_event) |
|
75 | - { |
|
76 | - $new_event_question_group_ids = array(); |
|
77 | - $question_groups_for_primary = maybe_unserialize($old_event['question_groups']); |
|
78 | - if (is_array($question_groups_for_primary)) { |
|
79 | - foreach ($question_groups_for_primary as $old_question_group_id) { |
|
80 | - $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true); |
|
81 | - if ($new_id) { |
|
82 | - $new_event_question_group_ids[] = $new_id; |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
86 | - $event_meta = maybe_unserialize($old_event['event_meta']); |
|
87 | - if (isset($event_meta['add_attendee_question_groups'])) { |
|
88 | - if (is_array($event_meta['add_attendee_question_groups'])) { |
|
89 | - foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) { |
|
90 | - $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false); |
|
91 | - if ($new_id) { |
|
92 | - $new_event_question_group_ids[] = $new_id; |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
66 | + /** |
|
67 | + * Attempts to insert a new question group inthe new format given an old one |
|
68 | + * @global type $wpdb |
|
69 | + * @param array $old_event |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + private function _insert_new_event_question_groups($old_event) |
|
73 | + { |
|
74 | + $new_event_question_group_ids = array(); |
|
75 | + $question_groups_for_primary = maybe_unserialize($old_event['question_groups']); |
|
76 | + if (is_array($question_groups_for_primary)) { |
|
77 | + foreach ($question_groups_for_primary as $old_question_group_id) { |
|
78 | + $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true); |
|
79 | + if ($new_id) { |
|
80 | + $new_event_question_group_ids[] = $new_id; |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + $event_meta = maybe_unserialize($old_event['event_meta']); |
|
85 | + if (isset($event_meta['add_attendee_question_groups'])) { |
|
86 | + if (is_array($event_meta['add_attendee_question_groups'])) { |
|
87 | + foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) { |
|
88 | + $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false); |
|
89 | + if ($new_id) { |
|
90 | + $new_event_question_group_ids[] = $new_id; |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
97 | 95 | |
98 | 96 | |
99 | - $this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids); |
|
100 | - } |
|
97 | + $this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids); |
|
98 | + } |
|
101 | 99 | |
102 | - private function _insert_event_question_group($old_event, $old_question_group_id, $primary) |
|
103 | - { |
|
104 | - global $wpdb; |
|
105 | - $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk( |
|
106 | - $wpdb->prefix . "events_qst_group", |
|
107 | - intval($old_question_group_id), |
|
108 | - $wpdb->prefix . "esp_question_group" |
|
109 | - ); |
|
100 | + private function _insert_event_question_group($old_event, $old_question_group_id, $primary) |
|
101 | + { |
|
102 | + global $wpdb; |
|
103 | + $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk( |
|
104 | + $wpdb->prefix . "events_qst_group", |
|
105 | + intval($old_question_group_id), |
|
106 | + $wpdb->prefix . "esp_question_group" |
|
107 | + ); |
|
110 | 108 | |
111 | - if (! $new_question_group_id) { |
|
112 | - $this->add_error( |
|
113 | - sprintf( |
|
114 | - // translators: %s question ID, %s event ID |
|
115 | - esc_html__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"), |
|
116 | - $old_question_group_id, |
|
117 | - $old_event['id'] |
|
118 | - ) |
|
119 | - ); |
|
120 | - return 0; |
|
121 | - } |
|
122 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
|
123 | - $wpdb->prefix . "events_detail", |
|
124 | - intval($old_event['id']), |
|
125 | - $wpdb->posts |
|
126 | - ); |
|
127 | - if (! $new_question_group_id) { |
|
128 | - $this->add_error( |
|
129 | - sprintf( |
|
130 | - // translators: %s event ID |
|
131 | - esc_html__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"), |
|
132 | - $old_event['id'] |
|
133 | - ) |
|
134 | - ); |
|
135 | - return 0; |
|
136 | - } |
|
137 | - $cols_n_values = array( |
|
138 | - 'EVT_ID' => $new_event_id, |
|
139 | - 'QSG_ID' => $new_question_group_id, |
|
140 | - 'EQG_primary' => $primary |
|
141 | - ); |
|
109 | + if (! $new_question_group_id) { |
|
110 | + $this->add_error( |
|
111 | + sprintf( |
|
112 | + // translators: %s question ID, %s event ID |
|
113 | + esc_html__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"), |
|
114 | + $old_question_group_id, |
|
115 | + $old_event['id'] |
|
116 | + ) |
|
117 | + ); |
|
118 | + return 0; |
|
119 | + } |
|
120 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
|
121 | + $wpdb->prefix . "events_detail", |
|
122 | + intval($old_event['id']), |
|
123 | + $wpdb->posts |
|
124 | + ); |
|
125 | + if (! $new_question_group_id) { |
|
126 | + $this->add_error( |
|
127 | + sprintf( |
|
128 | + // translators: %s event ID |
|
129 | + esc_html__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"), |
|
130 | + $old_event['id'] |
|
131 | + ) |
|
132 | + ); |
|
133 | + return 0; |
|
134 | + } |
|
135 | + $cols_n_values = array( |
|
136 | + 'EVT_ID' => $new_event_id, |
|
137 | + 'QSG_ID' => $new_question_group_id, |
|
138 | + 'EQG_primary' => $primary |
|
139 | + ); |
|
142 | 140 | |
143 | - $datatypes = array( |
|
144 | - '%d',// EVT_ID |
|
145 | - '%d',// QSG_ID |
|
146 | - '%d',// EQG_primary |
|
147 | - ); |
|
148 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
149 | - if (! $success) { |
|
150 | - $this->add_error( |
|
151 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
152 | - $this->_old_table, |
|
153 | - $old_event, |
|
154 | - $this->_new_table, |
|
155 | - $cols_n_values, |
|
156 | - $datatypes |
|
157 | - ) |
|
158 | - ); |
|
159 | - return 0; |
|
160 | - } |
|
161 | - return $wpdb->insert_id; |
|
162 | - } |
|
141 | + $datatypes = array( |
|
142 | + '%d',// EVT_ID |
|
143 | + '%d',// QSG_ID |
|
144 | + '%d',// EQG_primary |
|
145 | + ); |
|
146 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
147 | + if (! $success) { |
|
148 | + $this->add_error( |
|
149 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
150 | + $this->_old_table, |
|
151 | + $old_event, |
|
152 | + $this->_new_table, |
|
153 | + $cols_n_values, |
|
154 | + $datatypes |
|
155 | + ) |
|
156 | + ); |
|
157 | + return 0; |
|
158 | + } |
|
159 | + return $wpdb->insert_id; |
|
160 | + } |
|
163 | 161 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | public function __construct() |
59 | 59 | { |
60 | 60 | global $wpdb; |
61 | - $this->_old_table = $wpdb->prefix . "events_detail"; |
|
61 | + $this->_old_table = $wpdb->prefix."events_detail"; |
|
62 | 62 | $this->_extra_where_sql = 'WHERE event_status!="D"'; |
63 | - $this->_new_table = $wpdb->prefix . "esp_event_question_group"; |
|
63 | + $this->_new_table = $wpdb->prefix."esp_event_question_group"; |
|
64 | 64 | $this->_pretty_name = esc_html__("Question Groups in each Event", "event_espresso"); |
65 | 65 | parent::__construct(); |
66 | 66 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | { |
104 | 104 | global $wpdb; |
105 | 105 | $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk( |
106 | - $wpdb->prefix . "events_qst_group", |
|
106 | + $wpdb->prefix."events_qst_group", |
|
107 | 107 | intval($old_question_group_id), |
108 | - $wpdb->prefix . "esp_question_group" |
|
108 | + $wpdb->prefix."esp_question_group" |
|
109 | 109 | ); |
110 | 110 | |
111 | - if (! $new_question_group_id) { |
|
111 | + if ( ! $new_question_group_id) { |
|
112 | 112 | $this->add_error( |
113 | 113 | sprintf( |
114 | 114 | // translators: %s question ID, %s event ID |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | return 0; |
121 | 121 | } |
122 | 122 | $new_event_id = $this->get_migration_script()->get_mapping_new_pk( |
123 | - $wpdb->prefix . "events_detail", |
|
123 | + $wpdb->prefix."events_detail", |
|
124 | 124 | intval($old_event['id']), |
125 | 125 | $wpdb->posts |
126 | 126 | ); |
127 | - if (! $new_question_group_id) { |
|
127 | + if ( ! $new_question_group_id) { |
|
128 | 128 | $this->add_error( |
129 | 129 | sprintf( |
130 | 130 | // translators: %s event ID |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | ); |
142 | 142 | |
143 | 143 | $datatypes = array( |
144 | - '%d',// EVT_ID |
|
145 | - '%d',// QSG_ID |
|
146 | - '%d',// EQG_primary |
|
144 | + '%d', // EVT_ID |
|
145 | + '%d', // QSG_ID |
|
146 | + '%d', // EQG_primary |
|
147 | 147 | ); |
148 | 148 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
149 | - if (! $success) { |
|
149 | + if ( ! $success) { |
|
150 | 150 | $this->add_error( |
151 | 151 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
152 | 152 | $this->_old_table, |
@@ -25,105 +25,102 @@ |
||
25 | 25 | |
26 | 26 | ) |
27 | 27 | ); |
28 | - |
|
29 | - |
|
30 | - |
|
31 | 28 | * |
32 | 29 | */ |
33 | 30 | class EE_DMS_4_1_0_event_venue extends EE_Data_Migration_Script_Stage |
34 | 31 | { |
35 | - private $_old_table; |
|
36 | - private $_new_table; |
|
37 | - public function _migration_step($num_items = 50) |
|
38 | - { |
|
32 | + private $_old_table; |
|
33 | + private $_new_table; |
|
34 | + public function _migration_step($num_items = 50) |
|
35 | + { |
|
39 | 36 | |
40 | - global $wpdb; |
|
41 | - $start_at_record = $this->count_records_migrated(); |
|
42 | - $rows = $wpdb->get_results( |
|
43 | - $wpdb->prepare( |
|
44 | - "SELECT * FROM $this->_old_table AS ev |
|
37 | + global $wpdb; |
|
38 | + $start_at_record = $this->count_records_migrated(); |
|
39 | + $rows = $wpdb->get_results( |
|
40 | + $wpdb->prepare( |
|
41 | + "SELECT * FROM $this->_old_table AS ev |
|
45 | 42 | INNER JOIN " . $wpdb->prefix . "events_detail AS e ON ev.event_id=e.id |
46 | 43 | WHERE e.event_status!='D' LIMIT %d,%d", |
47 | - $start_at_record, |
|
48 | - $num_items |
|
49 | - ), |
|
50 | - ARRAY_A |
|
51 | - ); |
|
52 | - $items_actually_migrated = 0; |
|
53 | - foreach ($rows as $event_venue_rel) { |
|
54 | - $this->_insert_new_event_to_venue_rel($event_venue_rel); |
|
55 | - $items_actually_migrated++; |
|
56 | - } |
|
57 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
58 | - $this->set_completed(); |
|
59 | - } |
|
60 | - return $items_actually_migrated; |
|
61 | - } |
|
62 | - public function _count_records_to_migrate() |
|
63 | - { |
|
64 | - global $wpdb; |
|
65 | - $count = $wpdb->get_var( |
|
66 | - "SELECT COUNT(ev.id) FROM " . $this->_old_table . " AS ev |
|
44 | + $start_at_record, |
|
45 | + $num_items |
|
46 | + ), |
|
47 | + ARRAY_A |
|
48 | + ); |
|
49 | + $items_actually_migrated = 0; |
|
50 | + foreach ($rows as $event_venue_rel) { |
|
51 | + $this->_insert_new_event_to_venue_rel($event_venue_rel); |
|
52 | + $items_actually_migrated++; |
|
53 | + } |
|
54 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
55 | + $this->set_completed(); |
|
56 | + } |
|
57 | + return $items_actually_migrated; |
|
58 | + } |
|
59 | + public function _count_records_to_migrate() |
|
60 | + { |
|
61 | + global $wpdb; |
|
62 | + $count = $wpdb->get_var( |
|
63 | + "SELECT COUNT(ev.id) FROM " . $this->_old_table . " AS ev |
|
67 | 64 | INNER JOIN " . $wpdb->prefix . 'events_detail AS e ON ev.event_id=e.id |
68 | 65 | WHERE e.event_status!="D"' |
69 | - ); |
|
70 | - return $count; |
|
71 | - } |
|
72 | - public function __construct() |
|
73 | - { |
|
74 | - global $wpdb; |
|
75 | - $this->_old_table = $wpdb->prefix . "events_venue_rel"; |
|
76 | - $this->_new_table = $wpdb->prefix . "esp_event_venue"; |
|
77 | - $this->_pretty_name = esc_html__("Event to Venue Relations", "event_espresso"); |
|
78 | - parent::__construct(); |
|
79 | - } |
|
66 | + ); |
|
67 | + return $count; |
|
68 | + } |
|
69 | + public function __construct() |
|
70 | + { |
|
71 | + global $wpdb; |
|
72 | + $this->_old_table = $wpdb->prefix . "events_venue_rel"; |
|
73 | + $this->_new_table = $wpdb->prefix . "esp_event_venue"; |
|
74 | + $this->_pretty_name = esc_html__("Event to Venue Relations", "event_espresso"); |
|
75 | + parent::__construct(); |
|
76 | + } |
|
80 | 77 | |
81 | - /** |
|
82 | - * Attempts to insert a new question group inthe new format given an old one |
|
83 | - * @global type $wpdb |
|
84 | - * @param array $old_event_venue_rel |
|
85 | - * @return int |
|
86 | - */ |
|
87 | - private function _insert_new_event_to_venue_rel($old_event_venue_rel) |
|
88 | - { |
|
89 | - global $wpdb; |
|
90 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", $old_event_venue_rel['event_id'], $wpdb->prefix . "posts"); |
|
91 | - $new_venue_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_venue", $old_event_venue_rel['venue_id'], $wpdb->prefix . "posts"); |
|
92 | - if (! $new_event_id) { |
|
93 | - $this->add_error(sprintf(esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_venue_rel['event_id'])); |
|
94 | - return 0; |
|
95 | - } |
|
96 | - if (! $new_venue_id) { |
|
97 | - $this->add_error(sprintf(esc_html__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $old_event_venue_rel['venue_id'])); |
|
98 | - return 0; |
|
99 | - } |
|
100 | - // first ensure there are no other relation entries for this event |
|
101 | - // because although EE4 supports it, EE3 didn't really |
|
102 | - $wpdb->delete( |
|
103 | - $this->_new_table, |
|
104 | - array( |
|
105 | - 'EVT_ID' => $new_event_id, |
|
106 | - ), |
|
107 | - array( |
|
108 | - '%d',// EVT_ID |
|
109 | - ) |
|
110 | - ); |
|
78 | + /** |
|
79 | + * Attempts to insert a new question group inthe new format given an old one |
|
80 | + * @global type $wpdb |
|
81 | + * @param array $old_event_venue_rel |
|
82 | + * @return int |
|
83 | + */ |
|
84 | + private function _insert_new_event_to_venue_rel($old_event_venue_rel) |
|
85 | + { |
|
86 | + global $wpdb; |
|
87 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", $old_event_venue_rel['event_id'], $wpdb->prefix . "posts"); |
|
88 | + $new_venue_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_venue", $old_event_venue_rel['venue_id'], $wpdb->prefix . "posts"); |
|
89 | + if (! $new_event_id) { |
|
90 | + $this->add_error(sprintf(esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_venue_rel['event_id'])); |
|
91 | + return 0; |
|
92 | + } |
|
93 | + if (! $new_venue_id) { |
|
94 | + $this->add_error(sprintf(esc_html__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $old_event_venue_rel['venue_id'])); |
|
95 | + return 0; |
|
96 | + } |
|
97 | + // first ensure there are no other relation entries for this event |
|
98 | + // because although EE4 supports it, EE3 didn't really |
|
99 | + $wpdb->delete( |
|
100 | + $this->_new_table, |
|
101 | + array( |
|
102 | + 'EVT_ID' => $new_event_id, |
|
103 | + ), |
|
104 | + array( |
|
105 | + '%d',// EVT_ID |
|
106 | + ) |
|
107 | + ); |
|
111 | 108 | // echo "last query". $wpdb->last_query;die; |
112 | - $cols_n_values = array( |
|
113 | - 'EVT_ID' => $new_event_id, |
|
114 | - 'VNU_ID' => $new_venue_id, |
|
115 | - 'EVV_primary' => true |
|
116 | - ); |
|
117 | - $datatypes = array( |
|
118 | - '%d',// EVT_ID |
|
119 | - '%d',// VNU_ID |
|
120 | - '%d',// EVT_primary |
|
121 | - ); |
|
122 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
123 | - if (! $success) { |
|
124 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_venue_rel, $this->_new_table, $cols_n_values, $datatypes)); |
|
125 | - return 0; |
|
126 | - } |
|
127 | - return $wpdb->insert_id; |
|
128 | - } |
|
109 | + $cols_n_values = array( |
|
110 | + 'EVT_ID' => $new_event_id, |
|
111 | + 'VNU_ID' => $new_venue_id, |
|
112 | + 'EVV_primary' => true |
|
113 | + ); |
|
114 | + $datatypes = array( |
|
115 | + '%d',// EVT_ID |
|
116 | + '%d',// VNU_ID |
|
117 | + '%d',// EVT_primary |
|
118 | + ); |
|
119 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
120 | + if (! $success) { |
|
121 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_venue_rel, $this->_new_table, $cols_n_values, $datatypes)); |
|
122 | + return 0; |
|
123 | + } |
|
124 | + return $wpdb->insert_id; |
|
125 | + } |
|
129 | 126 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $rows = $wpdb->get_results( |
43 | 43 | $wpdb->prepare( |
44 | 44 | "SELECT * FROM $this->_old_table AS ev |
45 | - INNER JOIN " . $wpdb->prefix . "events_detail AS e ON ev.event_id=e.id |
|
45 | + INNER JOIN ".$wpdb->prefix."events_detail AS e ON ev.event_id=e.id |
|
46 | 46 | WHERE e.event_status!='D' LIMIT %d,%d", |
47 | 47 | $start_at_record, |
48 | 48 | $num_items |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | { |
64 | 64 | global $wpdb; |
65 | 65 | $count = $wpdb->get_var( |
66 | - "SELECT COUNT(ev.id) FROM " . $this->_old_table . " AS ev |
|
67 | - INNER JOIN " . $wpdb->prefix . 'events_detail AS e ON ev.event_id=e.id |
|
66 | + "SELECT COUNT(ev.id) FROM ".$this->_old_table." AS ev |
|
67 | + INNER JOIN " . $wpdb->prefix.'events_detail AS e ON ev.event_id=e.id |
|
68 | 68 | WHERE e.event_status!="D"' |
69 | 69 | ); |
70 | 70 | return $count; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | public function __construct() |
73 | 73 | { |
74 | 74 | global $wpdb; |
75 | - $this->_old_table = $wpdb->prefix . "events_venue_rel"; |
|
76 | - $this->_new_table = $wpdb->prefix . "esp_event_venue"; |
|
75 | + $this->_old_table = $wpdb->prefix."events_venue_rel"; |
|
76 | + $this->_new_table = $wpdb->prefix."esp_event_venue"; |
|
77 | 77 | $this->_pretty_name = esc_html__("Event to Venue Relations", "event_espresso"); |
78 | 78 | parent::__construct(); |
79 | 79 | } |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | private function _insert_new_event_to_venue_rel($old_event_venue_rel) |
88 | 88 | { |
89 | 89 | global $wpdb; |
90 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", $old_event_venue_rel['event_id'], $wpdb->prefix . "posts"); |
|
91 | - $new_venue_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_venue", $old_event_venue_rel['venue_id'], $wpdb->prefix . "posts"); |
|
92 | - if (! $new_event_id) { |
|
90 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_event_venue_rel['event_id'], $wpdb->prefix."posts"); |
|
91 | + $new_venue_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_venue", $old_event_venue_rel['venue_id'], $wpdb->prefix."posts"); |
|
92 | + if ( ! $new_event_id) { |
|
93 | 93 | $this->add_error(sprintf(esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_venue_rel['event_id'])); |
94 | 94 | return 0; |
95 | 95 | } |
96 | - if (! $new_venue_id) { |
|
96 | + if ( ! $new_venue_id) { |
|
97 | 97 | $this->add_error(sprintf(esc_html__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $old_event_venue_rel['venue_id'])); |
98 | 98 | return 0; |
99 | 99 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | 'EVT_ID' => $new_event_id, |
106 | 106 | ), |
107 | 107 | array( |
108 | - '%d',// EVT_ID |
|
108 | + '%d', // EVT_ID |
|
109 | 109 | ) |
110 | 110 | ); |
111 | 111 | // echo "last query". $wpdb->last_query;die; |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | 'EVV_primary' => true |
116 | 116 | ); |
117 | 117 | $datatypes = array( |
118 | - '%d',// EVT_ID |
|
119 | - '%d',// VNU_ID |
|
120 | - '%d',// EVT_primary |
|
118 | + '%d', // EVT_ID |
|
119 | + '%d', // VNU_ID |
|
120 | + '%d', // EVT_primary |
|
121 | 121 | ); |
122 | 122 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
123 | - if (! $success) { |
|
123 | + if ( ! $success) { |
|
124 | 124 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_venue_rel, $this->_new_table, $cols_n_values, $datatypes)); |
125 | 125 | return 0; |
126 | 126 | } |
@@ -12,8 +12,6 @@ discard block |
||
12 | 12 | KEY `group_id` (`group_id`), |
13 | 13 | KEY `question_id` (`question_id`) |
14 | 14 | ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8$$ |
15 | - |
|
16 | - |
|
17 | 15 | * 4.1 question group question model's tables and fields: |
18 | 16 | $this->_tables = array( |
19 | 17 | 'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question','QGQ_ID') |
@@ -29,114 +27,114 @@ discard block |
||
29 | 27 | */ |
30 | 28 | class EE_DMS_4_1_0_question_group_question extends EE_Data_Migration_Script_Stage |
31 | 29 | { |
32 | - private $_old_table; |
|
33 | - private $_new_table; |
|
34 | - public function _migration_step($num_items = 50) |
|
35 | - { |
|
30 | + private $_old_table; |
|
31 | + private $_new_table; |
|
32 | + public function _migration_step($num_items = 50) |
|
33 | + { |
|
36 | 34 | |
37 | - global $wpdb; |
|
38 | - $start_at_record = $this->count_records_migrated(); |
|
39 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
40 | - $items_actually_migrated = 0; |
|
41 | - foreach ($rows as $question_group_question) { |
|
42 | - $this->_insert_new_question_group_question($question_group_question); |
|
43 | - $items_actually_migrated++; |
|
44 | - } |
|
45 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
46 | - $this->set_completed(); |
|
47 | - } |
|
48 | - return $items_actually_migrated; |
|
49 | - } |
|
50 | - public function _count_records_to_migrate() |
|
51 | - { |
|
52 | - global $wpdb; |
|
53 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
54 | - return $count; |
|
55 | - } |
|
56 | - public function __construct() |
|
57 | - { |
|
58 | - global $wpdb; |
|
59 | - $this->_old_table = $wpdb->prefix . "events_qst_group_rel"; |
|
60 | - $this->_new_table = $wpdb->prefix . "esp_question_group_question"; |
|
61 | - $this->_pretty_name = esc_html__("Question Group to Question Relations", "event_espresso"); |
|
62 | - parent::__construct(); |
|
63 | - } |
|
35 | + global $wpdb; |
|
36 | + $start_at_record = $this->count_records_migrated(); |
|
37 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
38 | + $items_actually_migrated = 0; |
|
39 | + foreach ($rows as $question_group_question) { |
|
40 | + $this->_insert_new_question_group_question($question_group_question); |
|
41 | + $items_actually_migrated++; |
|
42 | + } |
|
43 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
44 | + $this->set_completed(); |
|
45 | + } |
|
46 | + return $items_actually_migrated; |
|
47 | + } |
|
48 | + public function _count_records_to_migrate() |
|
49 | + { |
|
50 | + global $wpdb; |
|
51 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
52 | + return $count; |
|
53 | + } |
|
54 | + public function __construct() |
|
55 | + { |
|
56 | + global $wpdb; |
|
57 | + $this->_old_table = $wpdb->prefix . "events_qst_group_rel"; |
|
58 | + $this->_new_table = $wpdb->prefix . "esp_question_group_question"; |
|
59 | + $this->_pretty_name = esc_html__("Question Group to Question Relations", "event_espresso"); |
|
60 | + parent::__construct(); |
|
61 | + } |
|
64 | 62 | |
65 | - /** |
|
66 | - * Attempts to insert a new question group inthe new format given an old one |
|
67 | - * @global type $wpdb |
|
68 | - * @param array $old_question_group_question |
|
69 | - * @return int |
|
70 | - */ |
|
71 | - private function _insert_new_question_group_question($old_question_group_question) |
|
72 | - { |
|
73 | - global $wpdb; |
|
74 | - $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_question", $old_question_group_question['question_id'], $wpdb->prefix . "esp_question"); |
|
75 | - $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix . "esp_question_group"); |
|
76 | - if (! $new_question_id) { |
|
77 | - $this->add_error(sprintf(esc_html__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id'])); |
|
78 | - return 0; |
|
79 | - } |
|
80 | - if (! $new_question_group_id) { |
|
81 | - $this->add_error(sprintf(esc_html__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id'])); |
|
82 | - return 0; |
|
83 | - } |
|
84 | - // if it's a system question, it needs to be in the right system group. otherwise no dice! |
|
85 | - if ( |
|
86 | - ($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) ) |
|
87 | - || |
|
88 | - ! $this->_is_system_question_for_question_group($new_question_id) |
|
89 | - ) { |
|
90 | - $cols_n_values = array( |
|
91 | - 'QSG_ID' => $new_question_group_id, |
|
92 | - 'QST_ID' => $new_question_id |
|
93 | - ); |
|
94 | - $datatypes = array( |
|
95 | - '%d',// QSG_ID |
|
96 | - '%d',// QST_ID |
|
97 | - ); |
|
98 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
99 | - if (! $success) { |
|
100 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes)); |
|
101 | - return 0; |
|
102 | - } |
|
103 | - return $wpdb->insert_id; |
|
104 | - } else { |
|
105 | - return false; |
|
106 | - } |
|
107 | - } |
|
63 | + /** |
|
64 | + * Attempts to insert a new question group inthe new format given an old one |
|
65 | + * @global type $wpdb |
|
66 | + * @param array $old_question_group_question |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + private function _insert_new_question_group_question($old_question_group_question) |
|
70 | + { |
|
71 | + global $wpdb; |
|
72 | + $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_question", $old_question_group_question['question_id'], $wpdb->prefix . "esp_question"); |
|
73 | + $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix . "esp_question_group"); |
|
74 | + if (! $new_question_id) { |
|
75 | + $this->add_error(sprintf(esc_html__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id'])); |
|
76 | + return 0; |
|
77 | + } |
|
78 | + if (! $new_question_group_id) { |
|
79 | + $this->add_error(sprintf(esc_html__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id'])); |
|
80 | + return 0; |
|
81 | + } |
|
82 | + // if it's a system question, it needs to be in the right system group. otherwise no dice! |
|
83 | + if ( |
|
84 | + ($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) ) |
|
85 | + || |
|
86 | + ! $this->_is_system_question_for_question_group($new_question_id) |
|
87 | + ) { |
|
88 | + $cols_n_values = array( |
|
89 | + 'QSG_ID' => $new_question_group_id, |
|
90 | + 'QST_ID' => $new_question_id |
|
91 | + ); |
|
92 | + $datatypes = array( |
|
93 | + '%d',// QSG_ID |
|
94 | + '%d',// QST_ID |
|
95 | + ); |
|
96 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
97 | + if (! $success) { |
|
98 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes)); |
|
99 | + return 0; |
|
100 | + } |
|
101 | + return $wpdb->insert_id; |
|
102 | + } else { |
|
103 | + return false; |
|
104 | + } |
|
105 | + } |
|
108 | 106 | |
109 | - /** |
|
110 | - * If this question is a system question, returns the QSG_system number that |
|
111 | - * indicates the question group its permitted in. |
|
112 | - * @global type $wpdb |
|
113 | - * @param type $new_question_id |
|
114 | - * @return int |
|
115 | - */ |
|
116 | - private function _is_system_question_for_question_group($new_question_id) |
|
117 | - { |
|
118 | - global $wpdb; |
|
119 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM " . $wpdb->prefix . "esp_question WHERE QST_ID=%d", $new_question_id)); |
|
120 | - if (in_array($system_id, array('fname','lname','email'))) { |
|
121 | - return 1; |
|
122 | - } elseif ($system_id != '' && $system_id) { |
|
123 | - return 2; |
|
124 | - } else { |
|
125 | - return 0; |
|
126 | - } |
|
127 | - } |
|
107 | + /** |
|
108 | + * If this question is a system question, returns the QSG_system number that |
|
109 | + * indicates the question group its permitted in. |
|
110 | + * @global type $wpdb |
|
111 | + * @param type $new_question_id |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + private function _is_system_question_for_question_group($new_question_id) |
|
115 | + { |
|
116 | + global $wpdb; |
|
117 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM " . $wpdb->prefix . "esp_question WHERE QST_ID=%d", $new_question_id)); |
|
118 | + if (in_array($system_id, array('fname','lname','email'))) { |
|
119 | + return 1; |
|
120 | + } elseif ($system_id != '' && $system_id) { |
|
121 | + return 2; |
|
122 | + } else { |
|
123 | + return 0; |
|
124 | + } |
|
125 | + } |
|
128 | 126 | |
129 | - /** |
|
130 | - * Returns the questino group's QSG_system value (1 meaning personal info, 2 |
|
131 | - * being address info, and 0 being neither) |
|
132 | - * @global type $wpdb |
|
133 | - * @param type $new_question_group_id |
|
134 | - * @return boolean |
|
135 | - */ |
|
136 | - private function _is_system_question_group($new_question_group_id) |
|
137 | - { |
|
138 | - global $wpdb; |
|
139 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM " . $wpdb->prefix . "esp_question_group WHERE QSG_ID=%d", $new_question_group_id)); |
|
140 | - return intval($system_id); |
|
141 | - } |
|
127 | + /** |
|
128 | + * Returns the questino group's QSG_system value (1 meaning personal info, 2 |
|
129 | + * being address info, and 0 being neither) |
|
130 | + * @global type $wpdb |
|
131 | + * @param type $new_question_group_id |
|
132 | + * @return boolean |
|
133 | + */ |
|
134 | + private function _is_system_question_group($new_question_group_id) |
|
135 | + { |
|
136 | + global $wpdb; |
|
137 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM " . $wpdb->prefix . "esp_question_group WHERE QSG_ID=%d", $new_question_group_id)); |
|
138 | + return intval($system_id); |
|
139 | + } |
|
142 | 140 | } |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | public function _count_records_to_migrate() |
51 | 51 | { |
52 | 52 | global $wpdb; |
53 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
53 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
54 | 54 | return $count; |
55 | 55 | } |
56 | 56 | public function __construct() |
57 | 57 | { |
58 | 58 | global $wpdb; |
59 | - $this->_old_table = $wpdb->prefix . "events_qst_group_rel"; |
|
60 | - $this->_new_table = $wpdb->prefix . "esp_question_group_question"; |
|
59 | + $this->_old_table = $wpdb->prefix."events_qst_group_rel"; |
|
60 | + $this->_new_table = $wpdb->prefix."esp_question_group_question"; |
|
61 | 61 | $this->_pretty_name = esc_html__("Question Group to Question Relations", "event_espresso"); |
62 | 62 | parent::__construct(); |
63 | 63 | } |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | private function _insert_new_question_group_question($old_question_group_question) |
72 | 72 | { |
73 | 73 | global $wpdb; |
74 | - $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_question", $old_question_group_question['question_id'], $wpdb->prefix . "esp_question"); |
|
75 | - $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix . "esp_question_group"); |
|
76 | - if (! $new_question_id) { |
|
74 | + $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question"); |
|
75 | + $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group"); |
|
76 | + if ( ! $new_question_id) { |
|
77 | 77 | $this->add_error(sprintf(esc_html__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id'])); |
78 | 78 | return 0; |
79 | 79 | } |
80 | - if (! $new_question_group_id) { |
|
80 | + if ( ! $new_question_group_id) { |
|
81 | 81 | $this->add_error(sprintf(esc_html__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id'])); |
82 | 82 | return 0; |
83 | 83 | } |
84 | 84 | // if it's a system question, it needs to be in the right system group. otherwise no dice! |
85 | 85 | if ( |
86 | - ($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) ) |
|
86 | + ($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id)) |
|
87 | 87 | || |
88 | 88 | ! $this->_is_system_question_for_question_group($new_question_id) |
89 | 89 | ) { |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | 'QST_ID' => $new_question_id |
93 | 93 | ); |
94 | 94 | $datatypes = array( |
95 | - '%d',// QSG_ID |
|
96 | - '%d',// QST_ID |
|
95 | + '%d', // QSG_ID |
|
96 | + '%d', // QST_ID |
|
97 | 97 | ); |
98 | 98 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
99 | - if (! $success) { |
|
99 | + if ( ! $success) { |
|
100 | 100 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes)); |
101 | 101 | return 0; |
102 | 102 | } |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | private function _is_system_question_for_question_group($new_question_id) |
117 | 117 | { |
118 | 118 | global $wpdb; |
119 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM " . $wpdb->prefix . "esp_question WHERE QST_ID=%d", $new_question_id)); |
|
120 | - if (in_array($system_id, array('fname','lname','email'))) { |
|
119 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id)); |
|
120 | + if (in_array($system_id, array('fname', 'lname', 'email'))) { |
|
121 | 121 | return 1; |
122 | 122 | } elseif ($system_id != '' && $system_id) { |
123 | 123 | return 2; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | private function _is_system_question_group($new_question_group_id) |
137 | 137 | { |
138 | 138 | global $wpdb; |
139 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM " . $wpdb->prefix . "esp_question_group WHERE QSG_ID=%d", $new_question_group_id)); |
|
139 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM ".$wpdb->prefix."esp_question_group WHERE QSG_ID=%d", $new_question_group_id)); |
|
140 | 140 | return intval($system_id); |
141 | 141 | } |
142 | 142 | } |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | // convert settings |
25 | 25 | $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone); |
26 | 26 | // just do a part of them on this request |
27 | - $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate; |
|
27 | + $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items); // $this->_gateways_we_know_how_to_migrate; |
|
28 | 28 | foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) { |
29 | 29 | $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
30 | - if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
30 | + if (isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) { |
|
31 | 31 | // determine the old option's name |
32 | 32 | $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug); |
33 | - if (! $old_gateway_settings) { |
|
33 | + if ( ! $old_gateway_settings) { |
|
34 | 34 | // no settings existed for this gateway anyways... weird... |
35 | 35 | $items_actually_migrated++; |
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | // now prepare the settings to make sure they're in the 4.1 format |
39 | 39 | $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug); |
40 | - $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings; |
|
40 | + $new_gateway_config_obj->payment_settings[$new_gateway_slug] = $new_gateway_settings; |
|
41 | 41 | // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
42 | 42 | // I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
43 | 43 | delete_option($old_gateway_wp_option_name); |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | global $wpdb; |
46 | 46 | // yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll |
47 | 47 | // only be saving users 50 milliseconds the one time this runs... |
48 | - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->options . " SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name)); |
|
48 | + $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->options." SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name)); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $items_actually_migrated++; |
52 | 52 | } |
53 | 53 | // if we can keep going, and it hasn' tbeen done yet, convert active gateways |
54 | - if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
54 | + if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
55 | 55 | $this->_convert_active_gateways(); |
56 | 56 | $this->_converted_active_gateways = true; |
57 | 57 | $items_actually_migrated++; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $step_of_setting_active_gateways = 1; |
70 | 70 | $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone); |
71 | 71 | // $button_images_to_update = |
72 | - return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
72 | + return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
73 | 73 | } |
74 | 74 | public function __construct() |
75 | 75 | { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | private function _get_old_gateway_option($new_gateway_slug) |
120 | 120 | { |
121 | 121 | $option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
122 | - $settings = get_option($option_name, null); |
|
122 | + $settings = get_option($option_name, null); |
|
123 | 123 | // if( ! $settings){ |
124 | 124 | // $this->add_error(sprintf(esc_html__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug)); |
125 | 125 | // } |
@@ -134,36 +134,36 @@ discard block |
||
134 | 134 | private function _get_old_gateway_option_name($new_gateway_slug) |
135 | 135 | { |
136 | 136 | $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone)); |
137 | - $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ]; |
|
137 | + $old_gateway_slug = $new_gateway_slugs_to_new[$new_gateway_slug]; |
|
138 | 138 | $normal_option_prefix = 'event_espresso_'; |
139 | 139 | $normal_option_postfix = '_settings'; |
140 | 140 | switch ($new_gateway_slug) { |
141 | 141 | case 'Bank': |
142 | - $option_name = $normal_option_prefix . 'bank_deposit' . $normal_option_postfix; |
|
142 | + $option_name = $normal_option_prefix.'bank_deposit'.$normal_option_postfix; |
|
143 | 143 | break; |
144 | 144 | case 'Aim': |
145 | - $option_name = $normal_option_prefix . 'authnet_aim' . $normal_option_postfix; |
|
145 | + $option_name = $normal_option_prefix.'authnet_aim'.$normal_option_postfix; |
|
146 | 146 | break; |
147 | 147 | case 'Check': |
148 | - $option_name = $normal_option_prefix . 'check_payment' . $normal_option_postfix; |
|
148 | + $option_name = $normal_option_prefix.'check_payment'.$normal_option_postfix; |
|
149 | 149 | break; |
150 | 150 | case 'Ideal': |
151 | - $option_name = $normal_option_prefix . 'ideal_mollie' . $normal_option_postfix; |
|
151 | + $option_name = $normal_option_prefix.'ideal_mollie'.$normal_option_postfix; |
|
152 | 152 | break; |
153 | 153 | case 'Invoice': |
154 | - $option_name = $normal_option_prefix . 'invoice_payment' . $normal_option_postfix; |
|
154 | + $option_name = $normal_option_prefix.'invoice_payment'.$normal_option_postfix; |
|
155 | 155 | break; |
156 | 156 | case 'Purchase_Order': |
157 | - $option_name = $normal_option_prefix . 'purchase_order_payment' . $normal_option_postfix; |
|
157 | + $option_name = $normal_option_prefix.'purchase_order_payment'.$normal_option_postfix; |
|
158 | 158 | break; |
159 | 159 | case 'USAePay_Offsite': |
160 | - $option_name = 'espresso_usaepay_offsite' . $normal_option_postfix; |
|
160 | + $option_name = 'espresso_usaepay_offsite'.$normal_option_postfix; |
|
161 | 161 | break; |
162 | 162 | case 'USAePay_Onsite': |
163 | - $option_name = 'espresso_usaepay_onsite' . $normal_option_postfix; |
|
163 | + $option_name = 'espresso_usaepay_onsite'.$normal_option_postfix; |
|
164 | 164 | break; |
165 | 165 | default: |
166 | - $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix . $old_gateway_slug . $normal_option_postfix); |
|
166 | + $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix.$old_gateway_slug.$normal_option_postfix); |
|
167 | 167 | } |
168 | 168 | return $option_name; |
169 | 169 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | $old_active_gateways = get_option('event_espresso_active_gateways'); |
175 | 175 | $new_active_gateways = EE_Config::instance()->gateway->active_gateways; |
176 | 176 | foreach ($old_active_gateways as $old_gateway_slug => $filepath) { |
177 | - if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
177 | + if ( ! isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) { |
|
178 | 178 | $this->add_error(sprintf(esc_html__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug)); |
179 | 179 | continue; |
180 | 180 | } |
181 | - $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ]; |
|
181 | + $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[$old_gateway_slug]; |
|
182 | 182 | |
183 | 183 | // in the new format we can also upload gateways to the uploads directory and |
184 | - $new_active_gateways[ $new_gateway_slug ] = false; |
|
184 | + $new_active_gateways[$new_gateway_slug] = false; |
|
185 | 185 | } |
186 | 186 | EE_Config::instance()->gateway->active_gateways = $new_active_gateways; |
187 | 187 | } |
@@ -13,68 +13,68 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_DMS_4_1_0_gateways extends EE_Data_Migration_Script_Stage |
15 | 15 | { |
16 | - private $_converted_active_gateways = false; |
|
16 | + private $_converted_active_gateways = false; |
|
17 | 17 | |
18 | - public function _migration_step($num_items = 50) |
|
19 | - { |
|
20 | - // loads existing EE_CONfig from DB, if it exists |
|
21 | - $new_gateway_config_obj = EE_Config::instance()->gateway; |
|
22 | - $items_actually_migrated = 0; |
|
23 | - // convert settings |
|
24 | - $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone); |
|
25 | - // just do a part of them on this request |
|
26 | - $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate; |
|
27 | - foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) { |
|
28 | - $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
29 | - if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
30 | - // determine the old option's name |
|
31 | - $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug); |
|
32 | - if (! $old_gateway_settings) { |
|
33 | - // no settings existed for this gateway anyways... weird... |
|
34 | - $items_actually_migrated++; |
|
35 | - continue; |
|
36 | - } |
|
37 | - // now prepare the settings to make sure they're in the 4.1 format |
|
38 | - $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug); |
|
39 | - $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings; |
|
40 | - // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
|
41 | - // I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
|
42 | - delete_option($old_gateway_wp_option_name); |
|
43 | - } else {// it must be one of the ones we mostly leave alone |
|
44 | - global $wpdb; |
|
45 | - // yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll |
|
46 | - // only be saving users 50 milliseconds the one time this runs... |
|
47 | - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->options . " SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name)); |
|
48 | - } |
|
18 | + public function _migration_step($num_items = 50) |
|
19 | + { |
|
20 | + // loads existing EE_CONfig from DB, if it exists |
|
21 | + $new_gateway_config_obj = EE_Config::instance()->gateway; |
|
22 | + $items_actually_migrated = 0; |
|
23 | + // convert settings |
|
24 | + $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone); |
|
25 | + // just do a part of them on this request |
|
26 | + $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate; |
|
27 | + foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) { |
|
28 | + $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
29 | + if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
30 | + // determine the old option's name |
|
31 | + $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug); |
|
32 | + if (! $old_gateway_settings) { |
|
33 | + // no settings existed for this gateway anyways... weird... |
|
34 | + $items_actually_migrated++; |
|
35 | + continue; |
|
36 | + } |
|
37 | + // now prepare the settings to make sure they're in the 4.1 format |
|
38 | + $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug); |
|
39 | + $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings; |
|
40 | + // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
|
41 | + // I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
|
42 | + delete_option($old_gateway_wp_option_name); |
|
43 | + } else {// it must be one of the ones we mostly leave alone |
|
44 | + global $wpdb; |
|
45 | + // yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll |
|
46 | + // only be saving users 50 milliseconds the one time this runs... |
|
47 | + $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->options . " SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name)); |
|
48 | + } |
|
49 | 49 | |
50 | - $items_actually_migrated++; |
|
51 | - } |
|
52 | - // if we can keep going, and it hasn' tbeen done yet, convert active gateways |
|
53 | - if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
54 | - $this->_convert_active_gateways(); |
|
55 | - $this->_converted_active_gateways = true; |
|
56 | - $items_actually_migrated++; |
|
57 | - } |
|
50 | + $items_actually_migrated++; |
|
51 | + } |
|
52 | + // if we can keep going, and it hasn' tbeen done yet, convert active gateways |
|
53 | + if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
54 | + $this->_convert_active_gateways(); |
|
55 | + $this->_converted_active_gateways = true; |
|
56 | + $items_actually_migrated++; |
|
57 | + } |
|
58 | 58 | |
59 | - EE_Config::instance()->update_espresso_config(false, false); |
|
60 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
61 | - $this->set_completed(); |
|
62 | - } |
|
63 | - return $items_actually_migrated; |
|
64 | - } |
|
65 | - public function _count_records_to_migrate() |
|
66 | - { |
|
67 | - $count_of_gateways_to_convert = count($this->_gateways_we_know_how_to_migrate); |
|
68 | - $step_of_setting_active_gateways = 1; |
|
69 | - $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone); |
|
70 | - // $button_images_to_update = |
|
71 | - return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
72 | - } |
|
73 | - public function __construct() |
|
74 | - { |
|
75 | - $this->_pretty_name = esc_html__("Gateways", "event_espresso"); |
|
76 | - parent::__construct(); |
|
77 | - } |
|
59 | + EE_Config::instance()->update_espresso_config(false, false); |
|
60 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
61 | + $this->set_completed(); |
|
62 | + } |
|
63 | + return $items_actually_migrated; |
|
64 | + } |
|
65 | + public function _count_records_to_migrate() |
|
66 | + { |
|
67 | + $count_of_gateways_to_convert = count($this->_gateways_we_know_how_to_migrate); |
|
68 | + $step_of_setting_active_gateways = 1; |
|
69 | + $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone); |
|
70 | + // $button_images_to_update = |
|
71 | + return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
72 | + } |
|
73 | + public function __construct() |
|
74 | + { |
|
75 | + $this->_pretty_name = esc_html__("Gateways", "event_espresso"); |
|
76 | + parent::__construct(); |
|
77 | + } |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Takes the old array of 3.1 gateway settings for this gateway and converts it |
@@ -84,148 +84,148 @@ discard block |
||
84 | 84 | * @param string $new_gateway_slug |
85 | 85 | * @return array |
86 | 86 | */ |
87 | - private function _convert_gateway_settings($old_gateway_settings, $new_gateway_slug) |
|
88 | - { |
|
89 | - $new_gateway_settings = $old_gateway_settings; |
|
90 | - switch ($new_gateway_slug) { |
|
91 | - case 'Bank': |
|
92 | - $new_gateway_settings['account_number'] = $old_gateway_settings['bank_account']; |
|
93 | - $new_gateway_settings['page_title'] = $old_gateway_settings['bank_title']; |
|
94 | - break; |
|
95 | - case 'Invoice': |
|
96 | - $new_gateway_settings['invoice_logo_url'] = $old_gateway_settings['image_url']; |
|
97 | - // Dont' migrate the old invoice payee address. It was usually given dummy data. And in EE4 |
|
98 | - // it gets used in the receipts which are available to everyone. So usually it's best to not |
|
99 | - // migrate this. |
|
100 | - unset($new_gateway_settings['payment_address']); |
|
101 | - break; |
|
102 | - case 'Paypal_Pro': |
|
103 | - $new_gateway_settings['email'] = $old_gateway_settings['paypal_pro_email']; |
|
104 | - $new_gateway_settings['username'] = $old_gateway_settings['paypal_api_username']; |
|
105 | - $new_gateway_settings['password'] = $old_gateway_settings['paypal_api_password']; |
|
106 | - $new_gateway_settings['signature'] = $old_gateway_settings['paypal_api_signature']; |
|
107 | - $new_gateway_settings['credit_cards'] = explode(",", $old_gateway_settings['paypal_api_credit_cards']); |
|
108 | - $new_gateway_settings['use_sandbox'] = $old_gateway_settings['paypal_pro_use_sandbox']; |
|
109 | - break; |
|
110 | - } |
|
111 | - return $new_gateway_settings; |
|
112 | - } |
|
87 | + private function _convert_gateway_settings($old_gateway_settings, $new_gateway_slug) |
|
88 | + { |
|
89 | + $new_gateway_settings = $old_gateway_settings; |
|
90 | + switch ($new_gateway_slug) { |
|
91 | + case 'Bank': |
|
92 | + $new_gateway_settings['account_number'] = $old_gateway_settings['bank_account']; |
|
93 | + $new_gateway_settings['page_title'] = $old_gateway_settings['bank_title']; |
|
94 | + break; |
|
95 | + case 'Invoice': |
|
96 | + $new_gateway_settings['invoice_logo_url'] = $old_gateway_settings['image_url']; |
|
97 | + // Dont' migrate the old invoice payee address. It was usually given dummy data. And in EE4 |
|
98 | + // it gets used in the receipts which are available to everyone. So usually it's best to not |
|
99 | + // migrate this. |
|
100 | + unset($new_gateway_settings['payment_address']); |
|
101 | + break; |
|
102 | + case 'Paypal_Pro': |
|
103 | + $new_gateway_settings['email'] = $old_gateway_settings['paypal_pro_email']; |
|
104 | + $new_gateway_settings['username'] = $old_gateway_settings['paypal_api_username']; |
|
105 | + $new_gateway_settings['password'] = $old_gateway_settings['paypal_api_password']; |
|
106 | + $new_gateway_settings['signature'] = $old_gateway_settings['paypal_api_signature']; |
|
107 | + $new_gateway_settings['credit_cards'] = explode(",", $old_gateway_settings['paypal_api_credit_cards']); |
|
108 | + $new_gateway_settings['use_sandbox'] = $old_gateway_settings['paypal_pro_use_sandbox']; |
|
109 | + break; |
|
110 | + } |
|
111 | + return $new_gateway_settings; |
|
112 | + } |
|
113 | 113 | /** |
114 | - * Figures out the correct 3.1 gateway settings option name for the given 4.1 gateway |
|
115 | - * @param string $new_gateway_slug |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - private function _get_old_gateway_option($new_gateway_slug) |
|
119 | - { |
|
120 | - $option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
121 | - $settings = get_option($option_name, null); |
|
122 | - // if( ! $settings){ |
|
123 | - // $this->add_error(sprintf(esc_html__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug)); |
|
124 | - // } |
|
125 | - return $settings; |
|
126 | - } |
|
114 | + * Figures out the correct 3.1 gateway settings option name for the given 4.1 gateway |
|
115 | + * @param string $new_gateway_slug |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + private function _get_old_gateway_option($new_gateway_slug) |
|
119 | + { |
|
120 | + $option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
121 | + $settings = get_option($option_name, null); |
|
122 | + // if( ! $settings){ |
|
123 | + // $this->add_error(sprintf(esc_html__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug)); |
|
124 | + // } |
|
125 | + return $settings; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Just gets the old gateways slug |
130 | 130 | * @param string $new_gateway_slug |
131 | 131 | * @return string |
132 | 132 | */ |
133 | - private function _get_old_gateway_option_name($new_gateway_slug) |
|
134 | - { |
|
135 | - $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone)); |
|
136 | - $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ]; |
|
137 | - $normal_option_prefix = 'event_espresso_'; |
|
138 | - $normal_option_postfix = '_settings'; |
|
139 | - switch ($new_gateway_slug) { |
|
140 | - case 'Bank': |
|
141 | - $option_name = $normal_option_prefix . 'bank_deposit' . $normal_option_postfix; |
|
142 | - break; |
|
143 | - case 'Aim': |
|
144 | - $option_name = $normal_option_prefix . 'authnet_aim' . $normal_option_postfix; |
|
145 | - break; |
|
146 | - case 'Check': |
|
147 | - $option_name = $normal_option_prefix . 'check_payment' . $normal_option_postfix; |
|
148 | - break; |
|
149 | - case 'Ideal': |
|
150 | - $option_name = $normal_option_prefix . 'ideal_mollie' . $normal_option_postfix; |
|
151 | - break; |
|
152 | - case 'Invoice': |
|
153 | - $option_name = $normal_option_prefix . 'invoice_payment' . $normal_option_postfix; |
|
154 | - break; |
|
155 | - case 'Purchase_Order': |
|
156 | - $option_name = $normal_option_prefix . 'purchase_order_payment' . $normal_option_postfix; |
|
157 | - break; |
|
158 | - case 'USAePay_Offsite': |
|
159 | - $option_name = 'espresso_usaepay_offsite' . $normal_option_postfix; |
|
160 | - break; |
|
161 | - case 'USAePay_Onsite': |
|
162 | - $option_name = 'espresso_usaepay_onsite' . $normal_option_postfix; |
|
163 | - break; |
|
164 | - default: |
|
165 | - $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix . $old_gateway_slug . $normal_option_postfix); |
|
166 | - } |
|
167 | - return $option_name; |
|
168 | - } |
|
133 | + private function _get_old_gateway_option_name($new_gateway_slug) |
|
134 | + { |
|
135 | + $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone)); |
|
136 | + $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ]; |
|
137 | + $normal_option_prefix = 'event_espresso_'; |
|
138 | + $normal_option_postfix = '_settings'; |
|
139 | + switch ($new_gateway_slug) { |
|
140 | + case 'Bank': |
|
141 | + $option_name = $normal_option_prefix . 'bank_deposit' . $normal_option_postfix; |
|
142 | + break; |
|
143 | + case 'Aim': |
|
144 | + $option_name = $normal_option_prefix . 'authnet_aim' . $normal_option_postfix; |
|
145 | + break; |
|
146 | + case 'Check': |
|
147 | + $option_name = $normal_option_prefix . 'check_payment' . $normal_option_postfix; |
|
148 | + break; |
|
149 | + case 'Ideal': |
|
150 | + $option_name = $normal_option_prefix . 'ideal_mollie' . $normal_option_postfix; |
|
151 | + break; |
|
152 | + case 'Invoice': |
|
153 | + $option_name = $normal_option_prefix . 'invoice_payment' . $normal_option_postfix; |
|
154 | + break; |
|
155 | + case 'Purchase_Order': |
|
156 | + $option_name = $normal_option_prefix . 'purchase_order_payment' . $normal_option_postfix; |
|
157 | + break; |
|
158 | + case 'USAePay_Offsite': |
|
159 | + $option_name = 'espresso_usaepay_offsite' . $normal_option_postfix; |
|
160 | + break; |
|
161 | + case 'USAePay_Onsite': |
|
162 | + $option_name = 'espresso_usaepay_onsite' . $normal_option_postfix; |
|
163 | + break; |
|
164 | + default: |
|
165 | + $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix . $old_gateway_slug . $normal_option_postfix); |
|
166 | + } |
|
167 | + return $option_name; |
|
168 | + } |
|
169 | 169 | |
170 | - private function _convert_active_gateways() |
|
171 | - { |
|
172 | - // just does it all one big swoop |
|
173 | - $old_active_gateways = get_option('event_espresso_active_gateways'); |
|
174 | - $new_active_gateways = EE_Config::instance()->gateway->active_gateways; |
|
175 | - foreach ($old_active_gateways as $old_gateway_slug => $filepath) { |
|
176 | - if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
177 | - $this->add_error(sprintf(esc_html__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug)); |
|
178 | - continue; |
|
179 | - } |
|
180 | - $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ]; |
|
170 | + private function _convert_active_gateways() |
|
171 | + { |
|
172 | + // just does it all one big swoop |
|
173 | + $old_active_gateways = get_option('event_espresso_active_gateways'); |
|
174 | + $new_active_gateways = EE_Config::instance()->gateway->active_gateways; |
|
175 | + foreach ($old_active_gateways as $old_gateway_slug => $filepath) { |
|
176 | + if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
177 | + $this->add_error(sprintf(esc_html__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug)); |
|
178 | + continue; |
|
179 | + } |
|
180 | + $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ]; |
|
181 | 181 | |
182 | - // in the new format we can also upload gateways to the uploads directory and |
|
183 | - $new_active_gateways[ $new_gateway_slug ] = false; |
|
184 | - } |
|
185 | - EE_Config::instance()->gateway->active_gateways = $new_active_gateways; |
|
186 | - } |
|
182 | + // in the new format we can also upload gateways to the uploads directory and |
|
183 | + $new_active_gateways[ $new_gateway_slug ] = false; |
|
184 | + } |
|
185 | + EE_Config::instance()->gateway->active_gateways = $new_active_gateways; |
|
186 | + } |
|
187 | 187 | |
188 | - protected $_gateways_we_know_how_to_migrate = array( |
|
189 | - 'aim' => 'Aim', |
|
190 | - 'bank' => 'Bank', |
|
191 | - 'check' => 'Check', |
|
192 | - 'invoice' => 'Invoice', |
|
193 | - 'paypal' => 'Paypal_Standard', |
|
194 | - 'paypal_pro' => 'Paypal_Pro', |
|
188 | + protected $_gateways_we_know_how_to_migrate = array( |
|
189 | + 'aim' => 'Aim', |
|
190 | + 'bank' => 'Bank', |
|
191 | + 'check' => 'Check', |
|
192 | + 'invoice' => 'Invoice', |
|
193 | + 'paypal' => 'Paypal_Standard', |
|
194 | + 'paypal_pro' => 'Paypal_Pro', |
|
195 | 195 | |
196 | - ); |
|
196 | + ); |
|
197 | 197 | |
198 | - protected $_gateways_we_leave_alone = array( |
|
199 | - '2checkout' => '2checkout', |
|
200 | - 'anz' => 'Anz', |
|
201 | - 'atos' => 'Atos', |
|
202 | - 'authnet' => 'Authnet', |
|
203 | - 'beanstream' => 'Beanstream', |
|
204 | - 'evertec' => 'Evertec', |
|
205 | - 'eway' => 'Eway', |
|
206 | - 'eway_rapid3' => 'Eway_Rapid3', |
|
207 | - 'exact' => 'Exact', |
|
208 | - 'firstdata' => 'Firstdata', |
|
209 | - 'firstdat_e4' => 'Firstdata_E4', |
|
210 | - 'ideal' => 'Ideal', |
|
211 | - 'infusion_payment' => 'InfusionSoft', |
|
212 | - 'luottokunta' => 'Luottokunta', |
|
213 | - 'megasoft' => 'Megasoft', |
|
214 | - 'moneris_hpp' => 'Moneris_HPP', |
|
215 | - 'mwarrior' => 'Mwarrior', |
|
216 | - 'nab' => 'NAB', |
|
217 | - 'paychoice' => 'Paychoice', |
|
218 | - 'paytrace' => 'Paytrace', |
|
219 | - 'psigate' => 'Psigate', |
|
220 | - 'purchase_order' => 'Purchase_Order', |
|
221 | - 'qbms' => 'QBMS', |
|
222 | - 'quickpay' => 'Quickpay', |
|
223 | - 'realauth' => 'Realauth', |
|
224 | - 'securepay_aus' => 'Securepay_Aus', |
|
225 | - 'stripe' => 'Stripe', |
|
226 | - 'usaepay_offsite' => 'USAePay_Offsite', |
|
227 | - 'usaepay_onsite' => 'USAePay_Onsite', |
|
228 | - 'wepay' => 'Wepay', |
|
229 | - 'worldpay' => 'Worldpay' |
|
230 | - ); |
|
198 | + protected $_gateways_we_leave_alone = array( |
|
199 | + '2checkout' => '2checkout', |
|
200 | + 'anz' => 'Anz', |
|
201 | + 'atos' => 'Atos', |
|
202 | + 'authnet' => 'Authnet', |
|
203 | + 'beanstream' => 'Beanstream', |
|
204 | + 'evertec' => 'Evertec', |
|
205 | + 'eway' => 'Eway', |
|
206 | + 'eway_rapid3' => 'Eway_Rapid3', |
|
207 | + 'exact' => 'Exact', |
|
208 | + 'firstdata' => 'Firstdata', |
|
209 | + 'firstdat_e4' => 'Firstdata_E4', |
|
210 | + 'ideal' => 'Ideal', |
|
211 | + 'infusion_payment' => 'InfusionSoft', |
|
212 | + 'luottokunta' => 'Luottokunta', |
|
213 | + 'megasoft' => 'Megasoft', |
|
214 | + 'moneris_hpp' => 'Moneris_HPP', |
|
215 | + 'mwarrior' => 'Mwarrior', |
|
216 | + 'nab' => 'NAB', |
|
217 | + 'paychoice' => 'Paychoice', |
|
218 | + 'paytrace' => 'Paytrace', |
|
219 | + 'psigate' => 'Psigate', |
|
220 | + 'purchase_order' => 'Purchase_Order', |
|
221 | + 'qbms' => 'QBMS', |
|
222 | + 'quickpay' => 'Quickpay', |
|
223 | + 'realauth' => 'Realauth', |
|
224 | + 'securepay_aus' => 'Securepay_Aus', |
|
225 | + 'stripe' => 'Stripe', |
|
226 | + 'usaepay_offsite' => 'USAePay_Offsite', |
|
227 | + 'usaepay_onsite' => 'USAePay_Onsite', |
|
228 | + 'wepay' => 'Wepay', |
|
229 | + 'worldpay' => 'Worldpay' |
|
230 | + ); |
|
231 | 231 | } |
@@ -24,87 +24,85 @@ |
||
24 | 24 | 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', esc_html__('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
25 | 25 | 'term_order'=>new EE_Integer_Field('term_order', esc_html__('Term Order','event_espresso'), false, 0) |
26 | 26 | )); |
27 | - |
|
28 | - |
|
29 | 27 | * |
30 | 28 | */ |
31 | 29 | class EE_DMS_4_1_0_event_category extends EE_Data_Migration_Script_Stage |
32 | 30 | { |
33 | - private $_old_table; |
|
34 | - private $_new_table; |
|
35 | - public function _migration_step($num_items = 50) |
|
36 | - { |
|
37 | - global $wpdb; |
|
38 | - $start_at_record = $this->count_records_migrated(); |
|
39 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
40 | - $items_actually_migrated = 0; |
|
41 | - foreach ($rows as $event_venue_rel) { |
|
42 | - $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel); |
|
43 | - if ($term_relation_id) { |
|
44 | - $this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id); |
|
45 | - } |
|
46 | - $items_actually_migrated++; |
|
47 | - } |
|
48 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
49 | - $this->set_completed(); |
|
50 | - } |
|
51 | - return $items_actually_migrated; |
|
52 | - } |
|
53 | - public function _count_records_to_migrate() |
|
54 | - { |
|
55 | - global $wpdb; |
|
56 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
57 | - return $count; |
|
58 | - } |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - global $wpdb; |
|
62 | - $this->_old_table = $wpdb->prefix . "events_category_rel"; |
|
63 | - $this->_new_table = $wpdb->prefix . "term_relationships"; |
|
64 | - $this->_pretty_name = esc_html__("Event to Category (4.1 Term Relationships)", "event_espresso"); |
|
65 | - parent::__construct(); |
|
66 | - } |
|
31 | + private $_old_table; |
|
32 | + private $_new_table; |
|
33 | + public function _migration_step($num_items = 50) |
|
34 | + { |
|
35 | + global $wpdb; |
|
36 | + $start_at_record = $this->count_records_migrated(); |
|
37 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
38 | + $items_actually_migrated = 0; |
|
39 | + foreach ($rows as $event_venue_rel) { |
|
40 | + $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel); |
|
41 | + if ($term_relation_id) { |
|
42 | + $this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id); |
|
43 | + } |
|
44 | + $items_actually_migrated++; |
|
45 | + } |
|
46 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
47 | + $this->set_completed(); |
|
48 | + } |
|
49 | + return $items_actually_migrated; |
|
50 | + } |
|
51 | + public function _count_records_to_migrate() |
|
52 | + { |
|
53 | + global $wpdb; |
|
54 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
55 | + return $count; |
|
56 | + } |
|
57 | + public function __construct() |
|
58 | + { |
|
59 | + global $wpdb; |
|
60 | + $this->_old_table = $wpdb->prefix . "events_category_rel"; |
|
61 | + $this->_new_table = $wpdb->prefix . "term_relationships"; |
|
62 | + $this->_pretty_name = esc_html__("Event to Category (4.1 Term Relationships)", "event_espresso"); |
|
63 | + parent::__construct(); |
|
64 | + } |
|
67 | 65 | |
68 | - /** |
|
69 | - * Attempts to insert a new question group inthe new format given an old one |
|
70 | - * @global type $wpdb |
|
71 | - * @param array $old_event_cat_relation |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation) |
|
75 | - { |
|
76 | - global $wpdb; |
|
77 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix . "posts"); |
|
78 | - $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix . "term_taxonomy"); |
|
79 | - if (! $new_event_id) { |
|
80 | - $this->add_error(sprintf(esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id'])); |
|
81 | - return 0; |
|
82 | - } |
|
83 | - if (! $new_term_taxonomy_id) { |
|
84 | - $this->add_error(sprintf(esc_html__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id'])); |
|
85 | - return 0; |
|
86 | - } |
|
87 | - $cols_n_values = array( |
|
88 | - 'object_id' => $new_event_id, |
|
89 | - 'term_taxonomy_id' => $new_term_taxonomy_id, |
|
90 | - 'term_order' => 0 |
|
91 | - ); |
|
92 | - $datatypes = array( |
|
93 | - '%d',// object_id |
|
94 | - '%d',// term_taxonomy_id |
|
95 | - '%d',// term_order |
|
96 | - ); |
|
97 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
98 | - if (! $success) { |
|
99 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes)); |
|
100 | - return 0; |
|
101 | - } else { |
|
102 | - // increment the term-taxonomie's count |
|
103 | - $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id)); |
|
104 | - if (! $success) { |
|
105 | - $this->add_error(sprintf(esc_html__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
|
106 | - } |
|
107 | - } |
|
108 | - return $wpdb->insert_id; |
|
109 | - } |
|
66 | + /** |
|
67 | + * Attempts to insert a new question group inthe new format given an old one |
|
68 | + * @global type $wpdb |
|
69 | + * @param array $old_event_cat_relation |
|
70 | + * @return int |
|
71 | + */ |
|
72 | + private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation) |
|
73 | + { |
|
74 | + global $wpdb; |
|
75 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix . "posts"); |
|
76 | + $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix . "term_taxonomy"); |
|
77 | + if (! $new_event_id) { |
|
78 | + $this->add_error(sprintf(esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id'])); |
|
79 | + return 0; |
|
80 | + } |
|
81 | + if (! $new_term_taxonomy_id) { |
|
82 | + $this->add_error(sprintf(esc_html__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id'])); |
|
83 | + return 0; |
|
84 | + } |
|
85 | + $cols_n_values = array( |
|
86 | + 'object_id' => $new_event_id, |
|
87 | + 'term_taxonomy_id' => $new_term_taxonomy_id, |
|
88 | + 'term_order' => 0 |
|
89 | + ); |
|
90 | + $datatypes = array( |
|
91 | + '%d',// object_id |
|
92 | + '%d',// term_taxonomy_id |
|
93 | + '%d',// term_order |
|
94 | + ); |
|
95 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
96 | + if (! $success) { |
|
97 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes)); |
|
98 | + return 0; |
|
99 | + } else { |
|
100 | + // increment the term-taxonomie's count |
|
101 | + $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id)); |
|
102 | + if (! $success) { |
|
103 | + $this->add_error(sprintf(esc_html__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
|
104 | + } |
|
105 | + } |
|
106 | + return $wpdb->insert_id; |
|
107 | + } |
|
110 | 108 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | public function _count_records_to_migrate() |
54 | 54 | { |
55 | 55 | global $wpdb; |
56 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table); |
|
56 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
57 | 57 | return $count; |
58 | 58 | } |
59 | 59 | public function __construct() |
60 | 60 | { |
61 | 61 | global $wpdb; |
62 | - $this->_old_table = $wpdb->prefix . "events_category_rel"; |
|
63 | - $this->_new_table = $wpdb->prefix . "term_relationships"; |
|
62 | + $this->_old_table = $wpdb->prefix."events_category_rel"; |
|
63 | + $this->_new_table = $wpdb->prefix."term_relationships"; |
|
64 | 64 | $this->_pretty_name = esc_html__("Event to Category (4.1 Term Relationships)", "event_espresso"); |
65 | 65 | parent::__construct(); |
66 | 66 | } |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation) |
75 | 75 | { |
76 | 76 | global $wpdb; |
77 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix . "posts"); |
|
78 | - $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix . "term_taxonomy"); |
|
79 | - if (! $new_event_id) { |
|
77 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts"); |
|
78 | + $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy"); |
|
79 | + if ( ! $new_event_id) { |
|
80 | 80 | $this->add_error(sprintf(esc_html__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id'])); |
81 | 81 | return 0; |
82 | 82 | } |
83 | - if (! $new_term_taxonomy_id) { |
|
83 | + if ( ! $new_term_taxonomy_id) { |
|
84 | 84 | $this->add_error(sprintf(esc_html__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id'])); |
85 | 85 | return 0; |
86 | 86 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | 'term_order' => 0 |
91 | 91 | ); |
92 | 92 | $datatypes = array( |
93 | - '%d',// object_id |
|
94 | - '%d',// term_taxonomy_id |
|
95 | - '%d',// term_order |
|
93 | + '%d', // object_id |
|
94 | + '%d', // term_taxonomy_id |
|
95 | + '%d', // term_order |
|
96 | 96 | ); |
97 | 97 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
98 | - if (! $success) { |
|
98 | + if ( ! $success) { |
|
99 | 99 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes)); |
100 | 100 | return 0; |
101 | 101 | } else { |
102 | 102 | // increment the term-taxonomie's count |
103 | 103 | $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id)); |
104 | - if (! $success) { |
|
104 | + if ( ! $success) { |
|
105 | 105 | $this->add_error(sprintf(esc_html__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
106 | 106 | } |
107 | 107 | } |