@@ -108,448 +108,448 @@ |
||
108 | 108 | class EE_DMS_4_1_0_prices extends EE_Data_Migration_Script_Stage_Table |
109 | 109 | { |
110 | 110 | |
111 | - const price_type_base = 1; |
|
111 | + const price_type_base = 1; |
|
112 | 112 | |
113 | - const price_type_member_discount = 3; |
|
113 | + const price_type_member_discount = 3; |
|
114 | 114 | |
115 | - const price_type_percent_surcharge = 4; |
|
115 | + const price_type_percent_surcharge = 4; |
|
116 | 116 | |
117 | - const price_type_flat_surcharge = 5; |
|
117 | + const price_type_flat_surcharge = 5; |
|
118 | 118 | |
119 | - private string $_new_price_table; |
|
119 | + private string $_new_price_table; |
|
120 | 120 | |
121 | - private string $_new_ticket_table; |
|
121 | + private string $_new_ticket_table; |
|
122 | 122 | |
123 | - private string $_new_ticket_price_table; |
|
123 | + private string $_new_ticket_price_table; |
|
124 | 124 | |
125 | - private string $_new_datetime_ticket_table; |
|
125 | + private string $_new_datetime_ticket_table; |
|
126 | 126 | |
127 | - /** |
|
128 | - * A count of all the different tickets created, used for setting the new ones' TKT_Order |
|
129 | - * |
|
130 | - * @var int |
|
131 | - */ |
|
132 | - private int $_ticket_count = 0; |
|
127 | + /** |
|
128 | + * A count of all the different tickets created, used for setting the new ones' TKT_Order |
|
129 | + * |
|
130 | + * @var int |
|
131 | + */ |
|
132 | + private int $_ticket_count = 0; |
|
133 | 133 | |
134 | - private array $price_data_types = [ |
|
135 | - '%d',// PRT_ID |
|
136 | - '%f',// PRT_amount |
|
137 | - '%s',// PRC_name |
|
138 | - '%d',// PRC_is_default |
|
139 | - '%d',// PRC_overrides |
|
140 | - '%d',// PRC_order |
|
141 | - '%d',// PRC_deleted |
|
142 | - '%d',// PRC_parent |
|
143 | - ]; |
|
134 | + private array $price_data_types = [ |
|
135 | + '%d',// PRT_ID |
|
136 | + '%f',// PRT_amount |
|
137 | + '%s',// PRC_name |
|
138 | + '%d',// PRC_is_default |
|
139 | + '%d',// PRC_overrides |
|
140 | + '%d',// PRC_order |
|
141 | + '%d',// PRC_deleted |
|
142 | + '%d',// PRC_parent |
|
143 | + ]; |
|
144 | 144 | |
145 | 145 | |
146 | - public function __construct() |
|
147 | - { |
|
148 | - global $wpdb; |
|
149 | - $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
|
150 | - $this->_old_table = $wpdb->prefix . "events_prices"; |
|
151 | - $this->select_expression = 'p.*, e.event_status'; |
|
152 | - $this->_extra_where_sql = ' AS p |
|
146 | + public function __construct() |
|
147 | + { |
|
148 | + global $wpdb; |
|
149 | + $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
|
150 | + $this->_old_table = $wpdb->prefix . "events_prices"; |
|
151 | + $this->select_expression = 'p.*, e.event_status'; |
|
152 | + $this->_extra_where_sql = ' AS p |
|
153 | 153 | INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON p.event_id=e.id |
154 | 154 | WHERE e.event_status!="D"'; |
155 | - $this->_new_price_table = $wpdb->prefix . "esp_price"; |
|
156 | - $this->_new_ticket_table = $wpdb->prefix . "esp_ticket"; |
|
157 | - $this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
158 | - $this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket"; |
|
159 | - parent::__construct(); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @throws EE_Error |
|
165 | - */ |
|
166 | - protected function _migrate_old_row($old_row) |
|
167 | - { |
|
168 | - // create the base price |
|
169 | - $new_price_id = $this->_insert_new_price($old_row); |
|
170 | - // create the member discount if there is any |
|
171 | - // commented-out because we may actually NOT be supporting this in 4.1 |
|
172 | - // if($old_row['event_cost'] != $old_row['member_price']){ |
|
173 | - // $member_price_discount_id = $this->_insert_new_member_price($old_row); |
|
174 | - // }else{ |
|
175 | - // $member_price_discount_id = 0; |
|
176 | - // } |
|
177 | - // create the surcharge if there is any |
|
178 | - if (floatval($old_row['surcharge']) >= 0.01) { |
|
179 | - $surcharge_price_id = $this->_insert_new_surcharge_price($old_row); |
|
180 | - $this->get_migration_script()->set_mapping( |
|
181 | - $this->_old_table, $old_row['id'], $this->_new_price_table, [$new_price_id, $surcharge_price_id] |
|
182 | - ); |
|
183 | - } else { |
|
184 | - $surcharge_price_id = 0; |
|
185 | - $this->get_migration_script()->set_mapping( |
|
186 | - $this->_old_table, $old_row['id'], $this->_new_price_table, [$new_price_id] |
|
187 | - ); |
|
188 | - } |
|
189 | - // associate the ticket to all datetimes for event (ie, this ONE ticket grants access to ALL datetimes, not just one of the attendee's choice. |
|
190 | - // if the latter were the case, then we'd create a separate ticket for each datetime and have their |
|
191 | - // association be one-to-one) |
|
192 | - // create ticket |
|
193 | - // $ticket_id = $this->_insert_new_ticket($old_row); |
|
194 | - // if($ticket_id){ |
|
195 | - // $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_ticket_table, $ticket_id); |
|
196 | - // //associate to the prices |
|
197 | - // $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
198 | - // $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
199 | - // //associate to datetimes for the event |
|
200 | - // foreach($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id){ |
|
201 | - // $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
202 | - // } |
|
203 | - // } |
|
204 | - // create a ticket for each old price -old datetime combo |
|
205 | - $tickets_for_old_price = []; |
|
206 | - foreach ($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id) { |
|
207 | - $ticket_id = $this->_insert_new_ticket($old_row); |
|
208 | - $tickets_for_old_price[] = $ticket_id; |
|
209 | - // associate to old prices |
|
210 | - $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
211 | - $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
212 | - $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
213 | - } |
|
214 | - $this->get_migration_script()->set_mapping( |
|
215 | - $this->_old_table, |
|
216 | - $old_row['id'], |
|
217 | - $this->_new_ticket_table, |
|
218 | - $tickets_for_old_price |
|
219 | - ); |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * Creates a 4.1 price base type |
|
225 | - * |
|
226 | - * @param array $old_price |
|
227 | - * @return int |
|
228 | - * @global wpdb $wpdb |
|
229 | - */ |
|
230 | - private function _insert_new_price(array $old_price): int |
|
231 | - { |
|
232 | - global $wpdb; |
|
233 | - $cols_n_values = [ |
|
234 | - 'PRT_ID' => self::price_type_base, |
|
235 | - 'PRC_amount' => floatval($old_price['event_cost']), |
|
236 | - 'PRC_name' => $old_price['price_type'], |
|
237 | - 'PRC_is_default' => false, |
|
238 | - 'PRC_overrides' => false, |
|
239 | - 'PRC_order' => 0, |
|
240 | - 'PRC_deleted' => false, |
|
241 | - 'PRC_parent' => null, |
|
242 | - |
|
243 | - ]; |
|
244 | - $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
245 | - if (! $success) { |
|
246 | - $this->add_error( |
|
247 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
248 | - $this->_old_table, |
|
249 | - $old_price, |
|
250 | - $this->_new_price_table, |
|
251 | - $cols_n_values, |
|
252 | - $this->price_data_types |
|
253 | - ) |
|
254 | - ); |
|
255 | - return 0; |
|
256 | - } |
|
257 | - return $wpdb->insert_id; |
|
258 | - } |
|
259 | - /** |
|
260 | - * Creates a 4.1 member price discount |
|
261 | - * |
|
262 | - * @param array $old_price |
|
263 | - * @return int |
|
264 | - * @global wpdb $wpdb |
|
265 | - */ |
|
266 | - // private function _insert_new_member_price($old_price){ |
|
267 | - // $discount_amount = floatval($old_price['event_cost']) - floatval($old_price['member_price']); |
|
268 | - // global $wpdb; |
|
269 | - // $cols_n_values = array( |
|
270 | - // 'PRT_ID'=>self::price_type_member_discount, |
|
271 | - // 'PRC_amount'=>$discount_amount, |
|
272 | - // 'PRC_name'=>$old_price['member_price_type'], |
|
273 | - // 'PRC_is_default'=>false, |
|
274 | - // 'PRC_overrides'=>false, |
|
275 | - // 'PRC_order'=>10, |
|
276 | - // 'PRC_deleted'=>false, |
|
277 | - // 'PRC_parent'=>null |
|
278 | - // |
|
279 | - // ); |
|
280 | - // $data_types = array( |
|
281 | - // '%d',//PRT_ID |
|
282 | - // '%f',//PRT_amount |
|
283 | - // '%s',//PRC_name |
|
284 | - // '%d',//PRC_is_default |
|
285 | - // '%d',//PRC_overrides |
|
286 | - // '%d',//PRC_order |
|
287 | - // '%d',//PRC_deleted |
|
288 | - // '%d',//PRC_parent |
|
289 | - // ); |
|
290 | - // $success = $wpdb->insert($this->_new_price_table,$cols_n_values,$data_types); |
|
291 | - // if ( ! $success){ |
|
292 | - // $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $data_types)); |
|
293 | - // return 0; |
|
294 | - // } |
|
295 | - // $new_id = $wpdb->insert_id; |
|
296 | - // return $new_id; |
|
297 | - // } |
|
298 | - /** |
|
299 | - * Creates a 4.1 member price discount |
|
300 | - * |
|
301 | - * @param array $old_price |
|
302 | - * @return int |
|
303 | - * @global wpdb $wpdb |
|
304 | - */ |
|
305 | - private function _insert_new_surcharge_price(array $old_price): int |
|
306 | - { |
|
307 | - if ($old_price['surcharge_type'] == 'flat_rate') { |
|
308 | - $price_type = self::price_type_flat_surcharge; |
|
309 | - } else { |
|
310 | - $price_type = self::price_type_percent_surcharge; |
|
311 | - } |
|
312 | - global $wpdb; |
|
313 | - $cols_n_values = [ |
|
314 | - 'PRT_ID' => $price_type, |
|
315 | - 'PRC_amount' => floatval($old_price['surcharge']), |
|
316 | - 'PRC_name' => esc_html__("Surcharge", "event_espresso"), |
|
317 | - 'PRC_is_default' => false, |
|
318 | - 'PRC_overrides' => false, |
|
319 | - 'PRC_order' => 20, |
|
320 | - 'PRC_deleted' => false, |
|
321 | - 'PRC_parent' => null, |
|
322 | - |
|
323 | - ]; |
|
324 | - $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
325 | - if (! $success) { |
|
326 | - $this->add_error( |
|
327 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
328 | - $this->_old_table, |
|
329 | - $old_price, |
|
330 | - $this->_new_price_table, |
|
331 | - $cols_n_values, |
|
332 | - $this->price_data_types |
|
333 | - ) |
|
334 | - ); |
|
335 | - return 0; |
|
336 | - } |
|
337 | - return $wpdb->insert_id; |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * Inserts a 4.1 ticket based off the 3.1 price, and the price IDs we've already made from the 3.1 price |
|
343 | - * |
|
344 | - * @param array $old_price_row array where keys are columns |
|
345 | - * @return int new ticket id |
|
346 | - */ |
|
347 | - private function _insert_new_ticket(array $old_price_row): int |
|
348 | - { |
|
349 | - global $wpdb; |
|
350 | - $event_row = $this->_get_event_row($old_price_row['event_id']); |
|
351 | - if ($old_price_row['surcharge_type'] == 'flat_rate') { |
|
352 | - $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']); |
|
353 | - } else {// percent surcharge |
|
354 | - $final_ticket_price = |
|
355 | - floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge']) / 100); |
|
356 | - } |
|
357 | - $start_date = |
|
358 | - $event_row['registration_start'] . |
|
359 | - " " . |
|
360 | - $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']); |
|
361 | - $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
362 | - $this, |
|
363 | - $old_price_row, |
|
364 | - $start_date, |
|
365 | - $event_row['timezone_string'] |
|
366 | - ); |
|
367 | - $end_date = |
|
368 | - $event_row['registration_end'] . |
|
369 | - " " . |
|
370 | - $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']); |
|
371 | - $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
372 | - $this, |
|
373 | - $old_price_row, |
|
374 | - $end_date, |
|
375 | - $event_row['timezone_string'] |
|
376 | - ); |
|
377 | - $cols_n_values = [ |
|
378 | - 'TTM_ID' => 0, |
|
379 | - 'TKT_name' => $old_price_row['price_type'], |
|
380 | - 'TKT_description' => '', |
|
381 | - 'TKT_start_date' => $start_date_utc, |
|
382 | - 'TKT_end_date' => $end_date_utc, |
|
383 | - 'TKT_min' => 0, |
|
384 | - 'TKT_max' => -1, |
|
385 | - 'TKT_price' => $final_ticket_price, |
|
386 | - 'TKT_sold' => 0, |
|
387 | - // note: this will get calculated as we actually add registrations during the migration |
|
388 | - 'TKT_qty' => -1, |
|
389 | - 'TKT_uses' => 1, |
|
390 | - 'TKT_taxable' => false, |
|
391 | - // so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices |
|
392 | - 'TKT_is_default' => false, |
|
393 | - 'TKT_order' => $this->_get_ticket_count(), |
|
394 | - 'TKT_row' => 0, |
|
395 | - // doesn't matter because UI reset this on first save anyways |
|
396 | - 'TKT_deleted' => false, |
|
397 | - 'TKT_parent' => 0, |
|
398 | - |
|
399 | - ]; |
|
400 | - $data_types = [ |
|
401 | - '%d',// TTM_ID |
|
402 | - '%s',// TKT_name |
|
403 | - '%s',// TKT_description |
|
404 | - '%s',// TKT_start_date |
|
405 | - '%s',// TKT_end_date |
|
406 | - '%d',// TKT_min |
|
407 | - '%d',// TKT_max |
|
408 | - '%f',// TKT_price |
|
409 | - '%d',// TKT_sold |
|
410 | - '%d',// TKT_qty |
|
411 | - '%d',// TKT_uses |
|
412 | - '%d',// TKT_taxable |
|
413 | - '%d',// TKT_is_default |
|
414 | - '%d',// TKT_order |
|
415 | - '%d',// TKT_row |
|
416 | - '%d',// TKT_deleted |
|
417 | - '%d',// TKT_parent |
|
418 | - ]; |
|
419 | - $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $data_types); |
|
420 | - if (! $success) { |
|
421 | - $this->add_error( |
|
422 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
423 | - $this->_old_table, |
|
424 | - $old_price_row, |
|
425 | - $this->_new_ticket_table, |
|
426 | - $cols_n_values, |
|
427 | - $data_types |
|
428 | - ) |
|
429 | - ); |
|
430 | - return 0; |
|
431 | - } |
|
432 | - return $wpdb->insert_id; |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * Adds a join between a ticket and a price |
|
438 | - * |
|
439 | - * @param int $new_ticket_id |
|
440 | - * @param int $new_price_id |
|
441 | - * @return void |
|
442 | - * @global wpdb $wpdb |
|
443 | - */ |
|
444 | - private function _insert_ticket_price_relation(int $new_ticket_id, int $new_price_id): void |
|
445 | - { |
|
446 | - global $wpdb; |
|
447 | - $cols_n_values = [ |
|
448 | - 'TKT_ID' => $new_ticket_id, |
|
449 | - 'PRC_ID' => $new_price_id, |
|
450 | - ]; |
|
451 | - $data_types = [ |
|
452 | - '%d',// TKT_ID |
|
453 | - '%d',// PRC_ID |
|
454 | - ]; |
|
455 | - $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $data_types); |
|
456 | - if (! $success) { |
|
457 | - $this->add_error( |
|
458 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
459 | - $this->_old_table, |
|
460 | - ['ticket id' => $new_ticket_id, 'price id' => $new_price_id], |
|
461 | - $this->_new_ticket_price_table, |
|
462 | - $cols_n_values, |
|
463 | - $data_types |
|
464 | - ) |
|
465 | - ); |
|
466 | - } |
|
467 | - } |
|
468 | - |
|
469 | - |
|
470 | - /** |
|
471 | - * Adds a join between a ticket and a datetime |
|
472 | - * |
|
473 | - * @param int $new_datetime_id |
|
474 | - * @param int $new_ticket_id |
|
475 | - * @return void |
|
476 | - * @global wpdb $wpdb |
|
477 | - */ |
|
478 | - private function _insert_datetime_ticket_relation(int $new_datetime_id, int $new_ticket_id) |
|
479 | - { |
|
480 | - global $wpdb; |
|
481 | - $cols_n_values = [ |
|
482 | - 'TKT_ID' => $new_ticket_id, |
|
483 | - 'DTT_ID' => $new_datetime_id, |
|
484 | - ]; |
|
485 | - $data_types = [ |
|
486 | - '%d',// TKT_ID |
|
487 | - '%d',// DTT_ID |
|
488 | - ]; |
|
489 | - $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $data_types); |
|
490 | - if (! $success) { |
|
491 | - $this->add_error( |
|
492 | - $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
493 | - $this->_old_table, |
|
494 | - ['ticket id' => $new_ticket_id, 'datetime id' => $new_datetime_id], |
|
495 | - $this->_new_datetime_ticket_table, |
|
496 | - $cols_n_values, |
|
497 | - $data_types |
|
498 | - ) |
|
499 | - ); |
|
500 | - } |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * Simply gets the 3.1 event row data |
|
506 | - * |
|
507 | - * @param int $event_id |
|
508 | - * @return array |
|
509 | - * @global wpdb $wpdb |
|
510 | - */ |
|
511 | - private function _get_event_row(int $event_id): array |
|
512 | - { |
|
513 | - global $wpdb; |
|
514 | - $old_event_table = $wpdb->prefix . "events_detail"; |
|
515 | - return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A); |
|
516 | - } |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * Gets a higher ticket count than last time it was called (and is persisted between HTTP requests). |
|
521 | - * Yes we COULD run a query joining events->datetimes->ticket_datetimes->tickets, but this should work fine too |
|
522 | - * |
|
523 | - * @return int |
|
524 | - */ |
|
525 | - private function _get_ticket_count(): int |
|
526 | - { |
|
527 | - return $this->_ticket_count++; |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - /** |
|
532 | - * Using the 3.1 event id, gets the 4.1 datetimes for it |
|
533 | - * |
|
534 | - * @param int $old_event_id |
|
535 | - * @return array where values are datetime ids |
|
536 | - * @throws EE_Error |
|
537 | - */ |
|
538 | - private function _get_datetime_ids_for_old_event_id(int $old_event_id): array |
|
539 | - { |
|
540 | - global $wpdb; |
|
541 | - $new_cpt_id = $this->get_migration_script()->get_mapping_new_pk( |
|
542 | - $wpdb->prefix . "events_detail", |
|
543 | - $old_event_id, |
|
544 | - $wpdb->posts |
|
545 | - ); |
|
546 | - return $wpdb->get_col( |
|
547 | - $wpdb->prepare( |
|
548 | - "SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d", |
|
549 | - $new_cpt_id |
|
550 | - ) |
|
551 | - ); |
|
552 | - } |
|
155 | + $this->_new_price_table = $wpdb->prefix . "esp_price"; |
|
156 | + $this->_new_ticket_table = $wpdb->prefix . "esp_ticket"; |
|
157 | + $this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
158 | + $this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket"; |
|
159 | + parent::__construct(); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @throws EE_Error |
|
165 | + */ |
|
166 | + protected function _migrate_old_row($old_row) |
|
167 | + { |
|
168 | + // create the base price |
|
169 | + $new_price_id = $this->_insert_new_price($old_row); |
|
170 | + // create the member discount if there is any |
|
171 | + // commented-out because we may actually NOT be supporting this in 4.1 |
|
172 | + // if($old_row['event_cost'] != $old_row['member_price']){ |
|
173 | + // $member_price_discount_id = $this->_insert_new_member_price($old_row); |
|
174 | + // }else{ |
|
175 | + // $member_price_discount_id = 0; |
|
176 | + // } |
|
177 | + // create the surcharge if there is any |
|
178 | + if (floatval($old_row['surcharge']) >= 0.01) { |
|
179 | + $surcharge_price_id = $this->_insert_new_surcharge_price($old_row); |
|
180 | + $this->get_migration_script()->set_mapping( |
|
181 | + $this->_old_table, $old_row['id'], $this->_new_price_table, [$new_price_id, $surcharge_price_id] |
|
182 | + ); |
|
183 | + } else { |
|
184 | + $surcharge_price_id = 0; |
|
185 | + $this->get_migration_script()->set_mapping( |
|
186 | + $this->_old_table, $old_row['id'], $this->_new_price_table, [$new_price_id] |
|
187 | + ); |
|
188 | + } |
|
189 | + // associate the ticket to all datetimes for event (ie, this ONE ticket grants access to ALL datetimes, not just one of the attendee's choice. |
|
190 | + // if the latter were the case, then we'd create a separate ticket for each datetime and have their |
|
191 | + // association be one-to-one) |
|
192 | + // create ticket |
|
193 | + // $ticket_id = $this->_insert_new_ticket($old_row); |
|
194 | + // if($ticket_id){ |
|
195 | + // $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_ticket_table, $ticket_id); |
|
196 | + // //associate to the prices |
|
197 | + // $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
198 | + // $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
199 | + // //associate to datetimes for the event |
|
200 | + // foreach($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id){ |
|
201 | + // $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
202 | + // } |
|
203 | + // } |
|
204 | + // create a ticket for each old price -old datetime combo |
|
205 | + $tickets_for_old_price = []; |
|
206 | + foreach ($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id) { |
|
207 | + $ticket_id = $this->_insert_new_ticket($old_row); |
|
208 | + $tickets_for_old_price[] = $ticket_id; |
|
209 | + // associate to old prices |
|
210 | + $this->_insert_ticket_price_relation($ticket_id, $new_price_id); |
|
211 | + $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id); |
|
212 | + $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id); |
|
213 | + } |
|
214 | + $this->get_migration_script()->set_mapping( |
|
215 | + $this->_old_table, |
|
216 | + $old_row['id'], |
|
217 | + $this->_new_ticket_table, |
|
218 | + $tickets_for_old_price |
|
219 | + ); |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * Creates a 4.1 price base type |
|
225 | + * |
|
226 | + * @param array $old_price |
|
227 | + * @return int |
|
228 | + * @global wpdb $wpdb |
|
229 | + */ |
|
230 | + private function _insert_new_price(array $old_price): int |
|
231 | + { |
|
232 | + global $wpdb; |
|
233 | + $cols_n_values = [ |
|
234 | + 'PRT_ID' => self::price_type_base, |
|
235 | + 'PRC_amount' => floatval($old_price['event_cost']), |
|
236 | + 'PRC_name' => $old_price['price_type'], |
|
237 | + 'PRC_is_default' => false, |
|
238 | + 'PRC_overrides' => false, |
|
239 | + 'PRC_order' => 0, |
|
240 | + 'PRC_deleted' => false, |
|
241 | + 'PRC_parent' => null, |
|
242 | + |
|
243 | + ]; |
|
244 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
245 | + if (! $success) { |
|
246 | + $this->add_error( |
|
247 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
248 | + $this->_old_table, |
|
249 | + $old_price, |
|
250 | + $this->_new_price_table, |
|
251 | + $cols_n_values, |
|
252 | + $this->price_data_types |
|
253 | + ) |
|
254 | + ); |
|
255 | + return 0; |
|
256 | + } |
|
257 | + return $wpdb->insert_id; |
|
258 | + } |
|
259 | + /** |
|
260 | + * Creates a 4.1 member price discount |
|
261 | + * |
|
262 | + * @param array $old_price |
|
263 | + * @return int |
|
264 | + * @global wpdb $wpdb |
|
265 | + */ |
|
266 | + // private function _insert_new_member_price($old_price){ |
|
267 | + // $discount_amount = floatval($old_price['event_cost']) - floatval($old_price['member_price']); |
|
268 | + // global $wpdb; |
|
269 | + // $cols_n_values = array( |
|
270 | + // 'PRT_ID'=>self::price_type_member_discount, |
|
271 | + // 'PRC_amount'=>$discount_amount, |
|
272 | + // 'PRC_name'=>$old_price['member_price_type'], |
|
273 | + // 'PRC_is_default'=>false, |
|
274 | + // 'PRC_overrides'=>false, |
|
275 | + // 'PRC_order'=>10, |
|
276 | + // 'PRC_deleted'=>false, |
|
277 | + // 'PRC_parent'=>null |
|
278 | + // |
|
279 | + // ); |
|
280 | + // $data_types = array( |
|
281 | + // '%d',//PRT_ID |
|
282 | + // '%f',//PRT_amount |
|
283 | + // '%s',//PRC_name |
|
284 | + // '%d',//PRC_is_default |
|
285 | + // '%d',//PRC_overrides |
|
286 | + // '%d',//PRC_order |
|
287 | + // '%d',//PRC_deleted |
|
288 | + // '%d',//PRC_parent |
|
289 | + // ); |
|
290 | + // $success = $wpdb->insert($this->_new_price_table,$cols_n_values,$data_types); |
|
291 | + // if ( ! $success){ |
|
292 | + // $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $data_types)); |
|
293 | + // return 0; |
|
294 | + // } |
|
295 | + // $new_id = $wpdb->insert_id; |
|
296 | + // return $new_id; |
|
297 | + // } |
|
298 | + /** |
|
299 | + * Creates a 4.1 member price discount |
|
300 | + * |
|
301 | + * @param array $old_price |
|
302 | + * @return int |
|
303 | + * @global wpdb $wpdb |
|
304 | + */ |
|
305 | + private function _insert_new_surcharge_price(array $old_price): int |
|
306 | + { |
|
307 | + if ($old_price['surcharge_type'] == 'flat_rate') { |
|
308 | + $price_type = self::price_type_flat_surcharge; |
|
309 | + } else { |
|
310 | + $price_type = self::price_type_percent_surcharge; |
|
311 | + } |
|
312 | + global $wpdb; |
|
313 | + $cols_n_values = [ |
|
314 | + 'PRT_ID' => $price_type, |
|
315 | + 'PRC_amount' => floatval($old_price['surcharge']), |
|
316 | + 'PRC_name' => esc_html__("Surcharge", "event_espresso"), |
|
317 | + 'PRC_is_default' => false, |
|
318 | + 'PRC_overrides' => false, |
|
319 | + 'PRC_order' => 20, |
|
320 | + 'PRC_deleted' => false, |
|
321 | + 'PRC_parent' => null, |
|
322 | + |
|
323 | + ]; |
|
324 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
325 | + if (! $success) { |
|
326 | + $this->add_error( |
|
327 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
328 | + $this->_old_table, |
|
329 | + $old_price, |
|
330 | + $this->_new_price_table, |
|
331 | + $cols_n_values, |
|
332 | + $this->price_data_types |
|
333 | + ) |
|
334 | + ); |
|
335 | + return 0; |
|
336 | + } |
|
337 | + return $wpdb->insert_id; |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * Inserts a 4.1 ticket based off the 3.1 price, and the price IDs we've already made from the 3.1 price |
|
343 | + * |
|
344 | + * @param array $old_price_row array where keys are columns |
|
345 | + * @return int new ticket id |
|
346 | + */ |
|
347 | + private function _insert_new_ticket(array $old_price_row): int |
|
348 | + { |
|
349 | + global $wpdb; |
|
350 | + $event_row = $this->_get_event_row($old_price_row['event_id']); |
|
351 | + if ($old_price_row['surcharge_type'] == 'flat_rate') { |
|
352 | + $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']); |
|
353 | + } else {// percent surcharge |
|
354 | + $final_ticket_price = |
|
355 | + floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge']) / 100); |
|
356 | + } |
|
357 | + $start_date = |
|
358 | + $event_row['registration_start'] . |
|
359 | + " " . |
|
360 | + $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']); |
|
361 | + $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
362 | + $this, |
|
363 | + $old_price_row, |
|
364 | + $start_date, |
|
365 | + $event_row['timezone_string'] |
|
366 | + ); |
|
367 | + $end_date = |
|
368 | + $event_row['registration_end'] . |
|
369 | + " " . |
|
370 | + $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']); |
|
371 | + $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
372 | + $this, |
|
373 | + $old_price_row, |
|
374 | + $end_date, |
|
375 | + $event_row['timezone_string'] |
|
376 | + ); |
|
377 | + $cols_n_values = [ |
|
378 | + 'TTM_ID' => 0, |
|
379 | + 'TKT_name' => $old_price_row['price_type'], |
|
380 | + 'TKT_description' => '', |
|
381 | + 'TKT_start_date' => $start_date_utc, |
|
382 | + 'TKT_end_date' => $end_date_utc, |
|
383 | + 'TKT_min' => 0, |
|
384 | + 'TKT_max' => -1, |
|
385 | + 'TKT_price' => $final_ticket_price, |
|
386 | + 'TKT_sold' => 0, |
|
387 | + // note: this will get calculated as we actually add registrations during the migration |
|
388 | + 'TKT_qty' => -1, |
|
389 | + 'TKT_uses' => 1, |
|
390 | + 'TKT_taxable' => false, |
|
391 | + // so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices |
|
392 | + 'TKT_is_default' => false, |
|
393 | + 'TKT_order' => $this->_get_ticket_count(), |
|
394 | + 'TKT_row' => 0, |
|
395 | + // doesn't matter because UI reset this on first save anyways |
|
396 | + 'TKT_deleted' => false, |
|
397 | + 'TKT_parent' => 0, |
|
398 | + |
|
399 | + ]; |
|
400 | + $data_types = [ |
|
401 | + '%d',// TTM_ID |
|
402 | + '%s',// TKT_name |
|
403 | + '%s',// TKT_description |
|
404 | + '%s',// TKT_start_date |
|
405 | + '%s',// TKT_end_date |
|
406 | + '%d',// TKT_min |
|
407 | + '%d',// TKT_max |
|
408 | + '%f',// TKT_price |
|
409 | + '%d',// TKT_sold |
|
410 | + '%d',// TKT_qty |
|
411 | + '%d',// TKT_uses |
|
412 | + '%d',// TKT_taxable |
|
413 | + '%d',// TKT_is_default |
|
414 | + '%d',// TKT_order |
|
415 | + '%d',// TKT_row |
|
416 | + '%d',// TKT_deleted |
|
417 | + '%d',// TKT_parent |
|
418 | + ]; |
|
419 | + $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $data_types); |
|
420 | + if (! $success) { |
|
421 | + $this->add_error( |
|
422 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
423 | + $this->_old_table, |
|
424 | + $old_price_row, |
|
425 | + $this->_new_ticket_table, |
|
426 | + $cols_n_values, |
|
427 | + $data_types |
|
428 | + ) |
|
429 | + ); |
|
430 | + return 0; |
|
431 | + } |
|
432 | + return $wpdb->insert_id; |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * Adds a join between a ticket and a price |
|
438 | + * |
|
439 | + * @param int $new_ticket_id |
|
440 | + * @param int $new_price_id |
|
441 | + * @return void |
|
442 | + * @global wpdb $wpdb |
|
443 | + */ |
|
444 | + private function _insert_ticket_price_relation(int $new_ticket_id, int $new_price_id): void |
|
445 | + { |
|
446 | + global $wpdb; |
|
447 | + $cols_n_values = [ |
|
448 | + 'TKT_ID' => $new_ticket_id, |
|
449 | + 'PRC_ID' => $new_price_id, |
|
450 | + ]; |
|
451 | + $data_types = [ |
|
452 | + '%d',// TKT_ID |
|
453 | + '%d',// PRC_ID |
|
454 | + ]; |
|
455 | + $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $data_types); |
|
456 | + if (! $success) { |
|
457 | + $this->add_error( |
|
458 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
459 | + $this->_old_table, |
|
460 | + ['ticket id' => $new_ticket_id, 'price id' => $new_price_id], |
|
461 | + $this->_new_ticket_price_table, |
|
462 | + $cols_n_values, |
|
463 | + $data_types |
|
464 | + ) |
|
465 | + ); |
|
466 | + } |
|
467 | + } |
|
468 | + |
|
469 | + |
|
470 | + /** |
|
471 | + * Adds a join between a ticket and a datetime |
|
472 | + * |
|
473 | + * @param int $new_datetime_id |
|
474 | + * @param int $new_ticket_id |
|
475 | + * @return void |
|
476 | + * @global wpdb $wpdb |
|
477 | + */ |
|
478 | + private function _insert_datetime_ticket_relation(int $new_datetime_id, int $new_ticket_id) |
|
479 | + { |
|
480 | + global $wpdb; |
|
481 | + $cols_n_values = [ |
|
482 | + 'TKT_ID' => $new_ticket_id, |
|
483 | + 'DTT_ID' => $new_datetime_id, |
|
484 | + ]; |
|
485 | + $data_types = [ |
|
486 | + '%d',// TKT_ID |
|
487 | + '%d',// DTT_ID |
|
488 | + ]; |
|
489 | + $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $data_types); |
|
490 | + if (! $success) { |
|
491 | + $this->add_error( |
|
492 | + $this->get_migration_script()->_create_error_message_for_db_insertion( |
|
493 | + $this->_old_table, |
|
494 | + ['ticket id' => $new_ticket_id, 'datetime id' => $new_datetime_id], |
|
495 | + $this->_new_datetime_ticket_table, |
|
496 | + $cols_n_values, |
|
497 | + $data_types |
|
498 | + ) |
|
499 | + ); |
|
500 | + } |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * Simply gets the 3.1 event row data |
|
506 | + * |
|
507 | + * @param int $event_id |
|
508 | + * @return array |
|
509 | + * @global wpdb $wpdb |
|
510 | + */ |
|
511 | + private function _get_event_row(int $event_id): array |
|
512 | + { |
|
513 | + global $wpdb; |
|
514 | + $old_event_table = $wpdb->prefix . "events_detail"; |
|
515 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A); |
|
516 | + } |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * Gets a higher ticket count than last time it was called (and is persisted between HTTP requests). |
|
521 | + * Yes we COULD run a query joining events->datetimes->ticket_datetimes->tickets, but this should work fine too |
|
522 | + * |
|
523 | + * @return int |
|
524 | + */ |
|
525 | + private function _get_ticket_count(): int |
|
526 | + { |
|
527 | + return $this->_ticket_count++; |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + /** |
|
532 | + * Using the 3.1 event id, gets the 4.1 datetimes for it |
|
533 | + * |
|
534 | + * @param int $old_event_id |
|
535 | + * @return array where values are datetime ids |
|
536 | + * @throws EE_Error |
|
537 | + */ |
|
538 | + private function _get_datetime_ids_for_old_event_id(int $old_event_id): array |
|
539 | + { |
|
540 | + global $wpdb; |
|
541 | + $new_cpt_id = $this->get_migration_script()->get_mapping_new_pk( |
|
542 | + $wpdb->prefix . "events_detail", |
|
543 | + $old_event_id, |
|
544 | + $wpdb->posts |
|
545 | + ); |
|
546 | + return $wpdb->get_col( |
|
547 | + $wpdb->prepare( |
|
548 | + "SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d", |
|
549 | + $new_cpt_id |
|
550 | + ) |
|
551 | + ); |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | // @todo: tell users that in 3.1 the limit was on registration PER event,in 4.1 it's limit PER TICKET... SO, if they sell 2 different types of tickets |
555 | 555 | // |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | private int $_ticket_count = 0; |
133 | 133 | |
134 | 134 | private array $price_data_types = [ |
135 | - '%d',// PRT_ID |
|
136 | - '%f',// PRT_amount |
|
137 | - '%s',// PRC_name |
|
138 | - '%d',// PRC_is_default |
|
139 | - '%d',// PRC_overrides |
|
140 | - '%d',// PRC_order |
|
141 | - '%d',// PRC_deleted |
|
142 | - '%d',// PRC_parent |
|
135 | + '%d', // PRT_ID |
|
136 | + '%f', // PRT_amount |
|
137 | + '%s', // PRC_name |
|
138 | + '%d', // PRC_is_default |
|
139 | + '%d', // PRC_overrides |
|
140 | + '%d', // PRC_order |
|
141 | + '%d', // PRC_deleted |
|
142 | + '%d', // PRC_parent |
|
143 | 143 | ]; |
144 | 144 | |
145 | 145 | |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | { |
148 | 148 | global $wpdb; |
149 | 149 | $this->_pretty_name = esc_html__("Prices", "event_espresso"); |
150 | - $this->_old_table = $wpdb->prefix . "events_prices"; |
|
150 | + $this->_old_table = $wpdb->prefix."events_prices"; |
|
151 | 151 | $this->select_expression = 'p.*, e.event_status'; |
152 | 152 | $this->_extra_where_sql = ' AS p |
153 | - INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON p.event_id=e.id |
|
153 | + INNER JOIN ' . $wpdb->prefix.'events_detail AS e ON p.event_id=e.id |
|
154 | 154 | WHERE e.event_status!="D"'; |
155 | - $this->_new_price_table = $wpdb->prefix . "esp_price"; |
|
156 | - $this->_new_ticket_table = $wpdb->prefix . "esp_ticket"; |
|
157 | - $this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
158 | - $this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket"; |
|
155 | + $this->_new_price_table = $wpdb->prefix."esp_price"; |
|
156 | + $this->_new_ticket_table = $wpdb->prefix."esp_ticket"; |
|
157 | + $this->_new_ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
|
158 | + $this->_new_datetime_ticket_table = $wpdb->prefix."esp_datetime_ticket"; |
|
159 | 159 | parent::__construct(); |
160 | 160 | } |
161 | 161 | |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | 'PRC_parent' => null, |
242 | 242 | |
243 | 243 | ]; |
244 | - $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
245 | - if (! $success) { |
|
244 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
245 | + if ( ! $success) { |
|
246 | 246 | $this->add_error( |
247 | 247 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
248 | 248 | $this->_old_table, |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | 'PRC_parent' => null, |
322 | 322 | |
323 | 323 | ]; |
324 | - $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
325 | - if (! $success) { |
|
324 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $this->price_data_types); |
|
325 | + if ( ! $success) { |
|
326 | 326 | $this->add_error( |
327 | 327 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
328 | 328 | $this->_old_table, |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | $final_ticket_price = |
355 | 355 | floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge']) / 100); |
356 | 356 | } |
357 | - $start_date = |
|
358 | - $event_row['registration_start'] . |
|
359 | - " " . |
|
357 | + $start_date = |
|
358 | + $event_row['registration_start']. |
|
359 | + " ". |
|
360 | 360 | $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']); |
361 | 361 | $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
362 | 362 | $this, |
@@ -364,17 +364,17 @@ discard block |
||
364 | 364 | $start_date, |
365 | 365 | $event_row['timezone_string'] |
366 | 366 | ); |
367 | - $end_date = |
|
368 | - $event_row['registration_end'] . |
|
369 | - " " . |
|
367 | + $end_date = |
|
368 | + $event_row['registration_end']. |
|
369 | + " ". |
|
370 | 370 | $this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']); |
371 | - $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
371 | + $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc( |
|
372 | 372 | $this, |
373 | 373 | $old_price_row, |
374 | 374 | $end_date, |
375 | 375 | $event_row['timezone_string'] |
376 | 376 | ); |
377 | - $cols_n_values = [ |
|
377 | + $cols_n_values = [ |
|
378 | 378 | 'TTM_ID' => 0, |
379 | 379 | 'TKT_name' => $old_price_row['price_type'], |
380 | 380 | 'TKT_description' => '', |
@@ -397,27 +397,27 @@ discard block |
||
397 | 397 | 'TKT_parent' => 0, |
398 | 398 | |
399 | 399 | ]; |
400 | - $data_types = [ |
|
401 | - '%d',// TTM_ID |
|
402 | - '%s',// TKT_name |
|
403 | - '%s',// TKT_description |
|
404 | - '%s',// TKT_start_date |
|
405 | - '%s',// TKT_end_date |
|
406 | - '%d',// TKT_min |
|
407 | - '%d',// TKT_max |
|
408 | - '%f',// TKT_price |
|
409 | - '%d',// TKT_sold |
|
410 | - '%d',// TKT_qty |
|
411 | - '%d',// TKT_uses |
|
412 | - '%d',// TKT_taxable |
|
413 | - '%d',// TKT_is_default |
|
414 | - '%d',// TKT_order |
|
415 | - '%d',// TKT_row |
|
416 | - '%d',// TKT_deleted |
|
417 | - '%d',// TKT_parent |
|
400 | + $data_types = [ |
|
401 | + '%d', // TTM_ID |
|
402 | + '%s', // TKT_name |
|
403 | + '%s', // TKT_description |
|
404 | + '%s', // TKT_start_date |
|
405 | + '%s', // TKT_end_date |
|
406 | + '%d', // TKT_min |
|
407 | + '%d', // TKT_max |
|
408 | + '%f', // TKT_price |
|
409 | + '%d', // TKT_sold |
|
410 | + '%d', // TKT_qty |
|
411 | + '%d', // TKT_uses |
|
412 | + '%d', // TKT_taxable |
|
413 | + '%d', // TKT_is_default |
|
414 | + '%d', // TKT_order |
|
415 | + '%d', // TKT_row |
|
416 | + '%d', // TKT_deleted |
|
417 | + '%d', // TKT_parent |
|
418 | 418 | ]; |
419 | - $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $data_types); |
|
420 | - if (! $success) { |
|
419 | + $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $data_types); |
|
420 | + if ( ! $success) { |
|
421 | 421 | $this->add_error( |
422 | 422 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
423 | 423 | $this->_old_table, |
@@ -448,12 +448,12 @@ discard block |
||
448 | 448 | 'TKT_ID' => $new_ticket_id, |
449 | 449 | 'PRC_ID' => $new_price_id, |
450 | 450 | ]; |
451 | - $data_types = [ |
|
452 | - '%d',// TKT_ID |
|
453 | - '%d',// PRC_ID |
|
451 | + $data_types = [ |
|
452 | + '%d', // TKT_ID |
|
453 | + '%d', // PRC_ID |
|
454 | 454 | ]; |
455 | - $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $data_types); |
|
456 | - if (! $success) { |
|
455 | + $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $data_types); |
|
456 | + if ( ! $success) { |
|
457 | 457 | $this->add_error( |
458 | 458 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
459 | 459 | $this->_old_table, |
@@ -482,12 +482,12 @@ discard block |
||
482 | 482 | 'TKT_ID' => $new_ticket_id, |
483 | 483 | 'DTT_ID' => $new_datetime_id, |
484 | 484 | ]; |
485 | - $data_types = [ |
|
486 | - '%d',// TKT_ID |
|
487 | - '%d',// DTT_ID |
|
485 | + $data_types = [ |
|
486 | + '%d', // TKT_ID |
|
487 | + '%d', // DTT_ID |
|
488 | 488 | ]; |
489 | - $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $data_types); |
|
490 | - if (! $success) { |
|
489 | + $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $data_types); |
|
490 | + if ( ! $success) { |
|
491 | 491 | $this->add_error( |
492 | 492 | $this->get_migration_script()->_create_error_message_for_db_insertion( |
493 | 493 | $this->_old_table, |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | private function _get_event_row(int $event_id): array |
512 | 512 | { |
513 | 513 | global $wpdb; |
514 | - $old_event_table = $wpdb->prefix . "events_detail"; |
|
514 | + $old_event_table = $wpdb->prefix."events_detail"; |
|
515 | 515 | return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A); |
516 | 516 | } |
517 | 517 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | { |
540 | 540 | global $wpdb; |
541 | 541 | $new_cpt_id = $this->get_migration_script()->get_mapping_new_pk( |
542 | - $wpdb->prefix . "events_detail", |
|
542 | + $wpdb->prefix."events_detail", |
|
543 | 543 | $old_event_id, |
544 | 544 | $wpdb->posts |
545 | 545 | ); |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | if (! empty($stages)) { |
13 | - foreach ($stages as $filepath) { |
|
14 | - $matches = []; |
|
15 | - preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | - } |
|
13 | + foreach ($stages as $filepath) { |
|
14 | + $matches = []; |
|
15 | + preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_3_0__autoloaded_stages', $class_to_filepath); |
@@ -31,63 +31,63 @@ discard block |
||
31 | 31 | class EE_DMS_Core_4_3_0 extends EE_Data_Migration_Script_Base |
32 | 32 | { |
33 | 33 | |
34 | - /** |
|
35 | - * EE_DMS_Core_4_3_0 constructor. |
|
36 | - * |
|
37 | - * @param TableManager|null $table_manager |
|
38 | - * @param TableAnalysis|null $table_analysis |
|
39 | - */ |
|
40 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | - { |
|
42 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.3.0", "event_espresso"); |
|
43 | - $this->_priority = 10; |
|
44 | - $this->_migration_stages = [ |
|
45 | - new EE_DMS_4_3_0_question_option_order(), |
|
46 | - new EE_DMS_4_3_0_event_message_templates(), |
|
47 | - ]; |
|
48 | - parent::__construct($table_manager, $table_analysis); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - public function can_migrate_from_version($version_array) |
|
53 | - { |
|
54 | - $version_string = $version_array['Core']; |
|
55 | - if ( |
|
56 | - version_compare($version_string, '4.3.0.decaf', '<') && |
|
57 | - version_compare($version_string, '4.2.0.decaf', '>=') |
|
58 | - ) { |
|
59 | - // echo "$version_string can be migrated fro"; |
|
60 | - return true; |
|
61 | - } elseif (! $version_string) { |
|
62 | - // echo "no version string provided: $version_string"; |
|
63 | - // no version string provided... this must be pre 4.2 |
|
64 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | - } else { |
|
66 | - // echo "$version_string doesnt apply"; |
|
67 | - return false; |
|
68 | - } |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @throws EE_Error |
|
74 | - * @throws ReflectionException |
|
75 | - */ |
|
76 | - public function schema_changes_before_migration() |
|
77 | - { |
|
78 | - // relies on 4.1's EEH_Activation::create_table |
|
79 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
80 | - |
|
81 | - $table_name = 'esp_answer'; |
|
82 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
34 | + /** |
|
35 | + * EE_DMS_Core_4_3_0 constructor. |
|
36 | + * |
|
37 | + * @param TableManager|null $table_manager |
|
38 | + * @param TableAnalysis|null $table_analysis |
|
39 | + */ |
|
40 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
41 | + { |
|
42 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.3.0", "event_espresso"); |
|
43 | + $this->_priority = 10; |
|
44 | + $this->_migration_stages = [ |
|
45 | + new EE_DMS_4_3_0_question_option_order(), |
|
46 | + new EE_DMS_4_3_0_event_message_templates(), |
|
47 | + ]; |
|
48 | + parent::__construct($table_manager, $table_analysis); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + public function can_migrate_from_version($version_array) |
|
53 | + { |
|
54 | + $version_string = $version_array['Core']; |
|
55 | + if ( |
|
56 | + version_compare($version_string, '4.3.0.decaf', '<') && |
|
57 | + version_compare($version_string, '4.2.0.decaf', '>=') |
|
58 | + ) { |
|
59 | + // echo "$version_string can be migrated fro"; |
|
60 | + return true; |
|
61 | + } elseif (! $version_string) { |
|
62 | + // echo "no version string provided: $version_string"; |
|
63 | + // no version string provided... this must be pre 4.2 |
|
64 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | + } else { |
|
66 | + // echo "$version_string doesnt apply"; |
|
67 | + return false; |
|
68 | + } |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @throws EE_Error |
|
74 | + * @throws ReflectionException |
|
75 | + */ |
|
76 | + public function schema_changes_before_migration() |
|
77 | + { |
|
78 | + // relies on 4.1's EEH_Activation::create_table |
|
79 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
80 | + |
|
81 | + $table_name = 'esp_answer'; |
|
82 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
83 | 83 | REG_ID int(10) unsigned NOT NULL, |
84 | 84 | QST_ID int(10) unsigned NOT NULL, |
85 | 85 | ANS_value text NOT NULL, |
86 | 86 | PRIMARY KEY (ANS_ID)"; |
87 | - $this->_table_should_exist_previously($table_name, $sql); |
|
87 | + $this->_table_should_exist_previously($table_name, $sql); |
|
88 | 88 | |
89 | - $table_name = 'esp_attendee_meta'; |
|
90 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
89 | + $table_name = 'esp_attendee_meta'; |
|
90 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
91 | 91 | ATT_ID bigint(20) unsigned NOT NULL, |
92 | 92 | ATT_fname varchar(45) NOT NULL, |
93 | 93 | ATT_lname varchar(45) NOT NULL, |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | KEY ATT_fname (ATT_fname), |
104 | 104 | KEY ATT_lname (ATT_lname), |
105 | 105 | KEY ATT_email (ATT_email(191))"; |
106 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
106 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
107 | 107 | |
108 | - $table_name = 'esp_country'; |
|
109 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
108 | + $table_name = 'esp_country'; |
|
109 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
110 | 110 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
111 | 111 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
112 | 112 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | CNT_is_EU tinyint(1) DEFAULT '0', |
123 | 123 | CNT_active tinyint(1) DEFAULT '0', |
124 | 124 | PRIMARY KEY (CNT_ISO)"; |
125 | - $this->_table_should_exist_previously($table_name, $sql); |
|
125 | + $this->_table_should_exist_previously($table_name, $sql); |
|
126 | 126 | |
127 | - $table_name = 'esp_datetime'; |
|
128 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
127 | + $table_name = 'esp_datetime'; |
|
128 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
129 | 129 | EVT_ID bigint(20) unsigned NOT NULL, |
130 | 130 | DTT_name varchar(255) NOT NULL DEFAULT '', |
131 | 131 | DTT_description text NOT NULL, |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | PRIMARY KEY (DTT_ID), |
141 | 141 | KEY EVT_ID (EVT_ID), |
142 | 142 | KEY DTT_is_primary (DTT_is_primary)"; |
143 | - $this->_table_should_exist_previously($table_name, $sql); |
|
143 | + $this->_table_should_exist_previously($table_name, $sql); |
|
144 | 144 | |
145 | - $table_name = 'esp_event_meta'; |
|
146 | - $sql = " |
|
145 | + $table_name = 'esp_event_meta'; |
|
146 | + $sql = " |
|
147 | 147 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
148 | 148 | EVT_ID bigint(20) unsigned NOT NULL, |
149 | 149 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | EVT_external_URL varchar(200) NULL, |
159 | 159 | EVT_donations tinyint(1) NULL, |
160 | 160 | PRIMARY KEY (EVTM_ID)"; |
161 | - $this->_table_should_exist_previously($table_name, $sql); |
|
161 | + $this->_table_should_exist_previously($table_name, $sql); |
|
162 | 162 | |
163 | - $table_name = 'esp_event_question_group'; |
|
164 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
163 | + $table_name = 'esp_event_question_group'; |
|
164 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
165 | 165 | EVT_ID bigint(20) unsigned NOT NULL, |
166 | 166 | QSG_ID int(10) unsigned NOT NULL, |
167 | 167 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
168 | 168 | PRIMARY KEY (EQG_ID)"; |
169 | - $this->_table_should_exist_previously($table_name, $sql); |
|
169 | + $this->_table_should_exist_previously($table_name, $sql); |
|
170 | 170 | |
171 | - $table_name = 'esp_event_venue'; |
|
172 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
171 | + $table_name = 'esp_event_venue'; |
|
172 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
173 | 173 | EVT_ID bigint(20) unsigned NOT NULL, |
174 | 174 | VNU_ID bigint(20) unsigned NOT NULL, |
175 | 175 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
176 | 176 | PRIMARY KEY (EVV_ID)"; |
177 | - $this->_table_should_exist_previously($table_name, $sql); |
|
177 | + $this->_table_should_exist_previously($table_name, $sql); |
|
178 | 178 | |
179 | - $table_name = 'esp_extra_meta'; |
|
180 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
179 | + $table_name = 'esp_extra_meta'; |
|
180 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
181 | 181 | OBJ_ID int(11) DEFAULT NULL, |
182 | 182 | EXM_type varchar(45) DEFAULT NULL, |
183 | 183 | EXM_key varchar(45) DEFAULT NULL, |
184 | 184 | EXM_value text, |
185 | 185 | PRIMARY KEY (EXM_ID)"; |
186 | - $this->_table_should_exist_previously($table_name, $sql); |
|
186 | + $this->_table_should_exist_previously($table_name, $sql); |
|
187 | 187 | |
188 | - $table_name = 'esp_line_item'; |
|
189 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
188 | + $table_name = 'esp_line_item'; |
|
189 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
190 | 190 | LIN_code varchar(245) NOT NULL DEFAULT '', |
191 | 191 | TXN_ID int(11) DEFAULT NULL, |
192 | 192 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -202,21 +202,21 @@ discard block |
||
202 | 202 | OBJ_ID int(11) DEFAULT NULL, |
203 | 203 | OBJ_type varchar(45)DEFAULT NULL, |
204 | 204 | PRIMARY KEY (LIN_ID)"; |
205 | - $this->_table_should_exist_previously($table_name, $sql); |
|
205 | + $this->_table_should_exist_previously($table_name, $sql); |
|
206 | 206 | |
207 | - $table_name = 'esp_message_template'; |
|
208 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
207 | + $table_name = 'esp_message_template'; |
|
208 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
209 | 209 | GRP_ID int(10) unsigned NOT NULL, |
210 | 210 | MTP_context varchar(50) NOT NULL, |
211 | 211 | MTP_template_field varchar(30) NOT NULL, |
212 | 212 | MTP_content text NOT NULL, |
213 | 213 | PRIMARY KEY (MTP_ID), |
214 | 214 | KEY GRP_ID (GRP_ID)"; |
215 | - $this->_table_should_exist_previously($table_name, $sql); |
|
216 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
215 | + $this->_table_should_exist_previously($table_name, $sql); |
|
216 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
217 | 217 | |
218 | - $table_name = 'esp_message_template_group'; |
|
219 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
218 | + $table_name = 'esp_message_template_group'; |
|
219 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
220 | 220 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
221 | 221 | MTP_name varchar(245) NOT NULL DEFAULT '', |
222 | 222 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -228,19 +228,19 @@ discard block |
||
228 | 228 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
229 | 229 | PRIMARY KEY (GRP_ID), |
230 | 230 | KEY MTP_user_id (MTP_user_id)"; |
231 | - $this->_table_should_exist_previously($table_name, $sql); |
|
231 | + $this->_table_should_exist_previously($table_name, $sql); |
|
232 | 232 | |
233 | - $table_name = 'esp_event_message_template'; |
|
234 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
233 | + $table_name = 'esp_event_message_template'; |
|
234 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
235 | 235 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
236 | 236 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
237 | 237 | PRIMARY KEY (EMT_ID), |
238 | 238 | KEY EVT_ID (EVT_ID), |
239 | 239 | KEY GRP_ID (GRP_ID)"; |
240 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
240 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
241 | 241 | |
242 | - $table_name = 'esp_payment'; |
|
243 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
242 | + $table_name = 'esp_payment'; |
|
243 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
244 | 244 | TXN_ID int(10) unsigned DEFAULT NULL, |
245 | 245 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
246 | 246 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | PRIMARY KEY (PAY_ID), |
257 | 257 | KEY TXN_ID (TXN_ID), |
258 | 258 | KEY PAY_timestamp (PAY_timestamp)"; |
259 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
259 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | 260 | |
261 | - $table_name = "esp_ticket"; |
|
262 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
261 | + $table_name = "esp_ticket"; |
|
262 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
263 | 263 | TTM_ID int(10) unsigned NOT NULL, |
264 | 264 | TKT_name varchar(245) NOT NULL DEFAULT '', |
265 | 265 | TKT_description text NOT NULL, |
@@ -279,32 +279,32 @@ discard block |
||
279 | 279 | TKT_parent int(10) unsigned DEFAULT '0', |
280 | 280 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
281 | 281 | PRIMARY KEY (TKT_ID)"; |
282 | - $this->_table_should_exist_previously($table_name, $sql); |
|
282 | + $this->_table_should_exist_previously($table_name, $sql); |
|
283 | 283 | |
284 | - $table_name = "esp_ticket_price"; |
|
285 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
284 | + $table_name = "esp_ticket_price"; |
|
285 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
286 | 286 | TKT_ID int(10) unsigned NOT NULL, |
287 | 287 | PRC_ID int(10) unsigned NOT NULL, |
288 | 288 | PRIMARY KEY (TKP_ID)"; |
289 | - $this->_table_should_exist_previously($table_name, $sql); |
|
289 | + $this->_table_should_exist_previously($table_name, $sql); |
|
290 | 290 | |
291 | - $table_name = "esp_datetime_ticket"; |
|
292 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
291 | + $table_name = "esp_datetime_ticket"; |
|
292 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
293 | 293 | DTT_ID int(10) unsigned NOT NULL, |
294 | 294 | TKT_ID int(10) unsigned NOT NULL, |
295 | 295 | PRIMARY KEY (DTK_ID)"; |
296 | - $this->_table_should_exist_previously($table_name, $sql); |
|
296 | + $this->_table_should_exist_previously($table_name, $sql); |
|
297 | 297 | |
298 | - $table_name = "esp_ticket_template"; |
|
299 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
298 | + $table_name = "esp_ticket_template"; |
|
299 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
300 | 300 | TTM_name varchar(45) NOT NULL, |
301 | 301 | TTM_description text, |
302 | 302 | TTM_file varchar(45), |
303 | 303 | PRIMARY KEY (TTM_ID)"; |
304 | - $this->_table_should_exist_previously($table_name, $sql); |
|
304 | + $this->_table_should_exist_previously($table_name, $sql); |
|
305 | 305 | |
306 | - $table_name = "esp_price"; |
|
307 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
306 | + $table_name = "esp_price"; |
|
307 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
308 | 308 | PRT_ID tinyint(3) unsigned NOT NULL, |
309 | 309 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
310 | 310 | PRC_name varchar(245) NOT NULL, |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
316 | 316 | PRC_parent int(10) unsigned DEFAULT 0, |
317 | 317 | PRIMARY KEY (PRC_ID)"; |
318 | - $this->_table_should_exist_previously($table_name, $sql); |
|
318 | + $this->_table_should_exist_previously($table_name, $sql); |
|
319 | 319 | |
320 | - $table_name = "esp_price_type"; |
|
321 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
320 | + $table_name = "esp_price_type"; |
|
321 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
322 | 322 | PRT_name varchar(45) NOT NULL, |
323 | 323 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
324 | 324 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
327 | 327 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
328 | 328 | PRIMARY KEY (PRT_ID)"; |
329 | - $this->_table_should_exist_previously($table_name, $sql); |
|
329 | + $this->_table_should_exist_previously($table_name, $sql); |
|
330 | 330 | |
331 | - $table_name = 'esp_question'; |
|
332 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
331 | + $table_name = 'esp_question'; |
|
332 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | 333 | QST_display_text text NOT NULL, |
334 | 334 | QST_admin_label varchar(255) NOT NULL, |
335 | 335 | QST_system varchar(25) DEFAULT NULL, |
@@ -341,11 +341,11 @@ discard block |
||
341 | 341 | QST_wp_user bigint(20) unsigned NULL, |
342 | 342 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
343 | 343 | PRIMARY KEY (QST_ID)'; |
344 | - $this->_table_should_exist_previously($table_name, $sql); |
|
345 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
344 | + $this->_table_should_exist_previously($table_name, $sql); |
|
345 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
346 | 346 | |
347 | - $table_name = 'esp_question_group'; |
|
348 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
347 | + $table_name = 'esp_question_group'; |
|
348 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
349 | 349 | QSG_name varchar(255) NOT NULL, |
350 | 350 | QSG_identifier varchar(100) NOT NULL, |
351 | 351 | QSG_desc text NULL, |
@@ -356,28 +356,28 @@ discard block |
||
356 | 356 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
357 | 357 | PRIMARY KEY (QSG_ID), |
358 | 358 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
359 | - $this->_table_should_exist_previously($table_name, $sql); |
|
359 | + $this->_table_should_exist_previously($table_name, $sql); |
|
360 | 360 | |
361 | - $table_name = 'esp_question_group_question'; |
|
362 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
361 | + $table_name = 'esp_question_group_question'; |
|
362 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
363 | 363 | QSG_ID int(10) unsigned NOT NULL, |
364 | 364 | QST_ID int(10) unsigned NOT NULL, |
365 | 365 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
366 | 366 | PRIMARY KEY (QGQ_ID) "; |
367 | - $this->_table_should_exist_previously($table_name, $sql); |
|
367 | + $this->_table_should_exist_previously($table_name, $sql); |
|
368 | 368 | |
369 | - $table_name = 'esp_question_option'; |
|
370 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
369 | + $table_name = 'esp_question_option'; |
|
370 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
371 | 371 | QSO_value varchar(255) NOT NULL, |
372 | 372 | QSO_desc text NOT NULL, |
373 | 373 | QST_ID int(10) unsigned NOT NULL, |
374 | 374 | QSO_order int(10) unsigned NOT NULL DEFAULT 0, |
375 | 375 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
376 | 376 | PRIMARY KEY (QSO_ID)"; |
377 | - $this->_table_should_exist_previously($table_name, $sql); |
|
377 | + $this->_table_should_exist_previously($table_name, $sql); |
|
378 | 378 | |
379 | - $table_name = 'esp_registration'; |
|
380 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
379 | + $table_name = 'esp_registration'; |
|
380 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
381 | 381 | EVT_ID bigint(20) unsigned NOT NULL, |
382 | 382 | ATT_ID bigint(20) unsigned NOT NULL, |
383 | 383 | TXN_ID int(10) unsigned NOT NULL, |
@@ -400,28 +400,28 @@ discard block |
||
400 | 400 | KEY STS_ID (STS_ID), |
401 | 401 | KEY REG_url_link (REG_url_link), |
402 | 402 | KEY REG_code (REG_code)"; |
403 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
403 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
404 | 404 | |
405 | - $table_name = 'esp_checkin'; |
|
406 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
405 | + $table_name = 'esp_checkin'; |
|
406 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
407 | 407 | REG_ID int(10) unsigned NOT NULL, |
408 | 408 | DTT_ID int(10) unsigned NOT NULL, |
409 | 409 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
410 | 410 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
411 | 411 | PRIMARY KEY (CHK_ID)"; |
412 | - $this->_table_should_exist_previously($table_name, $sql); |
|
412 | + $this->_table_should_exist_previously($table_name, $sql); |
|
413 | 413 | |
414 | - $table_name = 'esp_state'; |
|
415 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | + $table_name = 'esp_state'; |
|
415 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | 416 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
417 | 417 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
418 | 418 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
419 | 419 | STA_active tinyint(1) DEFAULT '1', |
420 | 420 | PRIMARY KEY (STA_ID)"; |
421 | - $this->_table_should_exist_previously($table_name, $sql); |
|
421 | + $this->_table_should_exist_previously($table_name, $sql); |
|
422 | 422 | |
423 | - $table_name = 'esp_status'; |
|
424 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
423 | + $table_name = 'esp_status'; |
|
424 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
425 | 425 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
426 | 426 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
427 | 427 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -429,10 +429,10 @@ discard block |
||
429 | 429 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
430 | 430 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
431 | 431 | KEY STS_type (STS_type)"; |
432 | - $this->_table_should_exist_previously($table_name, $sql); |
|
432 | + $this->_table_should_exist_previously($table_name, $sql); |
|
433 | 433 | |
434 | - $table_name = 'esp_transaction'; |
|
435 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
434 | + $table_name = 'esp_transaction'; |
|
435 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
436 | 436 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
437 | 437 | TXN_total decimal(10,3) DEFAULT '0.00', |
438 | 438 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | PRIMARY KEY (TXN_ID), |
443 | 443 | KEY TXN_timestamp (TXN_timestamp), |
444 | 444 | KEY STS_ID (STS_ID)"; |
445 | - $this->_table_should_exist_previously($table_name, $sql); |
|
445 | + $this->_table_should_exist_previously($table_name, $sql); |
|
446 | 446 | |
447 | - $table_name = 'esp_venue_meta'; |
|
448 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
447 | + $table_name = 'esp_venue_meta'; |
|
448 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
449 | 449 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
450 | 450 | VNU_address varchar(255) DEFAULT NULL, |
451 | 451 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -463,75 +463,75 @@ discard block |
||
463 | 463 | PRIMARY KEY (VNUM_ID), |
464 | 464 | KEY STA_ID (STA_ID), |
465 | 465 | KEY CNT_ISO (CNT_ISO)"; |
466 | - $this->_table_should_exist_previously($table_name, $sql); |
|
467 | - $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
468 | - // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
469 | - // (because many need to convert old string states to foreign keys into the states table) |
|
470 | - $script_with_defaults->insert_default_states(); |
|
471 | - $script_with_defaults->insert_default_countries(); |
|
472 | - // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
473 | - $script_with_defaults->insert_default_price_types(); |
|
474 | - $script_with_defaults->insert_default_prices(); |
|
475 | - // but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's |
|
476 | - $this->insert_default_tickets(); |
|
477 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
478 | - EE_Config::instance()->update_espresso_config(); |
|
479 | - return true; |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - /** |
|
484 | - * @return boolean |
|
485 | - */ |
|
486 | - public function schema_changes_after_migration() |
|
487 | - { |
|
488 | - return true; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - public function migration_page_hooks() |
|
493 | - { |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - /** |
|
498 | - * insert DEFAULT ticket |
|
499 | - * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field |
|
500 | - * |
|
501 | - * @access public |
|
502 | - * @static |
|
503 | - * @return void |
|
504 | - * @throws EE_Error |
|
505 | - */ |
|
506 | - public function insert_default_tickets() |
|
507 | - { |
|
508 | - global $wpdb; |
|
509 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
510 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
511 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
512 | - $tickets_exist = $wpdb->get_var($SQL); |
|
513 | - if (! $tickets_exist) { |
|
514 | - $SQL = "INSERT INTO $ticket_table |
|
466 | + $this->_table_should_exist_previously($table_name, $sql); |
|
467 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
468 | + // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
469 | + // (because many need to convert old string states to foreign keys into the states table) |
|
470 | + $script_with_defaults->insert_default_states(); |
|
471 | + $script_with_defaults->insert_default_countries(); |
|
472 | + // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
473 | + $script_with_defaults->insert_default_price_types(); |
|
474 | + $script_with_defaults->insert_default_prices(); |
|
475 | + // but the schema on the tickets table has changed since 4.1, so use our DEFAULT ticket method instead of 4.1's |
|
476 | + $this->insert_default_tickets(); |
|
477 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
478 | + EE_Config::instance()->update_espresso_config(); |
|
479 | + return true; |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + /** |
|
484 | + * @return boolean |
|
485 | + */ |
|
486 | + public function schema_changes_after_migration() |
|
487 | + { |
|
488 | + return true; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + public function migration_page_hooks() |
|
493 | + { |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + /** |
|
498 | + * insert DEFAULT ticket |
|
499 | + * Almost identical to EE_DMS_Core_4_1_0::insert_default_tickets, except is aware of the TKT_required field |
|
500 | + * |
|
501 | + * @access public |
|
502 | + * @static |
|
503 | + * @return void |
|
504 | + * @throws EE_Error |
|
505 | + */ |
|
506 | + public function insert_default_tickets() |
|
507 | + { |
|
508 | + global $wpdb; |
|
509 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
510 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
511 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
512 | + $tickets_exist = $wpdb->get_var($SQL); |
|
513 | + if (! $tickets_exist) { |
|
514 | + $SQL = "INSERT INTO $ticket_table |
|
515 | 515 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
516 | 516 | ( 1, 0, '" . |
517 | - esc_html__("Free Ticket", "event_espresso") . |
|
518 | - "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
519 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
520 | - $wpdb->query($SQL); |
|
521 | - } |
|
522 | - } |
|
523 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
524 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
525 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
526 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
527 | - if (! $ticket_prc_exist) { |
|
528 | - $SQL = "INSERT INTO $ticket_price_table |
|
517 | + esc_html__("Free Ticket", "event_espresso") . |
|
518 | + "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
|
519 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
|
520 | + $wpdb->query($SQL); |
|
521 | + } |
|
522 | + } |
|
523 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
524 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
525 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
526 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
527 | + if (! $ticket_prc_exist) { |
|
528 | + $SQL = "INSERT INTO $ticket_price_table |
|
529 | 529 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
530 | 530 | ( 1, 1, 1 ) |
531 | 531 | "; |
532 | - $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
533 | - $wpdb->query($SQL); |
|
534 | - } |
|
535 | - } |
|
536 | - } |
|
532 | + $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
533 | + $wpdb->query($SQL); |
|
534 | + } |
|
535 | + } |
|
536 | + } |
|
537 | 537 | } |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | // unfortunately, this needs to be done upon INCLUSION of this file, |
8 | 8 | // instead of construction, because it only gets constructed on first page load |
9 | 9 | // (all other times it gets resurrected from a wordpress option) |
10 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_3_0_stages/*'); |
|
10 | +$stages = glob(EE_CORE.'data_migration_scripts/4_3_0_stages/*'); |
|
11 | 11 | $class_to_filepath = []; |
12 | -if (! empty($stages)) { |
|
12 | +if ( ! empty($stages)) { |
|
13 | 13 | foreach ($stages as $filepath) { |
14 | 14 | $matches = []; |
15 | 15 | preg_match('~4_3_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
16 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | + $class_to_filepath[$matches[1]] = $filepath; |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | ) { |
59 | 59 | // echo "$version_string can be migrated fro"; |
60 | 60 | return true; |
61 | - } elseif (! $version_string) { |
|
61 | + } elseif ( ! $version_string) { |
|
62 | 62 | // echo "no version string provided: $version_string"; |
63 | 63 | // no version string provided... this must be pre 4.2 |
64 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
64 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
65 | 65 | } else { |
66 | 66 | // echo "$version_string doesnt apply"; |
67 | 67 | return false; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | public function schema_changes_before_migration() |
77 | 77 | { |
78 | 78 | // relies on 4.1's EEH_Activation::create_table |
79 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
79 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
80 | 80 | |
81 | 81 | $table_name = 'esp_answer'; |
82 | 82 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -506,25 +506,25 @@ discard block |
||
506 | 506 | public function insert_default_tickets() |
507 | 507 | { |
508 | 508 | global $wpdb; |
509 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
509 | + $ticket_table = $wpdb->prefix."esp_ticket"; |
|
510 | 510 | if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
511 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
511 | + $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table; |
|
512 | 512 | $tickets_exist = $wpdb->get_var($SQL); |
513 | - if (! $tickets_exist) { |
|
513 | + if ( ! $tickets_exist) { |
|
514 | 514 | $SQL = "INSERT INTO $ticket_table |
515 | 515 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES |
516 | - ( 1, 0, '" . |
|
517 | - esc_html__("Free Ticket", "event_espresso") . |
|
516 | + ( 1, 0, '". |
|
517 | + esc_html__("Free Ticket", "event_espresso"). |
|
518 | 518 | "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);"; |
519 | 519 | $SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL); |
520 | 520 | $wpdb->query($SQL); |
521 | 521 | } |
522 | 522 | } |
523 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
523 | + $ticket_price_table = $wpdb->prefix."esp_ticket_price"; |
|
524 | 524 | if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
525 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
525 | + $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table; |
|
526 | 526 | $ticket_prc_exist = $wpdb->get_var($SQL); |
527 | - if (! $ticket_prc_exist) { |
|
527 | + if ( ! $ticket_prc_exist) { |
|
528 | 528 | $SQL = "INSERT INTO $ticket_price_table |
529 | 529 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
530 | 530 | ( 1, 1, 1 ) |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = []; |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = []; |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
15 | + $matches = []; |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,73 +33,73 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager|null $table_manager |
|
40 | - * @param TableAnalysis|null $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = [ |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ]; |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Whether to migrate or not. |
|
56 | - * |
|
57 | - * @param array $version_array |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - public function can_migrate_from_version($version_array) |
|
61 | - { |
|
62 | - $version_string = $version_array['Core']; |
|
63 | - if ( |
|
64 | - version_compare($version_string, '4.9.0.decaf', '<') && |
|
65 | - version_compare($version_string, '4.8.0.decaf', '>=') |
|
66 | - ) { |
|
67 | - // echo "$version_string can be migrated from"; |
|
68 | - return true; |
|
69 | - } elseif (! $version_string) { |
|
70 | - // echo "no version string provided: $version_string"; |
|
71 | - // no version string provided... this must be pre 4.3 |
|
72 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
73 | - } else { |
|
74 | - // echo "$version_string doesnt apply"; |
|
75 | - return false; |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return bool |
|
82 | - * @throws EE_Error |
|
83 | - * @throws ReflectionException |
|
84 | - */ |
|
85 | - public function schema_changes_before_migration() |
|
86 | - { |
|
87 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
88 | - $now_in_mysql = current_time('mysql', true); |
|
89 | - |
|
90 | - $table_name = 'esp_answer'; |
|
91 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager|null $table_manager |
|
40 | + * @param TableAnalysis|null $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = [ |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ]; |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Whether to migrate or not. |
|
56 | + * |
|
57 | + * @param array $version_array |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + public function can_migrate_from_version($version_array) |
|
61 | + { |
|
62 | + $version_string = $version_array['Core']; |
|
63 | + if ( |
|
64 | + version_compare($version_string, '4.9.0.decaf', '<') && |
|
65 | + version_compare($version_string, '4.8.0.decaf', '>=') |
|
66 | + ) { |
|
67 | + // echo "$version_string can be migrated from"; |
|
68 | + return true; |
|
69 | + } elseif (! $version_string) { |
|
70 | + // echo "no version string provided: $version_string"; |
|
71 | + // no version string provided... this must be pre 4.3 |
|
72 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
73 | + } else { |
|
74 | + // echo "$version_string doesnt apply"; |
|
75 | + return false; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return bool |
|
82 | + * @throws EE_Error |
|
83 | + * @throws ReflectionException |
|
84 | + */ |
|
85 | + public function schema_changes_before_migration() |
|
86 | + { |
|
87 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
88 | + $now_in_mysql = current_time('mysql', true); |
|
89 | + |
|
90 | + $table_name = 'esp_answer'; |
|
91 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
92 | 92 | REG_ID int(10) unsigned NOT NULL, |
93 | 93 | QST_ID int(10) unsigned NOT NULL, |
94 | 94 | ANS_value text NOT NULL, |
95 | 95 | PRIMARY KEY (ANS_ID), |
96 | 96 | KEY REG_ID (REG_ID), |
97 | 97 | KEY QST_ID (QST_ID)"; |
98 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
98 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
99 | 99 | |
100 | - $table_name = 'esp_attendee_meta'; |
|
101 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
102 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
100 | + $table_name = 'esp_attendee_meta'; |
|
101 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
102 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
103 | 103 | ATT_ID bigint(20) unsigned NOT NULL, |
104 | 104 | ATT_fname varchar(45) NOT NULL, |
105 | 105 | ATT_lname varchar(45) NOT NULL, |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | KEY ATT_email (ATT_email(191)), |
117 | 117 | KEY ATT_lname (ATT_lname), |
118 | 118 | KEY ATT_fname (ATT_fname)"; |
119 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
119 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
120 | 120 | |
121 | - $table_name = 'esp_checkin'; |
|
122 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
121 | + $table_name = 'esp_checkin'; |
|
122 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
123 | 123 | REG_ID int(10) unsigned NOT NULL, |
124 | 124 | DTT_ID int(10) unsigned NOT NULL, |
125 | 125 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | PRIMARY KEY (CHK_ID), |
128 | 128 | KEY REG_ID (REG_ID), |
129 | 129 | KEY DTT_ID (DTT_ID)"; |
130 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
130 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
131 | 131 | |
132 | - $table_name = 'esp_country'; |
|
133 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
132 | + $table_name = 'esp_country'; |
|
133 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
134 | 134 | CNT_ISO3 varchar(3) NOT NULL, |
135 | 135 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
136 | 136 | CNT_name varchar(45) NOT NULL, |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | CNT_is_EU tinyint(1) DEFAULT '0', |
147 | 147 | CNT_active tinyint(1) DEFAULT '0', |
148 | 148 | PRIMARY KEY (CNT_ISO)"; |
149 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
149 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
150 | 150 | |
151 | - $table_name = 'esp_currency'; |
|
152 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
151 | + $table_name = 'esp_currency'; |
|
152 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
153 | 153 | CUR_single varchar(45) DEFAULT 'dollar', |
154 | 154 | CUR_plural varchar(45) DEFAULT 'dollars', |
155 | 155 | CUR_sign varchar(45) DEFAULT '$', |
156 | 156 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
157 | 157 | CUR_active tinyint(1) DEFAULT '0', |
158 | 158 | PRIMARY KEY (CUR_code)"; |
159 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
159 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
160 | 160 | |
161 | - $table_name = 'esp_datetime'; |
|
162 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
161 | + $table_name = 'esp_datetime'; |
|
162 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
163 | 163 | EVT_ID bigint(20) unsigned NOT NULL, |
164 | 164 | DTT_name varchar(255) NOT NULL DEFAULT '', |
165 | 165 | DTT_description text NOT NULL, |
@@ -176,28 +176,28 @@ discard block |
||
176 | 176 | KEY DTT_EVT_start (DTT_EVT_start), |
177 | 177 | KEY EVT_ID (EVT_ID), |
178 | 178 | KEY DTT_is_primary (DTT_is_primary)"; |
179 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
179 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
180 | 180 | |
181 | - $table_name = "esp_datetime_ticket"; |
|
182 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
181 | + $table_name = "esp_datetime_ticket"; |
|
182 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
183 | 183 | DTT_ID int(10) unsigned NOT NULL, |
184 | 184 | TKT_ID int(10) unsigned NOT NULL, |
185 | 185 | PRIMARY KEY (DTK_ID), |
186 | 186 | KEY DTT_ID (DTT_ID), |
187 | 187 | KEY TKT_ID (TKT_ID)"; |
188 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
188 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
189 | 189 | |
190 | - $table_name = 'esp_event_message_template'; |
|
191 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
190 | + $table_name = 'esp_event_message_template'; |
|
191 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
192 | 192 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
193 | 193 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
194 | 194 | PRIMARY KEY (EMT_ID), |
195 | 195 | KEY EVT_ID (EVT_ID), |
196 | 196 | KEY GRP_ID (GRP_ID)"; |
197 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
197 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
198 | 198 | |
199 | - $table_name = 'esp_event_meta'; |
|
200 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
199 | + $table_name = 'esp_event_meta'; |
|
200 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
201 | 201 | EVT_ID bigint(20) unsigned NOT NULL, |
202 | 202 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
203 | 203 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -212,38 +212,38 @@ discard block |
||
212 | 212 | EVT_donations tinyint(1) NULL, |
213 | 213 | PRIMARY KEY (EVTM_ID), |
214 | 214 | KEY EVT_ID (EVT_ID)"; |
215 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
215 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
216 | 216 | |
217 | - $table_name = 'esp_event_question_group'; |
|
218 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
217 | + $table_name = 'esp_event_question_group'; |
|
218 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
219 | 219 | EVT_ID bigint(20) unsigned NOT NULL, |
220 | 220 | QSG_ID int(10) unsigned NOT NULL, |
221 | 221 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
222 | 222 | PRIMARY KEY (EQG_ID), |
223 | 223 | KEY EVT_ID (EVT_ID), |
224 | 224 | KEY QSG_ID (QSG_ID)"; |
225 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
225 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
226 | 226 | |
227 | - $table_name = 'esp_event_venue'; |
|
228 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
227 | + $table_name = 'esp_event_venue'; |
|
228 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
229 | 229 | EVT_ID bigint(20) unsigned NOT NULL, |
230 | 230 | VNU_ID bigint(20) unsigned NOT NULL, |
231 | 231 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
232 | 232 | PRIMARY KEY (EVV_ID)"; |
233 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
233 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
234 | 234 | |
235 | - $table_name = 'esp_extra_meta'; |
|
236 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
235 | + $table_name = 'esp_extra_meta'; |
|
236 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
237 | 237 | OBJ_ID int(11) DEFAULT NULL, |
238 | 238 | EXM_type varchar(45) DEFAULT NULL, |
239 | 239 | EXM_key varchar(45) DEFAULT NULL, |
240 | 240 | EXM_value text, |
241 | 241 | PRIMARY KEY (EXM_ID), |
242 | 242 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
243 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
243 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
244 | 244 | |
245 | - $table_name = 'esp_extra_join'; |
|
246 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
245 | + $table_name = 'esp_extra_join'; |
|
246 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
247 | 247 | EXJ_first_model_id varchar(6) NOT NULL, |
248 | 248 | EXJ_first_model_name varchar(20) NOT NULL, |
249 | 249 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -251,10 +251,10 @@ discard block |
||
251 | 251 | PRIMARY KEY (EXJ_ID), |
252 | 252 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
253 | 253 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
254 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
254 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
255 | 255 | |
256 | - $table_name = 'esp_line_item'; |
|
257 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
256 | + $table_name = 'esp_line_item'; |
|
257 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
258 | 258 | LIN_code varchar(245) NOT NULL DEFAULT '', |
259 | 259 | TXN_ID int(11) DEFAULT NULL, |
260 | 260 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
276 | 276 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
277 | 277 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
278 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
279 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
280 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
278 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
279 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
280 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
281 | 281 | |
282 | - $table_name = 'esp_log'; |
|
283 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
282 | + $table_name = 'esp_log'; |
|
283 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
284 | 284 | LOG_time datetime DEFAULT NULL, |
285 | 285 | OBJ_ID varchar(45) DEFAULT NULL, |
286 | 286 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | KEY LOG_time (LOG_time), |
292 | 292 | KEY OBJ (OBJ_type,OBJ_ID), |
293 | 293 | KEY LOG_type (LOG_type)"; |
294 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
294 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
295 | 295 | |
296 | - $table_name = 'esp_message'; |
|
297 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
298 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
299 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
300 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
296 | + $table_name = 'esp_message'; |
|
297 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
298 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
299 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
300 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
301 | 301 | GRP_ID int(10) unsigned NULL, |
302 | 302 | MSG_token varchar(255) NULL, |
303 | 303 | TXN_ID int(10) unsigned NULL, |
@@ -329,20 +329,20 @@ discard block |
||
329 | 329 | KEY STS_ID (STS_ID), |
330 | 330 | KEY MSG_created (MSG_created), |
331 | 331 | KEY MSG_modified (MSG_modified)"; |
332 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
332 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
333 | 333 | |
334 | - $table_name = 'esp_message_template'; |
|
335 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
334 | + $table_name = 'esp_message_template'; |
|
335 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
336 | 336 | GRP_ID int(10) unsigned NOT NULL, |
337 | 337 | MTP_context varchar(50) NOT NULL, |
338 | 338 | MTP_template_field varchar(30) NOT NULL, |
339 | 339 | MTP_content text NOT NULL, |
340 | 340 | PRIMARY KEY (MTP_ID), |
341 | 341 | KEY GRP_ID (GRP_ID)"; |
342 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
342 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
343 | 343 | |
344 | - $table_name = 'esp_message_template_group'; |
|
345 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
344 | + $table_name = 'esp_message_template_group'; |
|
345 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
346 | 346 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
347 | 347 | MTP_name varchar(245) NOT NULL DEFAULT '', |
348 | 348 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
355 | 355 | PRIMARY KEY (GRP_ID), |
356 | 356 | KEY MTP_user_id (MTP_user_id)"; |
357 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
357 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
358 | 358 | |
359 | - $table_name = 'esp_payment'; |
|
360 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
359 | + $table_name = 'esp_payment'; |
|
360 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
361 | 361 | TXN_ID int(10) unsigned DEFAULT NULL, |
362 | 362 | STS_ID varchar(3) DEFAULT NULL, |
363 | 363 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | PRIMARY KEY (PAY_ID), |
375 | 375 | KEY PAY_timestamp (PAY_timestamp), |
376 | 376 | KEY TXN_ID (TXN_ID)"; |
377 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
377 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
378 | 378 | |
379 | - $table_name = 'esp_payment_method'; |
|
380 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
379 | + $table_name = 'esp_payment_method'; |
|
380 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
381 | 381 | PMD_type varchar(124) DEFAULT NULL, |
382 | 382 | PMD_name varchar(255) DEFAULT NULL, |
383 | 383 | PMD_desc text, |
@@ -393,27 +393,27 @@ discard block |
||
393 | 393 | PRIMARY KEY (PMD_ID), |
394 | 394 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
395 | 395 | KEY PMD_type (PMD_type)"; |
396 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
396 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
397 | 397 | |
398 | - $table_name = "esp_ticket_price"; |
|
399 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
398 | + $table_name = "esp_ticket_price"; |
|
399 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
400 | 400 | TKT_ID int(10) unsigned NOT NULL, |
401 | 401 | PRC_ID int(10) unsigned NOT NULL, |
402 | 402 | PRIMARY KEY (TKP_ID), |
403 | 403 | KEY TKT_ID (TKT_ID), |
404 | 404 | KEY PRC_ID (PRC_ID)"; |
405 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
405 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
406 | 406 | |
407 | - $table_name = "esp_ticket_template"; |
|
408 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
407 | + $table_name = "esp_ticket_template"; |
|
408 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
409 | 409 | TTM_name varchar(45) NOT NULL, |
410 | 410 | TTM_description text, |
411 | 411 | TTM_file varchar(45), |
412 | 412 | PRIMARY KEY (TTM_ID)"; |
413 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
413 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
414 | 414 | |
415 | - $table_name = 'esp_question'; |
|
416 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
415 | + $table_name = 'esp_question'; |
|
416 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
417 | 417 | QST_display_text text NOT NULL, |
418 | 418 | QST_admin_label varchar(255) NOT NULL, |
419 | 419 | QST_system varchar(25) DEFAULT NULL, |
@@ -427,20 +427,20 @@ discard block |
||
427 | 427 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
428 | 428 | PRIMARY KEY (QST_ID), |
429 | 429 | KEY QST_order (QST_order)'; |
430 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
430 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
431 | 431 | |
432 | - $table_name = 'esp_question_group_question'; |
|
433 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $table_name = 'esp_question_group_question'; |
|
433 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
434 | 434 | QSG_ID int(10) unsigned NOT NULL, |
435 | 435 | QST_ID int(10) unsigned NOT NULL, |
436 | 436 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
437 | 437 | PRIMARY KEY (QGQ_ID), |
438 | 438 | KEY QST_ID (QST_ID), |
439 | 439 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
440 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
440 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
441 | 441 | |
442 | - $table_name = 'esp_question_option'; |
|
443 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
442 | + $table_name = 'esp_question_option'; |
|
443 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
444 | 444 | QSO_value varchar(255) NOT NULL, |
445 | 445 | QSO_desc text NOT NULL, |
446 | 446 | QST_ID int(10) unsigned NOT NULL, |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | PRIMARY KEY (QSO_ID), |
451 | 451 | KEY QST_ID (QST_ID), |
452 | 452 | KEY QSO_order (QSO_order)"; |
453 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
453 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
454 | 454 | |
455 | - $table_name = 'esp_registration'; |
|
456 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
455 | + $table_name = 'esp_registration'; |
|
456 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
457 | 457 | EVT_ID bigint(20) unsigned NOT NULL, |
458 | 458 | ATT_ID bigint(20) unsigned NOT NULL, |
459 | 459 | TXN_ID int(10) unsigned NOT NULL, |
@@ -477,20 +477,20 @@ discard block |
||
477 | 477 | KEY TKT_ID (TKT_ID), |
478 | 478 | KEY EVT_ID (EVT_ID), |
479 | 479 | KEY STS_ID (STS_ID)"; |
480 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
480 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
481 | 481 | |
482 | - $table_name = 'esp_registration_payment'; |
|
483 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
482 | + $table_name = 'esp_registration_payment'; |
|
483 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
484 | 484 | REG_ID int(10) unsigned NOT NULL, |
485 | 485 | PAY_ID int(10) unsigned NULL, |
486 | 486 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
487 | 487 | PRIMARY KEY (RPY_ID), |
488 | 488 | KEY REG_ID (REG_ID), |
489 | 489 | KEY PAY_ID (PAY_ID)"; |
490 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
490 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
491 | 491 | |
492 | - $table_name = 'esp_state'; |
|
493 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
492 | + $table_name = 'esp_state'; |
|
493 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
494 | 494 | CNT_ISO varchar(2) NOT NULL, |
495 | 495 | STA_abbrev varchar(24) NOT NULL, |
496 | 496 | STA_name varchar(100) NOT NULL, |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | PRIMARY KEY (STA_ID), |
499 | 499 | KEY STA_abbrev (STA_abbrev), |
500 | 500 | KEY CNT_ISO (CNT_ISO)"; |
501 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
501 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
502 | 502 | |
503 | - $table_name = 'esp_status'; |
|
504 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
503 | + $table_name = 'esp_status'; |
|
504 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
505 | 505 | STS_code varchar(45) NOT NULL, |
506 | 506 | STS_type varchar(45) NOT NULL, |
507 | 507 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -509,10 +509,10 @@ discard block |
||
509 | 509 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
510 | 510 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
511 | 511 | KEY STS_type (STS_type)"; |
512 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
512 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
513 | 513 | |
514 | - $table_name = 'esp_transaction'; |
|
515 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
514 | + $table_name = 'esp_transaction'; |
|
515 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
516 | 516 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
517 | 517 | TXN_total decimal(12,3) DEFAULT '0.00', |
518 | 518 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -524,10 +524,10 @@ discard block |
||
524 | 524 | PRIMARY KEY (TXN_ID), |
525 | 525 | KEY TXN_timestamp (TXN_timestamp), |
526 | 526 | KEY STS_ID (STS_ID)"; |
527 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
527 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
528 | 528 | |
529 | - $table_name = 'esp_venue_meta'; |
|
530 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
529 | + $table_name = 'esp_venue_meta'; |
|
530 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
531 | 531 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
532 | 532 | VNU_address varchar(255) DEFAULT NULL, |
533 | 533 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -546,10 +546,10 @@ discard block |
||
546 | 546 | KEY VNU_ID (VNU_ID), |
547 | 547 | KEY STA_ID (STA_ID), |
548 | 548 | KEY CNT_ISO (CNT_ISO)"; |
549 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
550 | - // modified tables |
|
551 | - $table_name = "esp_price"; |
|
552 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
549 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
550 | + // modified tables |
|
551 | + $table_name = "esp_price"; |
|
552 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
553 | 553 | PRT_ID tinyint(3) unsigned NOT NULL, |
554 | 554 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
555 | 555 | PRC_name varchar(245) NOT NULL, |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | PRC_parent int(10) unsigned DEFAULT 0, |
563 | 563 | PRIMARY KEY (PRC_ID), |
564 | 564 | KEY PRT_ID (PRT_ID)"; |
565 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
565 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
566 | 566 | |
567 | - $table_name = "esp_price_type"; |
|
568 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
567 | + $table_name = "esp_price_type"; |
|
568 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
569 | 569 | PRT_name varchar(45) NOT NULL, |
570 | 570 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
571 | 571 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -574,10 +574,10 @@ discard block |
||
574 | 574 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
575 | 575 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
576 | 576 | PRIMARY KEY (PRT_ID)"; |
577 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
577 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
578 | 578 | |
579 | - $table_name = "esp_ticket"; |
|
580 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
579 | + $table_name = "esp_ticket"; |
|
580 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
581 | 581 | TTM_ID int(10) unsigned NOT NULL, |
582 | 582 | TKT_name varchar(245) NOT NULL DEFAULT '', |
583 | 583 | TKT_description text NOT NULL, |
@@ -600,10 +600,10 @@ discard block |
||
600 | 600 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
601 | 601 | PRIMARY KEY (TKT_ID), |
602 | 602 | KEY TKT_start_date (TKT_start_date)"; |
603 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
603 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
604 | 604 | |
605 | - $table_name = 'esp_question_group'; |
|
606 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
605 | + $table_name = 'esp_question_group'; |
|
606 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
607 | 607 | QSG_name varchar(255) NOT NULL, |
608 | 608 | QSG_identifier varchar(100) NOT NULL, |
609 | 609 | QSG_desc text NULL, |
@@ -616,169 +616,169 @@ discard block |
||
616 | 616 | PRIMARY KEY (QSG_ID), |
617 | 617 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
618 | 618 | KEY QSG_order (QSG_order)'; |
619 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
620 | - $this->insert_default_data(); |
|
621 | - return true; |
|
622 | - } |
|
623 | - |
|
624 | - |
|
625 | - /** |
|
626 | - * Inserts default data after parent was called. |
|
627 | - * |
|
628 | - * @throws EE_Error |
|
629 | - * @throws InvalidArgumentException |
|
630 | - * @throws ReflectionException |
|
631 | - * @throws InvalidDataTypeException |
|
632 | - * @throws InvalidInterfaceException |
|
633 | - * @since 4.10.0.p |
|
634 | - */ |
|
635 | - public function insert_default_data() |
|
636 | - { |
|
637 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
638 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
639 | - // (because many need to convert old string states to foreign keys into the states table) |
|
640 | - $script_4_1_defaults->insert_default_states(); |
|
641 | - $script_4_1_defaults->insert_default_countries(); |
|
642 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
643 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
644 | - $script_4_5_defaults->insert_default_price_types(); |
|
645 | - $script_4_5_defaults->insert_default_prices(); |
|
646 | - $script_4_5_defaults->insert_default_tickets(); |
|
647 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
648 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
649 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
650 | - $script_4_6_defaults->insert_default_currencies(); |
|
651 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
652 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
653 | - $script_4_8_defaults->verify_new_countries(); |
|
654 | - $script_4_8_defaults->verify_new_currencies(); |
|
655 | - $this->verify_db_collations(); |
|
656 | - $this->verify_db_collations_again(); |
|
657 | - } |
|
658 | - |
|
659 | - |
|
660 | - /** |
|
661 | - * @return boolean |
|
662 | - */ |
|
663 | - public function schema_changes_after_migration() |
|
664 | - { |
|
665 | - return true; |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - public function migration_page_hooks() |
|
670 | - { |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - /** |
|
675 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
676 | - * |
|
677 | - * @return void |
|
678 | - */ |
|
679 | - public function verify_db_collations() |
|
680 | - { |
|
681 | - global $wpdb; |
|
682 | - // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
683 | - if ( |
|
684 | - 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations', false) |
|
685 | - ) { |
|
686 | - return; |
|
687 | - } |
|
688 | - // grab tables from each model |
|
689 | - $tables_to_check = []; |
|
690 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
691 | - if (method_exists($model_name, 'instance')) { |
|
692 | - $model_obj = call_user_func([$model_name, 'instance']); |
|
693 | - if ($model_obj instanceof EEM_Base) { |
|
694 | - foreach ($model_obj->get_tables() as $table) { |
|
695 | - if ( |
|
696 | - strpos($table->get_table_name(), 'esp_') && |
|
697 | - (is_main_site() |
|
698 | - // for main tables, verify global tables |
|
699 | - || |
|
700 | - ! $table->is_global( |
|
701 | - )// if not the main site, then only verify non-global tables (avoid doubling up) |
|
702 | - ) && |
|
703 | - function_exists('maybe_convert_table_to_utf8mb4') |
|
704 | - ) { |
|
705 | - $tables_to_check[] = $table->get_table_name(); |
|
706 | - } |
|
707 | - } |
|
708 | - } |
|
709 | - } |
|
710 | - } |
|
711 | - // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
712 | - // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
713 | - // of hard-coding this |
|
714 | - $addon_tables = [ |
|
715 | - // mailchimp |
|
716 | - 'esp_event_mailchimp_list_group', |
|
717 | - 'esp_event_question_mailchimp_field', |
|
718 | - // multisite |
|
719 | - 'esp_blog_meta', |
|
720 | - // people |
|
721 | - 'esp_people_to_post', |
|
722 | - // promotions |
|
723 | - 'esp_promotion', |
|
724 | - 'esp_promotion_object', |
|
725 | - ]; |
|
726 | - foreach ($addon_tables as $table_name) { |
|
727 | - $tables_to_check[] = $table_name; |
|
728 | - } |
|
729 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
730 | - // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
731 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
732 | - // seeing how this ran with the fix from 10435, no need to check again |
|
733 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
734 | - } |
|
735 | - |
|
736 | - |
|
737 | - /** |
|
738 | - * Verifies DB collations because a bug was discovered on |
|
739 | - * https://events.codebasehq.com/projects/event-espresso/tickets/10435 which meant some DB collations might not |
|
740 | - * have been updated |
|
741 | - * |
|
742 | - * @return void |
|
743 | - */ |
|
744 | - public function verify_db_collations_again() |
|
745 | - { |
|
746 | - global $wpdb; |
|
747 | - // double-check we haven't already done this or that the DB doesn't support it |
|
748 | - // compare to how WordPress' upgrade_430() function does this check |
|
749 | - if ( |
|
750 | - 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations_again', false) |
|
751 | - ) { |
|
752 | - return; |
|
753 | - } |
|
754 | - $tables_to_check = [ |
|
755 | - 'esp_attendee_meta', |
|
756 | - 'esp_message', |
|
757 | - ]; |
|
758 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
759 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - /** |
|
764 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
765 | - * |
|
766 | - * @param $tables_to_check |
|
767 | - * @return boolean true if logic ran, false if it didn't |
|
768 | - */ |
|
769 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
770 | - { |
|
771 | - foreach ($tables_to_check as $table_name) { |
|
772 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
773 | - if ( |
|
774 | - ! apply_filters( |
|
775 | - 'FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', |
|
776 | - false, |
|
777 | - $table_name |
|
778 | - ) && $this->_get_table_analysis()->tableExists($table_name) |
|
779 | - ) { |
|
780 | - maybe_convert_table_to_utf8mb4($table_name); |
|
781 | - } |
|
782 | - } |
|
783 | - } |
|
619 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
620 | + $this->insert_default_data(); |
|
621 | + return true; |
|
622 | + } |
|
623 | + |
|
624 | + |
|
625 | + /** |
|
626 | + * Inserts default data after parent was called. |
|
627 | + * |
|
628 | + * @throws EE_Error |
|
629 | + * @throws InvalidArgumentException |
|
630 | + * @throws ReflectionException |
|
631 | + * @throws InvalidDataTypeException |
|
632 | + * @throws InvalidInterfaceException |
|
633 | + * @since 4.10.0.p |
|
634 | + */ |
|
635 | + public function insert_default_data() |
|
636 | + { |
|
637 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
638 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
639 | + // (because many need to convert old string states to foreign keys into the states table) |
|
640 | + $script_4_1_defaults->insert_default_states(); |
|
641 | + $script_4_1_defaults->insert_default_countries(); |
|
642 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
643 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
644 | + $script_4_5_defaults->insert_default_price_types(); |
|
645 | + $script_4_5_defaults->insert_default_prices(); |
|
646 | + $script_4_5_defaults->insert_default_tickets(); |
|
647 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
648 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
649 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
650 | + $script_4_6_defaults->insert_default_currencies(); |
|
651 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
652 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
653 | + $script_4_8_defaults->verify_new_countries(); |
|
654 | + $script_4_8_defaults->verify_new_currencies(); |
|
655 | + $this->verify_db_collations(); |
|
656 | + $this->verify_db_collations_again(); |
|
657 | + } |
|
658 | + |
|
659 | + |
|
660 | + /** |
|
661 | + * @return boolean |
|
662 | + */ |
|
663 | + public function schema_changes_after_migration() |
|
664 | + { |
|
665 | + return true; |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + public function migration_page_hooks() |
|
670 | + { |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + /** |
|
675 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
676 | + * |
|
677 | + * @return void |
|
678 | + */ |
|
679 | + public function verify_db_collations() |
|
680 | + { |
|
681 | + global $wpdb; |
|
682 | + // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
683 | + if ( |
|
684 | + 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations', false) |
|
685 | + ) { |
|
686 | + return; |
|
687 | + } |
|
688 | + // grab tables from each model |
|
689 | + $tables_to_check = []; |
|
690 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
691 | + if (method_exists($model_name, 'instance')) { |
|
692 | + $model_obj = call_user_func([$model_name, 'instance']); |
|
693 | + if ($model_obj instanceof EEM_Base) { |
|
694 | + foreach ($model_obj->get_tables() as $table) { |
|
695 | + if ( |
|
696 | + strpos($table->get_table_name(), 'esp_') && |
|
697 | + (is_main_site() |
|
698 | + // for main tables, verify global tables |
|
699 | + || |
|
700 | + ! $table->is_global( |
|
701 | + )// if not the main site, then only verify non-global tables (avoid doubling up) |
|
702 | + ) && |
|
703 | + function_exists('maybe_convert_table_to_utf8mb4') |
|
704 | + ) { |
|
705 | + $tables_to_check[] = $table->get_table_name(); |
|
706 | + } |
|
707 | + } |
|
708 | + } |
|
709 | + } |
|
710 | + } |
|
711 | + // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
712 | + // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
713 | + // of hard-coding this |
|
714 | + $addon_tables = [ |
|
715 | + // mailchimp |
|
716 | + 'esp_event_mailchimp_list_group', |
|
717 | + 'esp_event_question_mailchimp_field', |
|
718 | + // multisite |
|
719 | + 'esp_blog_meta', |
|
720 | + // people |
|
721 | + 'esp_people_to_post', |
|
722 | + // promotions |
|
723 | + 'esp_promotion', |
|
724 | + 'esp_promotion_object', |
|
725 | + ]; |
|
726 | + foreach ($addon_tables as $table_name) { |
|
727 | + $tables_to_check[] = $table_name; |
|
728 | + } |
|
729 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
730 | + // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
731 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
732 | + // seeing how this ran with the fix from 10435, no need to check again |
|
733 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
734 | + } |
|
735 | + |
|
736 | + |
|
737 | + /** |
|
738 | + * Verifies DB collations because a bug was discovered on |
|
739 | + * https://events.codebasehq.com/projects/event-espresso/tickets/10435 which meant some DB collations might not |
|
740 | + * have been updated |
|
741 | + * |
|
742 | + * @return void |
|
743 | + */ |
|
744 | + public function verify_db_collations_again() |
|
745 | + { |
|
746 | + global $wpdb; |
|
747 | + // double-check we haven't already done this or that the DB doesn't support it |
|
748 | + // compare to how WordPress' upgrade_430() function does this check |
|
749 | + if ( |
|
750 | + 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations_again', false) |
|
751 | + ) { |
|
752 | + return; |
|
753 | + } |
|
754 | + $tables_to_check = [ |
|
755 | + 'esp_attendee_meta', |
|
756 | + 'esp_message', |
|
757 | + ]; |
|
758 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
759 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + /** |
|
764 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
765 | + * |
|
766 | + * @param $tables_to_check |
|
767 | + * @return boolean true if logic ran, false if it didn't |
|
768 | + */ |
|
769 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
770 | + { |
|
771 | + foreach ($tables_to_check as $table_name) { |
|
772 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
773 | + if ( |
|
774 | + ! apply_filters( |
|
775 | + 'FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', |
|
776 | + false, |
|
777 | + $table_name |
|
778 | + ) && $this->_get_table_analysis()->tableExists($table_name) |
|
779 | + ) { |
|
780 | + maybe_convert_table_to_utf8mb4($table_name); |
|
781 | + } |
|
782 | + } |
|
783 | + } |
|
784 | 784 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | // unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | // instead of construction, because it only gets constructed on first page load |
11 | 11 | // (all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
|
12 | +$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
|
13 | 13 | $class_to_filepath = []; |
14 | 14 | foreach ($stages as $filepath) { |
15 | 15 | $matches = []; |
16 | 16 | preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | ) { |
67 | 67 | // echo "$version_string can be migrated from"; |
68 | 68 | return true; |
69 | - } elseif (! $version_string) { |
|
69 | + } elseif ( ! $version_string) { |
|
70 | 70 | // echo "no version string provided: $version_string"; |
71 | 71 | // no version string provided... this must be pre 4.3 |
72 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
72 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
73 | 73 | } else { |
74 | 74 | // echo "$version_string doesnt apply"; |
75 | 75 | return false; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function schema_changes_before_migration() |
86 | 86 | { |
87 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
87 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
88 | 88 | $now_in_mysql = current_time('mysql', true); |
89 | 89 | |
90 | 90 | $table_name = 'esp_answer'; |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | if (! empty($stages)) { |
13 | - foreach ($stages as $filepath) { |
|
14 | - $matches = []; |
|
15 | - preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | - } |
|
13 | + foreach ($stages as $filepath) { |
|
14 | + $matches = []; |
|
15 | + preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
16 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_2_0__autoloaded_stages', $class_to_filepath); |
@@ -33,64 +33,64 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_2_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * EE_DMS_Core_4_2_0 constructor. |
|
38 | - * |
|
39 | - * @param TableManager|null $table_manager |
|
40 | - * @param TableAnalysis|null $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = [ |
|
47 | - new EE_DMS_4_2_0_question_group_questions(), |
|
48 | - new EE_DMS_4_2_0_datetime_fields(), |
|
49 | - ]; |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - public function can_migrate_from_version($version_array) |
|
55 | - { |
|
56 | - $version_string = $version_array['Core']; |
|
57 | - if ( |
|
58 | - version_compare($version_string, '4.2.0.decaf', '<') && |
|
59 | - version_compare($version_string, '4.1.0.decaf', '>=') |
|
60 | - ) { |
|
61 | - // echo "$version_string can be migrated fro"; |
|
62 | - return true; |
|
63 | - } elseif (! $version_string) { |
|
64 | - // echo "no version string provided: $version_string"; |
|
65 | - // no version string provided... this must be pre 4.1 |
|
66 | - // because since 4.1 we're |
|
67 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
68 | - } else { |
|
69 | - // echo "$version_string doesnt apply"; |
|
70 | - return false; |
|
71 | - } |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @throws EE_Error |
|
77 | - * @throws ReflectionException |
|
78 | - */ |
|
79 | - public function schema_changes_before_migration() |
|
80 | - { |
|
81 | - // relies on 4.1's EEH_Activation::create_table |
|
82 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
83 | - |
|
84 | - $table_name = 'esp_answer'; |
|
85 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
36 | + /** |
|
37 | + * EE_DMS_Core_4_2_0 constructor. |
|
38 | + * |
|
39 | + * @param TableManager|null $table_manager |
|
40 | + * @param TableAnalysis|null $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.2.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = [ |
|
47 | + new EE_DMS_4_2_0_question_group_questions(), |
|
48 | + new EE_DMS_4_2_0_datetime_fields(), |
|
49 | + ]; |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + public function can_migrate_from_version($version_array) |
|
55 | + { |
|
56 | + $version_string = $version_array['Core']; |
|
57 | + if ( |
|
58 | + version_compare($version_string, '4.2.0.decaf', '<') && |
|
59 | + version_compare($version_string, '4.1.0.decaf', '>=') |
|
60 | + ) { |
|
61 | + // echo "$version_string can be migrated fro"; |
|
62 | + return true; |
|
63 | + } elseif (! $version_string) { |
|
64 | + // echo "no version string provided: $version_string"; |
|
65 | + // no version string provided... this must be pre 4.1 |
|
66 | + // because since 4.1 we're |
|
67 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
68 | + } else { |
|
69 | + // echo "$version_string doesnt apply"; |
|
70 | + return false; |
|
71 | + } |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @throws EE_Error |
|
77 | + * @throws ReflectionException |
|
78 | + */ |
|
79 | + public function schema_changes_before_migration() |
|
80 | + { |
|
81 | + // relies on 4.1's EEH_Activation::create_table |
|
82 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
83 | + |
|
84 | + $table_name = 'esp_answer'; |
|
85 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
86 | 86 | REG_ID int(10) unsigned NOT NULL, |
87 | 87 | QST_ID int(10) unsigned NOT NULL, |
88 | 88 | ANS_value text NOT NULL, |
89 | 89 | PRIMARY KEY (ANS_ID)"; |
90 | - $this->_table_should_exist_previously($table_name, $sql); |
|
90 | + $this->_table_should_exist_previously($table_name, $sql); |
|
91 | 91 | |
92 | - $table_name = 'esp_attendee_meta'; |
|
93 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
92 | + $table_name = 'esp_attendee_meta'; |
|
93 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | 94 | ATT_ID bigint(20) unsigned NOT NULL, |
95 | 95 | ATT_fname varchar(45) NOT NULL, |
96 | 96 | ATT_lname varchar(45) NOT NULL, |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | KEY ATT_fname (ATT_fname), |
107 | 107 | KEY ATT_lname (ATT_lname), |
108 | 108 | KEY ATT_email (ATT_email(191))"; |
109 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
109 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
110 | 110 | |
111 | - $table_name = 'esp_country'; |
|
112 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
111 | + $table_name = 'esp_country'; |
|
112 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
113 | 113 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
114 | 114 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
115 | 115 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | CNT_is_EU tinyint(1) DEFAULT '0', |
126 | 126 | CNT_active tinyint(1) DEFAULT '0', |
127 | 127 | PRIMARY KEY (CNT_ISO)"; |
128 | - $this->_table_should_exist_previously($table_name, $sql); |
|
128 | + $this->_table_should_exist_previously($table_name, $sql); |
|
129 | 129 | |
130 | - $table_name = 'esp_datetime'; |
|
131 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
130 | + $table_name = 'esp_datetime'; |
|
131 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
132 | 132 | EVT_ID bigint(20) unsigned NOT NULL, |
133 | 133 | DTT_name varchar(255) NOT NULL DEFAULT '', |
134 | 134 | DTT_description text NOT NULL, |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | PRIMARY KEY (DTT_ID), |
144 | 144 | KEY EVT_ID (EVT_ID), |
145 | 145 | KEY DTT_is_primary (DTT_is_primary)"; |
146 | - $this->_table_should_exist_previously($table_name, $sql); |
|
146 | + $this->_table_should_exist_previously($table_name, $sql); |
|
147 | 147 | |
148 | - $table_name = 'esp_event_meta'; |
|
149 | - $sql = " |
|
148 | + $table_name = 'esp_event_meta'; |
|
149 | + $sql = " |
|
150 | 150 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
151 | 151 | EVT_ID bigint(20) unsigned NOT NULL, |
152 | 152 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -161,35 +161,35 @@ discard block |
||
161 | 161 | EVT_external_URL varchar(200) NULL, |
162 | 162 | EVT_donations tinyint(1) NULL, |
163 | 163 | PRIMARY KEY (EVTM_ID)"; |
164 | - $this->_table_should_exist_previously($table_name, $sql); |
|
164 | + $this->_table_should_exist_previously($table_name, $sql); |
|
165 | 165 | |
166 | - $table_name = 'esp_event_question_group'; |
|
167 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
166 | + $table_name = 'esp_event_question_group'; |
|
167 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
168 | 168 | EVT_ID bigint(20) unsigned NOT NULL, |
169 | 169 | QSG_ID int(10) unsigned NOT NULL, |
170 | 170 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
171 | 171 | PRIMARY KEY (EQG_ID)"; |
172 | - $this->_table_should_exist_previously($table_name, $sql); |
|
172 | + $this->_table_should_exist_previously($table_name, $sql); |
|
173 | 173 | |
174 | - $table_name = 'esp_event_venue'; |
|
175 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
174 | + $table_name = 'esp_event_venue'; |
|
175 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
176 | 176 | EVT_ID bigint(20) unsigned NOT NULL, |
177 | 177 | VNU_ID bigint(20) unsigned NOT NULL, |
178 | 178 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
179 | 179 | PRIMARY KEY (EVV_ID)"; |
180 | - $this->_table_should_exist_previously($table_name, $sql); |
|
180 | + $this->_table_should_exist_previously($table_name, $sql); |
|
181 | 181 | |
182 | - $table_name = 'esp_extra_meta'; |
|
183 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
182 | + $table_name = 'esp_extra_meta'; |
|
183 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
184 | 184 | OBJ_ID int(11) DEFAULT NULL, |
185 | 185 | EXM_type varchar(45) DEFAULT NULL, |
186 | 186 | EXM_key varchar(45) DEFAULT NULL, |
187 | 187 | EXM_value text, |
188 | 188 | PRIMARY KEY (EXM_ID)"; |
189 | - $this->_table_should_exist_previously($table_name, $sql); |
|
189 | + $this->_table_should_exist_previously($table_name, $sql); |
|
190 | 190 | |
191 | - $table_name = 'esp_line_item'; |
|
192 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
191 | + $table_name = 'esp_line_item'; |
|
192 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
193 | 193 | LIN_code varchar(245) NOT NULL DEFAULT '', |
194 | 194 | TXN_ID int(11) DEFAULT NULL, |
195 | 195 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -205,20 +205,20 @@ discard block |
||
205 | 205 | OBJ_ID int(11) DEFAULT NULL, |
206 | 206 | OBJ_type varchar(45)DEFAULT NULL, |
207 | 207 | PRIMARY KEY (LIN_ID)"; |
208 | - $this->_table_should_exist_previously($table_name, $sql); |
|
208 | + $this->_table_should_exist_previously($table_name, $sql); |
|
209 | 209 | |
210 | - $table_name = 'esp_message_template'; |
|
211 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
210 | + $table_name = 'esp_message_template'; |
|
211 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
212 | 212 | GRP_ID int(10) unsigned NOT NULL, |
213 | 213 | MTP_context varchar(50) NOT NULL, |
214 | 214 | MTP_template_field varchar(30) NOT NULL, |
215 | 215 | MTP_content text NOT NULL, |
216 | 216 | PRIMARY KEY (MTP_ID), |
217 | 217 | KEY GRP_ID (GRP_ID)"; |
218 | - $this->_table_should_exist_previously($table_name, $sql); |
|
218 | + $this->_table_should_exist_previously($table_name, $sql); |
|
219 | 219 | |
220 | - $table_name = 'esp_message_template_group'; |
|
221 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
220 | + $table_name = 'esp_message_template_group'; |
|
221 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
222 | 222 | EVT_ID bigint(20) unsigned DEFAULT NULL, |
223 | 223 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
224 | 224 | MTP_messenger varchar(30) NOT NULL, |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | PRIMARY KEY (GRP_ID), |
231 | 231 | KEY EVT_ID (EVT_ID), |
232 | 232 | KEY MTP_user_id (MTP_user_id)"; |
233 | - $this->_table_should_exist_previously($table_name, $sql); |
|
233 | + $this->_table_should_exist_previously($table_name, $sql); |
|
234 | 234 | |
235 | - $table_name = 'esp_payment'; |
|
236 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
235 | + $table_name = 'esp_payment'; |
|
236 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
237 | 237 | TXN_ID int(10) unsigned DEFAULT NULL, |
238 | 238 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
239 | 239 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | PRIMARY KEY (PAY_ID), |
250 | 250 | KEY TXN_ID (TXN_ID), |
251 | 251 | KEY PAY_timestamp (PAY_timestamp)"; |
252 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
252 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
253 | 253 | |
254 | - $table_name = "esp_ticket"; |
|
255 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
254 | + $table_name = "esp_ticket"; |
|
255 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
256 | 256 | TTM_ID int(10) unsigned NOT NULL, |
257 | 257 | TKT_name varchar(245) NOT NULL DEFAULT '', |
258 | 258 | TKT_description text NOT NULL, |
@@ -271,32 +271,32 @@ discard block |
||
271 | 271 | TKT_parent int(10) unsigned DEFAULT '0', |
272 | 272 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
273 | 273 | PRIMARY KEY (TKT_ID)"; |
274 | - $this->_table_should_exist_previously($table_name, $sql); |
|
274 | + $this->_table_should_exist_previously($table_name, $sql); |
|
275 | 275 | |
276 | - $table_name = "esp_ticket_price"; |
|
277 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
276 | + $table_name = "esp_ticket_price"; |
|
277 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
278 | 278 | TKT_ID int(10) unsigned NOT NULL, |
279 | 279 | PRC_ID int(10) unsigned NOT NULL, |
280 | 280 | PRIMARY KEY (TKP_ID)"; |
281 | - $this->_table_should_exist_previously($table_name, $sql); |
|
281 | + $this->_table_should_exist_previously($table_name, $sql); |
|
282 | 282 | |
283 | - $table_name = "esp_datetime_ticket"; |
|
284 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
283 | + $table_name = "esp_datetime_ticket"; |
|
284 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
285 | 285 | DTT_ID int(10) unsigned NOT NULL, |
286 | 286 | TKT_ID int(10) unsigned NOT NULL, |
287 | 287 | PRIMARY KEY (DTK_ID)"; |
288 | - $this->_table_should_exist_previously($table_name, $sql); |
|
288 | + $this->_table_should_exist_previously($table_name, $sql); |
|
289 | 289 | |
290 | - $table_name = "esp_ticket_template"; |
|
291 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
290 | + $table_name = "esp_ticket_template"; |
|
291 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
292 | 292 | TTM_name varchar(45) NOT NULL, |
293 | 293 | TTM_description text, |
294 | 294 | TTM_file varchar(45), |
295 | 295 | PRIMARY KEY (TTM_ID)"; |
296 | - $this->_table_should_exist_previously($table_name, $sql); |
|
296 | + $this->_table_should_exist_previously($table_name, $sql); |
|
297 | 297 | |
298 | - $table_name = "esp_price"; |
|
299 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
298 | + $table_name = "esp_price"; |
|
299 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
300 | 300 | PRT_ID tinyint(3) unsigned NOT NULL, |
301 | 301 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
302 | 302 | PRC_name varchar(245) NOT NULL, |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | PRC_order tinyint(3) unsigned NOT NULL DEFAULT '0', |
308 | 308 | PRC_parent int(10) unsigned DEFAULT 0, |
309 | 309 | PRIMARY KEY (PRC_ID)"; |
310 | - $this->_table_should_exist_previously($table_name, $sql); |
|
310 | + $this->_table_should_exist_previously($table_name, $sql); |
|
311 | 311 | |
312 | - $table_name = "esp_price_type"; |
|
313 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
312 | + $table_name = "esp_price_type"; |
|
313 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
314 | 314 | PRT_name varchar(45) NOT NULL, |
315 | 315 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
316 | 316 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
319 | 319 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
320 | 320 | PRIMARY KEY (PRT_ID)"; |
321 | - $this->_table_should_exist_previously($table_name, $sql); |
|
321 | + $this->_table_should_exist_previously($table_name, $sql); |
|
322 | 322 | |
323 | - $table_name = 'esp_question'; |
|
324 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
323 | + $table_name = 'esp_question'; |
|
324 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
325 | 325 | QST_display_text text NOT NULL, |
326 | 326 | QST_admin_label varchar(255) NOT NULL, |
327 | 327 | QST_system varchar(25) DEFAULT NULL, |
@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | QST_wp_user bigint(20) unsigned NULL, |
334 | 334 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
335 | 335 | PRIMARY KEY (QST_ID)'; |
336 | - $this->_table_should_exist_previously($table_name, $sql); |
|
337 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
336 | + $this->_table_should_exist_previously($table_name, $sql); |
|
337 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
338 | 338 | |
339 | - $table_name = 'esp_question_group'; |
|
340 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
339 | + $table_name = 'esp_question_group'; |
|
340 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
341 | 341 | QSG_name varchar(255) NOT NULL, |
342 | 342 | QSG_identifier varchar(100) NOT NULL, |
343 | 343 | QSG_desc text NULL, |
@@ -348,27 +348,27 @@ discard block |
||
348 | 348 | QSG_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
349 | 349 | PRIMARY KEY (QSG_ID), |
350 | 350 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
351 | - $this->_table_should_exist_previously($table_name, $sql); |
|
351 | + $this->_table_should_exist_previously($table_name, $sql); |
|
352 | 352 | |
353 | - $table_name = 'esp_question_group_question'; |
|
354 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
353 | + $table_name = 'esp_question_group_question'; |
|
354 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
355 | 355 | QSG_ID int(10) unsigned NOT NULL, |
356 | 356 | QST_ID int(10) unsigned NOT NULL, |
357 | 357 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
358 | 358 | PRIMARY KEY (QGQ_ID) "; |
359 | - $this->_table_should_exist_previously($table_name, $sql); |
|
359 | + $this->_table_should_exist_previously($table_name, $sql); |
|
360 | 360 | |
361 | - $table_name = 'esp_question_option'; |
|
362 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
361 | + $table_name = 'esp_question_option'; |
|
362 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
363 | 363 | QSO_value varchar(255) NOT NULL, |
364 | 364 | QSO_desc text NOT NULL, |
365 | 365 | QST_ID int(10) unsigned NOT NULL, |
366 | 366 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
367 | 367 | PRIMARY KEY (QSO_ID)"; |
368 | - $this->_table_should_exist_previously($table_name, $sql); |
|
368 | + $this->_table_should_exist_previously($table_name, $sql); |
|
369 | 369 | |
370 | - $table_name = 'esp_registration'; |
|
371 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
370 | + $table_name = 'esp_registration'; |
|
371 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
372 | 372 | EVT_ID bigint(20) unsigned NOT NULL, |
373 | 373 | ATT_ID bigint(20) unsigned NOT NULL, |
374 | 374 | TXN_ID int(10) unsigned NOT NULL, |
@@ -391,28 +391,28 @@ discard block |
||
391 | 391 | KEY STS_ID (STS_ID), |
392 | 392 | KEY REG_url_link (REG_url_link), |
393 | 393 | KEY REG_code (REG_code)"; |
394 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
394 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
395 | 395 | |
396 | - $table_name = 'esp_checkin'; |
|
397 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
396 | + $table_name = 'esp_checkin'; |
|
397 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
398 | 398 | REG_ID int(10) unsigned NOT NULL, |
399 | 399 | DTT_ID int(10) unsigned NOT NULL, |
400 | 400 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
401 | 401 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
402 | 402 | PRIMARY KEY (CHK_ID)"; |
403 | - $this->_table_should_exist_previously($table_name, $sql); |
|
403 | + $this->_table_should_exist_previously($table_name, $sql); |
|
404 | 404 | |
405 | - $table_name = 'esp_state'; |
|
406 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
405 | + $table_name = 'esp_state'; |
|
406 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
407 | 407 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
408 | 408 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
409 | 409 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
410 | 410 | STA_active tinyint(1) DEFAULT '1', |
411 | 411 | PRIMARY KEY (STA_ID)"; |
412 | - $this->_table_should_exist_previously($table_name, $sql); |
|
412 | + $this->_table_should_exist_previously($table_name, $sql); |
|
413 | 413 | |
414 | - $table_name = 'esp_status'; |
|
415 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
414 | + $table_name = 'esp_status'; |
|
415 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
416 | 416 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
417 | 417 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
418 | 418 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -420,10 +420,10 @@ discard block |
||
420 | 420 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
421 | 421 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
422 | 422 | KEY STS_type (STS_type)"; |
423 | - $this->_table_should_exist_previously($table_name, $sql); |
|
423 | + $this->_table_should_exist_previously($table_name, $sql); |
|
424 | 424 | |
425 | - $table_name = 'esp_transaction'; |
|
426 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
425 | + $table_name = 'esp_transaction'; |
|
426 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
427 | 427 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
428 | 428 | TXN_total decimal(10,3) DEFAULT '0.00', |
429 | 429 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -433,10 +433,10 @@ discard block |
||
433 | 433 | PRIMARY KEY (TXN_ID), |
434 | 434 | KEY TXN_timestamp (TXN_timestamp), |
435 | 435 | KEY STS_ID (STS_ID)"; |
436 | - $this->_table_should_exist_previously($table_name, $sql); |
|
436 | + $this->_table_should_exist_previously($table_name, $sql); |
|
437 | 437 | |
438 | - $table_name = 'esp_venue_meta'; |
|
439 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
438 | + $table_name = 'esp_venue_meta'; |
|
439 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
440 | 440 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
441 | 441 | VNU_address varchar(255) DEFAULT NULL, |
442 | 442 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -454,34 +454,34 @@ discard block |
||
454 | 454 | PRIMARY KEY (VNUM_ID), |
455 | 455 | KEY STA_ID (STA_ID), |
456 | 456 | KEY CNT_ISO (CNT_ISO)"; |
457 | - $this->_table_should_exist_previously($table_name, $sql); |
|
458 | - $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
459 | - // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
460 | - // (because many need to convert old string states to foreign keys into the states table) |
|
461 | - $script_with_defaults->insert_default_states(); |
|
462 | - $script_with_defaults->insert_default_countries(); |
|
463 | - // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
464 | - $script_with_defaults->insert_default_price_types(); |
|
465 | - $script_with_defaults->insert_default_prices(); |
|
466 | - $script_with_defaults->insert_default_tickets(); |
|
467 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
468 | - EE_Config::instance()->update_espresso_config(); |
|
469 | - return true; |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
475 | - * |
|
476 | - * @return boolean |
|
477 | - */ |
|
478 | - public function schema_changes_after_migration() |
|
479 | - { |
|
480 | - return true; |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - public function migration_page_hooks() |
|
485 | - { |
|
486 | - } |
|
457 | + $this->_table_should_exist_previously($table_name, $sql); |
|
458 | + $script_with_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
459 | + // setting up the DEFAULT stats and countries is also essential for the data migrations to run |
|
460 | + // (because many need to convert old string states to foreign keys into the states table) |
|
461 | + $script_with_defaults->insert_default_states(); |
|
462 | + $script_with_defaults->insert_default_countries(); |
|
463 | + // setting up DEFAULT prices, price types, and tickets is also essential for the price migrations |
|
464 | + $script_with_defaults->insert_default_price_types(); |
|
465 | + $script_with_defaults->insert_default_prices(); |
|
466 | + $script_with_defaults->insert_default_tickets(); |
|
467 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
468 | + EE_Config::instance()->update_espresso_config(); |
|
469 | + return true; |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * We COULD clean up the esp_question.QST_order field here. We'll leave it for now |
|
475 | + * |
|
476 | + * @return boolean |
|
477 | + */ |
|
478 | + public function schema_changes_after_migration() |
|
479 | + { |
|
480 | + return true; |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + public function migration_page_hooks() |
|
485 | + { |
|
486 | + } |
|
487 | 487 | } |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | // unfortunately, this needs to be done upon INCLUSION of this file, |
8 | 8 | // instead of construction, because it only gets constructed on first page load |
9 | 9 | // (all other times it gets resurrected from a wordpress option) |
10 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_2_0_stages/*'); |
|
10 | +$stages = glob(EE_CORE.'data_migration_scripts/4_2_0_stages/*'); |
|
11 | 11 | $class_to_filepath = []; |
12 | -if (! empty($stages)) { |
|
12 | +if ( ! empty($stages)) { |
|
13 | 13 | foreach ($stages as $filepath) { |
14 | 14 | $matches = []; |
15 | 15 | preg_match('~4_2_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
16 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | + $class_to_filepath[$matches[1]] = $filepath; |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | ) { |
61 | 61 | // echo "$version_string can be migrated fro"; |
62 | 62 | return true; |
63 | - } elseif (! $version_string) { |
|
63 | + } elseif ( ! $version_string) { |
|
64 | 64 | // echo "no version string provided: $version_string"; |
65 | 65 | // no version string provided... this must be pre 4.1 |
66 | 66 | // because since 4.1 we're |
67 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
67 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
68 | 68 | } else { |
69 | 69 | // echo "$version_string doesnt apply"; |
70 | 70 | return false; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function schema_changes_before_migration() |
80 | 80 | { |
81 | 81 | // relies on 4.1's EEH_Activation::create_table |
82 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
82 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
83 | 83 | |
84 | 84 | $table_name = 'esp_answer'; |
85 | 85 | $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -10,46 +10,46 @@ |
||
10 | 10 | class EE_DMS_4_6_0_state_system_question extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - global $wpdb; |
|
16 | - $this->_pretty_name = esc_html__('State - System Question', 'event_espresso'); |
|
17 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
18 | - $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
|
19 | - parent::__construct(); |
|
20 | - } |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + global $wpdb; |
|
16 | + $this->_pretty_name = esc_html__('State - System Question', 'event_espresso'); |
|
17 | + $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
18 | + $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
|
19 | + parent::__construct(); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * updates the question with the new question type |
|
25 | - * |
|
26 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - protected function _migrate_old_row($old_row) |
|
30 | - { |
|
31 | - if ($old_row['QST_ID'] && $old_row['QST_system'] == 'state') { |
|
32 | - global $wpdb; |
|
33 | - $success = $wpdb->update( |
|
34 | - $this->_old_table, |
|
35 | - ['QST_type' => 'STATE'], // data |
|
36 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | - ['%s'], // data format |
|
38 | - ['%d'] // where format |
|
39 | - ); |
|
40 | - if (! $success) { |
|
41 | - $this->add_error( |
|
42 | - sprintf( |
|
43 | - esc_html__( |
|
44 | - 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
45 | - 'event_espresso' |
|
46 | - ), |
|
47 | - wp_json_encode($old_row['QST_system']), |
|
48 | - $old_row['QST_ID'], |
|
49 | - $wpdb->last_error |
|
50 | - ) |
|
51 | - ); |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
23 | + /** |
|
24 | + * updates the question with the new question type |
|
25 | + * |
|
26 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + protected function _migrate_old_row($old_row) |
|
30 | + { |
|
31 | + if ($old_row['QST_ID'] && $old_row['QST_system'] == 'state') { |
|
32 | + global $wpdb; |
|
33 | + $success = $wpdb->update( |
|
34 | + $this->_old_table, |
|
35 | + ['QST_type' => 'STATE'], // data |
|
36 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | + ['%s'], // data format |
|
38 | + ['%d'] // where format |
|
39 | + ); |
|
40 | + if (! $success) { |
|
41 | + $this->add_error( |
|
42 | + sprintf( |
|
43 | + esc_html__( |
|
44 | + 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
45 | + 'event_espresso' |
|
46 | + ), |
|
47 | + wp_json_encode($old_row['QST_system']), |
|
48 | + $old_row['QST_ID'], |
|
49 | + $wpdb->last_error |
|
50 | + ) |
|
51 | + ); |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | 55 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | global $wpdb; |
16 | 16 | $this->_pretty_name = esc_html__('State - System Question', 'event_espresso'); |
17 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
17 | + $this->_old_table = $wpdb->prefix.'esp_question'; |
|
18 | 18 | $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
19 | 19 | parent::__construct(); |
20 | 20 | } |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | global $wpdb; |
33 | 33 | $success = $wpdb->update( |
34 | 34 | $this->_old_table, |
35 | - ['QST_type' => 'STATE'], // data |
|
36 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | - ['%s'], // data format |
|
35 | + ['QST_type' => 'STATE'], // data |
|
36 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | + ['%s'], // data format |
|
38 | 38 | ['%d'] // where format |
39 | 39 | ); |
40 | - if (! $success) { |
|
40 | + if ( ! $success) { |
|
41 | 41 | $this->add_error( |
42 | 42 | sprintf( |
43 | 43 | esc_html__( |
@@ -10,78 +10,78 @@ |
||
10 | 10 | class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | 12 | |
13 | - protected string $_transaction_table; |
|
13 | + protected string $_transaction_table; |
|
14 | 14 | |
15 | - protected string $_payment_method_table; |
|
15 | + protected string $_payment_method_table; |
|
16 | 16 | |
17 | 17 | |
18 | - public function __construct() |
|
19 | - { |
|
20 | - global $wpdb; |
|
21 | - $this->_old_table = $wpdb->prefix . 'esp_extra_meta'; |
|
22 | - $this->_transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
23 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
24 | - $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso'); |
|
25 | - $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'"; |
|
26 | - parent::__construct(); |
|
27 | - } |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | + global $wpdb; |
|
21 | + $this->_old_table = $wpdb->prefix . 'esp_extra_meta'; |
|
22 | + $this->_transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
23 | + $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
24 | + $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso'); |
|
25 | + $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'"; |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - protected function _migrate_old_row($old_row) |
|
31 | - { |
|
32 | - global $wpdb; |
|
33 | - // get the payment method's ID |
|
34 | - $PMD_ID = $this->_get_payment_method_id_by_gateway_name($old_row['EXM_value']); |
|
35 | - if (! $PMD_ID) { |
|
36 | - $this->add_error( |
|
37 | - sprintf( |
|
38 | - esc_html__( |
|
39 | - 'Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', |
|
40 | - 'event_espresso' |
|
41 | - ), |
|
42 | - $old_row['EXM_value'], |
|
43 | - $this->_json_encode($old_row) |
|
44 | - ) |
|
45 | - ); |
|
46 | - return; |
|
47 | - } |
|
48 | - $new_values = ['PMD_ID' => $PMD_ID]; |
|
49 | - $wheres = ['TXN_ID' => $old_row['OBJ_ID']]; |
|
50 | - $new_value_data_types = ['%d']; |
|
51 | - $where_data_types = ['%d']; |
|
52 | - $success = $wpdb->update( |
|
53 | - $this->_transaction_table, |
|
54 | - $new_values, |
|
55 | - $wheres, |
|
56 | - $new_value_data_types, |
|
57 | - $where_data_types |
|
58 | - ); |
|
59 | - if (! $success) { |
|
60 | - $this->add_error( |
|
61 | - sprintf( |
|
62 | - esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
63 | - $this->_json_encode($new_values), |
|
64 | - $this->_transaction_table, |
|
65 | - $this->_json_encode($wheres) |
|
66 | - ) |
|
67 | - ); |
|
68 | - } |
|
69 | - } |
|
30 | + protected function _migrate_old_row($old_row) |
|
31 | + { |
|
32 | + global $wpdb; |
|
33 | + // get the payment method's ID |
|
34 | + $PMD_ID = $this->_get_payment_method_id_by_gateway_name($old_row['EXM_value']); |
|
35 | + if (! $PMD_ID) { |
|
36 | + $this->add_error( |
|
37 | + sprintf( |
|
38 | + esc_html__( |
|
39 | + 'Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', |
|
40 | + 'event_espresso' |
|
41 | + ), |
|
42 | + $old_row['EXM_value'], |
|
43 | + $this->_json_encode($old_row) |
|
44 | + ) |
|
45 | + ); |
|
46 | + return; |
|
47 | + } |
|
48 | + $new_values = ['PMD_ID' => $PMD_ID]; |
|
49 | + $wheres = ['TXN_ID' => $old_row['OBJ_ID']]; |
|
50 | + $new_value_data_types = ['%d']; |
|
51 | + $where_data_types = ['%d']; |
|
52 | + $success = $wpdb->update( |
|
53 | + $this->_transaction_table, |
|
54 | + $new_values, |
|
55 | + $wheres, |
|
56 | + $new_value_data_types, |
|
57 | + $where_data_types |
|
58 | + ); |
|
59 | + if (! $success) { |
|
60 | + $this->add_error( |
|
61 | + sprintf( |
|
62 | + esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
63 | + $this->_json_encode($new_values), |
|
64 | + $this->_transaction_table, |
|
65 | + $this->_json_encode($wheres) |
|
66 | + ) |
|
67 | + ); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * @param string $gateway_name |
|
74 | - * @return string |
|
75 | - * @global wpdb $wpdb |
|
76 | - */ |
|
77 | - protected function _get_payment_method_id_by_gateway_name(string $gateway_name): string |
|
78 | - { |
|
79 | - global $wpdb; |
|
80 | - return $wpdb->get_var( |
|
81 | - $wpdb->prepare( |
|
82 | - "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", |
|
83 | - $gateway_name |
|
84 | - ) |
|
85 | - ); |
|
86 | - } |
|
72 | + /** |
|
73 | + * @param string $gateway_name |
|
74 | + * @return string |
|
75 | + * @global wpdb $wpdb |
|
76 | + */ |
|
77 | + protected function _get_payment_method_id_by_gateway_name(string $gateway_name): string |
|
78 | + { |
|
79 | + global $wpdb; |
|
80 | + return $wpdb->get_var( |
|
81 | + $wpdb->prepare( |
|
82 | + "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", |
|
83 | + $gateway_name |
|
84 | + ) |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | } |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | public function __construct() |
19 | 19 | { |
20 | 20 | global $wpdb; |
21 | - $this->_old_table = $wpdb->prefix . 'esp_extra_meta'; |
|
22 | - $this->_transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
23 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
21 | + $this->_old_table = $wpdb->prefix.'esp_extra_meta'; |
|
22 | + $this->_transaction_table = $wpdb->prefix.'esp_transaction'; |
|
23 | + $this->_payment_method_table = $wpdb->prefix.'esp_payment_method'; |
|
24 | 24 | $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso'); |
25 | 25 | $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'"; |
26 | 26 | parent::__construct(); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | global $wpdb; |
33 | 33 | // get the payment method's ID |
34 | 34 | $PMD_ID = $this->_get_payment_method_id_by_gateway_name($old_row['EXM_value']); |
35 | - if (! $PMD_ID) { |
|
35 | + if ( ! $PMD_ID) { |
|
36 | 36 | $this->add_error( |
37 | 37 | sprintf( |
38 | 38 | esc_html__( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $new_value_data_types, |
57 | 57 | $where_data_types |
58 | 58 | ); |
59 | - if (! $success) { |
|
59 | + if ( ! $success) { |
|
60 | 60 | $this->add_error( |
61 | 61 | sprintf( |
62 | 62 | esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | global $wpdb; |
80 | 80 | return $wpdb->get_var( |
81 | 81 | $wpdb->prepare( |
82 | - "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", |
|
82 | + "SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s", |
|
83 | 83 | $gateway_name |
84 | 84 | ) |
85 | 85 | ); |
@@ -10,58 +10,58 @@ |
||
10 | 10 | class EE_DMS_4_6_0_question_types extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | 12 | |
13 | - protected array $_question_type_conversions = []; |
|
13 | + protected array $_question_type_conversions = []; |
|
14 | 14 | |
15 | 15 | |
16 | - public function __construct() |
|
17 | - { |
|
18 | - global $wpdb; |
|
19 | - $this->_pretty_name = esc_html__('Question Types', 'event_espresso'); |
|
20 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
21 | - $this->_question_type_conversions = [ |
|
22 | - 'MULTIPLE' => 'CHECKBOX', |
|
23 | - 'SINGLE' => 'RADIO_BTN', |
|
24 | - ]; |
|
25 | - // when fetching rows, because we automatically use a limit and offset |
|
26 | - // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
|
27 | - // so we need to include both the migrated rows as well as the non-migrated rows |
|
28 | - $QST_types_to_count = array_merge( |
|
29 | - array_keys($this->_question_type_conversions), |
|
30 | - $this->_question_type_conversions |
|
31 | - ); |
|
32 | - $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')"; |
|
33 | - parent::__construct(); |
|
34 | - } |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + global $wpdb; |
|
19 | + $this->_pretty_name = esc_html__('Question Types', 'event_espresso'); |
|
20 | + $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
21 | + $this->_question_type_conversions = [ |
|
22 | + 'MULTIPLE' => 'CHECKBOX', |
|
23 | + 'SINGLE' => 'RADIO_BTN', |
|
24 | + ]; |
|
25 | + // when fetching rows, because we automatically use a limit and offset |
|
26 | + // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
|
27 | + // so we need to include both the migrated rows as well as the non-migrated rows |
|
28 | + $QST_types_to_count = array_merge( |
|
29 | + array_keys($this->_question_type_conversions), |
|
30 | + $this->_question_type_conversions |
|
31 | + ); |
|
32 | + $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')"; |
|
33 | + parent::__construct(); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - protected function _migrate_old_row($old_row) |
|
42 | - { |
|
43 | - global $wpdb; |
|
44 | - if ($old_row['QST_ID'] && isset($this->_question_type_conversions[ $old_row['QST_type'] ])) { |
|
45 | - $success = $wpdb->update( |
|
46 | - $this->_old_table, |
|
47 | - ['QST_type' => $this->_question_type_conversions[ $old_row['QST_type'] ]], // data |
|
48 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
49 | - ['%s'], // data format |
|
50 | - ['%d'] // where format |
|
51 | - ); |
|
52 | - if (! $success) { |
|
53 | - $this->add_error( |
|
54 | - sprintf( |
|
55 | - esc_html__( |
|
56 | - 'Could not update question type %1$s for question ID=%2$d because "%3$s"', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - wp_json_encode($old_row['QST_type']), |
|
60 | - $old_row['QST_ID'], |
|
61 | - $wpdb->last_error |
|
62 | - ) |
|
63 | - ); |
|
64 | - } |
|
65 | - } |
|
66 | - } |
|
37 | + /** |
|
38 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + protected function _migrate_old_row($old_row) |
|
42 | + { |
|
43 | + global $wpdb; |
|
44 | + if ($old_row['QST_ID'] && isset($this->_question_type_conversions[ $old_row['QST_type'] ])) { |
|
45 | + $success = $wpdb->update( |
|
46 | + $this->_old_table, |
|
47 | + ['QST_type' => $this->_question_type_conversions[ $old_row['QST_type'] ]], // data |
|
48 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
49 | + ['%s'], // data format |
|
50 | + ['%d'] // where format |
|
51 | + ); |
|
52 | + if (! $success) { |
|
53 | + $this->add_error( |
|
54 | + sprintf( |
|
55 | + esc_html__( |
|
56 | + 'Could not update question type %1$s for question ID=%2$d because "%3$s"', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + wp_json_encode($old_row['QST_type']), |
|
60 | + $old_row['QST_ID'], |
|
61 | + $wpdb->last_error |
|
62 | + ) |
|
63 | + ); |
|
64 | + } |
|
65 | + } |
|
66 | + } |
|
67 | 67 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | global $wpdb; |
19 | 19 | $this->_pretty_name = esc_html__('Question Types', 'event_espresso'); |
20 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
20 | + $this->_old_table = $wpdb->prefix.'esp_question'; |
|
21 | 21 | $this->_question_type_conversions = [ |
22 | 22 | 'MULTIPLE' => 'CHECKBOX', |
23 | 23 | 'SINGLE' => 'RADIO_BTN', |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | // when fetching rows, because we automatically use a limit and offset |
26 | 26 | // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
27 | 27 | // so we need to include both the migrated rows as well as the non-migrated rows |
28 | - $QST_types_to_count = array_merge( |
|
28 | + $QST_types_to_count = array_merge( |
|
29 | 29 | array_keys($this->_question_type_conversions), |
30 | 30 | $this->_question_type_conversions |
31 | 31 | ); |
32 | - $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')"; |
|
32 | + $this->_extra_where_sql = "WHERE QST_type IN ('".implode("', '", $QST_types_to_count)."')"; |
|
33 | 33 | parent::__construct(); |
34 | 34 | } |
35 | 35 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | protected function _migrate_old_row($old_row) |
42 | 42 | { |
43 | 43 | global $wpdb; |
44 | - if ($old_row['QST_ID'] && isset($this->_question_type_conversions[ $old_row['QST_type'] ])) { |
|
44 | + if ($old_row['QST_ID'] && isset($this->_question_type_conversions[$old_row['QST_type']])) { |
|
45 | 45 | $success = $wpdb->update( |
46 | 46 | $this->_old_table, |
47 | - ['QST_type' => $this->_question_type_conversions[ $old_row['QST_type'] ]], // data |
|
48 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
49 | - ['%s'], // data format |
|
47 | + ['QST_type' => $this->_question_type_conversions[$old_row['QST_type']]], // data |
|
48 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
49 | + ['%s'], // data format |
|
50 | 50 | ['%d'] // where format |
51 | 51 | ); |
52 | - if (! $success) { |
|
52 | + if ( ! $success) { |
|
53 | 53 | $this->add_error( |
54 | 54 | sprintf( |
55 | 55 | esc_html__( |
@@ -10,125 +10,125 @@ |
||
10 | 10 | class EE_DMS_4_6_0_payments extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | 12 | |
13 | - protected string $_payment_method_table; |
|
13 | + protected string $_payment_method_table; |
|
14 | 14 | |
15 | 15 | |
16 | - public function __construct() |
|
17 | - { |
|
18 | - global $wpdb; |
|
19 | - $this->_old_table = $wpdb->prefix . 'esp_payment'; |
|
20 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
21 | - $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso'); |
|
22 | - parent::__construct(); |
|
23 | - } |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + global $wpdb; |
|
19 | + $this->_old_table = $wpdb->prefix . 'esp_payment'; |
|
20 | + $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
21 | + $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso'); |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - protected function _migrate_old_row($old_row) |
|
27 | - { |
|
28 | - global $wpdb; |
|
29 | - // get the payment method's ID |
|
30 | - $PMD_ID = apply_filters( |
|
31 | - 'FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', |
|
32 | - $this->_get_payment_method_id_by_gateway_name($old_row['PAY_gateway'], $old_row['PAY_method']) |
|
33 | - ); |
|
34 | - if (! $PMD_ID) { |
|
35 | - $this->add_error( |
|
36 | - sprintf( |
|
37 | - esc_html__( |
|
38 | - 'Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', |
|
39 | - 'event_espresso' |
|
40 | - ), |
|
41 | - $old_row['PAY_gateway'], |
|
42 | - $this->_json_encode($old_row) |
|
43 | - ) |
|
44 | - ); |
|
45 | - $PMD_ID = 0; |
|
46 | - } |
|
47 | - $new_values = [ |
|
48 | - 'PMD_ID' => $PMD_ID, |
|
49 | - 'PAY_source' => ($old_row['PAY_via_admin'] ? 'ADMIN' : 'CART'), |
|
50 | - ]; |
|
51 | - $wheres = ['PAY_ID' => $old_row['PAY_ID']]; |
|
52 | - $new_value_datatypes = ['%d', '%s']; |
|
53 | - $where_datatypes = ['%d']; |
|
54 | - $success = $wpdb->update( |
|
55 | - $this->_old_table, |
|
56 | - $new_values, |
|
57 | - $wheres, |
|
58 | - $new_value_datatypes, |
|
59 | - $where_datatypes |
|
60 | - ); |
|
61 | - if (! $success) { |
|
62 | - $this->add_error( |
|
63 | - sprintf( |
|
64 | - esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
65 | - $this->_json_encode($new_values), |
|
66 | - $this->_old_table, |
|
67 | - $this->_json_encode($wheres) |
|
68 | - ) |
|
69 | - ); |
|
70 | - } |
|
71 | - } |
|
26 | + protected function _migrate_old_row($old_row) |
|
27 | + { |
|
28 | + global $wpdb; |
|
29 | + // get the payment method's ID |
|
30 | + $PMD_ID = apply_filters( |
|
31 | + 'FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', |
|
32 | + $this->_get_payment_method_id_by_gateway_name($old_row['PAY_gateway'], $old_row['PAY_method']) |
|
33 | + ); |
|
34 | + if (! $PMD_ID) { |
|
35 | + $this->add_error( |
|
36 | + sprintf( |
|
37 | + esc_html__( |
|
38 | + 'Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', |
|
39 | + 'event_espresso' |
|
40 | + ), |
|
41 | + $old_row['PAY_gateway'], |
|
42 | + $this->_json_encode($old_row) |
|
43 | + ) |
|
44 | + ); |
|
45 | + $PMD_ID = 0; |
|
46 | + } |
|
47 | + $new_values = [ |
|
48 | + 'PMD_ID' => $PMD_ID, |
|
49 | + 'PAY_source' => ($old_row['PAY_via_admin'] ? 'ADMIN' : 'CART'), |
|
50 | + ]; |
|
51 | + $wheres = ['PAY_ID' => $old_row['PAY_ID']]; |
|
52 | + $new_value_datatypes = ['%d', '%s']; |
|
53 | + $where_datatypes = ['%d']; |
|
54 | + $success = $wpdb->update( |
|
55 | + $this->_old_table, |
|
56 | + $new_values, |
|
57 | + $wheres, |
|
58 | + $new_value_datatypes, |
|
59 | + $where_datatypes |
|
60 | + ); |
|
61 | + if (! $success) { |
|
62 | + $this->add_error( |
|
63 | + sprintf( |
|
64 | + esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
65 | + $this->_json_encode($new_values), |
|
66 | + $this->_old_table, |
|
67 | + $this->_json_encode($wheres) |
|
68 | + ) |
|
69 | + ); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * array( |
|
76 | - * 'PP' => esc_html__( 'PayPal', 'event_espresso' ), |
|
77 | - * 'CC' => esc_html__( 'Credit Card', 'event_espresso' ), |
|
78 | - * 'DB'=> esc_html__("Debit Card", 'event_espresso'), |
|
79 | - * 'CHQ' => esc_html__( 'Cheque', 'event_espresso' ), |
|
80 | - * 'CSH' => esc_html__( 'Cash', 'event_espresso' ), |
|
81 | - * 'BK'=> esc_html__("Bank", 'event_espresso'), |
|
82 | - * 'IV'=> esc_html__("Invoice", 'event_espresso'), |
|
83 | - * 'MO'=> esc_html__("Money Order", 'event_espresso'), |
|
84 | - * |
|
85 | - * @param string $gateway_name |
|
86 | - * @param string $old_pay_method_column |
|
87 | - * @return string |
|
88 | - * @global wpdb $wpdb |
|
89 | - */ |
|
90 | - protected function _get_payment_method_id_by_gateway_name( |
|
91 | - string $gateway_name, |
|
92 | - string $old_pay_method_column |
|
93 | - ): string { |
|
94 | - global $wpdb; |
|
95 | - // convert from old known PAY_method values to their corresponding |
|
96 | - // PMD_type or default PMD_name |
|
97 | - switch ($old_pay_method_column) { |
|
98 | - case 'PP': |
|
99 | - $pmd_type = 'Paypal_Standard'; |
|
100 | - break; |
|
101 | - case 'CC': |
|
102 | - $pmd_type = 'Credit_Card'; |
|
103 | - break; |
|
104 | - case 'DB': |
|
105 | - $pmd_type = 'Debit_Card'; |
|
106 | - break; |
|
107 | - case 'CHQ': |
|
108 | - $pmd_type = 'Check'; |
|
109 | - break; |
|
110 | - case 'CSH': |
|
111 | - $pmd_type = 'Cash'; |
|
112 | - break; |
|
113 | - case 'BK': |
|
114 | - $pmd_type = 'Bank'; |
|
115 | - break; |
|
116 | - case 'IV': |
|
117 | - $pmd_type = 'Invoice'; |
|
118 | - break; |
|
119 | - case 'MO': |
|
120 | - $pmd_type = 'Money_Order'; |
|
121 | - break; |
|
122 | - default: |
|
123 | - $pmd_type = $gateway_name; |
|
124 | - } |
|
125 | - $pmd_name = str_replace("_", " ", $pmd_type); |
|
126 | - return $wpdb->get_var( |
|
127 | - $wpdb->prepare( |
|
128 | - "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", |
|
129 | - $pmd_type, |
|
130 | - $pmd_name |
|
131 | - ) |
|
132 | - ); |
|
133 | - } |
|
74 | + /** |
|
75 | + * array( |
|
76 | + * 'PP' => esc_html__( 'PayPal', 'event_espresso' ), |
|
77 | + * 'CC' => esc_html__( 'Credit Card', 'event_espresso' ), |
|
78 | + * 'DB'=> esc_html__("Debit Card", 'event_espresso'), |
|
79 | + * 'CHQ' => esc_html__( 'Cheque', 'event_espresso' ), |
|
80 | + * 'CSH' => esc_html__( 'Cash', 'event_espresso' ), |
|
81 | + * 'BK'=> esc_html__("Bank", 'event_espresso'), |
|
82 | + * 'IV'=> esc_html__("Invoice", 'event_espresso'), |
|
83 | + * 'MO'=> esc_html__("Money Order", 'event_espresso'), |
|
84 | + * |
|
85 | + * @param string $gateway_name |
|
86 | + * @param string $old_pay_method_column |
|
87 | + * @return string |
|
88 | + * @global wpdb $wpdb |
|
89 | + */ |
|
90 | + protected function _get_payment_method_id_by_gateway_name( |
|
91 | + string $gateway_name, |
|
92 | + string $old_pay_method_column |
|
93 | + ): string { |
|
94 | + global $wpdb; |
|
95 | + // convert from old known PAY_method values to their corresponding |
|
96 | + // PMD_type or default PMD_name |
|
97 | + switch ($old_pay_method_column) { |
|
98 | + case 'PP': |
|
99 | + $pmd_type = 'Paypal_Standard'; |
|
100 | + break; |
|
101 | + case 'CC': |
|
102 | + $pmd_type = 'Credit_Card'; |
|
103 | + break; |
|
104 | + case 'DB': |
|
105 | + $pmd_type = 'Debit_Card'; |
|
106 | + break; |
|
107 | + case 'CHQ': |
|
108 | + $pmd_type = 'Check'; |
|
109 | + break; |
|
110 | + case 'CSH': |
|
111 | + $pmd_type = 'Cash'; |
|
112 | + break; |
|
113 | + case 'BK': |
|
114 | + $pmd_type = 'Bank'; |
|
115 | + break; |
|
116 | + case 'IV': |
|
117 | + $pmd_type = 'Invoice'; |
|
118 | + break; |
|
119 | + case 'MO': |
|
120 | + $pmd_type = 'Money_Order'; |
|
121 | + break; |
|
122 | + default: |
|
123 | + $pmd_type = $gateway_name; |
|
124 | + } |
|
125 | + $pmd_name = str_replace("_", " ", $pmd_type); |
|
126 | + return $wpdb->get_var( |
|
127 | + $wpdb->prepare( |
|
128 | + "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", |
|
129 | + $pmd_type, |
|
130 | + $pmd_name |
|
131 | + ) |
|
132 | + ); |
|
133 | + } |
|
134 | 134 | } |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | public function __construct() |
17 | 17 | { |
18 | 18 | global $wpdb; |
19 | - $this->_old_table = $wpdb->prefix . 'esp_payment'; |
|
20 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
19 | + $this->_old_table = $wpdb->prefix.'esp_payment'; |
|
20 | + $this->_payment_method_table = $wpdb->prefix.'esp_payment_method'; |
|
21 | 21 | $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso'); |
22 | 22 | parent::__construct(); |
23 | 23 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | 'FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', |
32 | 32 | $this->_get_payment_method_id_by_gateway_name($old_row['PAY_gateway'], $old_row['PAY_method']) |
33 | 33 | ); |
34 | - if (! $PMD_ID) { |
|
34 | + if ( ! $PMD_ID) { |
|
35 | 35 | $this->add_error( |
36 | 36 | sprintf( |
37 | 37 | esc_html__( |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | ); |
45 | 45 | $PMD_ID = 0; |
46 | 46 | } |
47 | - $new_values = [ |
|
47 | + $new_values = [ |
|
48 | 48 | 'PMD_ID' => $PMD_ID, |
49 | 49 | 'PAY_source' => ($old_row['PAY_via_admin'] ? 'ADMIN' : 'CART'), |
50 | 50 | ]; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $new_value_datatypes, |
59 | 59 | $where_datatypes |
60 | 60 | ); |
61 | - if (! $success) { |
|
61 | + if ( ! $success) { |
|
62 | 62 | $this->add_error( |
63 | 63 | sprintf( |
64 | 64 | esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $pmd_name = str_replace("_", " ", $pmd_type); |
126 | 126 | return $wpdb->get_var( |
127 | 127 | $wpdb->prepare( |
128 | - "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", |
|
128 | + "SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", |
|
129 | 129 | $pmd_type, |
130 | 130 | $pmd_name |
131 | 131 | ) |
@@ -10,46 +10,46 @@ |
||
10 | 10 | class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | 12 | |
13 | - public function __construct() |
|
14 | - { |
|
15 | - global $wpdb; |
|
16 | - $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso'); |
|
17 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
18 | - $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
|
19 | - parent::__construct(); |
|
20 | - } |
|
13 | + public function __construct() |
|
14 | + { |
|
15 | + global $wpdb; |
|
16 | + $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso'); |
|
17 | + $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
18 | + $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
|
19 | + parent::__construct(); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * updates the question with the new question type |
|
25 | - * |
|
26 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - protected function _migrate_old_row($old_row) |
|
30 | - { |
|
31 | - if ($old_row['QST_ID'] && $old_row['QST_system'] == 'country') { |
|
32 | - global $wpdb; |
|
33 | - $success = $wpdb->update( |
|
34 | - $this->_old_table, |
|
35 | - ['QST_type' => 'COUNTRY'], // data |
|
36 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | - ['%s'], // data format |
|
38 | - ['%d'] // where format |
|
39 | - ); |
|
40 | - if (! $success) { |
|
41 | - $this->add_error( |
|
42 | - sprintf( |
|
43 | - esc_html__( |
|
44 | - 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
45 | - 'event_espresso' |
|
46 | - ), |
|
47 | - wp_json_encode($old_row['QST_system']), |
|
48 | - $old_row['QST_ID'], |
|
49 | - $wpdb->last_error |
|
50 | - ) |
|
51 | - ); |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
23 | + /** |
|
24 | + * updates the question with the new question type |
|
25 | + * |
|
26 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + protected function _migrate_old_row($old_row) |
|
30 | + { |
|
31 | + if ($old_row['QST_ID'] && $old_row['QST_system'] == 'country') { |
|
32 | + global $wpdb; |
|
33 | + $success = $wpdb->update( |
|
34 | + $this->_old_table, |
|
35 | + ['QST_type' => 'COUNTRY'], // data |
|
36 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | + ['%s'], // data format |
|
38 | + ['%d'] // where format |
|
39 | + ); |
|
40 | + if (! $success) { |
|
41 | + $this->add_error( |
|
42 | + sprintf( |
|
43 | + esc_html__( |
|
44 | + 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
45 | + 'event_espresso' |
|
46 | + ), |
|
47 | + wp_json_encode($old_row['QST_system']), |
|
48 | + $old_row['QST_ID'], |
|
49 | + $wpdb->last_error |
|
50 | + ) |
|
51 | + ); |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | 55 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | global $wpdb; |
16 | 16 | $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso'); |
17 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
17 | + $this->_old_table = $wpdb->prefix.'esp_question'; |
|
18 | 18 | $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
19 | 19 | parent::__construct(); |
20 | 20 | } |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | global $wpdb; |
33 | 33 | $success = $wpdb->update( |
34 | 34 | $this->_old_table, |
35 | - ['QST_type' => 'COUNTRY'], // data |
|
36 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | - ['%s'], // data format |
|
35 | + ['QST_type' => 'COUNTRY'], // data |
|
36 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
37 | + ['%s'], // data format |
|
38 | 38 | ['%d'] // where format |
39 | 39 | ); |
40 | - if (! $success) { |
|
40 | + if ( ! $success) { |
|
41 | 41 | $this->add_error( |
42 | 42 | sprintf( |
43 | 43 | esc_html__( |