@@ -24,87 +24,85 @@ |
||
24 | 24 | 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
25 | 25 | 'term_order'=>new EE_Integer_Field('term_order', __('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 = __("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 = __("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(__("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(__("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(__('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(__("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(__("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(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
|
104 | + } |
|
105 | + } |
|
106 | + return $wpdb->insert_id; |
|
107 | + } |
|
110 | 108 | } |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | global $wpdb; |
77 | 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 | 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) { |
|
79 | + if ( ! $new_event_id) { |
|
80 | 80 | $this->add_error(sprintf(__("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(__("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(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
106 | 106 | } |
107 | 107 | } |
@@ -38,168 +38,168 @@ |
||
38 | 38 | */ |
39 | 39 | class EE_DMS_4_1_0_line_items extends EE_Data_Migration_Script_Stage_Table |
40 | 40 | { |
41 | - private $_new_line_table; |
|
42 | - private $_new_transaction_table; |
|
43 | - private $_new_reg_table; |
|
44 | - public function __construct() |
|
45 | - { |
|
46 | - global $wpdb; |
|
47 | - $this->_pretty_name = __("Line Items", "event_espresso"); |
|
48 | - $this->_old_table = $wpdb->prefix."events_attendee"; |
|
49 | - $this->_new_transaction_table = $wpdb->prefix."esp_transaction"; |
|
50 | - $this->_new_line_table = $wpdb->prefix."esp_line_item"; |
|
51 | - $this->_new_reg_table = $wpdb->prefix."esp_registration"; |
|
52 | - parent::__construct(); |
|
53 | - } |
|
41 | + private $_new_line_table; |
|
42 | + private $_new_transaction_table; |
|
43 | + private $_new_reg_table; |
|
44 | + public function __construct() |
|
45 | + { |
|
46 | + global $wpdb; |
|
47 | + $this->_pretty_name = __("Line Items", "event_espresso"); |
|
48 | + $this->_old_table = $wpdb->prefix."events_attendee"; |
|
49 | + $this->_new_transaction_table = $wpdb->prefix."esp_transaction"; |
|
50 | + $this->_new_line_table = $wpdb->prefix."esp_line_item"; |
|
51 | + $this->_new_reg_table = $wpdb->prefix."esp_registration"; |
|
52 | + parent::__construct(); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function _migrate_old_row($old_row) |
|
56 | - { |
|
57 | - // insert line items if its a primary id |
|
58 | - if (intval($old_row['is_primary'])) { |
|
59 | - $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $this->_new_transaction_table); |
|
60 | - if (! $txn_id) { |
|
61 | - $this->add_error(sprintf(__("Could not find the transaction for the 3.1 attendee %d from row %s", "event_espresso"), $old_row['id'], $this->_json_encode($old_row))); |
|
62 | - return; |
|
63 | - } |
|
64 | - $txn = $this->_get_txn($txn_id); |
|
65 | - $new_line_items = $this->_insert_new_line_items($txn, $old_row); |
|
66 | - $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_line_table, $new_line_items); |
|
67 | - } |
|
68 | - } |
|
55 | + protected function _migrate_old_row($old_row) |
|
56 | + { |
|
57 | + // insert line items if its a primary id |
|
58 | + if (intval($old_row['is_primary'])) { |
|
59 | + $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $this->_new_transaction_table); |
|
60 | + if (! $txn_id) { |
|
61 | + $this->add_error(sprintf(__("Could not find the transaction for the 3.1 attendee %d from row %s", "event_espresso"), $old_row['id'], $this->_json_encode($old_row))); |
|
62 | + return; |
|
63 | + } |
|
64 | + $txn = $this->_get_txn($txn_id); |
|
65 | + $new_line_items = $this->_insert_new_line_items($txn, $old_row); |
|
66 | + $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_line_table, $new_line_items); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - private function _get_txn($txn_id) |
|
71 | - { |
|
72 | - global $wpdb; |
|
73 | - $txn = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->_new_transaction_table WHERE TXN_ID=%d", $txn_id), ARRAY_A); |
|
74 | - return $txn; |
|
75 | - } |
|
70 | + private function _get_txn($txn_id) |
|
71 | + { |
|
72 | + global $wpdb; |
|
73 | + $txn = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->_new_transaction_table WHERE TXN_ID=%d", $txn_id), ARRAY_A); |
|
74 | + return $txn; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * In 4.1, we'd normally need more info than just the registrations to make the line items. Ie, we'd need |
|
79 | - * the transaction, and tax prices at the time of registration. (And probably promotions and other price factors). |
|
80 | - * But seeing how these are REGs created from 3.1 attendee data, which have |
|
81 | - * @param array $transaction |
|
82 | - * @return array new line item ids |
|
83 | - */ |
|
84 | - private function _insert_new_line_items($transaction, $old_attendee) |
|
85 | - { |
|
86 | - global $wpdb; |
|
87 | - $regs_on_this_transaction = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_new_reg_table." WHERE TXN_ID=%d", $transaction['TXN_ID']), ARRAY_A); |
|
88 | - $new_line_item_ids = array(); |
|
89 | - // create a totla line item |
|
90 | - $total_line_item_id = $this->_insert_new_line_item(array( |
|
91 | - 'LIN_code'=>'total', |
|
92 | - 'TXN_ID'=>$transaction['TXN_ID'], |
|
93 | - 'LIN_name'=> __("Total", "event_espresso"), |
|
94 | - 'LIN_total'=>$transaction['TXN_total'], |
|
95 | - 'LIN_type'=>'total', |
|
96 | - 'OBJ_ID'=>$transaction['TXN_ID'], |
|
97 | - 'OBJ_type'=>'Transaction' |
|
98 | - ), $old_attendee); |
|
99 | - $new_line_item_ids[] = $total_line_item_id; |
|
100 | - // create a subtotal line item |
|
101 | - $reg_total = 0; |
|
102 | - foreach ($regs_on_this_transaction as $new_reg) { |
|
103 | - $reg_total += floatval($new_reg['REG_final_price']); |
|
104 | - } |
|
105 | - $subtotal_line_item_id = $this->_insert_new_line_item(array( |
|
106 | - 'LIN_code'=>'sub-total', |
|
107 | - 'TXN_ID'=>$transaction['TXN_ID'], |
|
108 | - 'LIN_name'=> __("Subtotal", "event_espresso"), |
|
109 | - 'LIN_total'=>$reg_total, |
|
110 | - 'LIN_parent'=>$total_line_item_id, |
|
111 | - 'LIN_type'=>'sub-total', |
|
112 | - ), $old_attendee); |
|
113 | - $new_line_item_ids[] = $subtotal_line_item_id; |
|
114 | - // group REGs by TKT_ID |
|
115 | - $regs_by_tkt = array(); |
|
116 | - foreach ($regs_on_this_transaction as $new_reg) { |
|
117 | - $regs_by_tkt[ $new_reg['TKT_ID'] ][] = $new_reg; |
|
118 | - } |
|
77 | + /** |
|
78 | + * In 4.1, we'd normally need more info than just the registrations to make the line items. Ie, we'd need |
|
79 | + * the transaction, and tax prices at the time of registration. (And probably promotions and other price factors). |
|
80 | + * But seeing how these are REGs created from 3.1 attendee data, which have |
|
81 | + * @param array $transaction |
|
82 | + * @return array new line item ids |
|
83 | + */ |
|
84 | + private function _insert_new_line_items($transaction, $old_attendee) |
|
85 | + { |
|
86 | + global $wpdb; |
|
87 | + $regs_on_this_transaction = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_new_reg_table." WHERE TXN_ID=%d", $transaction['TXN_ID']), ARRAY_A); |
|
88 | + $new_line_item_ids = array(); |
|
89 | + // create a totla line item |
|
90 | + $total_line_item_id = $this->_insert_new_line_item(array( |
|
91 | + 'LIN_code'=>'total', |
|
92 | + 'TXN_ID'=>$transaction['TXN_ID'], |
|
93 | + 'LIN_name'=> __("Total", "event_espresso"), |
|
94 | + 'LIN_total'=>$transaction['TXN_total'], |
|
95 | + 'LIN_type'=>'total', |
|
96 | + 'OBJ_ID'=>$transaction['TXN_ID'], |
|
97 | + 'OBJ_type'=>'Transaction' |
|
98 | + ), $old_attendee); |
|
99 | + $new_line_item_ids[] = $total_line_item_id; |
|
100 | + // create a subtotal line item |
|
101 | + $reg_total = 0; |
|
102 | + foreach ($regs_on_this_transaction as $new_reg) { |
|
103 | + $reg_total += floatval($new_reg['REG_final_price']); |
|
104 | + } |
|
105 | + $subtotal_line_item_id = $this->_insert_new_line_item(array( |
|
106 | + 'LIN_code'=>'sub-total', |
|
107 | + 'TXN_ID'=>$transaction['TXN_ID'], |
|
108 | + 'LIN_name'=> __("Subtotal", "event_espresso"), |
|
109 | + 'LIN_total'=>$reg_total, |
|
110 | + 'LIN_parent'=>$total_line_item_id, |
|
111 | + 'LIN_type'=>'sub-total', |
|
112 | + ), $old_attendee); |
|
113 | + $new_line_item_ids[] = $subtotal_line_item_id; |
|
114 | + // group REGs by TKT_ID |
|
115 | + $regs_by_tkt = array(); |
|
116 | + foreach ($regs_on_this_transaction as $new_reg) { |
|
117 | + $regs_by_tkt[ $new_reg['TKT_ID'] ][] = $new_reg; |
|
118 | + } |
|
119 | 119 | |
120 | - // create individual line items |
|
120 | + // create individual line items |
|
121 | 121 | |
122 | - foreach ($regs_by_tkt as $ticket_id => $regs) { |
|
123 | - $count = count($regs); |
|
124 | - $line_total = 0; |
|
125 | - foreach ($regs as $new_reg) { |
|
126 | - $line_total += $new_reg['REG_final_price']; |
|
127 | - } |
|
128 | - $a_reg = reset($regs); |
|
129 | - $new_ticket = $this->_get_new_ticket_row($a_reg['TKT_ID']); |
|
130 | - $reg_line_item_id = $this->_insert_new_line_item(array( |
|
131 | - 'LIN_code'=> md5('Ticket' . $ticket_id . time()), |
|
132 | - 'TXN_ID'=>$transaction['TXN_ID'], |
|
133 | - 'LIN_name'=>$new_ticket['TKT_name'], |
|
134 | - 'LIN_unit_price'=>$a_reg['REG_final_price'], |
|
135 | - 'LIN_is_taxable'=>false, |
|
136 | - 'LIN_total'=>$line_total, |
|
137 | - 'LIN_quantity'=>$count, |
|
138 | - 'LIN_parent'=>$subtotal_line_item_id, |
|
139 | - 'OBJ_ID'=>$ticket_id, |
|
140 | - 'OBJ_type'=>'Ticket' |
|
141 | - ), $old_attendee); |
|
142 | - $new_line_item_ids[] = $reg_line_item_id; |
|
143 | - } |
|
122 | + foreach ($regs_by_tkt as $ticket_id => $regs) { |
|
123 | + $count = count($regs); |
|
124 | + $line_total = 0; |
|
125 | + foreach ($regs as $new_reg) { |
|
126 | + $line_total += $new_reg['REG_final_price']; |
|
127 | + } |
|
128 | + $a_reg = reset($regs); |
|
129 | + $new_ticket = $this->_get_new_ticket_row($a_reg['TKT_ID']); |
|
130 | + $reg_line_item_id = $this->_insert_new_line_item(array( |
|
131 | + 'LIN_code'=> md5('Ticket' . $ticket_id . time()), |
|
132 | + 'TXN_ID'=>$transaction['TXN_ID'], |
|
133 | + 'LIN_name'=>$new_ticket['TKT_name'], |
|
134 | + 'LIN_unit_price'=>$a_reg['REG_final_price'], |
|
135 | + 'LIN_is_taxable'=>false, |
|
136 | + 'LIN_total'=>$line_total, |
|
137 | + 'LIN_quantity'=>$count, |
|
138 | + 'LIN_parent'=>$subtotal_line_item_id, |
|
139 | + 'OBJ_ID'=>$ticket_id, |
|
140 | + 'OBJ_type'=>'Ticket' |
|
141 | + ), $old_attendee); |
|
142 | + $new_line_item_ids[] = $reg_line_item_id; |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | 146 | |
147 | - return $new_line_item_ids; |
|
148 | - } |
|
149 | - /** |
|
150 | - * Gets the full ticket by ID |
|
151 | - * @global type $wpdb |
|
152 | - * @param type $new_ticket_id |
|
153 | - * @return array |
|
154 | - */ |
|
155 | - private function _get_new_ticket_row($new_ticket_id) |
|
156 | - { |
|
157 | - global $wpdb; |
|
158 | - $ticket_row = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."esp_ticket WHERE TKT_ID=%d", $new_ticket_id), ARRAY_A); |
|
159 | - return $ticket_row; |
|
160 | - } |
|
147 | + return $new_line_item_ids; |
|
148 | + } |
|
149 | + /** |
|
150 | + * Gets the full ticket by ID |
|
151 | + * @global type $wpdb |
|
152 | + * @param type $new_ticket_id |
|
153 | + * @return array |
|
154 | + */ |
|
155 | + private function _get_new_ticket_row($new_ticket_id) |
|
156 | + { |
|
157 | + global $wpdb; |
|
158 | + $ticket_row = $wpdb->get_row($wpdb->prepare("SELECT * FROM ".$wpdb->prefix."esp_ticket WHERE TKT_ID=%d", $new_ticket_id), ARRAY_A); |
|
159 | + return $ticket_row; |
|
160 | + } |
|
161 | 161 | |
162 | - private function _insert_new_line_item($cols_n_values, $old_attendee) |
|
163 | - { |
|
164 | - global $wpdb; |
|
165 | - $default_cols_n_values = array( |
|
166 | - 'LIN_code'=>'', |
|
167 | - 'TXN_ID'=>0, |
|
168 | - 'LIN_name'=>'', |
|
169 | - 'LIN_desc'=>'', |
|
170 | - 'LIN_unit_price'=>0, |
|
171 | - 'LIN_percent'=>0, |
|
172 | - 'LIN_is_taxable'=>false, |
|
173 | - 'LIN_order'=>0, |
|
174 | - 'LIN_total'=>0, |
|
175 | - 'LIN_quantity'=>null, |
|
176 | - 'LIN_parent'=>0, |
|
177 | - 'LIN_type'=>'line-item', |
|
178 | - 'OBJ_ID'=>null, |
|
179 | - 'OBJ_type'=>null |
|
180 | - ); |
|
181 | - $cols_n_values = array_merge($default_cols_n_values, $cols_n_values); |
|
182 | - $datatypes = array( |
|
183 | - '%s',// LIN_code |
|
184 | - '%d',// TXN_ID |
|
185 | - '%s',// LIN_name |
|
186 | - '%s',// LIN_desc |
|
187 | - '%f',// LIN_unit_price |
|
188 | - '%f',// LIN_percent |
|
189 | - '%d',// LIN_is_taxable |
|
190 | - '%d',// LIN_order |
|
191 | - '%f',// LIN_total |
|
192 | - '%d',// LIN_quantity |
|
193 | - '%d',// LIN_parent |
|
194 | - '%s',// LIN_type |
|
195 | - '%d',// OBJ_ID |
|
196 | - '%s',// OBJ_type |
|
197 | - ); |
|
198 | - $success = $wpdb->insert($this->_new_line_table, $cols_n_values, $datatypes); |
|
199 | - if (! $success) { |
|
200 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_reg_table, $cols_n_values, $datatypes)); |
|
201 | - return 0; |
|
202 | - } |
|
203 | - return $wpdb->insert_id; |
|
204 | - } |
|
162 | + private function _insert_new_line_item($cols_n_values, $old_attendee) |
|
163 | + { |
|
164 | + global $wpdb; |
|
165 | + $default_cols_n_values = array( |
|
166 | + 'LIN_code'=>'', |
|
167 | + 'TXN_ID'=>0, |
|
168 | + 'LIN_name'=>'', |
|
169 | + 'LIN_desc'=>'', |
|
170 | + 'LIN_unit_price'=>0, |
|
171 | + 'LIN_percent'=>0, |
|
172 | + 'LIN_is_taxable'=>false, |
|
173 | + 'LIN_order'=>0, |
|
174 | + 'LIN_total'=>0, |
|
175 | + 'LIN_quantity'=>null, |
|
176 | + 'LIN_parent'=>0, |
|
177 | + 'LIN_type'=>'line-item', |
|
178 | + 'OBJ_ID'=>null, |
|
179 | + 'OBJ_type'=>null |
|
180 | + ); |
|
181 | + $cols_n_values = array_merge($default_cols_n_values, $cols_n_values); |
|
182 | + $datatypes = array( |
|
183 | + '%s',// LIN_code |
|
184 | + '%d',// TXN_ID |
|
185 | + '%s',// LIN_name |
|
186 | + '%s',// LIN_desc |
|
187 | + '%f',// LIN_unit_price |
|
188 | + '%f',// LIN_percent |
|
189 | + '%d',// LIN_is_taxable |
|
190 | + '%d',// LIN_order |
|
191 | + '%f',// LIN_total |
|
192 | + '%d',// LIN_quantity |
|
193 | + '%d',// LIN_parent |
|
194 | + '%s',// LIN_type |
|
195 | + '%d',// OBJ_ID |
|
196 | + '%s',// OBJ_type |
|
197 | + ); |
|
198 | + $success = $wpdb->insert($this->_new_line_table, $cols_n_values, $datatypes); |
|
199 | + if (! $success) { |
|
200 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_reg_table, $cols_n_values, $datatypes)); |
|
201 | + return 0; |
|
202 | + } |
|
203 | + return $wpdb->insert_id; |
|
204 | + } |
|
205 | 205 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | // insert line items if its a primary id |
58 | 58 | if (intval($old_row['is_primary'])) { |
59 | 59 | $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $this->_new_transaction_table); |
60 | - if (! $txn_id) { |
|
60 | + if ( ! $txn_id) { |
|
61 | 61 | $this->add_error(sprintf(__("Could not find the transaction for the 3.1 attendee %d from row %s", "event_espresso"), $old_row['id'], $this->_json_encode($old_row))); |
62 | 62 | return; |
63 | 63 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // group REGs by TKT_ID |
115 | 115 | $regs_by_tkt = array(); |
116 | 116 | foreach ($regs_on_this_transaction as $new_reg) { |
117 | - $regs_by_tkt[ $new_reg['TKT_ID'] ][] = $new_reg; |
|
117 | + $regs_by_tkt[$new_reg['TKT_ID']][] = $new_reg; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // create individual line items |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $a_reg = reset($regs); |
129 | 129 | $new_ticket = $this->_get_new_ticket_row($a_reg['TKT_ID']); |
130 | 130 | $reg_line_item_id = $this->_insert_new_line_item(array( |
131 | - 'LIN_code'=> md5('Ticket' . $ticket_id . time()), |
|
131 | + 'LIN_code'=> md5('Ticket'.$ticket_id.time()), |
|
132 | 132 | 'TXN_ID'=>$transaction['TXN_ID'], |
133 | 133 | 'LIN_name'=>$new_ticket['TKT_name'], |
134 | 134 | 'LIN_unit_price'=>$a_reg['REG_final_price'], |
@@ -180,23 +180,23 @@ discard block |
||
180 | 180 | ); |
181 | 181 | $cols_n_values = array_merge($default_cols_n_values, $cols_n_values); |
182 | 182 | $datatypes = array( |
183 | - '%s',// LIN_code |
|
184 | - '%d',// TXN_ID |
|
185 | - '%s',// LIN_name |
|
186 | - '%s',// LIN_desc |
|
187 | - '%f',// LIN_unit_price |
|
188 | - '%f',// LIN_percent |
|
189 | - '%d',// LIN_is_taxable |
|
190 | - '%d',// LIN_order |
|
191 | - '%f',// LIN_total |
|
192 | - '%d',// LIN_quantity |
|
193 | - '%d',// LIN_parent |
|
194 | - '%s',// LIN_type |
|
195 | - '%d',// OBJ_ID |
|
196 | - '%s',// OBJ_type |
|
183 | + '%s', // LIN_code |
|
184 | + '%d', // TXN_ID |
|
185 | + '%s', // LIN_name |
|
186 | + '%s', // LIN_desc |
|
187 | + '%f', // LIN_unit_price |
|
188 | + '%f', // LIN_percent |
|
189 | + '%d', // LIN_is_taxable |
|
190 | + '%d', // LIN_order |
|
191 | + '%f', // LIN_total |
|
192 | + '%d', // LIN_quantity |
|
193 | + '%d', // LIN_parent |
|
194 | + '%s', // LIN_type |
|
195 | + '%d', // OBJ_ID |
|
196 | + '%s', // OBJ_type |
|
197 | 197 | ); |
198 | 198 | $success = $wpdb->insert($this->_new_line_table, $cols_n_values, $datatypes); |
199 | - if (! $success) { |
|
199 | + if ( ! $success) { |
|
200 | 200 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_reg_table, $cols_n_values, $datatypes)); |
201 | 201 | return 0; |
202 | 202 | } |
@@ -25,92 +25,89 @@ |
||
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($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
43 | - $items_actually_migrated = 0; |
|
44 | - foreach ($rows as $event_venue_rel) { |
|
45 | - $this->_insert_new_event_to_venue_rel($event_venue_rel); |
|
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_venue_rel"; |
|
63 | - $this->_new_table = $wpdb->prefix."esp_event_venue"; |
|
64 | - $this->_pretty_name = __("Event to Venue Relations", "event_espresso"); |
|
65 | - parent::__construct(); |
|
66 | - } |
|
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 | + $this->_insert_new_event_to_venue_rel($event_venue_rel); |
|
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_venue_rel"; |
|
60 | + $this->_new_table = $wpdb->prefix."esp_event_venue"; |
|
61 | + $this->_pretty_name = __("Event to Venue Relations", "event_espresso"); |
|
62 | + parent::__construct(); |
|
63 | + } |
|
67 | 64 | |
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_venue_rel |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - private function _insert_new_event_to_venue_rel($old_event_venue_rel) |
|
75 | - { |
|
76 | - global $wpdb; |
|
77 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_event_venue_rel['event_id'], $wpdb->prefix."posts"); |
|
78 | - $new_venue_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_venue", $old_event_venue_rel['venue_id'], $wpdb->prefix."posts"); |
|
79 | - if (! $new_event_id) { |
|
80 | - $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_venue_rel['event_id'])); |
|
81 | - return 0; |
|
82 | - } |
|
83 | - if (! $new_venue_id) { |
|
84 | - $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $old_event_venue_rel['venue_id'])); |
|
85 | - return 0; |
|
86 | - } |
|
87 | - // first ensure there are no other relation entries for this event |
|
88 | - // because although EE4 supports it, EE3 didn't really |
|
89 | - $wpdb->delete( |
|
90 | - $this->_new_table, |
|
91 | - array( |
|
92 | - 'EVT_ID' => $new_event_id, |
|
93 | - ), |
|
94 | - array( |
|
95 | - '%d',// EVT_ID |
|
96 | - ) |
|
97 | - ); |
|
65 | + /** |
|
66 | + * Attempts to insert a new question group inthe new format given an old one |
|
67 | + * @global type $wpdb |
|
68 | + * @param array $old_event_venue_rel |
|
69 | + * @return int |
|
70 | + */ |
|
71 | + private function _insert_new_event_to_venue_rel($old_event_venue_rel) |
|
72 | + { |
|
73 | + global $wpdb; |
|
74 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_event_venue_rel['event_id'], $wpdb->prefix."posts"); |
|
75 | + $new_venue_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_venue", $old_event_venue_rel['venue_id'], $wpdb->prefix."posts"); |
|
76 | + if (! $new_event_id) { |
|
77 | + $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_venue_rel['event_id'])); |
|
78 | + return 0; |
|
79 | + } |
|
80 | + if (! $new_venue_id) { |
|
81 | + $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $old_event_venue_rel['venue_id'])); |
|
82 | + return 0; |
|
83 | + } |
|
84 | + // first ensure there are no other relation entries for this event |
|
85 | + // because although EE4 supports it, EE3 didn't really |
|
86 | + $wpdb->delete( |
|
87 | + $this->_new_table, |
|
88 | + array( |
|
89 | + 'EVT_ID' => $new_event_id, |
|
90 | + ), |
|
91 | + array( |
|
92 | + '%d',// EVT_ID |
|
93 | + ) |
|
94 | + ); |
|
98 | 95 | // echo "last query". $wpdb->last_query;die; |
99 | - $cols_n_values = array( |
|
100 | - 'EVT_ID'=>$new_event_id, |
|
101 | - 'VNU_ID'=>$new_venue_id, |
|
102 | - 'EVV_primary'=>true |
|
103 | - ); |
|
104 | - $datatypes = array( |
|
105 | - '%d',// EVT_ID |
|
106 | - '%d',// VNU_ID |
|
107 | - '%d',// EVT_primary |
|
108 | - ); |
|
109 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
110 | - if (! $success) { |
|
111 | - $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)); |
|
112 | - return 0; |
|
113 | - } |
|
114 | - return $wpdb->insert_id; |
|
115 | - } |
|
96 | + $cols_n_values = array( |
|
97 | + 'EVT_ID'=>$new_event_id, |
|
98 | + 'VNU_ID'=>$new_venue_id, |
|
99 | + 'EVV_primary'=>true |
|
100 | + ); |
|
101 | + $datatypes = array( |
|
102 | + '%d',// EVT_ID |
|
103 | + '%d',// VNU_ID |
|
104 | + '%d',// EVT_primary |
|
105 | + ); |
|
106 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
107 | + if (! $success) { |
|
108 | + $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)); |
|
109 | + return 0; |
|
110 | + } |
|
111 | + return $wpdb->insert_id; |
|
112 | + } |
|
116 | 113 | } |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | global $wpdb; |
77 | 77 | $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_event_venue_rel['event_id'], $wpdb->prefix."posts"); |
78 | 78 | $new_venue_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_venue", $old_event_venue_rel['venue_id'], $wpdb->prefix."posts"); |
79 | - if (! $new_event_id) { |
|
79 | + if ( ! $new_event_id) { |
|
80 | 80 | $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_venue_rel['event_id'])); |
81 | 81 | return 0; |
82 | 82 | } |
83 | - if (! $new_venue_id) { |
|
83 | + if ( ! $new_venue_id) { |
|
84 | 84 | $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $old_event_venue_rel['venue_id'])); |
85 | 85 | return 0; |
86 | 86 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | 'EVT_ID' => $new_event_id, |
93 | 93 | ), |
94 | 94 | array( |
95 | - '%d',// EVT_ID |
|
95 | + '%d', // EVT_ID |
|
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | // echo "last query". $wpdb->last_query;die; |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | 'EVV_primary'=>true |
103 | 103 | ); |
104 | 104 | $datatypes = array( |
105 | - '%d',// EVT_ID |
|
106 | - '%d',// VNU_ID |
|
107 | - '%d',// EVT_primary |
|
105 | + '%d', // EVT_ID |
|
106 | + '%d', // VNU_ID |
|
107 | + '%d', // EVT_primary |
|
108 | 108 | ); |
109 | 109 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
110 | - if (! $success) { |
|
110 | + if ( ! $success) { |
|
111 | 111 | $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)); |
112 | 112 | return 0; |
113 | 113 | } |
@@ -40,119 +40,119 @@ |
||
40 | 40 | */ |
41 | 41 | class EE_DMS_4_1_0_question_groups extends EE_Data_Migration_Script_Stage |
42 | 42 | { |
43 | - private $_old_table; |
|
44 | - private $_new_table; |
|
45 | - /** |
|
46 | - * Keeps track of whether or not we've already added a system question group, |
|
47 | - * in order to avoid adding more than 1 (basically, in 3.1 this would happen |
|
48 | - * with the Roles & Permissions addon, because each user had their own set of |
|
49 | - * question groups and questions), |
|
50 | - * @var boolean |
|
51 | - */ |
|
52 | - private $_already_got_system_question_group_1 = false; |
|
53 | - public function _migration_step($num_items = 50) |
|
54 | - { |
|
43 | + private $_old_table; |
|
44 | + private $_new_table; |
|
45 | + /** |
|
46 | + * Keeps track of whether or not we've already added a system question group, |
|
47 | + * in order to avoid adding more than 1 (basically, in 3.1 this would happen |
|
48 | + * with the Roles & Permissions addon, because each user had their own set of |
|
49 | + * question groups and questions), |
|
50 | + * @var boolean |
|
51 | + */ |
|
52 | + private $_already_got_system_question_group_1 = false; |
|
53 | + public function _migration_step($num_items = 50) |
|
54 | + { |
|
55 | 55 | |
56 | - global $wpdb; |
|
57 | - $start_at_record = $this->count_records_migrated(); |
|
58 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
59 | - $items_actually_migrated = 0; |
|
60 | - foreach ($rows as $question_group) { |
|
61 | - $new_id = $this->_insert_new_question_group($question_group); |
|
56 | + global $wpdb; |
|
57 | + $start_at_record = $this->count_records_migrated(); |
|
58 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
59 | + $items_actually_migrated = 0; |
|
60 | + foreach ($rows as $question_group) { |
|
61 | + $new_id = $this->_insert_new_question_group($question_group); |
|
62 | 62 | |
63 | - $this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id); |
|
64 | - $items_actually_migrated++; |
|
65 | - } |
|
66 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
67 | - $this->set_completed(); |
|
68 | - } |
|
69 | - return $items_actually_migrated; |
|
70 | - } |
|
71 | - public function _count_records_to_migrate() |
|
72 | - { |
|
73 | - global $wpdb; |
|
74 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
75 | - return $count; |
|
76 | - } |
|
77 | - public function __construct() |
|
78 | - { |
|
79 | - global $wpdb; |
|
80 | - $this->_old_table = $wpdb->prefix."events_qst_group"; |
|
81 | - $this->_new_table = $wpdb->prefix."esp_question_group"; |
|
82 | - $this->_pretty_name = __("Question Groups", "event_espresso"); |
|
83 | - parent::__construct(); |
|
84 | - } |
|
63 | + $this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id); |
|
64 | + $items_actually_migrated++; |
|
65 | + } |
|
66 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
67 | + $this->set_completed(); |
|
68 | + } |
|
69 | + return $items_actually_migrated; |
|
70 | + } |
|
71 | + public function _count_records_to_migrate() |
|
72 | + { |
|
73 | + global $wpdb; |
|
74 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
75 | + return $count; |
|
76 | + } |
|
77 | + public function __construct() |
|
78 | + { |
|
79 | + global $wpdb; |
|
80 | + $this->_old_table = $wpdb->prefix."events_qst_group"; |
|
81 | + $this->_new_table = $wpdb->prefix."esp_question_group"; |
|
82 | + $this->_pretty_name = __("Question Groups", "event_espresso"); |
|
83 | + parent::__construct(); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Attempts to insert a new question group inthe new format given an old one |
|
88 | - * @global type $wpdb |
|
89 | - * @param array $old_question_group |
|
90 | - * @return int |
|
91 | - */ |
|
92 | - private function _insert_new_question_group($old_question_group) |
|
93 | - { |
|
94 | - global $wpdb; |
|
95 | - // try to guess what the QST_system int should be... finding the Personal info system |
|
96 | - // question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but |
|
97 | - // could be easily removed. |
|
98 | - if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) { |
|
99 | - $guess_at_system_number = 1; |
|
100 | - } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) { |
|
101 | - $guess_at_system_number = 2; |
|
102 | - } else { |
|
103 | - $guess_at_system_number = 0; |
|
104 | - } |
|
105 | - // if the question group wasn't made by the normal admin, |
|
106 | - // we'd like to keep track of who made it |
|
107 | - if (intval($old_question_group['wp_user'])!=1) { |
|
108 | - $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user'])); |
|
109 | - $identifier = $old_question_group['group_identifier']."-by-".$username; |
|
110 | - } else { |
|
111 | - $identifier = $old_question_group['group_identifier']; |
|
112 | - } |
|
113 | - $cols_n_values = array( |
|
114 | - 'QSG_name'=>stripslashes($old_question_group['group_name']), |
|
115 | - 'QSG_identifier'=>$identifier, |
|
116 | - 'QSG_desc'=>stripslashes($old_question_group['group_description']), |
|
117 | - 'QSG_order'=>$old_question_group['group_order'], |
|
118 | - 'QSG_show_group_name'=>$old_question_group['show_group_name'], |
|
119 | - 'QSG_show_group_desc'=>$old_question_group['show_group_description'], |
|
120 | - 'QSG_system'=>$guess_at_system_number, |
|
121 | - 'QSG_deleted'=>false |
|
122 | - ); |
|
123 | - $datatypes = array( |
|
124 | - '%s',// QSG_name |
|
125 | - '%s',// QSG_identifier |
|
126 | - '%s',// QSG_desc |
|
127 | - '%d',// QSG_order |
|
128 | - '%d',// QSG_show_group_name |
|
129 | - '%d',// QSG_show_group_desc |
|
130 | - '%d',// QSG_system |
|
131 | - '%d',// QSG_deleted |
|
132 | - ); |
|
133 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
134 | - if (! $success) { |
|
135 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes)); |
|
136 | - return 0; |
|
137 | - } |
|
138 | - return $wpdb->insert_id; |
|
139 | - } |
|
86 | + /** |
|
87 | + * Attempts to insert a new question group inthe new format given an old one |
|
88 | + * @global type $wpdb |
|
89 | + * @param array $old_question_group |
|
90 | + * @return int |
|
91 | + */ |
|
92 | + private function _insert_new_question_group($old_question_group) |
|
93 | + { |
|
94 | + global $wpdb; |
|
95 | + // try to guess what the QST_system int should be... finding the Personal info system |
|
96 | + // question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but |
|
97 | + // could be easily removed. |
|
98 | + if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) { |
|
99 | + $guess_at_system_number = 1; |
|
100 | + } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) { |
|
101 | + $guess_at_system_number = 2; |
|
102 | + } else { |
|
103 | + $guess_at_system_number = 0; |
|
104 | + } |
|
105 | + // if the question group wasn't made by the normal admin, |
|
106 | + // we'd like to keep track of who made it |
|
107 | + if (intval($old_question_group['wp_user'])!=1) { |
|
108 | + $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user'])); |
|
109 | + $identifier = $old_question_group['group_identifier']."-by-".$username; |
|
110 | + } else { |
|
111 | + $identifier = $old_question_group['group_identifier']; |
|
112 | + } |
|
113 | + $cols_n_values = array( |
|
114 | + 'QSG_name'=>stripslashes($old_question_group['group_name']), |
|
115 | + 'QSG_identifier'=>$identifier, |
|
116 | + 'QSG_desc'=>stripslashes($old_question_group['group_description']), |
|
117 | + 'QSG_order'=>$old_question_group['group_order'], |
|
118 | + 'QSG_show_group_name'=>$old_question_group['show_group_name'], |
|
119 | + 'QSG_show_group_desc'=>$old_question_group['show_group_description'], |
|
120 | + 'QSG_system'=>$guess_at_system_number, |
|
121 | + 'QSG_deleted'=>false |
|
122 | + ); |
|
123 | + $datatypes = array( |
|
124 | + '%s',// QSG_name |
|
125 | + '%s',// QSG_identifier |
|
126 | + '%s',// QSG_desc |
|
127 | + '%d',// QSG_order |
|
128 | + '%d',// QSG_show_group_name |
|
129 | + '%d',// QSG_show_group_desc |
|
130 | + '%d',// QSG_system |
|
131 | + '%d',// QSG_deleted |
|
132 | + ); |
|
133 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
134 | + if (! $success) { |
|
135 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes)); |
|
136 | + return 0; |
|
137 | + } |
|
138 | + return $wpdb->insert_id; |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Checks if we've already added a system question 1 to the new question groups table |
|
143 | - * @global type $wpdb |
|
144 | - * @return boolean |
|
145 | - */ |
|
146 | - private function _already_got_system_question_group_1() |
|
147 | - { |
|
148 | - if (! $this->_already_got_system_question_group_1) { |
|
149 | - // check the db |
|
150 | - global $wpdb; |
|
151 | - $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1"); |
|
152 | - if (intval($exists)>0) { |
|
153 | - $this->_already_got_system_question_group_1 = true; |
|
154 | - } |
|
155 | - } |
|
156 | - return $this->_already_got_system_question_group_1; |
|
157 | - } |
|
141 | + /** |
|
142 | + * Checks if we've already added a system question 1 to the new question groups table |
|
143 | + * @global type $wpdb |
|
144 | + * @return boolean |
|
145 | + */ |
|
146 | + private function _already_got_system_question_group_1() |
|
147 | + { |
|
148 | + if (! $this->_already_got_system_question_group_1) { |
|
149 | + // check the db |
|
150 | + global $wpdb; |
|
151 | + $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1"); |
|
152 | + if (intval($exists)>0) { |
|
153 | + $this->_already_got_system_question_group_1 = true; |
|
154 | + } |
|
155 | + } |
|
156 | + return $this->_already_got_system_question_group_1; |
|
157 | + } |
|
158 | 158 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | // could be easily removed. |
98 | 98 | if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) { |
99 | 99 | $guess_at_system_number = 1; |
100 | - } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) { |
|
100 | + } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address') !== false) { |
|
101 | 101 | $guess_at_system_number = 2; |
102 | 102 | } else { |
103 | 103 | $guess_at_system_number = 0; |
104 | 104 | } |
105 | 105 | // if the question group wasn't made by the normal admin, |
106 | 106 | // we'd like to keep track of who made it |
107 | - if (intval($old_question_group['wp_user'])!=1) { |
|
107 | + if (intval($old_question_group['wp_user']) != 1) { |
|
108 | 108 | $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user'])); |
109 | 109 | $identifier = $old_question_group['group_identifier']."-by-".$username; |
110 | 110 | } else { |
@@ -121,17 +121,17 @@ discard block |
||
121 | 121 | 'QSG_deleted'=>false |
122 | 122 | ); |
123 | 123 | $datatypes = array( |
124 | - '%s',// QSG_name |
|
125 | - '%s',// QSG_identifier |
|
126 | - '%s',// QSG_desc |
|
127 | - '%d',// QSG_order |
|
128 | - '%d',// QSG_show_group_name |
|
129 | - '%d',// QSG_show_group_desc |
|
130 | - '%d',// QSG_system |
|
131 | - '%d',// QSG_deleted |
|
124 | + '%s', // QSG_name |
|
125 | + '%s', // QSG_identifier |
|
126 | + '%s', // QSG_desc |
|
127 | + '%d', // QSG_order |
|
128 | + '%d', // QSG_show_group_name |
|
129 | + '%d', // QSG_show_group_desc |
|
130 | + '%d', // QSG_system |
|
131 | + '%d', // QSG_deleted |
|
132 | 132 | ); |
133 | 133 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
134 | - if (! $success) { |
|
134 | + if ( ! $success) { |
|
135 | 135 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes)); |
136 | 136 | return 0; |
137 | 137 | } |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | */ |
146 | 146 | private function _already_got_system_question_group_1() |
147 | 147 | { |
148 | - if (! $this->_already_got_system_question_group_1) { |
|
148 | + if ( ! $this->_already_got_system_question_group_1) { |
|
149 | 149 | // check the db |
150 | 150 | global $wpdb; |
151 | 151 | $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1"); |
152 | - if (intval($exists)>0) { |
|
152 | + if (intval($exists) > 0) { |
|
153 | 153 | $this->_already_got_system_question_group_1 = true; |
154 | 154 | } |
155 | 155 | } |
@@ -2,58 +2,57 @@ |
||
2 | 2 | |
3 | 3 | /** |
4 | 4 | * Goes through all the posts and pages, and converts old shortcodes to new ones |
5 | - |
|
6 | -*/ |
|
5 | + */ |
|
7 | 6 | |
8 | 7 | class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage |
9 | 8 | { |
10 | - public function __construct() |
|
11 | - { |
|
12 | - global $wpdb; |
|
13 | - $this->_pretty_name = __("Shortcodes", "event_espresso"); |
|
14 | - $this->_old_table = $wpdb->posts; |
|
15 | - parent::__construct(); |
|
16 | - } |
|
17 | - protected function _migrate_old_row($old_row) |
|
18 | - { |
|
19 | - $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']); |
|
20 | - global $wpdb; |
|
21 | - $wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID'])); |
|
22 | - } |
|
9 | + public function __construct() |
|
10 | + { |
|
11 | + global $wpdb; |
|
12 | + $this->_pretty_name = __("Shortcodes", "event_espresso"); |
|
13 | + $this->_old_table = $wpdb->posts; |
|
14 | + parent::__construct(); |
|
15 | + } |
|
16 | + protected function _migrate_old_row($old_row) |
|
17 | + { |
|
18 | + $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']); |
|
19 | + global $wpdb; |
|
20 | + $wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID'])); |
|
21 | + } |
|
23 | 22 | |
24 | - /** |
|
25 | - * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...] |
|
26 | - * @param string $old_content |
|
27 | - */ |
|
28 | - private function _change_event_list_shortcode($old_content) |
|
29 | - { |
|
30 | - return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content); |
|
31 | - } |
|
23 | + /** |
|
24 | + * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...] |
|
25 | + * @param string $old_content |
|
26 | + */ |
|
27 | + private function _change_event_list_shortcode($old_content) |
|
28 | + { |
|
29 | + return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content); |
|
30 | + } |
|
32 | 31 | |
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 {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
38 | - $items_actually_migrated = 0; |
|
39 | - foreach ($rows as $old_row) { |
|
40 | - $this->_migrate_old_row($old_row); |
|
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.$this->_sql_to_only_select_non_drafts()); |
|
52 | - return $count; |
|
53 | - } |
|
32 | + public function _migration_step($num_items = 50) |
|
33 | + { |
|
34 | + global $wpdb; |
|
35 | + $start_at_record = $this->count_records_migrated(); |
|
36 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
37 | + $items_actually_migrated = 0; |
|
38 | + foreach ($rows as $old_row) { |
|
39 | + $this->_migrate_old_row($old_row); |
|
40 | + $items_actually_migrated++; |
|
41 | + } |
|
42 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
43 | + $this->set_completed(); |
|
44 | + } |
|
45 | + return $items_actually_migrated; |
|
46 | + } |
|
47 | + public function _count_records_to_migrate() |
|
48 | + { |
|
49 | + global $wpdb; |
|
50 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table.$this->_sql_to_only_select_non_drafts()); |
|
51 | + return $count; |
|
52 | + } |
|
54 | 53 | |
55 | - private function _sql_to_only_select_non_drafts() |
|
56 | - { |
|
57 | - return " WHERE post_type NOT IN ('revision','auto-draft') "; |
|
58 | - } |
|
54 | + private function _sql_to_only_select_non_drafts() |
|
55 | + { |
|
56 | + return " WHERE post_type NOT IN ('revision','auto-draft') "; |
|
57 | + } |
|
59 | 58 | } |
@@ -57,119 +57,119 @@ |
||
57 | 57 | */ |
58 | 58 | class EE_DMS_4_1_0_questions extends EE_Data_Migration_Script_Stage |
59 | 59 | { |
60 | - private $_old_table; |
|
61 | - private $_new_table; |
|
62 | - private $_option_table; |
|
63 | - public function _migration_step($num_items = 50) |
|
64 | - { |
|
65 | - global $wpdb; |
|
66 | - $start_at_record = $this->count_records_migrated(); |
|
67 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
68 | - $items_actually_migrated = 0; |
|
69 | - foreach ($rows as $question_row) { |
|
70 | - $new_id = $this->_insert_new_question($question_row); |
|
71 | - $this->get_migration_script()->set_mapping($this->_old_table, $question_row['id'], $this->_new_table, $new_id); |
|
72 | - $items_actually_migrated++; |
|
73 | - } |
|
74 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
75 | - $this->set_completed(); |
|
76 | - } |
|
77 | - return $items_actually_migrated; |
|
78 | - } |
|
79 | - public function _count_records_to_migrate() |
|
80 | - { |
|
81 | - global $wpdb; |
|
82 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
83 | - return $count; |
|
84 | - } |
|
85 | - public function __construct() |
|
86 | - { |
|
87 | - global $wpdb; |
|
88 | - $this->_pretty_name = __("Questions", "event_espresso"); |
|
89 | - $this->_old_table = $wpdb->prefix."events_question"; |
|
90 | - $this->_new_table = $wpdb->prefix."esp_question"; |
|
91 | - $this->_option_table = $wpdb->prefix."esp_question_option"; |
|
92 | - parent::__construct(); |
|
93 | - } |
|
94 | - private function _insert_new_question($old_question) |
|
95 | - { |
|
96 | - global $wpdb; |
|
97 | - // if this pretends to be a 'system' question, check if we already have a |
|
98 | - // system question for that string. If so, pretend THAT new question |
|
99 | - // is what we just isnerted |
|
100 | - if ($old_question['system_name']) { |
|
101 | - $id_of_new_system_question = intval($wpdb->get_var($wpdb->prepare("SELECT QST_ID FROM {$this->_new_table} WHERE QST_system = %s", $old_question['system_name']))); |
|
102 | - if ($id_of_new_system_question) { |
|
103 | - return $id_of_new_system_question; |
|
104 | - } |
|
105 | - // ok so this must be the first one. Carry on. |
|
106 | - } |
|
60 | + private $_old_table; |
|
61 | + private $_new_table; |
|
62 | + private $_option_table; |
|
63 | + public function _migration_step($num_items = 50) |
|
64 | + { |
|
65 | + global $wpdb; |
|
66 | + $start_at_record = $this->count_records_migrated(); |
|
67 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
68 | + $items_actually_migrated = 0; |
|
69 | + foreach ($rows as $question_row) { |
|
70 | + $new_id = $this->_insert_new_question($question_row); |
|
71 | + $this->get_migration_script()->set_mapping($this->_old_table, $question_row['id'], $this->_new_table, $new_id); |
|
72 | + $items_actually_migrated++; |
|
73 | + } |
|
74 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
75 | + $this->set_completed(); |
|
76 | + } |
|
77 | + return $items_actually_migrated; |
|
78 | + } |
|
79 | + public function _count_records_to_migrate() |
|
80 | + { |
|
81 | + global $wpdb; |
|
82 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
83 | + return $count; |
|
84 | + } |
|
85 | + public function __construct() |
|
86 | + { |
|
87 | + global $wpdb; |
|
88 | + $this->_pretty_name = __("Questions", "event_espresso"); |
|
89 | + $this->_old_table = $wpdb->prefix."events_question"; |
|
90 | + $this->_new_table = $wpdb->prefix."esp_question"; |
|
91 | + $this->_option_table = $wpdb->prefix."esp_question_option"; |
|
92 | + parent::__construct(); |
|
93 | + } |
|
94 | + private function _insert_new_question($old_question) |
|
95 | + { |
|
96 | + global $wpdb; |
|
97 | + // if this pretends to be a 'system' question, check if we already have a |
|
98 | + // system question for that string. If so, pretend THAT new question |
|
99 | + // is what we just isnerted |
|
100 | + if ($old_question['system_name']) { |
|
101 | + $id_of_new_system_question = intval($wpdb->get_var($wpdb->prepare("SELECT QST_ID FROM {$this->_new_table} WHERE QST_system = %s", $old_question['system_name']))); |
|
102 | + if ($id_of_new_system_question) { |
|
103 | + return $id_of_new_system_question; |
|
104 | + } |
|
105 | + // ok so this must be the first one. Carry on. |
|
106 | + } |
|
107 | 107 | |
108 | - $cols_n_values = array( |
|
109 | - 'QST_display_text'=>stripslashes($old_question['question']), |
|
110 | - 'QST_admin_label'=> $old_question['system_name'] ? $old_question['system_name'] : sanitize_title($old_question['question']), |
|
111 | - 'QST_system'=>$old_question['system_name'], |
|
112 | - 'QST_type'=>$old_question['question_type'], |
|
113 | - 'QST_required'=> 'Y' == $old_question['required'], |
|
114 | - 'QST_required_text'=>stripslashes($old_question['required_text']), |
|
115 | - 'QST_order'=>$old_question['sequence'], |
|
116 | - 'QST_admin_only'=> 'Y' == $old_question['admin_only'], |
|
117 | - 'QST_wp_user'=>$old_question['wp_user'], |
|
118 | - 'QST_deleted'=>false |
|
119 | - ); |
|
120 | - $datatypes = array( |
|
121 | - '%s',// QST_display_text |
|
122 | - '%s',// QST-admin_label |
|
123 | - '%s',// QST_system |
|
124 | - '%s',// QST_type |
|
125 | - '%d',// QST_required |
|
126 | - '%s',// QST_required_text |
|
127 | - '%d',// QST_order |
|
128 | - '%d',// QST_admin_only |
|
129 | - '%d',// QST_wp_user |
|
130 | - '%d',// QST_deleted |
|
131 | - ); |
|
132 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
133 | - if (! $success) { |
|
134 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question, $this->_new_table, $cols_n_values, $datatypes)); |
|
135 | - return 0; |
|
136 | - } |
|
137 | - $new_id = $wpdb->insert_id; |
|
138 | - // now take care of posisbly adding question options |
|
139 | - if (in_array($old_question['question_type'], array('DROPDOWN','SINGLE','MULTIPLE'))) { |
|
140 | - $options = explode(",", $old_question['response']); |
|
141 | - foreach ($options as $option) { |
|
142 | - $this->_insert_question_option($option, $new_id); |
|
143 | - } |
|
144 | - } |
|
145 | - return $new_id; |
|
146 | - } |
|
147 | - /** |
|
148 | - * Adds a question option to the db |
|
149 | - * @global type $wpdb |
|
150 | - * @param string $option |
|
151 | - * @param int $question_id |
|
152 | - * @return int |
|
153 | - */ |
|
154 | - private function _insert_question_option($option, $question_id) |
|
155 | - { |
|
156 | - $option = trim($option); |
|
157 | - global $wpdb; |
|
158 | - $cols_n_values = array( |
|
159 | - 'QST_ID'=>$question_id, |
|
160 | - 'QSO_value'=>$option, |
|
161 | - 'QSO_deleted'=>false |
|
162 | - ); |
|
163 | - $datatypes= array( |
|
164 | - '%d',// QST_ID |
|
165 | - '%s',// QSO_value |
|
166 | - '%d',// QSO_deleted |
|
167 | - ); |
|
168 | - $success = $wpdb->insert($this->_option_table, $cols_n_values, $datatypes); |
|
169 | - if (! $success) { |
|
170 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('option'=>$option,'new_question_id'=>$question_id), $this->_option_table, $cols_n_values, $datatypes)); |
|
171 | - return 0; |
|
172 | - } |
|
173 | - return $wpdb->insert_id; |
|
174 | - } |
|
108 | + $cols_n_values = array( |
|
109 | + 'QST_display_text'=>stripslashes($old_question['question']), |
|
110 | + 'QST_admin_label'=> $old_question['system_name'] ? $old_question['system_name'] : sanitize_title($old_question['question']), |
|
111 | + 'QST_system'=>$old_question['system_name'], |
|
112 | + 'QST_type'=>$old_question['question_type'], |
|
113 | + 'QST_required'=> 'Y' == $old_question['required'], |
|
114 | + 'QST_required_text'=>stripslashes($old_question['required_text']), |
|
115 | + 'QST_order'=>$old_question['sequence'], |
|
116 | + 'QST_admin_only'=> 'Y' == $old_question['admin_only'], |
|
117 | + 'QST_wp_user'=>$old_question['wp_user'], |
|
118 | + 'QST_deleted'=>false |
|
119 | + ); |
|
120 | + $datatypes = array( |
|
121 | + '%s',// QST_display_text |
|
122 | + '%s',// QST-admin_label |
|
123 | + '%s',// QST_system |
|
124 | + '%s',// QST_type |
|
125 | + '%d',// QST_required |
|
126 | + '%s',// QST_required_text |
|
127 | + '%d',// QST_order |
|
128 | + '%d',// QST_admin_only |
|
129 | + '%d',// QST_wp_user |
|
130 | + '%d',// QST_deleted |
|
131 | + ); |
|
132 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
133 | + if (! $success) { |
|
134 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question, $this->_new_table, $cols_n_values, $datatypes)); |
|
135 | + return 0; |
|
136 | + } |
|
137 | + $new_id = $wpdb->insert_id; |
|
138 | + // now take care of posisbly adding question options |
|
139 | + if (in_array($old_question['question_type'], array('DROPDOWN','SINGLE','MULTIPLE'))) { |
|
140 | + $options = explode(",", $old_question['response']); |
|
141 | + foreach ($options as $option) { |
|
142 | + $this->_insert_question_option($option, $new_id); |
|
143 | + } |
|
144 | + } |
|
145 | + return $new_id; |
|
146 | + } |
|
147 | + /** |
|
148 | + * Adds a question option to the db |
|
149 | + * @global type $wpdb |
|
150 | + * @param string $option |
|
151 | + * @param int $question_id |
|
152 | + * @return int |
|
153 | + */ |
|
154 | + private function _insert_question_option($option, $question_id) |
|
155 | + { |
|
156 | + $option = trim($option); |
|
157 | + global $wpdb; |
|
158 | + $cols_n_values = array( |
|
159 | + 'QST_ID'=>$question_id, |
|
160 | + 'QSO_value'=>$option, |
|
161 | + 'QSO_deleted'=>false |
|
162 | + ); |
|
163 | + $datatypes= array( |
|
164 | + '%d',// QST_ID |
|
165 | + '%s',// QSO_value |
|
166 | + '%d',// QSO_deleted |
|
167 | + ); |
|
168 | + $success = $wpdb->insert($this->_option_table, $cols_n_values, $datatypes); |
|
169 | + if (! $success) { |
|
170 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('option'=>$option,'new_question_id'=>$question_id), $this->_option_table, $cols_n_values, $datatypes)); |
|
171 | + return 0; |
|
172 | + } |
|
173 | + return $wpdb->insert_id; |
|
174 | + } |
|
175 | 175 | } |
@@ -118,25 +118,25 @@ discard block |
||
118 | 118 | 'QST_deleted'=>false |
119 | 119 | ); |
120 | 120 | $datatypes = array( |
121 | - '%s',// QST_display_text |
|
122 | - '%s',// QST-admin_label |
|
123 | - '%s',// QST_system |
|
124 | - '%s',// QST_type |
|
125 | - '%d',// QST_required |
|
126 | - '%s',// QST_required_text |
|
127 | - '%d',// QST_order |
|
128 | - '%d',// QST_admin_only |
|
129 | - '%d',// QST_wp_user |
|
130 | - '%d',// QST_deleted |
|
121 | + '%s', // QST_display_text |
|
122 | + '%s', // QST-admin_label |
|
123 | + '%s', // QST_system |
|
124 | + '%s', // QST_type |
|
125 | + '%d', // QST_required |
|
126 | + '%s', // QST_required_text |
|
127 | + '%d', // QST_order |
|
128 | + '%d', // QST_admin_only |
|
129 | + '%d', // QST_wp_user |
|
130 | + '%d', // QST_deleted |
|
131 | 131 | ); |
132 | 132 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
133 | - if (! $success) { |
|
133 | + if ( ! $success) { |
|
134 | 134 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question, $this->_new_table, $cols_n_values, $datatypes)); |
135 | 135 | return 0; |
136 | 136 | } |
137 | 137 | $new_id = $wpdb->insert_id; |
138 | 138 | // now take care of posisbly adding question options |
139 | - if (in_array($old_question['question_type'], array('DROPDOWN','SINGLE','MULTIPLE'))) { |
|
139 | + if (in_array($old_question['question_type'], array('DROPDOWN', 'SINGLE', 'MULTIPLE'))) { |
|
140 | 140 | $options = explode(",", $old_question['response']); |
141 | 141 | foreach ($options as $option) { |
142 | 142 | $this->_insert_question_option($option, $new_id); |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | 'QSO_value'=>$option, |
161 | 161 | 'QSO_deleted'=>false |
162 | 162 | ); |
163 | - $datatypes= array( |
|
164 | - '%d',// QST_ID |
|
165 | - '%s',// QSO_value |
|
166 | - '%d',// QSO_deleted |
|
163 | + $datatypes = array( |
|
164 | + '%d', // QST_ID |
|
165 | + '%s', // QSO_value |
|
166 | + '%d', // QSO_deleted |
|
167 | 167 | ); |
168 | 168 | $success = $wpdb->insert($this->_option_table, $cols_n_values, $datatypes); |
169 | - if (! $success) { |
|
170 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('option'=>$option,'new_question_id'=>$question_id), $this->_option_table, $cols_n_values, $datatypes)); |
|
169 | + if ( ! $success) { |
|
170 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('option'=>$option, 'new_question_id'=>$question_id), $this->_option_table, $cols_n_values, $datatypes)); |
|
171 | 171 | return 0; |
172 | 172 | } |
173 | 173 | return $wpdb->insert_id; |
@@ -11,77 +11,77 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_DMS_4_8_0_event_subtotals extends EE_Data_Migration_Script_Stage_Table |
13 | 13 | { |
14 | - public function __construct() |
|
15 | - { |
|
16 | - global $wpdb; |
|
17 | - $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
18 | - $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
19 | - $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
|
20 | - parent::__construct(); |
|
21 | - } |
|
22 | - protected function _migrate_old_row($line_item_row) |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
26 | - $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | - $new_line_item_data = array( |
|
28 | - 'LIN_code' => 'event-' . $event_id, |
|
29 | - 'TXN_ID' => $line_item_row['TXN_ID'], |
|
30 | - 'LIN_name' => __('Event', 'event_espresso'), |
|
31 | - 'LIN_desc' => $line_item_row['LIN_desc'], |
|
32 | - 'LIN_unit_price' => $line_item_row['LIN_unit_price'], |
|
33 | - 'LIN_percent' => $line_item_row['LIN_percent'], |
|
34 | - 'LIN_is_taxable' => $line_item_row['LIN_is_taxable'], |
|
35 | - 'LIN_order' => $line_item_row['LIN_order'], |
|
36 | - 'LIN_total' => $line_item_row['LIN_total'], |
|
37 | - 'LIN_quantity' => $line_item_row['LIN_quantity'], |
|
38 | - 'LIN_parent' => $line_item_row['LIN_ID'], |
|
39 | - 'LIN_type' => 'sub-total', |
|
40 | - 'OBJ_type' => 'Event', |
|
41 | - 'OBJ_ID' => $event_id, |
|
42 | - ); |
|
43 | - $new_line_item_datatypes = array( |
|
44 | - '%s',// LIN_code |
|
45 | - '%d',// TXN_ID |
|
46 | - '%s',// LIN_name |
|
47 | - '%s',// LIN_desc |
|
48 | - '%f',// LIN_unit_price |
|
49 | - '%f',// LIN_percent |
|
50 | - '%d',// LIN_is_taxable |
|
51 | - '%d',// LIN_order |
|
52 | - '%f',// LIN_total |
|
53 | - '%d',// LIN_quantity |
|
54 | - '%d',// LIN_parent |
|
55 | - '%s',// LIN_type |
|
56 | - '%s',// OBJ_type |
|
57 | - '%d',// OBJ_ID |
|
58 | - ); |
|
59 | - // insert the new event subtotal line item, pointing to this line item |
|
60 | - $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
|
61 | - if (! $success) { |
|
62 | - $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
|
63 | - } |
|
64 | - $new_line_item_id = $wpdb->insert_id; |
|
65 | - $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id); |
|
66 | - $query = $wpdb->prepare( |
|
67 | - "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
68 | - $new_line_item_id, |
|
69 | - $line_item_row['LIN_ID'], |
|
70 | - $new_line_item_id |
|
71 | - ); |
|
72 | - $success = $wpdb->query($query); |
|
73 | - if ($success === false) { |
|
74 | - $this->add_error( |
|
75 | - sprintf( |
|
76 | - __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'), |
|
77 | - $new_line_item_id, |
|
78 | - $line_item_row['LIN_ID'], |
|
79 | - $wpdb->last_error, |
|
80 | - $query, |
|
81 | - $success |
|
82 | - ) |
|
83 | - ); |
|
84 | - } |
|
85 | - return 1; |
|
86 | - } |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + global $wpdb; |
|
17 | + $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
18 | + $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
|
19 | + $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
|
20 | + parent::__construct(); |
|
21 | + } |
|
22 | + protected function _migrate_old_row($line_item_row) |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
|
26 | + $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | + $new_line_item_data = array( |
|
28 | + 'LIN_code' => 'event-' . $event_id, |
|
29 | + 'TXN_ID' => $line_item_row['TXN_ID'], |
|
30 | + 'LIN_name' => __('Event', 'event_espresso'), |
|
31 | + 'LIN_desc' => $line_item_row['LIN_desc'], |
|
32 | + 'LIN_unit_price' => $line_item_row['LIN_unit_price'], |
|
33 | + 'LIN_percent' => $line_item_row['LIN_percent'], |
|
34 | + 'LIN_is_taxable' => $line_item_row['LIN_is_taxable'], |
|
35 | + 'LIN_order' => $line_item_row['LIN_order'], |
|
36 | + 'LIN_total' => $line_item_row['LIN_total'], |
|
37 | + 'LIN_quantity' => $line_item_row['LIN_quantity'], |
|
38 | + 'LIN_parent' => $line_item_row['LIN_ID'], |
|
39 | + 'LIN_type' => 'sub-total', |
|
40 | + 'OBJ_type' => 'Event', |
|
41 | + 'OBJ_ID' => $event_id, |
|
42 | + ); |
|
43 | + $new_line_item_datatypes = array( |
|
44 | + '%s',// LIN_code |
|
45 | + '%d',// TXN_ID |
|
46 | + '%s',// LIN_name |
|
47 | + '%s',// LIN_desc |
|
48 | + '%f',// LIN_unit_price |
|
49 | + '%f',// LIN_percent |
|
50 | + '%d',// LIN_is_taxable |
|
51 | + '%d',// LIN_order |
|
52 | + '%f',// LIN_total |
|
53 | + '%d',// LIN_quantity |
|
54 | + '%d',// LIN_parent |
|
55 | + '%s',// LIN_type |
|
56 | + '%s',// OBJ_type |
|
57 | + '%d',// OBJ_ID |
|
58 | + ); |
|
59 | + // insert the new event subtotal line item, pointing to this line item |
|
60 | + $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
|
61 | + if (! $success) { |
|
62 | + $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
|
63 | + } |
|
64 | + $new_line_item_id = $wpdb->insert_id; |
|
65 | + $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id); |
|
66 | + $query = $wpdb->prepare( |
|
67 | + "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100", |
|
68 | + $new_line_item_id, |
|
69 | + $line_item_row['LIN_ID'], |
|
70 | + $new_line_item_id |
|
71 | + ); |
|
72 | + $success = $wpdb->query($query); |
|
73 | + if ($success === false) { |
|
74 | + $this->add_error( |
|
75 | + sprintf( |
|
76 | + __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'), |
|
77 | + $new_line_item_id, |
|
78 | + $line_item_row['LIN_ID'], |
|
79 | + $wpdb->last_error, |
|
80 | + $query, |
|
81 | + $success |
|
82 | + ) |
|
83 | + ); |
|
84 | + } |
|
85 | + return 1; |
|
86 | + } |
|
87 | 87 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct() |
15 | 15 | { |
16 | 16 | global $wpdb; |
17 | - $this->_old_table = $wpdb->prefix . 'esp_line_item'; |
|
17 | + $this->_old_table = $wpdb->prefix.'esp_line_item'; |
|
18 | 18 | $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"'; |
19 | 19 | $this->_pretty_name = __('Event Sub-total line items', 'event_espresso'); |
20 | 20 | parent::__construct(); |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $wpdb; |
25 | 25 | // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID |
26 | - $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
26 | + $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM '.$wpdb->prefix.'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID'])); |
|
27 | 27 | $new_line_item_data = array( |
28 | - 'LIN_code' => 'event-' . $event_id, |
|
28 | + 'LIN_code' => 'event-'.$event_id, |
|
29 | 29 | 'TXN_ID' => $line_item_row['TXN_ID'], |
30 | 30 | 'LIN_name' => __('Event', 'event_espresso'), |
31 | 31 | 'LIN_desc' => $line_item_row['LIN_desc'], |
@@ -41,24 +41,24 @@ discard block |
||
41 | 41 | 'OBJ_ID' => $event_id, |
42 | 42 | ); |
43 | 43 | $new_line_item_datatypes = array( |
44 | - '%s',// LIN_code |
|
45 | - '%d',// TXN_ID |
|
46 | - '%s',// LIN_name |
|
47 | - '%s',// LIN_desc |
|
48 | - '%f',// LIN_unit_price |
|
49 | - '%f',// LIN_percent |
|
50 | - '%d',// LIN_is_taxable |
|
51 | - '%d',// LIN_order |
|
52 | - '%f',// LIN_total |
|
53 | - '%d',// LIN_quantity |
|
54 | - '%d',// LIN_parent |
|
55 | - '%s',// LIN_type |
|
56 | - '%s',// OBJ_type |
|
57 | - '%d',// OBJ_ID |
|
44 | + '%s', // LIN_code |
|
45 | + '%d', // TXN_ID |
|
46 | + '%s', // LIN_name |
|
47 | + '%s', // LIN_desc |
|
48 | + '%f', // LIN_unit_price |
|
49 | + '%f', // LIN_percent |
|
50 | + '%d', // LIN_is_taxable |
|
51 | + '%d', // LIN_order |
|
52 | + '%f', // LIN_total |
|
53 | + '%d', // LIN_quantity |
|
54 | + '%d', // LIN_parent |
|
55 | + '%s', // LIN_type |
|
56 | + '%s', // OBJ_type |
|
57 | + '%d', // OBJ_ID |
|
58 | 58 | ); |
59 | 59 | // insert the new event subtotal line item, pointing to this line item |
60 | 60 | $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes); |
61 | - if (! $success) { |
|
61 | + if ( ! $success) { |
|
62 | 62 | $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes)); |
63 | 63 | } |
64 | 64 | $new_line_item_id = $wpdb->insert_id; |
@@ -13,53 +13,53 @@ |
||
13 | 13 | class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage |
14 | 14 | { |
15 | 15 | |
16 | - protected $_line_item_table_name; |
|
16 | + protected $_line_item_table_name; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * Just initializes the status of the migration |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - global $wpdb; |
|
25 | - $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | - $this->_pretty_name = __('Pre-tax total line items', 'event_espresso'); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
19 | + /** |
|
20 | + * Just initializes the status of the migration |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + global $wpdb; |
|
25 | + $this->_line_item_table_name = $wpdb->prefix."esp_line_item"; |
|
26 | + $this->_pretty_name = __('Pre-tax total line items', 'event_espresso'); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Counts the records to migrate; the public version may cache it |
|
34 | - * @return int |
|
35 | - */ |
|
36 | - protected function _count_records_to_migrate() |
|
37 | - { |
|
38 | - return 1; |
|
39 | - } |
|
32 | + /** |
|
33 | + * Counts the records to migrate; the public version may cache it |
|
34 | + * @return int |
|
35 | + */ |
|
36 | + protected function _count_records_to_migrate() |
|
37 | + { |
|
38 | + return 1; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
45 | - * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
46 | - * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
47 | - * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
48 | - * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
49 | - * @param int $num_items_to_migrate |
|
50 | - * @return int number of items ACTUALLY migrated |
|
51 | - */ |
|
52 | - protected function _migration_step($num_items_to_migrate = 50) |
|
53 | - { |
|
54 | - global $wpdb; |
|
55 | - $rows_updated = $wpdb->update( |
|
56 | - $this->_line_item_table_name, |
|
57 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | - array( 'LIN_code' => 'tickets' ), |
|
59 | - array( '%s' ), |
|
60 | - array( '%s' ) |
|
61 | - ); |
|
62 | - $this->set_completed(); |
|
63 | - return 1; |
|
64 | - } |
|
43 | + /** |
|
44 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
45 | + * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
46 | + * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
47 | + * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
48 | + * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
49 | + * @param int $num_items_to_migrate |
|
50 | + * @return int number of items ACTUALLY migrated |
|
51 | + */ |
|
52 | + protected function _migration_step($num_items_to_migrate = 50) |
|
53 | + { |
|
54 | + global $wpdb; |
|
55 | + $rows_updated = $wpdb->update( |
|
56 | + $this->_line_item_table_name, |
|
57 | + array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | + array( 'LIN_code' => 'tickets' ), |
|
59 | + array( '%s' ), |
|
60 | + array( '%s' ) |
|
61 | + ); |
|
62 | + $this->set_completed(); |
|
63 | + return 1; |
|
64 | + } |
|
65 | 65 | } |
@@ -54,10 +54,10 @@ |
||
54 | 54 | global $wpdb; |
55 | 55 | $rows_updated = $wpdb->update( |
56 | 56 | $this->_line_item_table_name, |
57 | - array( 'LIN_code' => 'pre-tax-subtotal' ), |
|
58 | - array( 'LIN_code' => 'tickets' ), |
|
59 | - array( '%s' ), |
|
60 | - array( '%s' ) |
|
57 | + array('LIN_code' => 'pre-tax-subtotal'), |
|
58 | + array('LIN_code' => 'tickets'), |
|
59 | + array('%s'), |
|
60 | + array('%s') |
|
61 | 61 | ); |
62 | 62 | $this->set_completed(); |
63 | 63 | return 1; |
@@ -8,49 +8,49 @@ |
||
8 | 8 | |
9 | 9 | class EE_DMS_4_2_0_datetime_fields extends EE_Data_Migration_Script_Stage_Table |
10 | 10 | { |
11 | - public function __construct() |
|
12 | - { |
|
13 | - global $wpdb; |
|
14 | - $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
|
15 | - $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
16 | - parent::__construct(); |
|
17 | - } |
|
11 | + public function __construct() |
|
12 | + { |
|
13 | + global $wpdb; |
|
14 | + $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
|
15 | + $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
16 | + parent::__construct(); |
|
17 | + } |
|
18 | 18 | |
19 | - protected function _migrate_old_row($old_row) |
|
20 | - { |
|
21 | - // foreach question_group_question entry with this QST_ID, we want to set its |
|
22 | - // QSG_order equal to this question's QST_order |
|
23 | - global $wpdb; |
|
19 | + protected function _migrate_old_row($old_row) |
|
20 | + { |
|
21 | + // foreach question_group_question entry with this QST_ID, we want to set its |
|
22 | + // QSG_order equal to this question's QST_order |
|
23 | + global $wpdb; |
|
24 | 24 | |
25 | - $updated = $wpdb->update( |
|
26 | - $this->_old_table, |
|
27 | - array( |
|
28 | - 'DTT_name' => '', |
|
29 | - 'DTT_description' => '', |
|
30 | - ), |
|
31 | - array( |
|
32 | - 'DTT_ID' => $old_row['DTT_ID'], |
|
33 | - ), |
|
34 | - array( |
|
35 | - '%s',// DTT_name, |
|
36 | - '%s',// DTT_description |
|
37 | - ), |
|
38 | - array( |
|
39 | - '%d',// DTT_ID |
|
40 | - ) |
|
41 | - ); |
|
42 | - if (false === $updated) { |
|
43 | - $this->add_error( |
|
44 | - sprintf( |
|
45 | - __( |
|
46 | - "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d", |
|
47 | - 'event_espresso' |
|
48 | - ), |
|
49 | - $this->_old_table, |
|
50 | - $old_row['QST_ID'] |
|
51 | - ) |
|
52 | - ); |
|
53 | - } |
|
54 | - // nothing to map really |
|
55 | - } |
|
25 | + $updated = $wpdb->update( |
|
26 | + $this->_old_table, |
|
27 | + array( |
|
28 | + 'DTT_name' => '', |
|
29 | + 'DTT_description' => '', |
|
30 | + ), |
|
31 | + array( |
|
32 | + 'DTT_ID' => $old_row['DTT_ID'], |
|
33 | + ), |
|
34 | + array( |
|
35 | + '%s',// DTT_name, |
|
36 | + '%s',// DTT_description |
|
37 | + ), |
|
38 | + array( |
|
39 | + '%d',// DTT_ID |
|
40 | + ) |
|
41 | + ); |
|
42 | + if (false === $updated) { |
|
43 | + $this->add_error( |
|
44 | + sprintf( |
|
45 | + __( |
|
46 | + "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d", |
|
47 | + 'event_espresso' |
|
48 | + ), |
|
49 | + $this->_old_table, |
|
50 | + $old_row['QST_ID'] |
|
51 | + ) |
|
52 | + ); |
|
53 | + } |
|
54 | + // nothing to map really |
|
55 | + } |
|
56 | 56 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | { |
13 | 13 | global $wpdb; |
14 | 14 | $this->_pretty_name = __("Datetime Fields", "event_espresso"); |
15 | - $this->_old_table = $wpdb->prefix . "esp_datetime"; |
|
15 | + $this->_old_table = $wpdb->prefix."esp_datetime"; |
|
16 | 16 | parent::__construct(); |
17 | 17 | } |
18 | 18 | |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | 'DTT_ID' => $old_row['DTT_ID'], |
33 | 33 | ), |
34 | 34 | array( |
35 | - '%s',// DTT_name, |
|
36 | - '%s',// DTT_description |
|
35 | + '%s', // DTT_name, |
|
36 | + '%s', // DTT_description |
|
37 | 37 | ), |
38 | 38 | array( |
39 | - '%d',// DTT_ID |
|
39 | + '%d', // DTT_ID |
|
40 | 40 | ) |
41 | 41 | ); |
42 | 42 | if (false === $updated) { |