@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | // unfortunately, this needs to be done upon INCLUSION of this file, |
15 | 15 | // instead of construction, because it only gets constructed on first page load |
16 | 16 | // (all other times it gets resurrected from a wordpress option) |
17 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*'); |
|
17 | +$stages = glob(EE_CORE.'data_migration_scripts/4_8_0_stages/*'); |
|
18 | 18 | $class_to_filepath = array(); |
19 | 19 | foreach ($stages as $filepath) { |
20 | 20 | $matches = array(); |
21 | 21 | preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
22 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
22 | + $class_to_filepath[$matches[1]] = $filepath; |
|
23 | 23 | } |
24 | 24 | // give addons a chance to autoload their stages too |
25 | 25 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) { |
73 | 73 | // echo "$version_string can be migrated from"; |
74 | 74 | return true; |
75 | - } elseif (! $version_string) { |
|
75 | + } elseif ( ! $version_string) { |
|
76 | 76 | // echo "no version string provided: $version_string"; |
77 | 77 | // no version string provided... this must be pre 4.3 |
78 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
78 | + return false; // changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | 79 | } else { |
80 | 80 | // echo "$version_string doesnt apply"; |
81 | 81 | return false; |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function schema_changes_before_migration() |
91 | 91 | { |
92 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
93 | 93 | $now_in_mysql = current_time('mysql', true); |
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
94 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
95 | 95 | $table_name = 'esp_answer'; |
96 | 96 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
97 | 97 | REG_ID int(10) unsigned NOT NULL, |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | ), |
688 | 688 | ); |
689 | 689 | global $wpdb; |
690 | - $country_table = $wpdb->prefix . "esp_country"; |
|
690 | + $country_table = $wpdb->prefix."esp_country"; |
|
691 | 691 | $country_format = array( |
692 | 692 | "CNT_ISO" => '%s', |
693 | 693 | "CNT_ISO3" => '%s', |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | foreach ($newer_countries as $country) { |
708 | 708 | $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
709 | 709 | $countries = $wpdb->get_var($SQL); |
710 | - if (! $countries) { |
|
710 | + if ( ! $countries) { |
|
711 | 711 | $wpdb->insert( |
712 | 712 | $country_table, |
713 | 713 | array_combine(array_keys($country_format), $country), |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
735 | 735 | ); |
736 | 736 | global $wpdb; |
737 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
737 | + $currency_table = $wpdb->prefix."esp_currency"; |
|
738 | 738 | $currency_format = array( |
739 | 739 | "CUR_code" => '%s', |
740 | 740 | "CUR_single" => '%s', |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | foreach ($newer_currencies as $currency) { |
748 | 748 | $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
749 | 749 | $countries = $wpdb->get_var($SQL); |
750 | - if (! $countries) { |
|
750 | + if ( ! $countries) { |
|
751 | 751 | $wpdb->insert( |
752 | 752 | $currency_table, |
753 | 753 | array_combine(array_keys($currency_format), $currency), |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | $stages = glob(EE_CORE . 'data_migration_scripts/4_8_0_stages/*'); |
18 | 18 | $class_to_filepath = array(); |
19 | 19 | foreach ($stages as $filepath) { |
20 | - $matches = array(); |
|
21 | - preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
22 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
20 | + $matches = array(); |
|
21 | + preg_match('~4_8_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
22 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
23 | 23 | } |
24 | 24 | // give addons a chance to autoload their stages too |
25 | 25 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_8_0__autoloaded_stages', $class_to_filepath); |
@@ -38,71 +38,71 @@ discard block |
||
38 | 38 | class EE_DMS_Core_4_8_0 extends EE_Data_Migration_Script_Base |
39 | 39 | { |
40 | 40 | |
41 | - /** |
|
42 | - * return EE_DMS_Core_4_8_0 |
|
43 | - * |
|
44 | - * @param TableManager $table_manager |
|
45 | - * @param TableAnalysis $table_analysis |
|
46 | - */ |
|
47 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
48 | - { |
|
49 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso"); |
|
50 | - $this->_priority = 10; |
|
51 | - $this->_migration_stages = array( |
|
52 | - new EE_DMS_4_8_0_pretax_totals(), |
|
53 | - new EE_DMS_4_8_0_event_subtotals(), |
|
54 | - ); |
|
55 | - parent::__construct($table_manager, $table_analysis); |
|
56 | - } |
|
41 | + /** |
|
42 | + * return EE_DMS_Core_4_8_0 |
|
43 | + * |
|
44 | + * @param TableManager $table_manager |
|
45 | + * @param TableAnalysis $table_analysis |
|
46 | + */ |
|
47 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
48 | + { |
|
49 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.8.0", "event_espresso"); |
|
50 | + $this->_priority = 10; |
|
51 | + $this->_migration_stages = array( |
|
52 | + new EE_DMS_4_8_0_pretax_totals(), |
|
53 | + new EE_DMS_4_8_0_event_subtotals(), |
|
54 | + ); |
|
55 | + parent::__construct($table_manager, $table_analysis); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * Because this is being done at basically the same time as the MER-ready branch |
|
62 | - * of core, it's possible people might have installed MEr-ready branch first, |
|
63 | - * and then this one, in which case we still want to perform this migration, |
|
64 | - * even though the version might not have increased |
|
65 | - * |
|
66 | - * @param array $version_array |
|
67 | - * @return bool |
|
68 | - */ |
|
69 | - public function can_migrate_from_version($version_array) |
|
70 | - { |
|
71 | - $version_string = $version_array['Core']; |
|
72 | - if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) { |
|
60 | + /** |
|
61 | + * Because this is being done at basically the same time as the MER-ready branch |
|
62 | + * of core, it's possible people might have installed MEr-ready branch first, |
|
63 | + * and then this one, in which case we still want to perform this migration, |
|
64 | + * even though the version might not have increased |
|
65 | + * |
|
66 | + * @param array $version_array |
|
67 | + * @return bool |
|
68 | + */ |
|
69 | + public function can_migrate_from_version($version_array) |
|
70 | + { |
|
71 | + $version_string = $version_array['Core']; |
|
72 | + if (version_compare($version_string, '4.8.0', '<=') && version_compare($version_string, '4.7.0', '>=')) { |
|
73 | 73 | // echo "$version_string can be migrated from"; |
74 | - return true; |
|
75 | - } elseif (! $version_string) { |
|
74 | + return true; |
|
75 | + } elseif (! $version_string) { |
|
76 | 76 | // echo "no version string provided: $version_string"; |
77 | - // no version string provided... this must be pre 4.3 |
|
78 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | - } else { |
|
77 | + // no version string provided... this must be pre 4.3 |
|
78 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
79 | + } else { |
|
80 | 80 | // echo "$version_string doesnt apply"; |
81 | - return false; |
|
82 | - } |
|
83 | - } |
|
81 | + return false; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @return bool |
|
89 | - */ |
|
90 | - public function schema_changes_before_migration() |
|
91 | - { |
|
92 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
93 | - $now_in_mysql = current_time('mysql', true); |
|
94 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | - $table_name = 'esp_answer'; |
|
96 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
87 | + /** |
|
88 | + * @return bool |
|
89 | + */ |
|
90 | + public function schema_changes_before_migration() |
|
91 | + { |
|
92 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
93 | + $now_in_mysql = current_time('mysql', true); |
|
94 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
95 | + $table_name = 'esp_answer'; |
|
96 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
97 | 97 | REG_ID int(10) unsigned NOT NULL, |
98 | 98 | QST_ID int(10) unsigned NOT NULL, |
99 | 99 | ANS_value text NOT NULL, |
100 | 100 | PRIMARY KEY (ANS_ID), |
101 | 101 | KEY REG_ID (REG_ID), |
102 | 102 | KEY QST_ID (QST_ID)"; |
103 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
104 | - $table_name = 'esp_attendee_meta'; |
|
105 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
103 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
104 | + $table_name = 'esp_attendee_meta'; |
|
105 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
106 | 106 | ATT_ID bigint(20) unsigned NOT NULL, |
107 | 107 | ATT_fname varchar(45) NOT NULL, |
108 | 108 | ATT_lname varchar(45) NOT NULL, |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | PRIMARY KEY (ATTM_ID), |
118 | 118 | KEY ATT_ID (ATT_ID), |
119 | 119 | KEY ATT_email (ATT_email(191))"; |
120 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
121 | - $table_name = 'esp_country'; |
|
122 | - $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
120 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
121 | + $table_name = 'esp_country'; |
|
122 | + $sql = "CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
|
123 | 123 | CNT_ISO3 varchar(3) collate utf8_bin NOT NULL, |
124 | 124 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
125 | 125 | CNT_name varchar(45) collate utf8_bin NOT NULL, |
@@ -135,25 +135,25 @@ discard block |
||
135 | 135 | CNT_is_EU tinyint(1) DEFAULT '0', |
136 | 136 | CNT_active tinyint(1) DEFAULT '0', |
137 | 137 | PRIMARY KEY (CNT_ISO)"; |
138 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
139 | - $table_name = 'esp_currency'; |
|
140 | - $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
138 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
139 | + $table_name = 'esp_currency'; |
|
140 | + $sql = "CUR_code varchar(6) collate utf8_bin NOT NULL, |
|
141 | 141 | CUR_single varchar(45) collate utf8_bin DEFAULT 'dollar', |
142 | 142 | CUR_plural varchar(45) collate utf8_bin DEFAULT 'dollars', |
143 | 143 | CUR_sign varchar(45) collate utf8_bin DEFAULT '$', |
144 | 144 | CUR_dec_plc varchar(1) collate utf8_bin NOT NULL DEFAULT '2', |
145 | 145 | CUR_active tinyint(1) DEFAULT '0', |
146 | 146 | PRIMARY KEY (CUR_code)"; |
147 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
148 | - $table_name = 'esp_currency_payment_method'; |
|
149 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
147 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
148 | + $table_name = 'esp_currency_payment_method'; |
|
149 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
150 | 150 | CUR_code varchar(6) collate utf8_bin NOT NULL, |
151 | 151 | PMD_ID int(11) NOT NULL, |
152 | 152 | PRIMARY KEY (CPM_ID), |
153 | 153 | KEY PMD_ID (PMD_ID)"; |
154 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
155 | - $table_name = 'esp_datetime'; |
|
156 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
154 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
155 | + $table_name = 'esp_datetime'; |
|
156 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
157 | 157 | EVT_ID bigint(20) unsigned NOT NULL, |
158 | 158 | DTT_name varchar(255) NOT NULL DEFAULT '', |
159 | 159 | DTT_description text NOT NULL, |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | KEY DTT_EVT_start (DTT_EVT_start), |
170 | 170 | KEY EVT_ID (EVT_ID), |
171 | 171 | KEY DTT_is_primary (DTT_is_primary)"; |
172 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
173 | - $table_name = 'esp_event_meta'; |
|
174 | - $sql = " |
|
172 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
173 | + $table_name = 'esp_event_meta'; |
|
174 | + $sql = " |
|
175 | 175 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
176 | 176 | EVT_ID bigint(20) unsigned NOT NULL, |
177 | 177 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -187,34 +187,34 @@ discard block |
||
187 | 187 | EVT_donations tinyint(1) NULL, |
188 | 188 | PRIMARY KEY (EVTM_ID), |
189 | 189 | KEY EVT_ID (EVT_ID)"; |
190 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | - $table_name = 'esp_event_question_group'; |
|
192 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
190 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | + $table_name = 'esp_event_question_group'; |
|
192 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
193 | 193 | EVT_ID bigint(20) unsigned NOT NULL, |
194 | 194 | QSG_ID int(10) unsigned NOT NULL, |
195 | 195 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
196 | 196 | PRIMARY KEY (EQG_ID), |
197 | 197 | KEY EVT_ID (EVT_ID), |
198 | 198 | KEY QSG_ID (QSG_ID)"; |
199 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
200 | - $table_name = 'esp_event_venue'; |
|
201 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
199 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
200 | + $table_name = 'esp_event_venue'; |
|
201 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
202 | 202 | EVT_ID bigint(20) unsigned NOT NULL, |
203 | 203 | VNU_ID bigint(20) unsigned NOT NULL, |
204 | 204 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
205 | 205 | PRIMARY KEY (EVV_ID)"; |
206 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
207 | - $table_name = 'esp_extra_meta'; |
|
208 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
206 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
207 | + $table_name = 'esp_extra_meta'; |
|
208 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
209 | 209 | OBJ_ID int(11) DEFAULT NULL, |
210 | 210 | EXM_type varchar(45) DEFAULT NULL, |
211 | 211 | EXM_key varchar(45) DEFAULT NULL, |
212 | 212 | EXM_value text, |
213 | 213 | PRIMARY KEY (EXM_ID), |
214 | 214 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
215 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | - $table_name = 'esp_extra_join'; |
|
217 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
215 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
216 | + $table_name = 'esp_extra_join'; |
|
217 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
218 | 218 | EXJ_first_model_id varchar(6) NOT NULL, |
219 | 219 | EXJ_first_model_name varchar(20) NOT NULL, |
220 | 220 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | PRIMARY KEY (EXJ_ID), |
223 | 223 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
224 | 224 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
225 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
226 | - $table_name = 'esp_line_item'; |
|
227 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
225 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
226 | + $table_name = 'esp_line_item'; |
|
227 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
228 | 228 | LIN_code varchar(245) NOT NULL DEFAULT '', |
229 | 229 | TXN_ID int(11) DEFAULT NULL, |
230 | 230 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | PRIMARY KEY (LIN_ID), |
244 | 244 | KEY LIN_code (LIN_code(191)), |
245 | 245 | KEY TXN_ID (TXN_ID)"; |
246 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | - $table_name = 'esp_log'; |
|
248 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
246 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
247 | + $table_name = 'esp_log'; |
|
248 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
249 | 249 | LOG_time datetime DEFAULT NULL, |
250 | 250 | OBJ_ID varchar(45) DEFAULT NULL, |
251 | 251 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -256,18 +256,18 @@ discard block |
||
256 | 256 | KEY LOG_time (LOG_time), |
257 | 257 | KEY OBJ (OBJ_type,OBJ_ID), |
258 | 258 | KEY LOG_type (LOG_type)"; |
259 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | - $table_name = 'esp_message_template'; |
|
261 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
259 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
260 | + $table_name = 'esp_message_template'; |
|
261 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
262 | 262 | GRP_ID int(10) unsigned NOT NULL, |
263 | 263 | MTP_context varchar(50) NOT NULL, |
264 | 264 | MTP_template_field varchar(30) NOT NULL, |
265 | 265 | MTP_content text NOT NULL, |
266 | 266 | PRIMARY KEY (MTP_ID), |
267 | 267 | KEY GRP_ID (GRP_ID)"; |
268 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
269 | - $table_name = 'esp_message_template_group'; |
|
270 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
268 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
269 | + $table_name = 'esp_message_template_group'; |
|
270 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
271 | 271 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
272 | 272 | MTP_name varchar(245) NOT NULL DEFAULT '', |
273 | 273 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
280 | 280 | PRIMARY KEY (GRP_ID), |
281 | 281 | KEY MTP_user_id (MTP_user_id)"; |
282 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
283 | - $table_name = 'esp_event_message_template'; |
|
284 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
282 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
283 | + $table_name = 'esp_event_message_template'; |
|
284 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
285 | 285 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
286 | 286 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
287 | 287 | PRIMARY KEY (EMT_ID), |
288 | 288 | KEY EVT_ID (EVT_ID), |
289 | 289 | KEY GRP_ID (GRP_ID)"; |
290 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
291 | - $table_name = 'esp_payment'; |
|
292 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
290 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
291 | + $table_name = 'esp_payment'; |
|
292 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
293 | 293 | TXN_ID int(10) unsigned DEFAULT NULL, |
294 | 294 | STS_ID varchar(3) collate utf8_bin DEFAULT NULL, |
295 | 295 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | PRIMARY KEY (PAY_ID), |
307 | 307 | KEY PAY_timestamp (PAY_timestamp), |
308 | 308 | KEY TXN_ID (TXN_ID)"; |
309 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
310 | - $table_name = 'esp_payment_method'; |
|
311 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
309 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
310 | + $table_name = 'esp_payment_method'; |
|
311 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
312 | 312 | PMD_type varchar(124) DEFAULT NULL, |
313 | 313 | PMD_name varchar(255) DEFAULT NULL, |
314 | 314 | PMD_desc text, |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | PRIMARY KEY (PMD_ID), |
325 | 325 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
326 | 326 | KEY PMD_type (PMD_type)"; |
327 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
328 | - $table_name = "esp_ticket_price"; |
|
329 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
327 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
328 | + $table_name = "esp_ticket_price"; |
|
329 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
330 | 330 | TKT_ID int(10) unsigned NOT NULL, |
331 | 331 | PRC_ID int(10) unsigned NOT NULL, |
332 | 332 | PRIMARY KEY (TKP_ID), |
333 | 333 | KEY TKT_ID (TKT_ID), |
334 | 334 | KEY PRC_ID (PRC_ID)"; |
335 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
336 | - $table_name = "esp_datetime_ticket"; |
|
337 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
335 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
336 | + $table_name = "esp_datetime_ticket"; |
|
337 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
338 | 338 | DTT_ID int(10) unsigned NOT NULL, |
339 | 339 | TKT_ID int(10) unsigned NOT NULL, |
340 | 340 | PRIMARY KEY (DTK_ID), |
341 | 341 | KEY DTT_ID (DTT_ID), |
342 | 342 | KEY TKT_ID (TKT_ID)"; |
343 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | - $table_name = "esp_ticket_template"; |
|
345 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
344 | + $table_name = "esp_ticket_template"; |
|
345 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
346 | 346 | TTM_name varchar(45) NOT NULL, |
347 | 347 | TTM_description text, |
348 | 348 | TTM_file varchar(45), |
349 | 349 | PRIMARY KEY (TTM_ID)"; |
350 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | - $table_name = 'esp_question'; |
|
352 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
350 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | + $table_name = 'esp_question'; |
|
352 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
353 | 353 | QST_display_text text NOT NULL, |
354 | 354 | QST_admin_label varchar(255) NOT NULL, |
355 | 355 | QST_system varchar(25) NOT NULL DEFAULT "", |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
364 | 364 | PRIMARY KEY (QST_ID), |
365 | 365 | KEY QST_order (QST_order)'; |
366 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
367 | - $table_name = 'esp_question_group_question'; |
|
368 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
366 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
367 | + $table_name = 'esp_question_group_question'; |
|
368 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
369 | 369 | QSG_ID int(10) unsigned NOT NULL, |
370 | 370 | QST_ID int(10) unsigned NOT NULL, |
371 | 371 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
372 | 372 | PRIMARY KEY (QGQ_ID), |
373 | 373 | KEY QST_ID (QST_ID), |
374 | 374 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
375 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | - $table_name = 'esp_question_option'; |
|
377 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
376 | + $table_name = 'esp_question_option'; |
|
377 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
378 | 378 | QSO_value varchar(255) NOT NULL, |
379 | 379 | QSO_desc text NOT NULL, |
380 | 380 | QST_ID int(10) unsigned NOT NULL, |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | PRIMARY KEY (QSO_ID), |
385 | 385 | KEY QST_ID (QST_ID), |
386 | 386 | KEY QSO_order (QSO_order)"; |
387 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
388 | - $table_name = 'esp_registration'; |
|
389 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
388 | + $table_name = 'esp_registration'; |
|
389 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
390 | 390 | EVT_ID bigint(20) unsigned NOT NULL, |
391 | 391 | ATT_ID bigint(20) unsigned NOT NULL, |
392 | 392 | TXN_ID int(10) unsigned NOT NULL, |
@@ -410,18 +410,18 @@ discard block |
||
410 | 410 | KEY TKT_ID (TKT_ID), |
411 | 411 | KEY EVT_ID (EVT_ID), |
412 | 412 | KEY STS_ID (STS_ID)"; |
413 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
414 | - $table_name = 'esp_registration_payment'; |
|
415 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
413 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
414 | + $table_name = 'esp_registration_payment'; |
|
415 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | 416 | REG_ID int(10) unsigned NOT NULL, |
417 | 417 | PAY_ID int(10) unsigned NULL, |
418 | 418 | RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
419 | 419 | PRIMARY KEY (RPY_ID), |
420 | 420 | KEY REG_ID (REG_ID), |
421 | 421 | KEY PAY_ID (PAY_ID)"; |
422 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
423 | - $table_name = 'esp_checkin'; |
|
424 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
422 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
423 | + $table_name = 'esp_checkin'; |
|
424 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
425 | 425 | REG_ID int(10) unsigned NOT NULL, |
426 | 426 | DTT_ID int(10) unsigned NOT NULL, |
427 | 427 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | PRIMARY KEY (CHK_ID), |
430 | 430 | KEY REG_ID (REG_ID), |
431 | 431 | KEY DTT_ID (DTT_ID)"; |
432 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | - $table_name = 'esp_state'; |
|
434 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
432 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
433 | + $table_name = 'esp_state'; |
|
434 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
435 | 435 | CNT_ISO varchar(2) collate utf8_bin NOT NULL, |
436 | 436 | STA_abbrev varchar(24) collate utf8_bin NOT NULL, |
437 | 437 | STA_name varchar(100) collate utf8_bin NOT NULL, |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | PRIMARY KEY (STA_ID), |
440 | 440 | KEY STA_abbrev (STA_abbrev), |
441 | 441 | KEY CNT_ISO (CNT_ISO)"; |
442 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
443 | - $table_name = 'esp_status'; |
|
444 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
442 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
443 | + $table_name = 'esp_status'; |
|
444 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
445 | 445 | STS_code varchar(45) NOT NULL, |
446 | 446 | STS_type varchar(45) NOT NULL, |
447 | 447 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
450 | 450 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
451 | 451 | KEY STS_type (STS_type)"; |
452 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
453 | - $table_name = 'esp_transaction'; |
|
454 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
452 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
453 | + $table_name = 'esp_transaction'; |
|
454 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
455 | 455 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
456 | 456 | TXN_total decimal(10,3) DEFAULT '0.00', |
457 | 457 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | PRIMARY KEY (TXN_ID), |
464 | 464 | KEY TXN_timestamp (TXN_timestamp), |
465 | 465 | KEY STS_ID (STS_ID)"; |
466 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | - $table_name = 'esp_venue_meta'; |
|
468 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
466 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
467 | + $table_name = 'esp_venue_meta'; |
|
468 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
469 | 469 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
470 | 470 | VNU_address varchar(255) DEFAULT NULL, |
471 | 471 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | KEY VNU_ID (VNU_ID), |
485 | 485 | KEY STA_ID (STA_ID), |
486 | 486 | KEY CNT_ISO (CNT_ISO)"; |
487 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | - // modified tables |
|
489 | - $table_name = "esp_price"; |
|
490 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
487 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
488 | + // modified tables |
|
489 | + $table_name = "esp_price"; |
|
490 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | 491 | PRT_ID tinyint(3) unsigned NOT NULL, |
492 | 492 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
493 | 493 | PRC_name varchar(245) NOT NULL, |
@@ -500,9 +500,9 @@ discard block |
||
500 | 500 | PRC_parent int(10) unsigned DEFAULT 0, |
501 | 501 | PRIMARY KEY (PRC_ID), |
502 | 502 | KEY PRT_ID (PRT_ID)"; |
503 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
504 | - $table_name = "esp_price_type"; |
|
505 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
503 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
504 | + $table_name = "esp_price_type"; |
|
505 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
506 | 506 | PRT_name varchar(45) NOT NULL, |
507 | 507 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
508 | 508 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -511,9 +511,9 @@ discard block |
||
511 | 511 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
512 | 512 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
513 | 513 | PRIMARY KEY (PRT_ID)"; |
514 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
515 | - $table_name = "esp_ticket"; |
|
516 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
514 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
515 | + $table_name = "esp_ticket"; |
|
516 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
517 | 517 | TTM_ID int(10) unsigned NOT NULL, |
518 | 518 | TKT_name varchar(245) NOT NULL DEFAULT '', |
519 | 519 | TKT_description text NOT NULL, |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
536 | 536 | PRIMARY KEY (TKT_ID), |
537 | 537 | KEY TKT_start_date (TKT_start_date)"; |
538 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | - $table_name = 'esp_question_group'; |
|
540 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
538 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
539 | + $table_name = 'esp_question_group'; |
|
540 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
541 | 541 | QSG_name varchar(255) NOT NULL, |
542 | 542 | QSG_identifier varchar(100) NOT NULL, |
543 | 543 | QSG_desc text NULL, |
@@ -550,223 +550,223 @@ discard block |
||
550 | 550 | PRIMARY KEY (QSG_ID), |
551 | 551 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
552 | 552 | KEY QSG_order (QSG_order)'; |
553 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
554 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
555 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
556 | - // (because many need to convert old string states to foreign keys into the states table) |
|
557 | - $script_4_1_defaults->insert_default_states(); |
|
558 | - $script_4_1_defaults->insert_default_countries(); |
|
559 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
560 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
561 | - $script_4_5_defaults->insert_default_price_types(); |
|
562 | - $script_4_5_defaults->insert_default_prices(); |
|
563 | - $script_4_5_defaults->insert_default_tickets(); |
|
564 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
565 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
566 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
567 | - $script_4_6_defaults->insert_default_currencies(); |
|
568 | - $this->verify_new_countries(); |
|
569 | - $this->verify_new_currencies(); |
|
570 | - return true; |
|
571 | - } |
|
553 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
554 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
555 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
556 | + // (because many need to convert old string states to foreign keys into the states table) |
|
557 | + $script_4_1_defaults->insert_default_states(); |
|
558 | + $script_4_1_defaults->insert_default_countries(); |
|
559 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
560 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
561 | + $script_4_5_defaults->insert_default_price_types(); |
|
562 | + $script_4_5_defaults->insert_default_prices(); |
|
563 | + $script_4_5_defaults->insert_default_tickets(); |
|
564 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
565 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
566 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
567 | + $script_4_6_defaults->insert_default_currencies(); |
|
568 | + $this->verify_new_countries(); |
|
569 | + $this->verify_new_currencies(); |
|
570 | + return true; |
|
571 | + } |
|
572 | 572 | |
573 | 573 | |
574 | 574 | |
575 | - /** |
|
576 | - * @return boolean |
|
577 | - */ |
|
578 | - public function schema_changes_after_migration() |
|
579 | - { |
|
580 | - $this->fix_non_default_taxes(); |
|
581 | - // this is actually the same as the last DMS |
|
582 | - /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
583 | - $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
584 | - return $script_4_7_defaults->schema_changes_after_migration(); |
|
585 | - } |
|
575 | + /** |
|
576 | + * @return boolean |
|
577 | + */ |
|
578 | + public function schema_changes_after_migration() |
|
579 | + { |
|
580 | + $this->fix_non_default_taxes(); |
|
581 | + // this is actually the same as the last DMS |
|
582 | + /** @var EE_DMS_Core_4_7_0 $script_4_7_defaults */ |
|
583 | + $script_4_7_defaults = EE_Registry::instance()->load_dms('Core_4_7_0'); |
|
584 | + return $script_4_7_defaults->schema_changes_after_migration(); |
|
585 | + } |
|
586 | 586 | |
587 | 587 | |
588 | 588 | |
589 | - public function migration_page_hooks() |
|
590 | - { |
|
591 | - } |
|
589 | + public function migration_page_hooks() |
|
590 | + { |
|
591 | + } |
|
592 | 592 | |
593 | 593 | |
594 | 594 | |
595 | - /** |
|
596 | - * verifies each of the new countries exists that somehow we missed in 4.1 |
|
597 | - */ |
|
598 | - public function verify_new_countries() |
|
599 | - { |
|
600 | - // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
601 | - // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
602 | - // currency symbols: http://www.xe.com/symbols.php |
|
603 | - // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active |
|
604 | - // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
605 | - $newer_countries = array( |
|
606 | - array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0), |
|
607 | - array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
608 | - array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0), |
|
609 | - array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0), |
|
610 | - array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
611 | - array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
612 | - array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
613 | - array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0), |
|
614 | - array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0), |
|
615 | - array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0), |
|
616 | - array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0), |
|
617 | - array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0), |
|
618 | - array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0), |
|
619 | - array( |
|
620 | - 'BQ', |
|
621 | - 'BES', |
|
622 | - 0, |
|
623 | - 'Bonaire, Saint Eustatius and Saba', |
|
624 | - 'USD', |
|
625 | - 'Dollar', |
|
626 | - 'Dollars', |
|
627 | - '$', |
|
628 | - 1, |
|
629 | - 2, |
|
630 | - '+599', |
|
631 | - 0, |
|
632 | - 0, |
|
633 | - ), |
|
634 | - array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0), |
|
635 | - array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0), |
|
636 | - array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0), |
|
637 | - array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0), |
|
638 | - array( |
|
639 | - 'HM', |
|
640 | - 'HMD', |
|
641 | - 0, |
|
642 | - 'Heard Island and McDonald Islands', |
|
643 | - 'AUD', |
|
644 | - 'Dollar', |
|
645 | - 'Dollars', |
|
646 | - '$', |
|
647 | - 1, |
|
648 | - 2, |
|
649 | - '+891', |
|
650 | - 0, |
|
651 | - 0, |
|
652 | - ), |
|
653 | - array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0), |
|
654 | - array( |
|
655 | - 'GS', |
|
656 | - 'SGS', |
|
657 | - 0, |
|
658 | - 'South Georgia and the South Sandwich Islands', |
|
659 | - 'GBP', |
|
660 | - 'Pound', |
|
661 | - 'Pounds', |
|
662 | - '£', |
|
663 | - 1, |
|
664 | - 2, |
|
665 | - '+500', |
|
666 | - 0, |
|
667 | - 0, |
|
668 | - ), |
|
669 | - array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0), |
|
670 | - array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0), |
|
671 | - array( |
|
672 | - 'UM', |
|
673 | - 'UMI', |
|
674 | - 0, |
|
675 | - 'United States Minor Outlying Islands', |
|
676 | - 'USD', |
|
677 | - 'Dollar', |
|
678 | - 'Dollars', |
|
679 | - '$', |
|
680 | - 1, |
|
681 | - 2, |
|
682 | - '+1', |
|
683 | - 0, |
|
684 | - 0, |
|
685 | - ), |
|
686 | - ); |
|
687 | - global $wpdb; |
|
688 | - $country_table = $wpdb->prefix . "esp_country"; |
|
689 | - $country_format = array( |
|
690 | - "CNT_ISO" => '%s', |
|
691 | - "CNT_ISO3" => '%s', |
|
692 | - "RGN_ID" => '%d', |
|
693 | - "CNT_name" => '%s', |
|
694 | - "CNT_cur_code" => '%s', |
|
695 | - "CNT_cur_single" => '%s', |
|
696 | - "CNT_cur_plural" => '%s', |
|
697 | - "CNT_cur_sign" => '%s', |
|
698 | - "CNT_cur_sign_b4" => '%d', |
|
699 | - "CNT_cur_dec_plc" => '%d', |
|
700 | - "CNT_tel_code" => '%s', |
|
701 | - "CNT_is_EU" => '%d', |
|
702 | - "CNT_active" => '%d', |
|
703 | - ); |
|
704 | - if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
705 | - foreach ($newer_countries as $country) { |
|
706 | - $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
|
707 | - $countries = $wpdb->get_var($SQL); |
|
708 | - if (! $countries) { |
|
709 | - $wpdb->insert( |
|
710 | - $country_table, |
|
711 | - array_combine(array_keys($country_format), $country), |
|
712 | - $country_format |
|
713 | - ); |
|
714 | - } |
|
715 | - } |
|
716 | - } |
|
717 | - } |
|
595 | + /** |
|
596 | + * verifies each of the new countries exists that somehow we missed in 4.1 |
|
597 | + */ |
|
598 | + public function verify_new_countries() |
|
599 | + { |
|
600 | + // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
601 | + // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
602 | + // currency symbols: http://www.xe.com/symbols.php |
|
603 | + // CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active |
|
604 | + // ('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0), |
|
605 | + $newer_countries = array( |
|
606 | + array('AX', 'ALA', 0, 'Åland Islands', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+358', 1, 0), |
|
607 | + array('BL', 'BLM', 0, 'Saint Barthelemy', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
608 | + array('CW', 'CUW', 0, 'Curacao', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+599', 1, 0), |
|
609 | + array('GG', 'GGY', 0, 'Guernsey', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+44', 0, 0), |
|
610 | + array('IM', 'IMN', 0, 'Isle of Man', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
611 | + array('JE', 'JEY', 0, 'Jersey', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+44', 0, 0), |
|
612 | + array('MF', 'MAF', 0, 'Saint Martin', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+590', 1, 0), |
|
613 | + array('ME', 'MNE', 0, 'Montenegro', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+382', 0, 0), |
|
614 | + array('RS', 'SRB', 0, 'Serbia', 'RSD', 'Dinar', 'Dinars', '', 0, 2, '+381', 1, 0), |
|
615 | + array('SS', 'SSD', 0, 'South Sudan', 'SSP', 'Pound', 'Pounds', '£', 1, 2, '+211', 0, 0), |
|
616 | + array('SX', 'SXM', 0, 'Sint Maarten', 'ANG', 'Guilder', 'Guilders', 'ƒ', 1, 2, '+1', 1, 0), |
|
617 | + array('XK', 'XKX', 0, 'Kosovo', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+383', 0, 0), |
|
618 | + array('YT', 'MYT', 0, 'Mayotte', 'EUR', 'Euro', 'Euros', '€', 0, 2, '+262', 1, 0), |
|
619 | + array( |
|
620 | + 'BQ', |
|
621 | + 'BES', |
|
622 | + 0, |
|
623 | + 'Bonaire, Saint Eustatius and Saba', |
|
624 | + 'USD', |
|
625 | + 'Dollar', |
|
626 | + 'Dollars', |
|
627 | + '$', |
|
628 | + 1, |
|
629 | + 2, |
|
630 | + '+599', |
|
631 | + 0, |
|
632 | + 0, |
|
633 | + ), |
|
634 | + array('BV', 'BVT', 0, 'Bouvet Island', 'NOK', 'Krone', 'Krones', 'kr', 1, 2, '+47', 0, 0), |
|
635 | + array('IO', 'IOT', 0, 'British Indian Ocean Territory', 'GBP', 'Pound', 'Pounds', '£', 1, 2, '+246', 0, 0), |
|
636 | + array('CX', 'CXR', 0, 'Christmas Island', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+61', 0, 0), |
|
637 | + array('CC', 'CCK', 0, 'Cocos (Keeling) Islands', 'AUD', 'Dollar', 'Dollars', '$', 1, 2, '+891', 0, 0), |
|
638 | + array( |
|
639 | + 'HM', |
|
640 | + 'HMD', |
|
641 | + 0, |
|
642 | + 'Heard Island and McDonald Islands', |
|
643 | + 'AUD', |
|
644 | + 'Dollar', |
|
645 | + 'Dollars', |
|
646 | + '$', |
|
647 | + 1, |
|
648 | + 2, |
|
649 | + '+891', |
|
650 | + 0, |
|
651 | + 0, |
|
652 | + ), |
|
653 | + array('PS', 'PSE', 0, 'Palestinian Territory', 'ILS', 'Shekel', 'Shekels', '₪', 1, 2, '+970', 0, 0), |
|
654 | + array( |
|
655 | + 'GS', |
|
656 | + 'SGS', |
|
657 | + 0, |
|
658 | + 'South Georgia and the South Sandwich Islands', |
|
659 | + 'GBP', |
|
660 | + 'Pound', |
|
661 | + 'Pounds', |
|
662 | + '£', |
|
663 | + 1, |
|
664 | + 2, |
|
665 | + '+500', |
|
666 | + 0, |
|
667 | + 0, |
|
668 | + ), |
|
669 | + array('TL', 'TLS', 0, 'Timor-Leste', 'USD', 'Dollar', 'Dollars', '$', 1, 2, '+670', 0, 0), |
|
670 | + array('TF', 'ATF', 0, 'French Southern Territories', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+262', 0, 0), |
|
671 | + array( |
|
672 | + 'UM', |
|
673 | + 'UMI', |
|
674 | + 0, |
|
675 | + 'United States Minor Outlying Islands', |
|
676 | + 'USD', |
|
677 | + 'Dollar', |
|
678 | + 'Dollars', |
|
679 | + '$', |
|
680 | + 1, |
|
681 | + 2, |
|
682 | + '+1', |
|
683 | + 0, |
|
684 | + 0, |
|
685 | + ), |
|
686 | + ); |
|
687 | + global $wpdb; |
|
688 | + $country_table = $wpdb->prefix . "esp_country"; |
|
689 | + $country_format = array( |
|
690 | + "CNT_ISO" => '%s', |
|
691 | + "CNT_ISO3" => '%s', |
|
692 | + "RGN_ID" => '%d', |
|
693 | + "CNT_name" => '%s', |
|
694 | + "CNT_cur_code" => '%s', |
|
695 | + "CNT_cur_single" => '%s', |
|
696 | + "CNT_cur_plural" => '%s', |
|
697 | + "CNT_cur_sign" => '%s', |
|
698 | + "CNT_cur_sign_b4" => '%d', |
|
699 | + "CNT_cur_dec_plc" => '%d', |
|
700 | + "CNT_tel_code" => '%s', |
|
701 | + "CNT_is_EU" => '%d', |
|
702 | + "CNT_active" => '%d', |
|
703 | + ); |
|
704 | + if ($this->_get_table_analysis()->tableExists($country_table)) { |
|
705 | + foreach ($newer_countries as $country) { |
|
706 | + $SQL = "SELECT COUNT('CNT_ISO') FROM {$country_table} WHERE CNT_ISO='{$country[0]}' LIMIT 1"; |
|
707 | + $countries = $wpdb->get_var($SQL); |
|
708 | + if (! $countries) { |
|
709 | + $wpdb->insert( |
|
710 | + $country_table, |
|
711 | + array_combine(array_keys($country_format), $country), |
|
712 | + $country_format |
|
713 | + ); |
|
714 | + } |
|
715 | + } |
|
716 | + } |
|
717 | + } |
|
718 | 718 | |
719 | 719 | |
720 | 720 | |
721 | - /** |
|
722 | - * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
723 | - */ |
|
724 | - public function verify_new_currencies() |
|
725 | - { |
|
726 | - // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
727 | - // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
728 | - // currency symbols: http://www.xe.com/symbols.php |
|
729 | - // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
730 | - // ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
731 | - $newer_currencies = array( |
|
732 | - array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
|
733 | - ); |
|
734 | - global $wpdb; |
|
735 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
736 | - $currency_format = array( |
|
737 | - "CUR_code" => '%s', |
|
738 | - "CUR_single" => '%s', |
|
739 | - "CUR_plural" => '%s', |
|
740 | - "CUR_sign" => '%s', |
|
741 | - "CUR_dec_plc" => '%d', |
|
742 | - "CUR_active" => '%d', |
|
743 | - ); |
|
744 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
745 | - foreach ($newer_currencies as $currency) { |
|
746 | - $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
|
747 | - $countries = $wpdb->get_var($SQL); |
|
748 | - if (! $countries) { |
|
749 | - $wpdb->insert( |
|
750 | - $currency_table, |
|
751 | - array_combine(array_keys($currency_format), $currency), |
|
752 | - $currency_format |
|
753 | - ); |
|
754 | - } |
|
755 | - } |
|
756 | - } |
|
757 | - } |
|
721 | + /** |
|
722 | + * verifies each of the new currencies exists that somehow we missed in 4.6 |
|
723 | + */ |
|
724 | + public function verify_new_currencies() |
|
725 | + { |
|
726 | + // a list of countries (and specifically some which were missed in another list):https://gist.github.com/adhipg/1600028 |
|
727 | + // how many decimal places? https://en.wikipedia.org/wiki/ISO_4217 |
|
728 | + // currency symbols: http://www.xe.com/symbols.php |
|
729 | + // CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active |
|
730 | + // ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
|
731 | + $newer_currencies = array( |
|
732 | + array('RSD', 'Dinar', 'Dinars', '', 3, 1), |
|
733 | + ); |
|
734 | + global $wpdb; |
|
735 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
736 | + $currency_format = array( |
|
737 | + "CUR_code" => '%s', |
|
738 | + "CUR_single" => '%s', |
|
739 | + "CUR_plural" => '%s', |
|
740 | + "CUR_sign" => '%s', |
|
741 | + "CUR_dec_plc" => '%d', |
|
742 | + "CUR_active" => '%d', |
|
743 | + ); |
|
744 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
745 | + foreach ($newer_currencies as $currency) { |
|
746 | + $SQL = "SELECT COUNT('CUR_code') FROM {$currency_table} WHERE CUR_code='{$currency[0]}' LIMIT 1"; |
|
747 | + $countries = $wpdb->get_var($SQL); |
|
748 | + if (! $countries) { |
|
749 | + $wpdb->insert( |
|
750 | + $currency_table, |
|
751 | + array_combine(array_keys($currency_format), $currency), |
|
752 | + $currency_format |
|
753 | + ); |
|
754 | + } |
|
755 | + } |
|
756 | + } |
|
757 | + } |
|
758 | 758 | |
759 | 759 | |
760 | 760 | |
761 | - /** |
|
762 | - * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
763 | - * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
764 | - * we should be able to stop doing this in 4.9 |
|
765 | - */ |
|
766 | - public function fix_non_default_taxes() |
|
767 | - { |
|
768 | - global $wpdb; |
|
769 | - $query = $wpdb->prepare("UPDATE |
|
761 | + /** |
|
762 | + * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731 |
|
763 | + * which should just be a temporary issue for folks who installed 4.8.0-4.8.5; |
|
764 | + * we should be able to stop doing this in 4.9 |
|
765 | + */ |
|
766 | + public function fix_non_default_taxes() |
|
767 | + { |
|
768 | + global $wpdb; |
|
769 | + $query = $wpdb->prepare("UPDATE |
|
770 | 770 | {$wpdb->prefix}esp_price p INNER JOIN |
771 | 771 | {$wpdb->prefix}esp_price_type pt ON p.PRT_ID = pt.PRT_ID |
772 | 772 | SET |
@@ -775,6 +775,6 @@ discard block |
||
775 | 775 | p.PRC_is_default = 0 AND |
776 | 776 | pt.PBT_ID = %d |
777 | 777 | ", EEM_Price_Type::base_type_tax); |
778 | - $wpdb->query($query); |
|
779 | - } |
|
778 | + $wpdb->query($query); |
|
779 | + } |
|
780 | 780 | } |
@@ -17,406 +17,406 @@ |
||
17 | 17 | abstract class EE_Data_Migration_Class_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var $records_to_migrate int count of all that have been migrated |
|
22 | - */ |
|
23 | - protected $_records_to_migrate = 0; |
|
24 | - |
|
25 | - /** |
|
26 | - * |
|
27 | - * @var $records_migrated int |
|
28 | - */ |
|
29 | - protected $_records_migrated = 0; |
|
30 | - |
|
31 | - /** |
|
32 | - * Whether this migration script is done or not. This COULD be deduced by |
|
33 | - * _records_to_migrate and _records_migrated, but that might nto be accurate |
|
34 | - * |
|
35 | - * @var string one of EE_Data_migration_Manager::status_* constants |
|
36 | - */ |
|
37 | - protected $_status = null; |
|
38 | - |
|
39 | - /** |
|
40 | - * internationalized name of this class. Convention is to NOT restate that |
|
41 | - * this class if a migration script or a migration script stage |
|
42 | - * |
|
43 | - * @var string (i18ned) |
|
44 | - */ |
|
45 | - protected $_pretty_name = null; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - protected $_errors = array(); |
|
51 | - |
|
52 | - /** |
|
53 | - * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
54 | - */ |
|
55 | - protected $_table_manager; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
59 | - */ |
|
60 | - protected $_table_analysis; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Just initializes the status of the migration |
|
65 | - * |
|
66 | - * @param TableManager $table_manager |
|
67 | - * @param TableAnalysis $table_analysis |
|
68 | - */ |
|
69 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
70 | - { |
|
71 | - $this->_table_manager = $table_manager; |
|
72 | - $this->_table_analysis = $table_analysis; |
|
73 | - $this->set_status(EE_Data_Migration_Manager::status_continue); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Just gets the pretty name for this migration script or stage |
|
79 | - * |
|
80 | - * @throws EE_Error |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function pretty_name() |
|
84 | - { |
|
85 | - if ($this->_pretty_name === null) { |
|
86 | - throw new EE_Error( |
|
87 | - sprintf( |
|
88 | - __( |
|
89 | - "Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", |
|
90 | - "event_espresso" |
|
91 | - ), |
|
92 | - get_class($this) |
|
93 | - ) |
|
94 | - ); |
|
95 | - } |
|
96 | - return $this->_pretty_name; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * |
|
101 | - * @return int |
|
102 | - */ |
|
103 | - public function count_records_to_migrate() |
|
104 | - { |
|
105 | - if ($this->_records_to_migrate == null) { |
|
106 | - $this->_records_to_migrate = $this->_count_records_to_migrate(); |
|
107 | - } |
|
108 | - return $this->_records_to_migrate; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Counts records already migrated. This should only be implemented by EE_Data_Migration_Script_base and |
|
113 | - * EE_Data_migration_Script_Stage |
|
114 | - * |
|
115 | - * @return int |
|
116 | - */ |
|
117 | - abstract public function count_records_migrated(); |
|
118 | - |
|
119 | - /** |
|
120 | - * Counts the records to migrate; the public version may cache it |
|
121 | - * |
|
122 | - * @return int |
|
123 | - */ |
|
124 | - abstract protected function _count_records_to_migrate(); |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns a string indicating the migration script's status. |
|
128 | - * |
|
129 | - * @return string one of EE_Data_Migration_Manager::status_* constants |
|
130 | - * @throws EE_Error |
|
131 | - */ |
|
132 | - public function get_status() |
|
133 | - { |
|
134 | - if ($this->_status === null) { |
|
135 | - throw new EE_Error( |
|
136 | - sprintf( |
|
137 | - __( |
|
138 | - "Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", |
|
139 | - "event_espresso" |
|
140 | - ), |
|
141 | - get_class($this) |
|
142 | - ) |
|
143 | - ); |
|
144 | - } |
|
145 | - return $this->_status; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * |
|
150 | - * @param string $status |
|
151 | - * @return void |
|
152 | - */ |
|
153 | - protected function set_status($status) |
|
154 | - { |
|
155 | - $this->_status = $status; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @return array of strings |
|
160 | - */ |
|
161 | - abstract public function get_errors(); |
|
162 | - |
|
163 | - /** |
|
164 | - * Returns the last error that occurred. If none occurred, returns null |
|
165 | - * |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - public function get_last_error() |
|
169 | - { |
|
170 | - $errors = $this->get_errors(); |
|
171 | - if ($errors) { |
|
172 | - return end($errors); |
|
173 | - } else { |
|
174 | - return null; |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Adds an error to the array of errors on this class. |
|
180 | - * |
|
181 | - * @param string $error a string describing the error that will be useful for debugging. Consider including all |
|
182 | - * the data that led to the error, and a stack trace etc. |
|
183 | - * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are |
|
184 | - * already at their limit, we will purposefully forget the first half |
|
185 | - */ |
|
186 | - public function add_error($error, $force = false) |
|
187 | - { |
|
188 | - if (! defined('EE_DMS_ERROR_LIMIT')) { |
|
189 | - $limit = 50; |
|
190 | - } else { |
|
191 | - $limit = EE_DMS_ERROR_LIMIT; |
|
192 | - } |
|
193 | - // make sure errors is an array, see ticket #8261 |
|
194 | - if (is_string($this->_errors)) { |
|
195 | - $this->_errors = array($this->_errors); |
|
196 | - } |
|
197 | - if (count($this->_errors) >= $limit) { |
|
198 | - if ($force) { |
|
199 | - // get rid of the first half of the errors and any above the limit |
|
200 | - $this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2); |
|
201 | - $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
|
202 | - $this->_errors[] = $error; |
|
203 | - } else { |
|
204 | - $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
205 | - } |
|
206 | - } else { |
|
207 | - $this->_errors[] = $error; |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Indicates there was a fatal error and the migration cannot possibly continue |
|
213 | - * |
|
214 | - * @return boolean |
|
215 | - */ |
|
216 | - public function is_broken() |
|
217 | - { |
|
218 | - return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error; |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * @deprecated since 4.6.12 |
|
223 | - */ |
|
224 | - public function is_borked() |
|
225 | - { |
|
226 | - EE_Error::doing_it_wrong( |
|
227 | - 'is_borked', |
|
228 | - __( |
|
229 | - 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
230 | - 'event_espresso' |
|
231 | - ), |
|
232 | - '4.6.12' |
|
233 | - ); |
|
234 | - return $this->is_broken(); |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Sets the status to as having a fatal error |
|
239 | - */ |
|
240 | - public function set_broken() |
|
241 | - { |
|
242 | - $this->_status = EE_Data_Migration_Manager::status_fatal_error; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * |
|
247 | - * @deprecated since 4.6.12 |
|
248 | - */ |
|
249 | - public function set_borked() |
|
250 | - { |
|
251 | - EE_Error::doing_it_wrong( |
|
252 | - 'is_borked', |
|
253 | - __( |
|
254 | - 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
255 | - 'event_espresso' |
|
256 | - ), |
|
257 | - '4.6.12' |
|
258 | - ); |
|
259 | - return $this->set_broken(); |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Checks if this thing believes it is completed |
|
264 | - * |
|
265 | - * @return boolean |
|
266 | - */ |
|
267 | - public function is_completed() |
|
268 | - { |
|
269 | - return $this->get_status() == EE_Data_Migration_Manager::status_completed; |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Checks if the current script has more to do or not (ie, if it's status is CONTINUE) |
|
274 | - * |
|
275 | - * @return boolean |
|
276 | - */ |
|
277 | - public function has_more_to_do() |
|
278 | - { |
|
279 | - return $this->get_status() == EE_Data_Migration_Manager::status_continue; |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * Marks that we believe this migration thing is completed |
|
284 | - */ |
|
285 | - public function set_completed() |
|
286 | - { |
|
287 | - $this->_status = EE_Data_Migration_Manager::status_completed; |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Marks that we think this migration class can continue to migrate |
|
292 | - */ |
|
293 | - public function reattempt() |
|
294 | - { |
|
295 | - $this->_status = EE_Data_Migration_Manager::status_continue; |
|
296 | - $this->add_error(__('Reattempt migration', 'event_espresso'), true); |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * A lot like "__sleep()" magic method in purpose, this is meant for persisting this class' |
|
301 | - * properties to the DB. However, we don't want to use __sleep() because its quite |
|
302 | - * possible that this class is defined when it goes to sleep, but NOT available when it |
|
303 | - * awakes (eg, this class is part of an addon that is deactivated at some point). |
|
304 | - */ |
|
305 | - public function properties_as_array() |
|
306 | - { |
|
307 | - $properties = get_object_vars($this); |
|
308 | - $properties['class'] = get_class($this); |
|
309 | - unset($properties['_migration_script']); |
|
310 | - return $properties; |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
315 | - * to have been made from the properties_as_array() function. |
|
316 | - * |
|
317 | - * @param array $array_of_properties like what's produced from properties_as_array() method |
|
318 | - */ |
|
319 | - abstract public function instantiate_from_array_of_properties($array_of_properties); |
|
320 | - |
|
321 | - /** |
|
322 | - * Convenience method for showing a database insertion error |
|
323 | - * |
|
324 | - * @param string $old_table |
|
325 | - * @param array $old_row_as_array |
|
326 | - * @param string $new_table |
|
327 | - * @param array $new_row_as_array columns=>values like used in wpdb->insert |
|
328 | - * @param array $data_types numerically indexed |
|
329 | - * @return string |
|
330 | - */ |
|
331 | - protected function _create_error_message_for_db_insertion( |
|
332 | - $old_table, |
|
333 | - $old_row_as_array, |
|
334 | - $new_table, |
|
335 | - $new_row_as_array, |
|
336 | - $data_types |
|
337 | - ) { |
|
338 | - global $wpdb; |
|
339 | - $old_columns_and_values_for_string = array(); |
|
340 | - foreach ($old_row_as_array as $column => $value) { |
|
341 | - $old_columns_and_values_for_string[] = "$column => $value"; |
|
342 | - } |
|
343 | - $new_columns_and_values_for_string = array(); |
|
344 | - $count = 0; |
|
345 | - foreach ($new_row_as_array as $column => $value) { |
|
346 | - $new_columns_and_values_for_string[] = " $column => $value (" . $data_types[ $count++ ] . ")"; |
|
347 | - } |
|
348 | - return sprintf( |
|
349 | - __( |
|
350 | - 'Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4$s.', |
|
351 | - 'event_espresso' |
|
352 | - ), |
|
353 | - implode(", ", $new_columns_and_values_for_string), |
|
354 | - $new_table, |
|
355 | - implode(", ", $old_columns_and_values_for_string), |
|
356 | - $old_table, |
|
357 | - '<br/>', |
|
358 | - $wpdb->last_error |
|
359 | - ); |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - /** |
|
364 | - * Same as json_encode, just avoids putting |
|
365 | - * serialized arrays into the http build query, as that would |
|
366 | - * |
|
367 | - * @param array $array_of_data |
|
368 | - * @return string |
|
369 | - */ |
|
370 | - protected function _json_encode($array_of_data) |
|
371 | - { |
|
372 | - // we'd rather NOT serialize the transaction details |
|
373 | - $fields_to_include = array(); |
|
374 | - foreach ($array_of_data as $name => $value) { |
|
375 | - $unserialized_data = @unserialize($value); |
|
376 | - if ($unserialized_data === false) { |
|
377 | - $fields_to_include[ $name ] = $value; |
|
378 | - } |
|
379 | - } |
|
380 | - return wp_json_encode($fields_to_include); |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * Gets the table manager (or throws an exception if it cannot be retrieved) |
|
385 | - * |
|
386 | - * @return TableManager |
|
387 | - * @throws EE_Error |
|
388 | - */ |
|
389 | - protected function _get_table_manager() |
|
390 | - { |
|
391 | - if ($this->_table_manager instanceof TableManager) { |
|
392 | - return $this->_table_manager; |
|
393 | - } else { |
|
394 | - throw new EE_Error( |
|
395 | - sprintf( |
|
396 | - __('Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
397 | - get_class($this) |
|
398 | - ) |
|
399 | - ); |
|
400 | - } |
|
401 | - } |
|
402 | - |
|
403 | - /** |
|
404 | - * Gets the injected table analyzer, or throws an exception |
|
405 | - * |
|
406 | - * @return TableAnalysis |
|
407 | - * @throws EE_Error |
|
408 | - */ |
|
409 | - protected function _get_table_analysis() |
|
410 | - { |
|
411 | - if ($this->_table_analysis instanceof TableAnalysis) { |
|
412 | - return $this->_table_analysis; |
|
413 | - } else { |
|
414 | - throw new EE_Error( |
|
415 | - sprintf( |
|
416 | - __('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
417 | - get_class($this) |
|
418 | - ) |
|
419 | - ); |
|
420 | - } |
|
421 | - } |
|
20 | + /** |
|
21 | + * @var $records_to_migrate int count of all that have been migrated |
|
22 | + */ |
|
23 | + protected $_records_to_migrate = 0; |
|
24 | + |
|
25 | + /** |
|
26 | + * |
|
27 | + * @var $records_migrated int |
|
28 | + */ |
|
29 | + protected $_records_migrated = 0; |
|
30 | + |
|
31 | + /** |
|
32 | + * Whether this migration script is done or not. This COULD be deduced by |
|
33 | + * _records_to_migrate and _records_migrated, but that might nto be accurate |
|
34 | + * |
|
35 | + * @var string one of EE_Data_migration_Manager::status_* constants |
|
36 | + */ |
|
37 | + protected $_status = null; |
|
38 | + |
|
39 | + /** |
|
40 | + * internationalized name of this class. Convention is to NOT restate that |
|
41 | + * this class if a migration script or a migration script stage |
|
42 | + * |
|
43 | + * @var string (i18ned) |
|
44 | + */ |
|
45 | + protected $_pretty_name = null; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + protected $_errors = array(); |
|
51 | + |
|
52 | + /** |
|
53 | + * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
54 | + */ |
|
55 | + protected $_table_manager; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
59 | + */ |
|
60 | + protected $_table_analysis; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Just initializes the status of the migration |
|
65 | + * |
|
66 | + * @param TableManager $table_manager |
|
67 | + * @param TableAnalysis $table_analysis |
|
68 | + */ |
|
69 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
70 | + { |
|
71 | + $this->_table_manager = $table_manager; |
|
72 | + $this->_table_analysis = $table_analysis; |
|
73 | + $this->set_status(EE_Data_Migration_Manager::status_continue); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Just gets the pretty name for this migration script or stage |
|
79 | + * |
|
80 | + * @throws EE_Error |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function pretty_name() |
|
84 | + { |
|
85 | + if ($this->_pretty_name === null) { |
|
86 | + throw new EE_Error( |
|
87 | + sprintf( |
|
88 | + __( |
|
89 | + "Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", |
|
90 | + "event_espresso" |
|
91 | + ), |
|
92 | + get_class($this) |
|
93 | + ) |
|
94 | + ); |
|
95 | + } |
|
96 | + return $this->_pretty_name; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * |
|
101 | + * @return int |
|
102 | + */ |
|
103 | + public function count_records_to_migrate() |
|
104 | + { |
|
105 | + if ($this->_records_to_migrate == null) { |
|
106 | + $this->_records_to_migrate = $this->_count_records_to_migrate(); |
|
107 | + } |
|
108 | + return $this->_records_to_migrate; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Counts records already migrated. This should only be implemented by EE_Data_Migration_Script_base and |
|
113 | + * EE_Data_migration_Script_Stage |
|
114 | + * |
|
115 | + * @return int |
|
116 | + */ |
|
117 | + abstract public function count_records_migrated(); |
|
118 | + |
|
119 | + /** |
|
120 | + * Counts the records to migrate; the public version may cache it |
|
121 | + * |
|
122 | + * @return int |
|
123 | + */ |
|
124 | + abstract protected function _count_records_to_migrate(); |
|
125 | + |
|
126 | + /** |
|
127 | + * Returns a string indicating the migration script's status. |
|
128 | + * |
|
129 | + * @return string one of EE_Data_Migration_Manager::status_* constants |
|
130 | + * @throws EE_Error |
|
131 | + */ |
|
132 | + public function get_status() |
|
133 | + { |
|
134 | + if ($this->_status === null) { |
|
135 | + throw new EE_Error( |
|
136 | + sprintf( |
|
137 | + __( |
|
138 | + "Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", |
|
139 | + "event_espresso" |
|
140 | + ), |
|
141 | + get_class($this) |
|
142 | + ) |
|
143 | + ); |
|
144 | + } |
|
145 | + return $this->_status; |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * |
|
150 | + * @param string $status |
|
151 | + * @return void |
|
152 | + */ |
|
153 | + protected function set_status($status) |
|
154 | + { |
|
155 | + $this->_status = $status; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @return array of strings |
|
160 | + */ |
|
161 | + abstract public function get_errors(); |
|
162 | + |
|
163 | + /** |
|
164 | + * Returns the last error that occurred. If none occurred, returns null |
|
165 | + * |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + public function get_last_error() |
|
169 | + { |
|
170 | + $errors = $this->get_errors(); |
|
171 | + if ($errors) { |
|
172 | + return end($errors); |
|
173 | + } else { |
|
174 | + return null; |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Adds an error to the array of errors on this class. |
|
180 | + * |
|
181 | + * @param string $error a string describing the error that will be useful for debugging. Consider including all |
|
182 | + * the data that led to the error, and a stack trace etc. |
|
183 | + * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are |
|
184 | + * already at their limit, we will purposefully forget the first half |
|
185 | + */ |
|
186 | + public function add_error($error, $force = false) |
|
187 | + { |
|
188 | + if (! defined('EE_DMS_ERROR_LIMIT')) { |
|
189 | + $limit = 50; |
|
190 | + } else { |
|
191 | + $limit = EE_DMS_ERROR_LIMIT; |
|
192 | + } |
|
193 | + // make sure errors is an array, see ticket #8261 |
|
194 | + if (is_string($this->_errors)) { |
|
195 | + $this->_errors = array($this->_errors); |
|
196 | + } |
|
197 | + if (count($this->_errors) >= $limit) { |
|
198 | + if ($force) { |
|
199 | + // get rid of the first half of the errors and any above the limit |
|
200 | + $this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2); |
|
201 | + $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
|
202 | + $this->_errors[] = $error; |
|
203 | + } else { |
|
204 | + $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
205 | + } |
|
206 | + } else { |
|
207 | + $this->_errors[] = $error; |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * Indicates there was a fatal error and the migration cannot possibly continue |
|
213 | + * |
|
214 | + * @return boolean |
|
215 | + */ |
|
216 | + public function is_broken() |
|
217 | + { |
|
218 | + return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error; |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * @deprecated since 4.6.12 |
|
223 | + */ |
|
224 | + public function is_borked() |
|
225 | + { |
|
226 | + EE_Error::doing_it_wrong( |
|
227 | + 'is_borked', |
|
228 | + __( |
|
229 | + 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
230 | + 'event_espresso' |
|
231 | + ), |
|
232 | + '4.6.12' |
|
233 | + ); |
|
234 | + return $this->is_broken(); |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Sets the status to as having a fatal error |
|
239 | + */ |
|
240 | + public function set_broken() |
|
241 | + { |
|
242 | + $this->_status = EE_Data_Migration_Manager::status_fatal_error; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * |
|
247 | + * @deprecated since 4.6.12 |
|
248 | + */ |
|
249 | + public function set_borked() |
|
250 | + { |
|
251 | + EE_Error::doing_it_wrong( |
|
252 | + 'is_borked', |
|
253 | + __( |
|
254 | + 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', |
|
255 | + 'event_espresso' |
|
256 | + ), |
|
257 | + '4.6.12' |
|
258 | + ); |
|
259 | + return $this->set_broken(); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Checks if this thing believes it is completed |
|
264 | + * |
|
265 | + * @return boolean |
|
266 | + */ |
|
267 | + public function is_completed() |
|
268 | + { |
|
269 | + return $this->get_status() == EE_Data_Migration_Manager::status_completed; |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Checks if the current script has more to do or not (ie, if it's status is CONTINUE) |
|
274 | + * |
|
275 | + * @return boolean |
|
276 | + */ |
|
277 | + public function has_more_to_do() |
|
278 | + { |
|
279 | + return $this->get_status() == EE_Data_Migration_Manager::status_continue; |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Marks that we believe this migration thing is completed |
|
284 | + */ |
|
285 | + public function set_completed() |
|
286 | + { |
|
287 | + $this->_status = EE_Data_Migration_Manager::status_completed; |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Marks that we think this migration class can continue to migrate |
|
292 | + */ |
|
293 | + public function reattempt() |
|
294 | + { |
|
295 | + $this->_status = EE_Data_Migration_Manager::status_continue; |
|
296 | + $this->add_error(__('Reattempt migration', 'event_espresso'), true); |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * A lot like "__sleep()" magic method in purpose, this is meant for persisting this class' |
|
301 | + * properties to the DB. However, we don't want to use __sleep() because its quite |
|
302 | + * possible that this class is defined when it goes to sleep, but NOT available when it |
|
303 | + * awakes (eg, this class is part of an addon that is deactivated at some point). |
|
304 | + */ |
|
305 | + public function properties_as_array() |
|
306 | + { |
|
307 | + $properties = get_object_vars($this); |
|
308 | + $properties['class'] = get_class($this); |
|
309 | + unset($properties['_migration_script']); |
|
310 | + return $properties; |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Sets all of the properties of this script stage to match what's in the array, which is assumed |
|
315 | + * to have been made from the properties_as_array() function. |
|
316 | + * |
|
317 | + * @param array $array_of_properties like what's produced from properties_as_array() method |
|
318 | + */ |
|
319 | + abstract public function instantiate_from_array_of_properties($array_of_properties); |
|
320 | + |
|
321 | + /** |
|
322 | + * Convenience method for showing a database insertion error |
|
323 | + * |
|
324 | + * @param string $old_table |
|
325 | + * @param array $old_row_as_array |
|
326 | + * @param string $new_table |
|
327 | + * @param array $new_row_as_array columns=>values like used in wpdb->insert |
|
328 | + * @param array $data_types numerically indexed |
|
329 | + * @return string |
|
330 | + */ |
|
331 | + protected function _create_error_message_for_db_insertion( |
|
332 | + $old_table, |
|
333 | + $old_row_as_array, |
|
334 | + $new_table, |
|
335 | + $new_row_as_array, |
|
336 | + $data_types |
|
337 | + ) { |
|
338 | + global $wpdb; |
|
339 | + $old_columns_and_values_for_string = array(); |
|
340 | + foreach ($old_row_as_array as $column => $value) { |
|
341 | + $old_columns_and_values_for_string[] = "$column => $value"; |
|
342 | + } |
|
343 | + $new_columns_and_values_for_string = array(); |
|
344 | + $count = 0; |
|
345 | + foreach ($new_row_as_array as $column => $value) { |
|
346 | + $new_columns_and_values_for_string[] = " $column => $value (" . $data_types[ $count++ ] . ")"; |
|
347 | + } |
|
348 | + return sprintf( |
|
349 | + __( |
|
350 | + 'Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4$s.', |
|
351 | + 'event_espresso' |
|
352 | + ), |
|
353 | + implode(", ", $new_columns_and_values_for_string), |
|
354 | + $new_table, |
|
355 | + implode(", ", $old_columns_and_values_for_string), |
|
356 | + $old_table, |
|
357 | + '<br/>', |
|
358 | + $wpdb->last_error |
|
359 | + ); |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + /** |
|
364 | + * Same as json_encode, just avoids putting |
|
365 | + * serialized arrays into the http build query, as that would |
|
366 | + * |
|
367 | + * @param array $array_of_data |
|
368 | + * @return string |
|
369 | + */ |
|
370 | + protected function _json_encode($array_of_data) |
|
371 | + { |
|
372 | + // we'd rather NOT serialize the transaction details |
|
373 | + $fields_to_include = array(); |
|
374 | + foreach ($array_of_data as $name => $value) { |
|
375 | + $unserialized_data = @unserialize($value); |
|
376 | + if ($unserialized_data === false) { |
|
377 | + $fields_to_include[ $name ] = $value; |
|
378 | + } |
|
379 | + } |
|
380 | + return wp_json_encode($fields_to_include); |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Gets the table manager (or throws an exception if it cannot be retrieved) |
|
385 | + * |
|
386 | + * @return TableManager |
|
387 | + * @throws EE_Error |
|
388 | + */ |
|
389 | + protected function _get_table_manager() |
|
390 | + { |
|
391 | + if ($this->_table_manager instanceof TableManager) { |
|
392 | + return $this->_table_manager; |
|
393 | + } else { |
|
394 | + throw new EE_Error( |
|
395 | + sprintf( |
|
396 | + __('Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
397 | + get_class($this) |
|
398 | + ) |
|
399 | + ); |
|
400 | + } |
|
401 | + } |
|
402 | + |
|
403 | + /** |
|
404 | + * Gets the injected table analyzer, or throws an exception |
|
405 | + * |
|
406 | + * @return TableAnalysis |
|
407 | + * @throws EE_Error |
|
408 | + */ |
|
409 | + protected function _get_table_analysis() |
|
410 | + { |
|
411 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
412 | + return $this->_table_analysis; |
|
413 | + } else { |
|
414 | + throw new EE_Error( |
|
415 | + sprintf( |
|
416 | + __('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
417 | + get_class($this) |
|
418 | + ) |
|
419 | + ); |
|
420 | + } |
|
421 | + } |
|
422 | 422 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function add_error($error, $force = false) |
187 | 187 | { |
188 | - if (! defined('EE_DMS_ERROR_LIMIT')) { |
|
188 | + if ( ! defined('EE_DMS_ERROR_LIMIT')) { |
|
189 | 189 | $limit = 50; |
190 | 190 | } else { |
191 | 191 | $limit = EE_DMS_ERROR_LIMIT; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
202 | 202 | $this->_errors[] = $error; |
203 | 203 | } else { |
204 | - $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
204 | + $this->_errors[$limit] = 'More, but limit reached...'; |
|
205 | 205 | } |
206 | 206 | } else { |
207 | 207 | $this->_errors[] = $error; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $new_columns_and_values_for_string = array(); |
344 | 344 | $count = 0; |
345 | 345 | foreach ($new_row_as_array as $column => $value) { |
346 | - $new_columns_and_values_for_string[] = " $column => $value (" . $data_types[ $count++ ] . ")"; |
|
346 | + $new_columns_and_values_for_string[] = " $column => $value (".$data_types[$count++].")"; |
|
347 | 347 | } |
348 | 348 | return sprintf( |
349 | 349 | __( |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | foreach ($array_of_data as $name => $value) { |
375 | 375 | $unserialized_data = @unserialize($value); |
376 | 376 | if ($unserialized_data === false) { |
377 | - $fields_to_include[ $name ] = $value; |
|
377 | + $fields_to_include[$name] = $value; |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | return wp_json_encode($fields_to_include); |
@@ -8,53 +8,53 @@ |
||
8 | 8 | */ |
9 | 9 | class EE_DMS_4_1_0_category_details extends EE_Data_Migration_Script_Stage |
10 | 10 | { |
11 | - private $_old_table; |
|
12 | - private $_new_table; |
|
13 | - private $_new_term_table; |
|
14 | - public function _migration_step($num_items = 50) |
|
15 | - { |
|
16 | - global $wpdb; |
|
17 | - $start_at_record = $this->count_records_migrated(); |
|
18 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
19 | - $items_actually_migrated = 0; |
|
20 | - foreach ($rows as $category_detail_row) { |
|
21 | - $term_and_taxonomy_ids = wp_insert_term( |
|
22 | - stripslashes($category_detail_row['category_name']), |
|
23 | - 'espresso_event_categories', |
|
24 | - array( |
|
25 | - 'description'=> stripslashes($category_detail_row['category_desc']), |
|
26 | - 'slug'=>$category_detail_row['category_identifier'] |
|
27 | - ) |
|
28 | - ); |
|
29 | - if ($term_and_taxonomy_ids instanceof WP_Error) { |
|
30 | - $this->add_error(sprintf(__("Could not create WP Term_Taxonomy from old category: %s. The Error was: %s", "event_espresso"), $this->_json_encode($category_detail_row), $term_and_taxonomy_ids->get_error_message())); |
|
31 | - $items_actually_migrated++; |
|
32 | - continue; |
|
33 | - } |
|
34 | - $term_id = $term_and_taxonomy_ids['term_id']; |
|
35 | - $term_taxonomy_id = $term_and_taxonomy_ids['term_taxonomy_id']; |
|
36 | - $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_term_table, $term_id); |
|
37 | - $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_table, $term_taxonomy_id); |
|
38 | - $items_actually_migrated++; |
|
39 | - } |
|
40 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
41 | - $this->set_completed(); |
|
42 | - } |
|
43 | - return $items_actually_migrated; |
|
44 | - } |
|
45 | - public function _count_records_to_migrate() |
|
46 | - { |
|
47 | - global $wpdb; |
|
48 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM $this->_old_table"); |
|
49 | - return $count; |
|
50 | - } |
|
51 | - public function __construct() |
|
52 | - { |
|
53 | - $this->_pretty_name = __("Category Details", "event_espresso"); |
|
54 | - global $wpdb; |
|
55 | - $this->_old_table = $wpdb->prefix."events_category_detail"; |
|
56 | - $this->_new_table = $wpdb->prefix."term_taxonomy"; |
|
57 | - $this->_new_term_table = $wpdb->prefix."terms"; |
|
58 | - parent::__construct(); |
|
59 | - } |
|
11 | + private $_old_table; |
|
12 | + private $_new_table; |
|
13 | + private $_new_term_table; |
|
14 | + public function _migration_step($num_items = 50) |
|
15 | + { |
|
16 | + global $wpdb; |
|
17 | + $start_at_record = $this->count_records_migrated(); |
|
18 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
19 | + $items_actually_migrated = 0; |
|
20 | + foreach ($rows as $category_detail_row) { |
|
21 | + $term_and_taxonomy_ids = wp_insert_term( |
|
22 | + stripslashes($category_detail_row['category_name']), |
|
23 | + 'espresso_event_categories', |
|
24 | + array( |
|
25 | + 'description'=> stripslashes($category_detail_row['category_desc']), |
|
26 | + 'slug'=>$category_detail_row['category_identifier'] |
|
27 | + ) |
|
28 | + ); |
|
29 | + if ($term_and_taxonomy_ids instanceof WP_Error) { |
|
30 | + $this->add_error(sprintf(__("Could not create WP Term_Taxonomy from old category: %s. The Error was: %s", "event_espresso"), $this->_json_encode($category_detail_row), $term_and_taxonomy_ids->get_error_message())); |
|
31 | + $items_actually_migrated++; |
|
32 | + continue; |
|
33 | + } |
|
34 | + $term_id = $term_and_taxonomy_ids['term_id']; |
|
35 | + $term_taxonomy_id = $term_and_taxonomy_ids['term_taxonomy_id']; |
|
36 | + $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_term_table, $term_id); |
|
37 | + $this->get_migration_script()->set_mapping($this->_old_table, $category_detail_row['id'], $this->_new_table, $term_taxonomy_id); |
|
38 | + $items_actually_migrated++; |
|
39 | + } |
|
40 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
41 | + $this->set_completed(); |
|
42 | + } |
|
43 | + return $items_actually_migrated; |
|
44 | + } |
|
45 | + public function _count_records_to_migrate() |
|
46 | + { |
|
47 | + global $wpdb; |
|
48 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM $this->_old_table"); |
|
49 | + return $count; |
|
50 | + } |
|
51 | + public function __construct() |
|
52 | + { |
|
53 | + $this->_pretty_name = __("Category Details", "event_espresso"); |
|
54 | + global $wpdb; |
|
55 | + $this->_old_table = $wpdb->prefix."events_category_detail"; |
|
56 | + $this->_new_table = $wpdb->prefix."term_taxonomy"; |
|
57 | + $this->_new_term_table = $wpdb->prefix."terms"; |
|
58 | + parent::__construct(); |
|
59 | + } |
|
60 | 60 | } |
@@ -24,87 +24,85 @@ |
||
24 | 24 | 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
25 | 25 | 'term_order'=>new EE_Integer_Field('term_order', __('Term Order','event_espresso'), false, 0) |
26 | 26 | )); |
27 | - |
|
28 | - |
|
29 | 27 | * |
30 | 28 | */ |
31 | 29 | class EE_DMS_4_1_0_event_category extends EE_Data_Migration_Script_Stage |
32 | 30 | { |
33 | - private $_old_table; |
|
34 | - private $_new_table; |
|
35 | - public function _migration_step($num_items = 50) |
|
36 | - { |
|
37 | - global $wpdb; |
|
38 | - $start_at_record = $this->count_records_migrated(); |
|
39 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
40 | - $items_actually_migrated = 0; |
|
41 | - foreach ($rows as $event_venue_rel) { |
|
42 | - $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel); |
|
43 | - if ($term_relation_id) { |
|
44 | - $this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id); |
|
45 | - } |
|
46 | - $items_actually_migrated++; |
|
47 | - } |
|
48 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
49 | - $this->set_completed(); |
|
50 | - } |
|
51 | - return $items_actually_migrated; |
|
52 | - } |
|
53 | - public function _count_records_to_migrate() |
|
54 | - { |
|
55 | - global $wpdb; |
|
56 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
57 | - return $count; |
|
58 | - } |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - global $wpdb; |
|
62 | - $this->_old_table = $wpdb->prefix."events_category_rel"; |
|
63 | - $this->_new_table = $wpdb->prefix."term_relationships"; |
|
64 | - $this->_pretty_name = __("Event to Category (4.1 Term Relationships)", "event_espresso"); |
|
65 | - parent::__construct(); |
|
66 | - } |
|
31 | + private $_old_table; |
|
32 | + private $_new_table; |
|
33 | + public function _migration_step($num_items = 50) |
|
34 | + { |
|
35 | + global $wpdb; |
|
36 | + $start_at_record = $this->count_records_migrated(); |
|
37 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
38 | + $items_actually_migrated = 0; |
|
39 | + foreach ($rows as $event_venue_rel) { |
|
40 | + $term_relation_id = $this->_add_relation_from_event_to_term_taxonomy($event_venue_rel); |
|
41 | + if ($term_relation_id) { |
|
42 | + $this->get_migration_script()->set_mapping($this->_old_table, $event_venue_rel['id'], $this->_new_table, $term_relation_id); |
|
43 | + } |
|
44 | + $items_actually_migrated++; |
|
45 | + } |
|
46 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
47 | + $this->set_completed(); |
|
48 | + } |
|
49 | + return $items_actually_migrated; |
|
50 | + } |
|
51 | + public function _count_records_to_migrate() |
|
52 | + { |
|
53 | + global $wpdb; |
|
54 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
55 | + return $count; |
|
56 | + } |
|
57 | + public function __construct() |
|
58 | + { |
|
59 | + global $wpdb; |
|
60 | + $this->_old_table = $wpdb->prefix."events_category_rel"; |
|
61 | + $this->_new_table = $wpdb->prefix."term_relationships"; |
|
62 | + $this->_pretty_name = __("Event to Category (4.1 Term Relationships)", "event_espresso"); |
|
63 | + parent::__construct(); |
|
64 | + } |
|
67 | 65 | |
68 | - /** |
|
69 | - * Attempts to insert a new question group inthe new format given an old one |
|
70 | - * @global type $wpdb |
|
71 | - * @param array $old_event_cat_relation |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation) |
|
75 | - { |
|
76 | - global $wpdb; |
|
77 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts"); |
|
78 | - $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy"); |
|
79 | - if (! $new_event_id) { |
|
80 | - $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id'])); |
|
81 | - return 0; |
|
82 | - } |
|
83 | - if (! $new_term_taxonomy_id) { |
|
84 | - $this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id'])); |
|
85 | - return 0; |
|
86 | - } |
|
87 | - $cols_n_values = array( |
|
88 | - 'object_id'=>$new_event_id, |
|
89 | - 'term_taxonomy_id'=>$new_term_taxonomy_id, |
|
90 | - 'term_order'=>0 |
|
91 | - ); |
|
92 | - $datatypes = array( |
|
93 | - '%d',// object_id |
|
94 | - '%d',// term_taxonomy_id |
|
95 | - '%d',// term_order |
|
96 | - ); |
|
97 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
98 | - if (! $success) { |
|
99 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes)); |
|
100 | - return 0; |
|
101 | - } else { |
|
102 | - // increment the term-taxonomie's count |
|
103 | - $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id)); |
|
104 | - if (! $success) { |
|
105 | - $this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
|
106 | - } |
|
107 | - } |
|
108 | - return $wpdb->insert_id; |
|
109 | - } |
|
66 | + /** |
|
67 | + * Attempts to insert a new question group inthe new format given an old one |
|
68 | + * @global type $wpdb |
|
69 | + * @param array $old_event_cat_relation |
|
70 | + * @return int |
|
71 | + */ |
|
72 | + private function _add_relation_from_event_to_term_taxonomy($old_event_cat_relation) |
|
73 | + { |
|
74 | + global $wpdb; |
|
75 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts"); |
|
76 | + $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy"); |
|
77 | + if (! $new_event_id) { |
|
78 | + $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id'])); |
|
79 | + return 0; |
|
80 | + } |
|
81 | + if (! $new_term_taxonomy_id) { |
|
82 | + $this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id'])); |
|
83 | + return 0; |
|
84 | + } |
|
85 | + $cols_n_values = array( |
|
86 | + 'object_id'=>$new_event_id, |
|
87 | + 'term_taxonomy_id'=>$new_term_taxonomy_id, |
|
88 | + 'term_order'=>0 |
|
89 | + ); |
|
90 | + $datatypes = array( |
|
91 | + '%d',// object_id |
|
92 | + '%d',// term_taxonomy_id |
|
93 | + '%d',// term_order |
|
94 | + ); |
|
95 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
96 | + if (! $success) { |
|
97 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes)); |
|
98 | + return 0; |
|
99 | + } else { |
|
100 | + // increment the term-taxonomie's count |
|
101 | + $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id)); |
|
102 | + if (! $success) { |
|
103 | + $this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
|
104 | + } |
|
105 | + } |
|
106 | + return $wpdb->insert_id; |
|
107 | + } |
|
110 | 108 | } |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | global $wpdb; |
77 | 77 | $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event_cat_relation['event_id']), $wpdb->prefix."posts"); |
78 | 78 | $new_term_taxonomy_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_category_detail", intval($old_event_cat_relation['cat_id']), $wpdb->prefix."term_taxonomy"); |
79 | - if (! $new_event_id) { |
|
79 | + if ( ! $new_event_id) { |
|
80 | 80 | $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $old_event_cat_relation['event_id'])); |
81 | 81 | return 0; |
82 | 82 | } |
83 | - if (! $new_term_taxonomy_id) { |
|
83 | + if ( ! $new_term_taxonomy_id) { |
|
84 | 84 | $this->add_error(sprintf(__("Could not find 4.1 term-taxonomy id for 3.1 category #%d.", "event_espresso"), $old_event_cat_relation['cat_id'])); |
85 | 85 | return 0; |
86 | 86 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | 'term_order'=>0 |
91 | 91 | ); |
92 | 92 | $datatypes = array( |
93 | - '%d',// object_id |
|
94 | - '%d',// term_taxonomy_id |
|
95 | - '%d',// term_order |
|
93 | + '%d', // object_id |
|
94 | + '%d', // term_taxonomy_id |
|
95 | + '%d', // term_order |
|
96 | 96 | ); |
97 | 97 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
98 | - if (! $success) { |
|
98 | + if ( ! $success) { |
|
99 | 99 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_cat_relation, $this->_new_table, $cols_n_values, $datatypes)); |
100 | 100 | return 0; |
101 | 101 | } else { |
102 | 102 | // increment the term-taxonomie's count |
103 | 103 | $success = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->term_taxonomy} SET count = count +1 WHERE term_taxonomy_id=%d", $new_term_taxonomy_id)); |
104 | - if (! $success) { |
|
104 | + if ( ! $success) { |
|
105 | 105 | $this->add_error(sprintf(__('Could not increment term_taxonomy\'s count because %s', 'event_espresso'), $wpdb->last_error)); |
106 | 106 | } |
107 | 107 | } |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | private function _insert_event_question_group($old_event, $old_question_group_id, $primary) |
102 | 102 | { |
103 | 103 | global $wpdb; |
104 | - $new_question_group_id =$this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", intval($old_question_group_id), $wpdb->prefix."esp_question_group"); |
|
104 | + $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", intval($old_question_group_id), $wpdb->prefix."esp_question_group"); |
|
105 | 105 | |
106 | - if (! $new_question_group_id) { |
|
106 | + if ( ! $new_question_group_id) { |
|
107 | 107 | $this->add_error(sprintf(__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"), $old_question_group_id, $old_event['id'])); |
108 | 108 | return 0; |
109 | 109 | } |
110 | 110 | $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event['id']), $wpdb->posts); |
111 | - if (! $new_question_group_id) { |
|
111 | + if ( ! $new_question_group_id) { |
|
112 | 112 | $this->add_error(sprintf(__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"), $old_event['id'])); |
113 | 113 | return 0; |
114 | 114 | } |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | 'EQG_primary'=>$primary |
119 | 119 | ); |
120 | 120 | $datatypes = array( |
121 | - '%d',// EVT_ID |
|
122 | - '%d',// QSG_ID |
|
123 | - '%d',// EQG_primary |
|
121 | + '%d', // EVT_ID |
|
122 | + '%d', // QSG_ID |
|
123 | + '%d', // EQG_primary |
|
124 | 124 | ); |
125 | 125 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
126 | - if (! $success) { |
|
126 | + if ( ! $success) { |
|
127 | 127 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes)); |
128 | 128 | return 0; |
129 | 129 | } |
@@ -16,15 +16,13 @@ discard block |
||
16 | 16 | 'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees','event_espresso'), false, false) |
17 | 17 | ) |
18 | 18 | ); |
19 | - |
|
20 | - |
|
21 | 19 | * |
22 | 20 | */ |
23 | 21 | class EE_DMS_4_1_0_event_question_group extends EE_Data_Migration_Script_Stage_Table |
24 | 22 | { |
25 | - private $_new_table; |
|
26 | - public function _migrate_old_row($old_row) |
|
27 | - { |
|
23 | + private $_new_table; |
|
24 | + public function _migrate_old_row($old_row) |
|
25 | + { |
|
28 | 26 | // $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $this->_new_transaction_table); |
29 | 27 | // if ( ! $txn_id ){ |
30 | 28 | // $this->add_error(sprintf(__("Could not find the transaction for the 3.1 attendee %d from row %s", "event_espresso"),$old_row['id'],$this->_json_encode($old_row))); |
@@ -34,8 +32,8 @@ discard block |
||
34 | 32 | // $new_line_items = $this->_insert_new_line_items($txn,$old_row); |
35 | 33 | // $this->get_migration_script()->set_mapping($this->_old_table,$old_row['id'],$this->_new_line_table,$new_line_items); |
36 | 34 | |
37 | - $this->_insert_new_event_question_groups($old_row); |
|
38 | - } |
|
35 | + $this->_insert_new_event_question_groups($old_row); |
|
36 | + } |
|
39 | 37 | // function _migration_step($num_items=50){ |
40 | 38 | // global $wpdb; |
41 | 39 | // $start_at_record = $this->count_records_migrated(); |
@@ -55,79 +53,79 @@ discard block |
||
55 | 53 | // $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
56 | 54 | // return $count; |
57 | 55 | // } |
58 | - public function __construct() |
|
59 | - { |
|
60 | - global $wpdb; |
|
61 | - $this->_old_table = $wpdb->prefix."events_detail"; |
|
62 | - $this->_extra_where_sql = 'WHERE event_status!="D"'; |
|
63 | - $this->_new_table = $wpdb->prefix."esp_event_question_group"; |
|
64 | - $this->_pretty_name = __("Question Groups in each Event", "event_espresso"); |
|
65 | - parent::__construct(); |
|
66 | - } |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + global $wpdb; |
|
59 | + $this->_old_table = $wpdb->prefix."events_detail"; |
|
60 | + $this->_extra_where_sql = 'WHERE event_status!="D"'; |
|
61 | + $this->_new_table = $wpdb->prefix."esp_event_question_group"; |
|
62 | + $this->_pretty_name = __("Question Groups in each Event", "event_espresso"); |
|
63 | + parent::__construct(); |
|
64 | + } |
|
67 | 65 | |
68 | - /** |
|
69 | - * Attempts to insert a new question group inthe new format given an old one |
|
70 | - * @global type $wpdb |
|
71 | - * @param array $old_event |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - private function _insert_new_event_question_groups($old_event) |
|
75 | - { |
|
76 | - $new_event_question_group_ids = array(); |
|
77 | - $question_groups_for_primary = maybe_unserialize($old_event['question_groups']); |
|
78 | - if (is_array($question_groups_for_primary)) { |
|
79 | - foreach ($question_groups_for_primary as $old_question_group_id) { |
|
80 | - $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true); |
|
81 | - if ($new_id) { |
|
82 | - $new_event_question_group_ids[] = $new_id; |
|
83 | - } |
|
84 | - } |
|
85 | - } |
|
86 | - $event_meta = maybe_unserialize($old_event['event_meta']); |
|
87 | - if (isset($event_meta['add_attendee_question_groups'])) { |
|
88 | - if (is_array($event_meta['add_attendee_question_groups'])) { |
|
89 | - foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) { |
|
90 | - $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false); |
|
91 | - if ($new_id) { |
|
92 | - $new_event_question_group_ids[] = $new_id; |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
66 | + /** |
|
67 | + * Attempts to insert a new question group inthe new format given an old one |
|
68 | + * @global type $wpdb |
|
69 | + * @param array $old_event |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + private function _insert_new_event_question_groups($old_event) |
|
73 | + { |
|
74 | + $new_event_question_group_ids = array(); |
|
75 | + $question_groups_for_primary = maybe_unserialize($old_event['question_groups']); |
|
76 | + if (is_array($question_groups_for_primary)) { |
|
77 | + foreach ($question_groups_for_primary as $old_question_group_id) { |
|
78 | + $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, true); |
|
79 | + if ($new_id) { |
|
80 | + $new_event_question_group_ids[] = $new_id; |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + $event_meta = maybe_unserialize($old_event['event_meta']); |
|
85 | + if (isset($event_meta['add_attendee_question_groups'])) { |
|
86 | + if (is_array($event_meta['add_attendee_question_groups'])) { |
|
87 | + foreach ($event_meta['add_attendee_question_groups'] as $old_question_group_id) { |
|
88 | + $new_id = $this->_insert_event_question_group($old_event, $old_question_group_id, false); |
|
89 | + if ($new_id) { |
|
90 | + $new_event_question_group_ids[] = $new_id; |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
97 | 95 | |
98 | 96 | |
99 | - $this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids); |
|
100 | - } |
|
97 | + $this->get_migration_script()->set_mapping($this->_old_table, $old_event['id'], $this->_new_table, $new_event_question_group_ids); |
|
98 | + } |
|
101 | 99 | |
102 | - private function _insert_event_question_group($old_event, $old_question_group_id, $primary) |
|
103 | - { |
|
104 | - global $wpdb; |
|
105 | - $new_question_group_id =$this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", intval($old_question_group_id), $wpdb->prefix."esp_question_group"); |
|
100 | + private function _insert_event_question_group($old_event, $old_question_group_id, $primary) |
|
101 | + { |
|
102 | + global $wpdb; |
|
103 | + $new_question_group_id =$this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", intval($old_question_group_id), $wpdb->prefix."esp_question_group"); |
|
106 | 104 | |
107 | - if (! $new_question_group_id) { |
|
108 | - $this->add_error(sprintf(__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"), $old_question_group_id, $old_event['id'])); |
|
109 | - return 0; |
|
110 | - } |
|
111 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event['id']), $wpdb->posts); |
|
112 | - if (! $new_question_group_id) { |
|
113 | - $this->add_error(sprintf(__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"), $old_event['id'])); |
|
114 | - return 0; |
|
115 | - } |
|
116 | - $cols_n_values = array( |
|
117 | - 'EVT_ID'=>$new_event_id, |
|
118 | - 'QSG_ID'=>$new_question_group_id, |
|
119 | - 'EQG_primary'=>$primary |
|
120 | - ); |
|
121 | - $datatypes = array( |
|
122 | - '%d',// EVT_ID |
|
123 | - '%d',// QSG_ID |
|
124 | - '%d',// EQG_primary |
|
125 | - ); |
|
126 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
127 | - if (! $success) { |
|
128 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes)); |
|
129 | - return 0; |
|
130 | - } |
|
131 | - return $wpdb->insert_id; |
|
132 | - } |
|
105 | + if (! $new_question_group_id) { |
|
106 | + $this->add_error(sprintf(__("Could not find 4.1 question ID for 3.1 question id #%s on event $%s", "event_espresso"), $old_question_group_id, $old_event['id'])); |
|
107 | + return 0; |
|
108 | + } |
|
109 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", intval($old_event['id']), $wpdb->posts); |
|
110 | + if (! $new_question_group_id) { |
|
111 | + $this->add_error(sprintf(__("Could not find 4.1 event 3.1 event id #%s", "event_espresso"), $old_event['id'])); |
|
112 | + return 0; |
|
113 | + } |
|
114 | + $cols_n_values = array( |
|
115 | + 'EVT_ID'=>$new_event_id, |
|
116 | + 'QSG_ID'=>$new_question_group_id, |
|
117 | + 'EQG_primary'=>$primary |
|
118 | + ); |
|
119 | + $datatypes = array( |
|
120 | + '%d',// EVT_ID |
|
121 | + '%d',// QSG_ID |
|
122 | + '%d',// EQG_primary |
|
123 | + ); |
|
124 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
125 | + if (! $success) { |
|
126 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes)); |
|
127 | + return 0; |
|
128 | + } |
|
129 | + return $wpdb->insert_id; |
|
130 | + } |
|
133 | 131 | } |
@@ -103,289 +103,289 @@ |
||
103 | 103 | class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage |
104 | 104 | { |
105 | 105 | |
106 | - public function _migration_step($num_items = 50) |
|
107 | - { |
|
106 | + public function _migration_step($num_items = 50) |
|
107 | + { |
|
108 | 108 | |
109 | - $items_actually_migrated = 0; |
|
110 | - $old_org_options = get_option('events_organization_settings'); |
|
111 | - foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
112 | - // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
113 | - if (isset($old_org_options[ $option_name ])) { |
|
114 | - $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
115 | - } |
|
116 | - if ($option_name=='surcharge') { |
|
117 | - $this->_insert_new_global_surcharge_price($old_org_options); |
|
118 | - } |
|
119 | - $items_actually_migrated++; |
|
120 | - } |
|
109 | + $items_actually_migrated = 0; |
|
110 | + $old_org_options = get_option('events_organization_settings'); |
|
111 | + foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
112 | + // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
|
113 | + if (isset($old_org_options[ $option_name ])) { |
|
114 | + $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
115 | + } |
|
116 | + if ($option_name=='surcharge') { |
|
117 | + $this->_insert_new_global_surcharge_price($old_org_options); |
|
118 | + } |
|
119 | + $items_actually_migrated++; |
|
120 | + } |
|
121 | 121 | |
122 | - $success = EE_Config::instance()->update_espresso_config(false, true); |
|
123 | - if (! $success) { |
|
124 | - $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
|
125 | - EE_Error::overwrite_errors(); |
|
126 | - } |
|
127 | - EE_Network_Config::instance()->update_config(false, false); |
|
128 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
129 | - // we may have added new pages and this might be necessary |
|
130 | - flush_rewrite_rules(); |
|
131 | - $this->set_completed(); |
|
132 | - } |
|
133 | - return $items_actually_migrated; |
|
134 | - } |
|
135 | - public function _count_records_to_migrate() |
|
136 | - { |
|
137 | - $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate); |
|
138 | - return $count_of_options_to_migrate; |
|
139 | - } |
|
140 | - public function __construct() |
|
141 | - { |
|
142 | - $this->_pretty_name = __("Organization Options/Config", "event_espresso"); |
|
143 | - $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate); |
|
144 | - parent::__construct(); |
|
145 | - } |
|
122 | + $success = EE_Config::instance()->update_espresso_config(false, true); |
|
123 | + if (! $success) { |
|
124 | + $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
|
125 | + EE_Error::overwrite_errors(); |
|
126 | + } |
|
127 | + EE_Network_Config::instance()->update_config(false, false); |
|
128 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
129 | + // we may have added new pages and this might be necessary |
|
130 | + flush_rewrite_rules(); |
|
131 | + $this->set_completed(); |
|
132 | + } |
|
133 | + return $items_actually_migrated; |
|
134 | + } |
|
135 | + public function _count_records_to_migrate() |
|
136 | + { |
|
137 | + $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate); |
|
138 | + return $count_of_options_to_migrate; |
|
139 | + } |
|
140 | + public function __construct() |
|
141 | + { |
|
142 | + $this->_pretty_name = __("Organization Options/Config", "event_espresso"); |
|
143 | + $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate); |
|
144 | + parent::__construct(); |
|
145 | + } |
|
146 | 146 | |
147 | - private function _handle_org_option($option_name, $value) |
|
148 | - { |
|
149 | - $c = EE_Config::instance(); |
|
150 | - $cn = EE_Network_Config::instance(); |
|
151 | - switch ($option_name) { |
|
152 | - case 'organization': |
|
153 | - $c->organization->name = $value; |
|
154 | - break; |
|
155 | - case 'organization_street1': |
|
156 | - $c->organization->address_1 = $value; |
|
157 | - break; |
|
158 | - case 'organization_street2': |
|
159 | - $c->organization->address_2 = $value; |
|
160 | - break; |
|
161 | - case 'organization_city': |
|
162 | - $c->organization->city = $value; |
|
163 | - break; |
|
164 | - case 'organization_state': |
|
165 | - try { |
|
166 | - $state = $this->get_migration_script()->get_or_create_state($value); |
|
167 | - $state_id = $state['STA_ID']; |
|
168 | - $c->organization->STA_ID = $state_id; |
|
169 | - } catch (EE_Error $e) { |
|
170 | - } |
|
171 | - break; |
|
172 | - case 'organization_zip': |
|
173 | - $c->organization->zip = $value; |
|
174 | - break; |
|
175 | - case 'contact_email': |
|
176 | - $c->organization->email = $value; |
|
177 | - break; |
|
178 | - case 'default_payment_status': |
|
179 | - $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
180 | - break; |
|
181 | - case 'organization_country': |
|
182 | - $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
183 | - $c->organization->CNT_ISO = $iso; |
|
184 | - $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
185 | - if (! $country_row) { |
|
186 | - $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
|
187 | - } |
|
188 | - // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
189 | - $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
190 | - $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
191 | - $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
192 | - $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
193 | - $c->currency->sign_b4 = intval($country_row['CNT_cur_sign_b4']); // currency sign before or after: $TRUE or FALSE$ |
|
194 | - $c->currency->dec_plc = intval($country_row['CNT_cur_dec_plc']); // decimal places: 2 = 0.00 3 = 0.000 |
|
195 | - $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
196 | - $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
147 | + private function _handle_org_option($option_name, $value) |
|
148 | + { |
|
149 | + $c = EE_Config::instance(); |
|
150 | + $cn = EE_Network_Config::instance(); |
|
151 | + switch ($option_name) { |
|
152 | + case 'organization': |
|
153 | + $c->organization->name = $value; |
|
154 | + break; |
|
155 | + case 'organization_street1': |
|
156 | + $c->organization->address_1 = $value; |
|
157 | + break; |
|
158 | + case 'organization_street2': |
|
159 | + $c->organization->address_2 = $value; |
|
160 | + break; |
|
161 | + case 'organization_city': |
|
162 | + $c->organization->city = $value; |
|
163 | + break; |
|
164 | + case 'organization_state': |
|
165 | + try { |
|
166 | + $state = $this->get_migration_script()->get_or_create_state($value); |
|
167 | + $state_id = $state['STA_ID']; |
|
168 | + $c->organization->STA_ID = $state_id; |
|
169 | + } catch (EE_Error $e) { |
|
170 | + } |
|
171 | + break; |
|
172 | + case 'organization_zip': |
|
173 | + $c->organization->zip = $value; |
|
174 | + break; |
|
175 | + case 'contact_email': |
|
176 | + $c->organization->email = $value; |
|
177 | + break; |
|
178 | + case 'default_payment_status': |
|
179 | + $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
180 | + break; |
|
181 | + case 'organization_country': |
|
182 | + $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
183 | + $c->organization->CNT_ISO = $iso; |
|
184 | + $country_row = $this->get_migration_script()->get_or_create_country($iso); |
|
185 | + if (! $country_row) { |
|
186 | + $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
|
187 | + } |
|
188 | + // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
|
189 | + $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
190 | + $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
191 | + $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
192 | + $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
193 | + $c->currency->sign_b4 = intval($country_row['CNT_cur_sign_b4']); // currency sign before or after: $TRUE or FALSE$ |
|
194 | + $c->currency->dec_plc = intval($country_row['CNT_cur_dec_plc']); // decimal places: 2 = 0.00 3 = 0.000 |
|
195 | + $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
196 | + $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
197 | 197 | // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
198 | 198 | // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
199 | 199 | // $c->currency->sign = $value;break; |
200 | - case 'show_pending_payment_options': |
|
201 | - $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
202 | - break; |
|
203 | - case 'display_address_in_regform': |
|
204 | - $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
205 | - break; |
|
206 | - case 'default_logo_url': |
|
207 | - $c->organization->logo_url = $value; |
|
208 | - break; |
|
209 | - case 'event_page_id': |
|
210 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
211 | - // to ESPRESSO_THANK_YOU |
|
212 | - $reg_page_post = get_post($value); |
|
213 | - $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content); |
|
214 | - wp_update_post($reg_page_post); |
|
215 | - $c->core->reg_page_id = $value; |
|
216 | - break; |
|
217 | - case 'return_url': |
|
218 | - // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
219 | - // to ESPRESSO_THANK_YOU |
|
220 | - $thank_you_page_post = get_post($value); |
|
221 | - $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content); |
|
222 | - wp_update_post($thank_you_page_post); |
|
223 | - $c->core->thank_you_page_id = $value; |
|
224 | - break; |
|
225 | - case 'cancel_return': |
|
226 | - $c->core->cancel_page_id = $value; |
|
200 | + case 'show_pending_payment_options': |
|
201 | + $c->registration->show_pending_payment_options = ($value == 'Y'); |
|
202 | + break; |
|
203 | + case 'display_address_in_regform': |
|
204 | + $c->template_settings->display_address_in_regform = ($value == 'Y'); |
|
205 | + break; |
|
206 | + case 'default_logo_url': |
|
207 | + $c->organization->logo_url = $value; |
|
208 | + break; |
|
209 | + case 'event_page_id': |
|
210 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
211 | + // to ESPRESSO_THANK_YOU |
|
212 | + $reg_page_post = get_post($value); |
|
213 | + $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content); |
|
214 | + wp_update_post($reg_page_post); |
|
215 | + $c->core->reg_page_id = $value; |
|
216 | + break; |
|
217 | + case 'return_url': |
|
218 | + // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
219 | + // to ESPRESSO_THANK_YOU |
|
220 | + $thank_you_page_post = get_post($value); |
|
221 | + $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content); |
|
222 | + wp_update_post($thank_you_page_post); |
|
223 | + $c->core->thank_you_page_id = $value; |
|
224 | + break; |
|
225 | + case 'cancel_return': |
|
226 | + $c->core->cancel_page_id = $value; |
|
227 | 227 | |
228 | - break; |
|
229 | - case 'notify_url': |
|
230 | - $c->core->txn_page_id = $value; |
|
231 | - break; |
|
232 | - case 'use_captcha': |
|
233 | - $c->registration->use_captcha = ($value == 'Y'); |
|
234 | - break; |
|
235 | - case 'recaptcha_publickey': |
|
236 | - $c->registration->recaptcha_publickey = $value; |
|
237 | - break; |
|
238 | - case 'recaptcha_privatekey': |
|
239 | - $c->registration->recaptcha_privatekey = $value; |
|
240 | - break; |
|
241 | - case 'recaptcha_theme': |
|
242 | - $c->registration->recaptcha_theme = $value; |
|
243 | - break; |
|
244 | - case 'recaptcha_width': |
|
245 | - $c->registration->recaptcha_width = $value; |
|
246 | - break; |
|
247 | - case 'recaptcha_language': |
|
248 | - $c->registration->recaptcha_language = $value; |
|
249 | - break; |
|
250 | - case 'espresso_dashboard_widget': |
|
251 | - $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
252 | - break; |
|
253 | - case 'use_personnel_manager': |
|
254 | - $c->admin->use_personnel_manager = ($value == 'Y'); |
|
255 | - break; |
|
256 | - case 'use_event_timezones': |
|
257 | - $c->admin->use_event_timezones = ($value == 'Y'); |
|
258 | - break; |
|
259 | - case 'full_logging': |
|
260 | - $c->admin->use_full_logging = ($value == 'Y'); |
|
261 | - break; |
|
262 | - case 'affiliate_id': |
|
263 | - $c->admin->affiliate_id = $value; |
|
264 | - break; |
|
265 | - case 'site_license_key': |
|
266 | - $cn->core->site_license_key = $value; |
|
267 | - break; |
|
268 | - default: |
|
269 | - do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
270 | - } |
|
271 | - } |
|
228 | + break; |
|
229 | + case 'notify_url': |
|
230 | + $c->core->txn_page_id = $value; |
|
231 | + break; |
|
232 | + case 'use_captcha': |
|
233 | + $c->registration->use_captcha = ($value == 'Y'); |
|
234 | + break; |
|
235 | + case 'recaptcha_publickey': |
|
236 | + $c->registration->recaptcha_publickey = $value; |
|
237 | + break; |
|
238 | + case 'recaptcha_privatekey': |
|
239 | + $c->registration->recaptcha_privatekey = $value; |
|
240 | + break; |
|
241 | + case 'recaptcha_theme': |
|
242 | + $c->registration->recaptcha_theme = $value; |
|
243 | + break; |
|
244 | + case 'recaptcha_width': |
|
245 | + $c->registration->recaptcha_width = $value; |
|
246 | + break; |
|
247 | + case 'recaptcha_language': |
|
248 | + $c->registration->recaptcha_language = $value; |
|
249 | + break; |
|
250 | + case 'espresso_dashboard_widget': |
|
251 | + $c->admin->use_dashboard_widget = ($value == 'Y'); |
|
252 | + break; |
|
253 | + case 'use_personnel_manager': |
|
254 | + $c->admin->use_personnel_manager = ($value == 'Y'); |
|
255 | + break; |
|
256 | + case 'use_event_timezones': |
|
257 | + $c->admin->use_event_timezones = ($value == 'Y'); |
|
258 | + break; |
|
259 | + case 'full_logging': |
|
260 | + $c->admin->use_full_logging = ($value == 'Y'); |
|
261 | + break; |
|
262 | + case 'affiliate_id': |
|
263 | + $c->admin->affiliate_id = $value; |
|
264 | + break; |
|
265 | + case 'site_license_key': |
|
266 | + $cn->core->site_license_key = $value; |
|
267 | + break; |
|
268 | + default: |
|
269 | + do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
270 | + } |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
274 | - * Creates a 4.1 member price discount |
|
275 | - * @global type $wpdb |
|
276 | - * @param type $old_price |
|
277 | - * @return int |
|
278 | - */ |
|
279 | - private function _insert_new_global_surcharge_price($org_options) |
|
280 | - { |
|
281 | - $amount = floatval($org_options['surcharge']); |
|
282 | - // dont createa a price if the surcharge is 0 |
|
283 | - if ($amount <=.01) { |
|
284 | - return 0; |
|
285 | - } |
|
286 | - if ($org_options['surcharge_type'] == 'flat_rate') { |
|
287 | - $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
288 | - } else { |
|
289 | - $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
290 | - } |
|
291 | - global $wpdb; |
|
292 | - $cols_n_values = array( |
|
293 | - 'PRT_ID'=>$price_type, |
|
294 | - 'PRC_amount'=>$amount, |
|
295 | - 'PRC_name'=> $org_options['surcharge_text'], |
|
296 | - 'PRC_is_default'=>true, |
|
297 | - 'PRC_overrides'=>false, |
|
298 | - 'PRC_order'=>100, |
|
299 | - 'PRC_deleted'=>false, |
|
300 | - 'PRC_parent'=>null |
|
273 | + /** |
|
274 | + * Creates a 4.1 member price discount |
|
275 | + * @global type $wpdb |
|
276 | + * @param type $old_price |
|
277 | + * @return int |
|
278 | + */ |
|
279 | + private function _insert_new_global_surcharge_price($org_options) |
|
280 | + { |
|
281 | + $amount = floatval($org_options['surcharge']); |
|
282 | + // dont createa a price if the surcharge is 0 |
|
283 | + if ($amount <=.01) { |
|
284 | + return 0; |
|
285 | + } |
|
286 | + if ($org_options['surcharge_type'] == 'flat_rate') { |
|
287 | + $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
|
288 | + } else { |
|
289 | + $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
|
290 | + } |
|
291 | + global $wpdb; |
|
292 | + $cols_n_values = array( |
|
293 | + 'PRT_ID'=>$price_type, |
|
294 | + 'PRC_amount'=>$amount, |
|
295 | + 'PRC_name'=> $org_options['surcharge_text'], |
|
296 | + 'PRC_is_default'=>true, |
|
297 | + 'PRC_overrides'=>false, |
|
298 | + 'PRC_order'=>100, |
|
299 | + 'PRC_deleted'=>false, |
|
300 | + 'PRC_parent'=>null |
|
301 | 301 | |
302 | - ); |
|
303 | - $datatypes = array( |
|
304 | - '%d',// PRT_ID |
|
305 | - '%f',// PRT_amount |
|
306 | - '%s',// PRC_name |
|
307 | - '%d',// PRC_is_default |
|
308 | - '%d',// PRC_overrides |
|
309 | - '%d',// PRC_order |
|
310 | - '%d',// PRC_deleted |
|
311 | - '%d',// PRC_parent |
|
312 | - ); |
|
313 | - $price_table = $wpdb->prefix."esp_price"; |
|
314 | - $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
|
315 | - if (! $success) { |
|
316 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
|
317 | - 'org_options', |
|
318 | - array( |
|
319 | - 'surcharge'=>$org_options['surcharge'], |
|
320 | - 'surcharge_type'=>$org_options['surcharge_type'], |
|
321 | - 'surcharge_text'=>$org_options['surcharge_text']), |
|
322 | - $price_table, |
|
323 | - $cols_n_values, |
|
324 | - $datatypes |
|
325 | - )); |
|
326 | - return 0; |
|
327 | - } |
|
328 | - $new_id = $wpdb->insert_id; |
|
329 | - return $new_id; |
|
330 | - } |
|
302 | + ); |
|
303 | + $datatypes = array( |
|
304 | + '%d',// PRT_ID |
|
305 | + '%f',// PRT_amount |
|
306 | + '%s',// PRC_name |
|
307 | + '%d',// PRC_is_default |
|
308 | + '%d',// PRC_overrides |
|
309 | + '%d',// PRC_order |
|
310 | + '%d',// PRC_deleted |
|
311 | + '%d',// PRC_parent |
|
312 | + ); |
|
313 | + $price_table = $wpdb->prefix."esp_price"; |
|
314 | + $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
|
315 | + if (! $success) { |
|
316 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
|
317 | + 'org_options', |
|
318 | + array( |
|
319 | + 'surcharge'=>$org_options['surcharge'], |
|
320 | + 'surcharge_type'=>$org_options['surcharge_type'], |
|
321 | + 'surcharge_text'=>$org_options['surcharge_text']), |
|
322 | + $price_table, |
|
323 | + $cols_n_values, |
|
324 | + $datatypes |
|
325 | + )); |
|
326 | + return 0; |
|
327 | + } |
|
328 | + $new_id = $wpdb->insert_id; |
|
329 | + return $new_id; |
|
330 | + } |
|
331 | 331 | |
332 | - protected $_org_options_we_know_how_to_migrate = array( |
|
333 | - 'organization', |
|
334 | - 'organization_street1', |
|
335 | - 'organization_street2', |
|
336 | - 'organization_city', |
|
337 | - 'organization_state', |
|
338 | - 'organization_zip', |
|
339 | - 'contact_email', |
|
340 | - 'default_mail', |
|
341 | - 'payment_subject', |
|
342 | - 'payment_message', |
|
343 | - 'message', |
|
344 | - 'default_payment_status', |
|
345 | - 'surcharge',// unused? |
|
346 | - 'country_id',// unused? |
|
347 | - 'organization_country', |
|
332 | + protected $_org_options_we_know_how_to_migrate = array( |
|
333 | + 'organization', |
|
334 | + 'organization_street1', |
|
335 | + 'organization_street2', |
|
336 | + 'organization_city', |
|
337 | + 'organization_state', |
|
338 | + 'organization_zip', |
|
339 | + 'contact_email', |
|
340 | + 'default_mail', |
|
341 | + 'payment_subject', |
|
342 | + 'payment_message', |
|
343 | + 'message', |
|
344 | + 'default_payment_status', |
|
345 | + 'surcharge',// unused? |
|
346 | + 'country_id',// unused? |
|
347 | + 'organization_country', |
|
348 | 348 | // 'currency_symbol', |
349 | - 'expire_on_registration_end', |
|
350 | - 'email_before_payment', |
|
351 | - 'email_fancy_headers', |
|
352 | - 'enable_default_style', |
|
353 | - 'event_ssl_active', |
|
354 | - 'selected_style', |
|
355 | - 'show_pending_payment_options', |
|
356 | - 'show_reg_footer', |
|
357 | - 'skip_confirmation_page', |
|
358 | - 'allow_mer_discounts',// no equiv |
|
359 | - 'allow_mer_vouchers',// no equiv |
|
360 | - 'display_short_description_in_event_list', |
|
361 | - 'display_description_on_multi_reg_page', |
|
362 | - 'display_address_in_event_list', |
|
363 | - 'display_address_in_regform', |
|
364 | - 'use_custom_post_types',// no equiv |
|
365 | - 'display_ical_download', |
|
366 | - 'display_featured_image', |
|
367 | - 'themeroller', |
|
368 | - 'default_logo_url', |
|
369 | - 'event_page_id', |
|
370 | - 'return_url', |
|
371 | - 'cancel_return', |
|
372 | - 'notify_url', |
|
373 | - 'events_in_dashboard', |
|
374 | - 'use_captcha', |
|
375 | - 'recaptcha_publickey', |
|
376 | - 'recaptcha_privatekey', |
|
377 | - 'recaptcha_theme', |
|
378 | - 'recaptcha_width', |
|
379 | - 'recaptcha_language', |
|
380 | - 'espresso_dashboard_widget', |
|
381 | - 'time_reg_limit', |
|
349 | + 'expire_on_registration_end', |
|
350 | + 'email_before_payment', |
|
351 | + 'email_fancy_headers', |
|
352 | + 'enable_default_style', |
|
353 | + 'event_ssl_active', |
|
354 | + 'selected_style', |
|
355 | + 'show_pending_payment_options', |
|
356 | + 'show_reg_footer', |
|
357 | + 'skip_confirmation_page', |
|
358 | + 'allow_mer_discounts',// no equiv |
|
359 | + 'allow_mer_vouchers',// no equiv |
|
360 | + 'display_short_description_in_event_list', |
|
361 | + 'display_description_on_multi_reg_page', |
|
362 | + 'display_address_in_event_list', |
|
363 | + 'display_address_in_regform', |
|
364 | + 'use_custom_post_types',// no equiv |
|
365 | + 'display_ical_download', |
|
366 | + 'display_featured_image', |
|
367 | + 'themeroller', |
|
368 | + 'default_logo_url', |
|
369 | + 'event_page_id', |
|
370 | + 'return_url', |
|
371 | + 'cancel_return', |
|
372 | + 'notify_url', |
|
373 | + 'events_in_dashboard', |
|
374 | + 'use_captcha', |
|
375 | + 'recaptcha_publickey', |
|
376 | + 'recaptcha_privatekey', |
|
377 | + 'recaptcha_theme', |
|
378 | + 'recaptcha_width', |
|
379 | + 'recaptcha_language', |
|
380 | + 'espresso_dashboard_widget', |
|
381 | + 'time_reg_limit', |
|
382 | 382 | // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
383 | - 'use_personnel_manager',// no equiv |
|
384 | - 'use_event_timezones', |
|
385 | - 'full_logging', |
|
386 | - 'surcharge_type',// unused |
|
387 | - 'surcharge_text',// unused |
|
388 | - 'affiliate_id', |
|
389 | - 'site_license_key', |
|
390 | - ); |
|
383 | + 'use_personnel_manager',// no equiv |
|
384 | + 'use_event_timezones', |
|
385 | + 'full_logging', |
|
386 | + 'surcharge_type',// unused |
|
387 | + 'surcharge_text',// unused |
|
388 | + 'affiliate_id', |
|
389 | + 'site_license_key', |
|
390 | + ); |
|
391 | 391 | } |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | $old_org_options = get_option('events_organization_settings'); |
111 | 111 | foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
112 | 112 | // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
113 | - if (isset($old_org_options[ $option_name ])) { |
|
114 | - $this->_handle_org_option($option_name, $old_org_options[ $option_name ]); |
|
113 | + if (isset($old_org_options[$option_name])) { |
|
114 | + $this->_handle_org_option($option_name, $old_org_options[$option_name]); |
|
115 | 115 | } |
116 | - if ($option_name=='surcharge') { |
|
116 | + if ($option_name == 'surcharge') { |
|
117 | 117 | $this->_insert_new_global_surcharge_price($old_org_options); |
118 | 118 | } |
119 | 119 | $items_actually_migrated++; |
120 | 120 | } |
121 | 121 | |
122 | 122 | $success = EE_Config::instance()->update_espresso_config(false, true); |
123 | - if (! $success) { |
|
123 | + if ( ! $success) { |
|
124 | 124 | $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false))); |
125 | 125 | EE_Error::overwrite_errors(); |
126 | 126 | } |
@@ -176,24 +176,24 @@ discard block |
||
176 | 176 | $c->organization->email = $value; |
177 | 177 | break; |
178 | 178 | case 'default_payment_status': |
179 | - $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
179 | + $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); |
|
180 | 180 | break; |
181 | 181 | case 'organization_country': |
182 | - $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
182 | + $iso = $this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
183 | 183 | $c->organization->CNT_ISO = $iso; |
184 | 184 | $country_row = $this->get_migration_script()->get_or_create_country($iso); |
185 | - if (! $country_row) { |
|
185 | + if ( ! $country_row) { |
|
186 | 186 | $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
187 | 187 | } |
188 | 188 | // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
189 | - $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
190 | - $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
191 | - $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
192 | - $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
193 | - $c->currency->sign_b4 = intval($country_row['CNT_cur_sign_b4']); // currency sign before or after: $TRUE or FALSE$ |
|
194 | - $c->currency->dec_plc = intval($country_row['CNT_cur_dec_plc']); // decimal places: 2 = 0.00 3 = 0.000 |
|
195 | - $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
196 | - $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
189 | + $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
190 | + $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
191 | + $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
192 | + $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
193 | + $c->currency->sign_b4 = intval($country_row['CNT_cur_sign_b4']); // currency sign before or after: $TRUE or FALSE$ |
|
194 | + $c->currency->dec_plc = intval($country_row['CNT_cur_dec_plc']); // decimal places: 2 = 0.00 3 = 0.000 |
|
195 | + $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
196 | + $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
197 | 197 | // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
198 | 198 | // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
199 | 199 | // $c->currency->sign = $value;break; |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | { |
281 | 281 | $amount = floatval($org_options['surcharge']); |
282 | 282 | // dont createa a price if the surcharge is 0 |
283 | - if ($amount <=.01) { |
|
283 | + if ($amount <= .01) { |
|
284 | 284 | return 0; |
285 | 285 | } |
286 | 286 | if ($org_options['surcharge_type'] == 'flat_rate') { |
@@ -301,18 +301,18 @@ discard block |
||
301 | 301 | |
302 | 302 | ); |
303 | 303 | $datatypes = array( |
304 | - '%d',// PRT_ID |
|
305 | - '%f',// PRT_amount |
|
306 | - '%s',// PRC_name |
|
307 | - '%d',// PRC_is_default |
|
308 | - '%d',// PRC_overrides |
|
309 | - '%d',// PRC_order |
|
310 | - '%d',// PRC_deleted |
|
311 | - '%d',// PRC_parent |
|
304 | + '%d', // PRT_ID |
|
305 | + '%f', // PRT_amount |
|
306 | + '%s', // PRC_name |
|
307 | + '%d', // PRC_is_default |
|
308 | + '%d', // PRC_overrides |
|
309 | + '%d', // PRC_order |
|
310 | + '%d', // PRC_deleted |
|
311 | + '%d', // PRC_parent |
|
312 | 312 | ); |
313 | 313 | $price_table = $wpdb->prefix."esp_price"; |
314 | 314 | $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
315 | - if (! $success) { |
|
315 | + if ( ! $success) { |
|
316 | 316 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion( |
317 | 317 | 'org_options', |
318 | 318 | array( |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | 'payment_message', |
343 | 343 | 'message', |
344 | 344 | 'default_payment_status', |
345 | - 'surcharge',// unused? |
|
346 | - 'country_id',// unused? |
|
345 | + 'surcharge', // unused? |
|
346 | + 'country_id', // unused? |
|
347 | 347 | 'organization_country', |
348 | 348 | // 'currency_symbol', |
349 | 349 | 'expire_on_registration_end', |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | 'show_pending_payment_options', |
356 | 356 | 'show_reg_footer', |
357 | 357 | 'skip_confirmation_page', |
358 | - 'allow_mer_discounts',// no equiv |
|
359 | - 'allow_mer_vouchers',// no equiv |
|
358 | + 'allow_mer_discounts', // no equiv |
|
359 | + 'allow_mer_vouchers', // no equiv |
|
360 | 360 | 'display_short_description_in_event_list', |
361 | 361 | 'display_description_on_multi_reg_page', |
362 | 362 | 'display_address_in_event_list', |
363 | 363 | 'display_address_in_regform', |
364 | - 'use_custom_post_types',// no equiv |
|
364 | + 'use_custom_post_types', // no equiv |
|
365 | 365 | 'display_ical_download', |
366 | 366 | 'display_featured_image', |
367 | 367 | 'themeroller', |
@@ -380,11 +380,11 @@ discard block |
||
380 | 380 | 'espresso_dashboard_widget', |
381 | 381 | 'time_reg_limit', |
382 | 382 | // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
383 | - 'use_personnel_manager',// no equiv |
|
383 | + 'use_personnel_manager', // no equiv |
|
384 | 384 | 'use_event_timezones', |
385 | 385 | 'full_logging', |
386 | - 'surcharge_type',// unused |
|
387 | - 'surcharge_text',// unused |
|
386 | + 'surcharge_type', // unused |
|
387 | + 'surcharge_text', // unused |
|
388 | 388 | 'affiliate_id', |
389 | 389 | 'site_license_key', |
390 | 390 | ); |
@@ -40,119 +40,119 @@ |
||
40 | 40 | */ |
41 | 41 | class EE_DMS_4_1_0_question_groups extends EE_Data_Migration_Script_Stage |
42 | 42 | { |
43 | - private $_old_table; |
|
44 | - private $_new_table; |
|
45 | - /** |
|
46 | - * Keeps track of whether or not we've already added a system question group, |
|
47 | - * in order to avoid adding more than 1 (basically, in 3.1 this would happen |
|
48 | - * with the Roles & Permissions addon, because each user had their own set of |
|
49 | - * question groups and questions), |
|
50 | - * @var boolean |
|
51 | - */ |
|
52 | - private $_already_got_system_question_group_1 = false; |
|
53 | - public function _migration_step($num_items = 50) |
|
54 | - { |
|
43 | + private $_old_table; |
|
44 | + private $_new_table; |
|
45 | + /** |
|
46 | + * Keeps track of whether or not we've already added a system question group, |
|
47 | + * in order to avoid adding more than 1 (basically, in 3.1 this would happen |
|
48 | + * with the Roles & Permissions addon, because each user had their own set of |
|
49 | + * question groups and questions), |
|
50 | + * @var boolean |
|
51 | + */ |
|
52 | + private $_already_got_system_question_group_1 = false; |
|
53 | + public function _migration_step($num_items = 50) |
|
54 | + { |
|
55 | 55 | |
56 | - global $wpdb; |
|
57 | - $start_at_record = $this->count_records_migrated(); |
|
58 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
59 | - $items_actually_migrated = 0; |
|
60 | - foreach ($rows as $question_group) { |
|
61 | - $new_id = $this->_insert_new_question_group($question_group); |
|
56 | + global $wpdb; |
|
57 | + $start_at_record = $this->count_records_migrated(); |
|
58 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
59 | + $items_actually_migrated = 0; |
|
60 | + foreach ($rows as $question_group) { |
|
61 | + $new_id = $this->_insert_new_question_group($question_group); |
|
62 | 62 | |
63 | - $this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id); |
|
64 | - $items_actually_migrated++; |
|
65 | - } |
|
66 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
67 | - $this->set_completed(); |
|
68 | - } |
|
69 | - return $items_actually_migrated; |
|
70 | - } |
|
71 | - public function _count_records_to_migrate() |
|
72 | - { |
|
73 | - global $wpdb; |
|
74 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
75 | - return $count; |
|
76 | - } |
|
77 | - public function __construct() |
|
78 | - { |
|
79 | - global $wpdb; |
|
80 | - $this->_old_table = $wpdb->prefix."events_qst_group"; |
|
81 | - $this->_new_table = $wpdb->prefix."esp_question_group"; |
|
82 | - $this->_pretty_name = __("Question Groups", "event_espresso"); |
|
83 | - parent::__construct(); |
|
84 | - } |
|
63 | + $this->get_migration_script()->set_mapping($this->_old_table, $question_group['id'], $this->_new_table, $new_id); |
|
64 | + $items_actually_migrated++; |
|
65 | + } |
|
66 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
67 | + $this->set_completed(); |
|
68 | + } |
|
69 | + return $items_actually_migrated; |
|
70 | + } |
|
71 | + public function _count_records_to_migrate() |
|
72 | + { |
|
73 | + global $wpdb; |
|
74 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
75 | + return $count; |
|
76 | + } |
|
77 | + public function __construct() |
|
78 | + { |
|
79 | + global $wpdb; |
|
80 | + $this->_old_table = $wpdb->prefix."events_qst_group"; |
|
81 | + $this->_new_table = $wpdb->prefix."esp_question_group"; |
|
82 | + $this->_pretty_name = __("Question Groups", "event_espresso"); |
|
83 | + parent::__construct(); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Attempts to insert a new question group inthe new format given an old one |
|
88 | - * @global type $wpdb |
|
89 | - * @param array $old_question_group |
|
90 | - * @return int |
|
91 | - */ |
|
92 | - private function _insert_new_question_group($old_question_group) |
|
93 | - { |
|
94 | - global $wpdb; |
|
95 | - // try to guess what the QST_system int should be... finding the Personal info system |
|
96 | - // question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but |
|
97 | - // could be easily removed. |
|
98 | - if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) { |
|
99 | - $guess_at_system_number = 1; |
|
100 | - } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) { |
|
101 | - $guess_at_system_number = 2; |
|
102 | - } else { |
|
103 | - $guess_at_system_number = 0; |
|
104 | - } |
|
105 | - // if the question group wasn't made by the normal admin, |
|
106 | - // we'd like to keep track of who made it |
|
107 | - if (intval($old_question_group['wp_user'])!=1) { |
|
108 | - $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user'])); |
|
109 | - $identifier = $old_question_group['group_identifier']."-by-".$username; |
|
110 | - } else { |
|
111 | - $identifier = $old_question_group['group_identifier']; |
|
112 | - } |
|
113 | - $cols_n_values = array( |
|
114 | - 'QSG_name'=>stripslashes($old_question_group['group_name']), |
|
115 | - 'QSG_identifier'=>$identifier, |
|
116 | - 'QSG_desc'=>stripslashes($old_question_group['group_description']), |
|
117 | - 'QSG_order'=>$old_question_group['group_order'], |
|
118 | - 'QSG_show_group_name'=>$old_question_group['show_group_name'], |
|
119 | - 'QSG_show_group_desc'=>$old_question_group['show_group_description'], |
|
120 | - 'QSG_system'=>$guess_at_system_number, |
|
121 | - 'QSG_deleted'=>false |
|
122 | - ); |
|
123 | - $datatypes = array( |
|
124 | - '%s',// QSG_name |
|
125 | - '%s',// QSG_identifier |
|
126 | - '%s',// QSG_desc |
|
127 | - '%d',// QSG_order |
|
128 | - '%d',// QSG_show_group_name |
|
129 | - '%d',// QSG_show_group_desc |
|
130 | - '%d',// QSG_system |
|
131 | - '%d',// QSG_deleted |
|
132 | - ); |
|
133 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
134 | - if (! $success) { |
|
135 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes)); |
|
136 | - return 0; |
|
137 | - } |
|
138 | - return $wpdb->insert_id; |
|
139 | - } |
|
86 | + /** |
|
87 | + * Attempts to insert a new question group inthe new format given an old one |
|
88 | + * @global type $wpdb |
|
89 | + * @param array $old_question_group |
|
90 | + * @return int |
|
91 | + */ |
|
92 | + private function _insert_new_question_group($old_question_group) |
|
93 | + { |
|
94 | + global $wpdb; |
|
95 | + // try to guess what the QST_system int should be... finding the Personal info system |
|
96 | + // question group is quite easy. But in 3.1 address info WASN'T a system group, it just exitsed by default but |
|
97 | + // could be easily removed. |
|
98 | + if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) { |
|
99 | + $guess_at_system_number = 1; |
|
100 | + } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) { |
|
101 | + $guess_at_system_number = 2; |
|
102 | + } else { |
|
103 | + $guess_at_system_number = 0; |
|
104 | + } |
|
105 | + // if the question group wasn't made by the normal admin, |
|
106 | + // we'd like to keep track of who made it |
|
107 | + if (intval($old_question_group['wp_user'])!=1) { |
|
108 | + $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user'])); |
|
109 | + $identifier = $old_question_group['group_identifier']."-by-".$username; |
|
110 | + } else { |
|
111 | + $identifier = $old_question_group['group_identifier']; |
|
112 | + } |
|
113 | + $cols_n_values = array( |
|
114 | + 'QSG_name'=>stripslashes($old_question_group['group_name']), |
|
115 | + 'QSG_identifier'=>$identifier, |
|
116 | + 'QSG_desc'=>stripslashes($old_question_group['group_description']), |
|
117 | + 'QSG_order'=>$old_question_group['group_order'], |
|
118 | + 'QSG_show_group_name'=>$old_question_group['show_group_name'], |
|
119 | + 'QSG_show_group_desc'=>$old_question_group['show_group_description'], |
|
120 | + 'QSG_system'=>$guess_at_system_number, |
|
121 | + 'QSG_deleted'=>false |
|
122 | + ); |
|
123 | + $datatypes = array( |
|
124 | + '%s',// QSG_name |
|
125 | + '%s',// QSG_identifier |
|
126 | + '%s',// QSG_desc |
|
127 | + '%d',// QSG_order |
|
128 | + '%d',// QSG_show_group_name |
|
129 | + '%d',// QSG_show_group_desc |
|
130 | + '%d',// QSG_system |
|
131 | + '%d',// QSG_deleted |
|
132 | + ); |
|
133 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
134 | + if (! $success) { |
|
135 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes)); |
|
136 | + return 0; |
|
137 | + } |
|
138 | + return $wpdb->insert_id; |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Checks if we've already added a system question 1 to the new question groups table |
|
143 | - * @global type $wpdb |
|
144 | - * @return boolean |
|
145 | - */ |
|
146 | - private function _already_got_system_question_group_1() |
|
147 | - { |
|
148 | - if (! $this->_already_got_system_question_group_1) { |
|
149 | - // check the db |
|
150 | - global $wpdb; |
|
151 | - $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1"); |
|
152 | - if (intval($exists)>0) { |
|
153 | - $this->_already_got_system_question_group_1 = true; |
|
154 | - } |
|
155 | - } |
|
156 | - return $this->_already_got_system_question_group_1; |
|
157 | - } |
|
141 | + /** |
|
142 | + * Checks if we've already added a system question 1 to the new question groups table |
|
143 | + * @global type $wpdb |
|
144 | + * @return boolean |
|
145 | + */ |
|
146 | + private function _already_got_system_question_group_1() |
|
147 | + { |
|
148 | + if (! $this->_already_got_system_question_group_1) { |
|
149 | + // check the db |
|
150 | + global $wpdb; |
|
151 | + $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1"); |
|
152 | + if (intval($exists)>0) { |
|
153 | + $this->_already_got_system_question_group_1 = true; |
|
154 | + } |
|
155 | + } |
|
156 | + return $this->_already_got_system_question_group_1; |
|
157 | + } |
|
158 | 158 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | // could be easily removed. |
98 | 98 | if ($old_question_group['system_group'] && ! $this->_already_got_system_question_group_1()) { |
99 | 99 | $guess_at_system_number = 1; |
100 | - } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address')!==false) { |
|
100 | + } elseif ($old_question_group['id'] == '2' && strpos($old_question_group['group_name'], 'Address') !== false) { |
|
101 | 101 | $guess_at_system_number = 2; |
102 | 102 | } else { |
103 | 103 | $guess_at_system_number = 0; |
104 | 104 | } |
105 | 105 | // if the question group wasn't made by the normal admin, |
106 | 106 | // we'd like to keep track of who made it |
107 | - if (intval($old_question_group['wp_user'])!=1) { |
|
107 | + if (intval($old_question_group['wp_user']) != 1) { |
|
108 | 108 | $username = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM ".$wpdb->users." WHERE ID = %d", $old_question_group['wp_user'])); |
109 | 109 | $identifier = $old_question_group['group_identifier']."-by-".$username; |
110 | 110 | } else { |
@@ -121,17 +121,17 @@ discard block |
||
121 | 121 | 'QSG_deleted'=>false |
122 | 122 | ); |
123 | 123 | $datatypes = array( |
124 | - '%s',// QSG_name |
|
125 | - '%s',// QSG_identifier |
|
126 | - '%s',// QSG_desc |
|
127 | - '%d',// QSG_order |
|
128 | - '%d',// QSG_show_group_name |
|
129 | - '%d',// QSG_show_group_desc |
|
130 | - '%d',// QSG_system |
|
131 | - '%d',// QSG_deleted |
|
124 | + '%s', // QSG_name |
|
125 | + '%s', // QSG_identifier |
|
126 | + '%s', // QSG_desc |
|
127 | + '%d', // QSG_order |
|
128 | + '%d', // QSG_show_group_name |
|
129 | + '%d', // QSG_show_group_desc |
|
130 | + '%d', // QSG_system |
|
131 | + '%d', // QSG_deleted |
|
132 | 132 | ); |
133 | 133 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
134 | - if (! $success) { |
|
134 | + if ( ! $success) { |
|
135 | 135 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group, $this->_new_table, $cols_n_values, $datatypes)); |
136 | 136 | return 0; |
137 | 137 | } |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | */ |
146 | 146 | private function _already_got_system_question_group_1() |
147 | 147 | { |
148 | - if (! $this->_already_got_system_question_group_1) { |
|
148 | + if ( ! $this->_already_got_system_question_group_1) { |
|
149 | 149 | // check the db |
150 | 150 | global $wpdb; |
151 | 151 | $exists = $wpdb->get_var("SELECT COUNT(*) FROM {$this->_new_table} WHERE QSG_system=1"); |
152 | - if (intval($exists)>0) { |
|
152 | + if (intval($exists) > 0) { |
|
153 | 153 | $this->_already_got_system_question_group_1 = true; |
154 | 154 | } |
155 | 155 | } |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | // convert settings |
25 | 25 | $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone); |
26 | 26 | // just do a part of them on this request |
27 | - $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate; |
|
27 | + $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items); // $this->_gateways_we_know_how_to_migrate; |
|
28 | 28 | foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) { |
29 | 29 | $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
30 | - if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
30 | + if (isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) { |
|
31 | 31 | // determine the old option's name |
32 | 32 | $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug); |
33 | - if (! $old_gateway_settings) { |
|
33 | + if ( ! $old_gateway_settings) { |
|
34 | 34 | // no settings existed for this gateway anyways... weird... |
35 | 35 | $items_actually_migrated++; |
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | // now prepare the settings to make sure they're in the 4.1 format |
39 | 39 | $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug); |
40 | - $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings; |
|
40 | + $new_gateway_config_obj->payment_settings[$new_gateway_slug] = $new_gateway_settings; |
|
41 | 41 | // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
42 | 42 | // I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
43 | 43 | delete_option($old_gateway_wp_option_name); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $items_actually_migrated++; |
52 | 52 | } |
53 | 53 | // if we can keep going, and it hasn' tbeen done yet, convert active gateways |
54 | - if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
54 | + if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
55 | 55 | $this->_convert_active_gateways(); |
56 | 56 | $this->_converted_active_gateways = true; |
57 | 57 | $items_actually_migrated++; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $step_of_setting_active_gateways = 1; |
70 | 70 | $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone); |
71 | 71 | // $button_images_to_update = |
72 | - return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
72 | + return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
73 | 73 | } |
74 | 74 | public function __construct() |
75 | 75 | { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | private function _get_old_gateway_option($new_gateway_slug) |
116 | 116 | { |
117 | 117 | $option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
118 | - $settings = get_option($option_name, null); |
|
118 | + $settings = get_option($option_name, null); |
|
119 | 119 | // if( ! $settings){ |
120 | 120 | // $this->add_error(sprintf(__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug)); |
121 | 121 | // } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | private function _get_old_gateway_option_name($new_gateway_slug) |
131 | 131 | { |
132 | 132 | $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone)); |
133 | - $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ]; |
|
133 | + $old_gateway_slug = $new_gateway_slugs_to_new[$new_gateway_slug]; |
|
134 | 134 | $normal_option_prefix = 'event_espresso_'; |
135 | 135 | $normal_option_postfix = '_settings'; |
136 | 136 | switch ($new_gateway_slug) { |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | $old_active_gateways = get_option('event_espresso_active_gateways'); |
171 | 171 | $new_active_gateways = EE_Config::instance()->gateway->active_gateways; |
172 | 172 | foreach ($old_active_gateways as $old_gateway_slug => $filepath) { |
173 | - if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
173 | + if ( ! isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) { |
|
174 | 174 | $this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug)); |
175 | 175 | continue; |
176 | 176 | } |
177 | - $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ]; |
|
177 | + $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[$old_gateway_slug]; |
|
178 | 178 | |
179 | 179 | // in the new format we can also upload gateways to the uploads directory and |
180 | - $new_active_gateways[ $new_gateway_slug ] = false; |
|
180 | + $new_active_gateways[$new_gateway_slug] = false; |
|
181 | 181 | } |
182 | 182 | EE_Config::instance()->gateway->active_gateways = $new_active_gateways; |
183 | 183 | } |
@@ -14,68 +14,68 @@ discard block |
||
14 | 14 | class EE_DMS_4_1_0_gateways extends EE_Data_Migration_Script_Stage |
15 | 15 | { |
16 | 16 | |
17 | - private $_converted_active_gateways = false; |
|
17 | + private $_converted_active_gateways = false; |
|
18 | 18 | |
19 | - public function _migration_step($num_items = 50) |
|
20 | - { |
|
21 | - // loads existing EE_CONfig from DB, if it exists |
|
22 | - $new_gateway_config_obj = EE_Config::instance()->gateway; |
|
23 | - $items_actually_migrated = 0; |
|
24 | - // convert settings |
|
25 | - $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone); |
|
26 | - // just do a part of them on this request |
|
27 | - $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate; |
|
28 | - foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) { |
|
29 | - $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
30 | - if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
31 | - // determine the old option's name |
|
32 | - $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug); |
|
33 | - if (! $old_gateway_settings) { |
|
34 | - // no settings existed for this gateway anyways... weird... |
|
35 | - $items_actually_migrated++; |
|
36 | - continue; |
|
37 | - } |
|
38 | - // now prepare the settings to make sure they're in the 4.1 format |
|
39 | - $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug); |
|
40 | - $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings; |
|
41 | - // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
|
42 | - // I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
|
43 | - delete_option($old_gateway_wp_option_name); |
|
44 | - } else {// it must be one of the ones we mostly leave alone |
|
45 | - global $wpdb; |
|
46 | - // yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll |
|
47 | - // only be saving users 50 milliseconds the one time this runs... |
|
48 | - $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->options." SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name)); |
|
49 | - } |
|
19 | + public function _migration_step($num_items = 50) |
|
20 | + { |
|
21 | + // loads existing EE_CONfig from DB, if it exists |
|
22 | + $new_gateway_config_obj = EE_Config::instance()->gateway; |
|
23 | + $items_actually_migrated = 0; |
|
24 | + // convert settings |
|
25 | + $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone); |
|
26 | + // just do a part of them on this request |
|
27 | + $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate; |
|
28 | + foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) { |
|
29 | + $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
30 | + if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
31 | + // determine the old option's name |
|
32 | + $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug); |
|
33 | + if (! $old_gateway_settings) { |
|
34 | + // no settings existed for this gateway anyways... weird... |
|
35 | + $items_actually_migrated++; |
|
36 | + continue; |
|
37 | + } |
|
38 | + // now prepare the settings to make sure they're in the 4.1 format |
|
39 | + $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug); |
|
40 | + $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings; |
|
41 | + // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
|
42 | + // I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
|
43 | + delete_option($old_gateway_wp_option_name); |
|
44 | + } else {// it must be one of the ones we mostly leave alone |
|
45 | + global $wpdb; |
|
46 | + // yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll |
|
47 | + // only be saving users 50 milliseconds the one time this runs... |
|
48 | + $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->options." SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name)); |
|
49 | + } |
|
50 | 50 | |
51 | - $items_actually_migrated++; |
|
52 | - } |
|
53 | - // if we can keep going, and it hasn' tbeen done yet, convert active gateways |
|
54 | - if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
55 | - $this->_convert_active_gateways(); |
|
56 | - $this->_converted_active_gateways = true; |
|
57 | - $items_actually_migrated++; |
|
58 | - } |
|
51 | + $items_actually_migrated++; |
|
52 | + } |
|
53 | + // if we can keep going, and it hasn' tbeen done yet, convert active gateways |
|
54 | + if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
55 | + $this->_convert_active_gateways(); |
|
56 | + $this->_converted_active_gateways = true; |
|
57 | + $items_actually_migrated++; |
|
58 | + } |
|
59 | 59 | |
60 | - EE_Config::instance()->update_espresso_config(false, false); |
|
61 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
62 | - $this->set_completed(); |
|
63 | - } |
|
64 | - return $items_actually_migrated; |
|
65 | - } |
|
66 | - public function _count_records_to_migrate() |
|
67 | - { |
|
68 | - $count_of_gateways_to_convert = count($this->_gateways_we_know_how_to_migrate); |
|
69 | - $step_of_setting_active_gateways = 1; |
|
70 | - $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone); |
|
71 | - // $button_images_to_update = |
|
72 | - return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
73 | - } |
|
74 | - public function __construct() |
|
75 | - { |
|
76 | - $this->_pretty_name = __("Gateways", "event_espresso"); |
|
77 | - parent::__construct(); |
|
78 | - } |
|
60 | + EE_Config::instance()->update_espresso_config(false, false); |
|
61 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
62 | + $this->set_completed(); |
|
63 | + } |
|
64 | + return $items_actually_migrated; |
|
65 | + } |
|
66 | + public function _count_records_to_migrate() |
|
67 | + { |
|
68 | + $count_of_gateways_to_convert = count($this->_gateways_we_know_how_to_migrate); |
|
69 | + $step_of_setting_active_gateways = 1; |
|
70 | + $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone); |
|
71 | + // $button_images_to_update = |
|
72 | + return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
73 | + } |
|
74 | + public function __construct() |
|
75 | + { |
|
76 | + $this->_pretty_name = __("Gateways", "event_espresso"); |
|
77 | + parent::__construct(); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Takes the old array of 3.1 gateway settings for this gateway and converts it |
@@ -85,148 +85,148 @@ discard block |
||
85 | 85 | * @param string $new_gateway_slug |
86 | 86 | * @return array |
87 | 87 | */ |
88 | - private function _convert_gateway_settings($old_gateway_settings, $new_gateway_slug) |
|
89 | - { |
|
90 | - $new_gateway_settings = $old_gateway_settings; |
|
91 | - switch ($new_gateway_slug) { |
|
92 | - case 'Bank': |
|
93 | - $new_gateway_settings['account_number'] = $old_gateway_settings['bank_account']; |
|
94 | - $new_gateway_settings['page_title'] = $old_gateway_settings['bank_title']; |
|
95 | - break; |
|
96 | - case 'Invoice': |
|
97 | - $new_gateway_settings['invoice_logo_url'] = $old_gateway_settings['image_url']; |
|
98 | - // Dont' migrate the old invoice payee address. It was usually given dummy data. And in EE4 |
|
99 | - // it gets used in the receipts which are available to everyone. So usually it's best to not |
|
100 | - // migrate this. |
|
101 | - unset($new_gateway_settings['payment_address']); |
|
102 | - break; |
|
103 | - case 'Paypal_Pro': |
|
104 | - $new_gateway_settings['email'] = $old_gateway_settings['paypal_pro_email']; |
|
105 | - $new_gateway_settings['username'] = $old_gateway_settings['paypal_api_username']; |
|
106 | - $new_gateway_settings['password'] = $old_gateway_settings['paypal_api_password']; |
|
107 | - $new_gateway_settings['signature'] = $old_gateway_settings['paypal_api_signature']; |
|
108 | - $new_gateway_settings['credit_cards'] = explode(",", $old_gateway_settings['paypal_api_credit_cards']); |
|
109 | - $new_gateway_settings['use_sandbox'] = $old_gateway_settings['paypal_pro_use_sandbox']; |
|
110 | - break; |
|
111 | - } |
|
112 | - return $new_gateway_settings; |
|
113 | - } |
|
88 | + private function _convert_gateway_settings($old_gateway_settings, $new_gateway_slug) |
|
89 | + { |
|
90 | + $new_gateway_settings = $old_gateway_settings; |
|
91 | + switch ($new_gateway_slug) { |
|
92 | + case 'Bank': |
|
93 | + $new_gateway_settings['account_number'] = $old_gateway_settings['bank_account']; |
|
94 | + $new_gateway_settings['page_title'] = $old_gateway_settings['bank_title']; |
|
95 | + break; |
|
96 | + case 'Invoice': |
|
97 | + $new_gateway_settings['invoice_logo_url'] = $old_gateway_settings['image_url']; |
|
98 | + // Dont' migrate the old invoice payee address. It was usually given dummy data. And in EE4 |
|
99 | + // it gets used in the receipts which are available to everyone. So usually it's best to not |
|
100 | + // migrate this. |
|
101 | + unset($new_gateway_settings['payment_address']); |
|
102 | + break; |
|
103 | + case 'Paypal_Pro': |
|
104 | + $new_gateway_settings['email'] = $old_gateway_settings['paypal_pro_email']; |
|
105 | + $new_gateway_settings['username'] = $old_gateway_settings['paypal_api_username']; |
|
106 | + $new_gateway_settings['password'] = $old_gateway_settings['paypal_api_password']; |
|
107 | + $new_gateway_settings['signature'] = $old_gateway_settings['paypal_api_signature']; |
|
108 | + $new_gateway_settings['credit_cards'] = explode(",", $old_gateway_settings['paypal_api_credit_cards']); |
|
109 | + $new_gateway_settings['use_sandbox'] = $old_gateway_settings['paypal_pro_use_sandbox']; |
|
110 | + break; |
|
111 | + } |
|
112 | + return $new_gateway_settings; |
|
113 | + } |
|
114 | 114 | /** |
115 | - * Figures out the correct 3.1 gateway settings option name for the given 4.1 gateway |
|
116 | - * @param string $new_gateway_slug |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - private function _get_old_gateway_option($new_gateway_slug) |
|
120 | - { |
|
121 | - $option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
122 | - $settings = get_option($option_name, null); |
|
123 | - // if( ! $settings){ |
|
124 | - // $this->add_error(sprintf(__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug)); |
|
125 | - // } |
|
126 | - return $settings; |
|
127 | - } |
|
115 | + * Figures out the correct 3.1 gateway settings option name for the given 4.1 gateway |
|
116 | + * @param string $new_gateway_slug |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + private function _get_old_gateway_option($new_gateway_slug) |
|
120 | + { |
|
121 | + $option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
|
122 | + $settings = get_option($option_name, null); |
|
123 | + // if( ! $settings){ |
|
124 | + // $this->add_error(sprintf(__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug)); |
|
125 | + // } |
|
126 | + return $settings; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Just gets the old gateways slug |
131 | 131 | * @param string $new_gateway_slug |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - private function _get_old_gateway_option_name($new_gateway_slug) |
|
135 | - { |
|
136 | - $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone)); |
|
137 | - $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ]; |
|
138 | - $normal_option_prefix = 'event_espresso_'; |
|
139 | - $normal_option_postfix = '_settings'; |
|
140 | - switch ($new_gateway_slug) { |
|
141 | - case 'Bank': |
|
142 | - $option_name = $normal_option_prefix.'bank_deposit'.$normal_option_postfix; |
|
143 | - break; |
|
144 | - case 'Aim': |
|
145 | - $option_name = $normal_option_prefix.'authnet_aim'.$normal_option_postfix; |
|
146 | - break; |
|
147 | - case 'Check': |
|
148 | - $option_name = $normal_option_prefix.'check_payment'.$normal_option_postfix; |
|
149 | - break; |
|
150 | - case 'Ideal': |
|
151 | - $option_name = $normal_option_prefix.'ideal_mollie'.$normal_option_postfix; |
|
152 | - break; |
|
153 | - case 'Invoice': |
|
154 | - $option_name = $normal_option_prefix.'invoice_payment'.$normal_option_postfix; |
|
155 | - break; |
|
156 | - case 'Purchase_Order': |
|
157 | - $option_name = $normal_option_prefix.'purchase_order_payment'.$normal_option_postfix; |
|
158 | - break; |
|
159 | - case 'USAePay_Offsite': |
|
160 | - $option_name = 'espresso_usaepay_offsite'.$normal_option_postfix; |
|
161 | - break; |
|
162 | - case 'USAePay_Onsite': |
|
163 | - $option_name = 'espresso_usaepay_onsite'.$normal_option_postfix; |
|
164 | - break; |
|
165 | - default: |
|
166 | - $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix.$old_gateway_slug.$normal_option_postfix); |
|
167 | - } |
|
168 | - return $option_name; |
|
169 | - } |
|
134 | + private function _get_old_gateway_option_name($new_gateway_slug) |
|
135 | + { |
|
136 | + $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone)); |
|
137 | + $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ]; |
|
138 | + $normal_option_prefix = 'event_espresso_'; |
|
139 | + $normal_option_postfix = '_settings'; |
|
140 | + switch ($new_gateway_slug) { |
|
141 | + case 'Bank': |
|
142 | + $option_name = $normal_option_prefix.'bank_deposit'.$normal_option_postfix; |
|
143 | + break; |
|
144 | + case 'Aim': |
|
145 | + $option_name = $normal_option_prefix.'authnet_aim'.$normal_option_postfix; |
|
146 | + break; |
|
147 | + case 'Check': |
|
148 | + $option_name = $normal_option_prefix.'check_payment'.$normal_option_postfix; |
|
149 | + break; |
|
150 | + case 'Ideal': |
|
151 | + $option_name = $normal_option_prefix.'ideal_mollie'.$normal_option_postfix; |
|
152 | + break; |
|
153 | + case 'Invoice': |
|
154 | + $option_name = $normal_option_prefix.'invoice_payment'.$normal_option_postfix; |
|
155 | + break; |
|
156 | + case 'Purchase_Order': |
|
157 | + $option_name = $normal_option_prefix.'purchase_order_payment'.$normal_option_postfix; |
|
158 | + break; |
|
159 | + case 'USAePay_Offsite': |
|
160 | + $option_name = 'espresso_usaepay_offsite'.$normal_option_postfix; |
|
161 | + break; |
|
162 | + case 'USAePay_Onsite': |
|
163 | + $option_name = 'espresso_usaepay_onsite'.$normal_option_postfix; |
|
164 | + break; |
|
165 | + default: |
|
166 | + $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix.$old_gateway_slug.$normal_option_postfix); |
|
167 | + } |
|
168 | + return $option_name; |
|
169 | + } |
|
170 | 170 | |
171 | - private function _convert_active_gateways() |
|
172 | - { |
|
173 | - // just does it all one big swoop |
|
174 | - $old_active_gateways = get_option('event_espresso_active_gateways'); |
|
175 | - $new_active_gateways = EE_Config::instance()->gateway->active_gateways; |
|
176 | - foreach ($old_active_gateways as $old_gateway_slug => $filepath) { |
|
177 | - if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
178 | - $this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug)); |
|
179 | - continue; |
|
180 | - } |
|
181 | - $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ]; |
|
171 | + private function _convert_active_gateways() |
|
172 | + { |
|
173 | + // just does it all one big swoop |
|
174 | + $old_active_gateways = get_option('event_espresso_active_gateways'); |
|
175 | + $new_active_gateways = EE_Config::instance()->gateway->active_gateways; |
|
176 | + foreach ($old_active_gateways as $old_gateway_slug => $filepath) { |
|
177 | + if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) { |
|
178 | + $this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug)); |
|
179 | + continue; |
|
180 | + } |
|
181 | + $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ]; |
|
182 | 182 | |
183 | - // in the new format we can also upload gateways to the uploads directory and |
|
184 | - $new_active_gateways[ $new_gateway_slug ] = false; |
|
185 | - } |
|
186 | - EE_Config::instance()->gateway->active_gateways = $new_active_gateways; |
|
187 | - } |
|
183 | + // in the new format we can also upload gateways to the uploads directory and |
|
184 | + $new_active_gateways[ $new_gateway_slug ] = false; |
|
185 | + } |
|
186 | + EE_Config::instance()->gateway->active_gateways = $new_active_gateways; |
|
187 | + } |
|
188 | 188 | |
189 | - protected $_gateways_we_know_how_to_migrate = array( |
|
190 | - 'aim'=>'Aim', |
|
191 | - 'bank'=>'Bank', |
|
192 | - 'check'=>'Check', |
|
193 | - 'invoice'=>'Invoice', |
|
194 | - 'paypal'=>'Paypal_Standard', |
|
195 | - 'paypal_pro'=>'Paypal_Pro', |
|
189 | + protected $_gateways_we_know_how_to_migrate = array( |
|
190 | + 'aim'=>'Aim', |
|
191 | + 'bank'=>'Bank', |
|
192 | + 'check'=>'Check', |
|
193 | + 'invoice'=>'Invoice', |
|
194 | + 'paypal'=>'Paypal_Standard', |
|
195 | + 'paypal_pro'=>'Paypal_Pro', |
|
196 | 196 | |
197 | - ); |
|
197 | + ); |
|
198 | 198 | |
199 | - protected $_gateways_we_leave_alone = array( |
|
200 | - '2checkout'=>'2checkout', |
|
201 | - 'anz'=>'Anz', |
|
202 | - 'atos'=>'Atos', |
|
203 | - 'authnet'=>'Authnet', |
|
204 | - 'beanstream'=>'Beanstream', |
|
205 | - 'evertec'=>'Evertec', |
|
206 | - 'eway'=>'Eway', |
|
207 | - 'eway_rapid3'=>'Eway_Rapid3', |
|
208 | - 'exact'=>'Exact', |
|
209 | - 'firstdata'=>'Firstdata', |
|
210 | - 'firstdat_e4'=>'Firstdata_E4', |
|
211 | - 'ideal'=>'Ideal', |
|
212 | - 'infusion_payment'=>'InfusionSoft', |
|
213 | - 'luottokunta'=>'Luottokunta', |
|
214 | - 'megasoft'=>'Megasoft', |
|
215 | - 'moneris_hpp'=>'Moneris_HPP', |
|
216 | - 'mwarrior'=>'Mwarrior', |
|
217 | - 'nab'=>'NAB', |
|
218 | - 'paychoice'=>'Paychoice', |
|
219 | - 'paytrace'=>'Paytrace', |
|
220 | - 'psigate'=>'Psigate', |
|
221 | - 'purchase_order'=>'Purchase_Order', |
|
222 | - 'qbms'=>'QBMS', |
|
223 | - 'quickpay'=>'Quickpay', |
|
224 | - 'realauth'=>'Realauth', |
|
225 | - 'securepay_aus'=>'Securepay_Aus', |
|
226 | - 'stripe'=>'Stripe', |
|
227 | - 'usaepay_offsite'=>'USAePay_Offsite', |
|
228 | - 'usaepay_onsite'=>'USAePay_Onsite', |
|
229 | - 'wepay'=>'Wepay', |
|
230 | - 'worldpay'=>'Worldpay' |
|
231 | - ); |
|
199 | + protected $_gateways_we_leave_alone = array( |
|
200 | + '2checkout'=>'2checkout', |
|
201 | + 'anz'=>'Anz', |
|
202 | + 'atos'=>'Atos', |
|
203 | + 'authnet'=>'Authnet', |
|
204 | + 'beanstream'=>'Beanstream', |
|
205 | + 'evertec'=>'Evertec', |
|
206 | + 'eway'=>'Eway', |
|
207 | + 'eway_rapid3'=>'Eway_Rapid3', |
|
208 | + 'exact'=>'Exact', |
|
209 | + 'firstdata'=>'Firstdata', |
|
210 | + 'firstdat_e4'=>'Firstdata_E4', |
|
211 | + 'ideal'=>'Ideal', |
|
212 | + 'infusion_payment'=>'InfusionSoft', |
|
213 | + 'luottokunta'=>'Luottokunta', |
|
214 | + 'megasoft'=>'Megasoft', |
|
215 | + 'moneris_hpp'=>'Moneris_HPP', |
|
216 | + 'mwarrior'=>'Mwarrior', |
|
217 | + 'nab'=>'NAB', |
|
218 | + 'paychoice'=>'Paychoice', |
|
219 | + 'paytrace'=>'Paytrace', |
|
220 | + 'psigate'=>'Psigate', |
|
221 | + 'purchase_order'=>'Purchase_Order', |
|
222 | + 'qbms'=>'QBMS', |
|
223 | + 'quickpay'=>'Quickpay', |
|
224 | + 'realauth'=>'Realauth', |
|
225 | + 'securepay_aus'=>'Securepay_Aus', |
|
226 | + 'stripe'=>'Stripe', |
|
227 | + 'usaepay_offsite'=>'USAePay_Offsite', |
|
228 | + 'usaepay_onsite'=>'USAePay_Onsite', |
|
229 | + 'wepay'=>'Wepay', |
|
230 | + 'worldpay'=>'Worldpay' |
|
231 | + ); |
|
232 | 232 | } |
@@ -63,210 +63,210 @@ |
||
63 | 63 | */ |
64 | 64 | class EE_DMS_4_1_0_venues extends EE_Data_Migration_Script_Stage |
65 | 65 | { |
66 | - private $_old_table; |
|
67 | - private $_new_table; |
|
68 | - private $_new_meta_table; |
|
69 | - public function _migration_step($num_items = 50) |
|
70 | - { |
|
71 | - global $wpdb; |
|
72 | - $start_at_record = $this->count_records_migrated(); |
|
73 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
74 | - $items_actually_migrated = 0; |
|
75 | - foreach ($rows as $old_venue) { |
|
76 | - if (! $new_id = $this->_insert_into_posts($old_venue)) { |
|
77 | - $items_actually_migrated++; |
|
78 | - continue; |
|
79 | - } |
|
80 | - $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_table, $new_id); |
|
81 | - if (! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) { |
|
82 | - $items_actually_migrated++; |
|
83 | - continue; |
|
84 | - } |
|
85 | - $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_meta_table, $new_meta_id); |
|
86 | - // lastly, save the 'contact' as post meta, because it doesn't exist anywhere else but someone may still want it |
|
87 | - $venue_meta = maybe_unserialize($old_venue['meta']); |
|
88 | - if (isset($venue_meta['contact']) && $venue_meta['contact']) { |
|
89 | - add_post_meta($new_id, 'contact', $venue_meta['contact']); |
|
90 | - } |
|
91 | - // is there an image on this venue? |
|
92 | - $guid = isset($venue_meta['image']) && $venue_meta['image'] ? $venue_meta['image'] : null; |
|
93 | - if ($guid) { |
|
94 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
95 | - } |
|
96 | - $items_actually_migrated++; |
|
97 | - if ($guid) { |
|
98 | - // if there was an image, we may have had to download it etc and it may have taken |
|
99 | - // longer, then let's not bother migrating anymore on this step |
|
100 | - break; |
|
101 | - } |
|
102 | - } |
|
103 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
104 | - $this->set_completed(); |
|
105 | - } |
|
106 | - return $items_actually_migrated; |
|
107 | - } |
|
108 | - public function _count_records_to_migrate() |
|
109 | - { |
|
110 | - global $wpdb; |
|
111 | - $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
112 | - return $count; |
|
113 | - } |
|
114 | - public function __construct() |
|
115 | - { |
|
116 | - $this->_pretty_name = __("Venues", "event_espresso"); |
|
117 | - global $wpdb; |
|
118 | - $this->_old_table = $wpdb->prefix."events_venue"; |
|
119 | - $this->_new_table = $wpdb->posts; |
|
120 | - $this->_new_meta_table = $wpdb->prefix."esp_venue_meta"; |
|
121 | - parent::__construct(); |
|
122 | - } |
|
66 | + private $_old_table; |
|
67 | + private $_new_table; |
|
68 | + private $_new_meta_table; |
|
69 | + public function _migration_step($num_items = 50) |
|
70 | + { |
|
71 | + global $wpdb; |
|
72 | + $start_at_record = $this->count_records_migrated(); |
|
73 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
74 | + $items_actually_migrated = 0; |
|
75 | + foreach ($rows as $old_venue) { |
|
76 | + if (! $new_id = $this->_insert_into_posts($old_venue)) { |
|
77 | + $items_actually_migrated++; |
|
78 | + continue; |
|
79 | + } |
|
80 | + $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_table, $new_id); |
|
81 | + if (! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) { |
|
82 | + $items_actually_migrated++; |
|
83 | + continue; |
|
84 | + } |
|
85 | + $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_meta_table, $new_meta_id); |
|
86 | + // lastly, save the 'contact' as post meta, because it doesn't exist anywhere else but someone may still want it |
|
87 | + $venue_meta = maybe_unserialize($old_venue['meta']); |
|
88 | + if (isset($venue_meta['contact']) && $venue_meta['contact']) { |
|
89 | + add_post_meta($new_id, 'contact', $venue_meta['contact']); |
|
90 | + } |
|
91 | + // is there an image on this venue? |
|
92 | + $guid = isset($venue_meta['image']) && $venue_meta['image'] ? $venue_meta['image'] : null; |
|
93 | + if ($guid) { |
|
94 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
95 | + } |
|
96 | + $items_actually_migrated++; |
|
97 | + if ($guid) { |
|
98 | + // if there was an image, we may have had to download it etc and it may have taken |
|
99 | + // longer, then let's not bother migrating anymore on this step |
|
100 | + break; |
|
101 | + } |
|
102 | + } |
|
103 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
104 | + $this->set_completed(); |
|
105 | + } |
|
106 | + return $items_actually_migrated; |
|
107 | + } |
|
108 | + public function _count_records_to_migrate() |
|
109 | + { |
|
110 | + global $wpdb; |
|
111 | + $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table); |
|
112 | + return $count; |
|
113 | + } |
|
114 | + public function __construct() |
|
115 | + { |
|
116 | + $this->_pretty_name = __("Venues", "event_espresso"); |
|
117 | + global $wpdb; |
|
118 | + $this->_old_table = $wpdb->prefix."events_venue"; |
|
119 | + $this->_new_table = $wpdb->posts; |
|
120 | + $this->_new_meta_table = $wpdb->prefix."esp_venue_meta"; |
|
121 | + parent::__construct(); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Inserts the CPT |
|
126 | - * @param array $old_venue keys are cols, values are col values |
|
127 | - * @return int |
|
128 | - */ |
|
129 | - private function _insert_into_posts($old_venue) |
|
130 | - { |
|
131 | - global $wpdb; |
|
132 | - $meta = maybe_unserialize($old_venue['meta']); |
|
133 | - $slug = $this->_find_unique_slug($old_venue['name'], $old_venue['identifier']); |
|
134 | - $insertion_array = array( |
|
135 | - 'post_title'=>stripslashes($old_venue['name']),// VNU_name |
|
136 | - 'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '',// VNU_desc |
|
137 | - 'post_name'=> $slug,// VNU_identifier |
|
138 | - 'post_date'=>current_time('mysql'),// VNU_created |
|
139 | - 'post_date_gmt'=> current_time('mysql', true), |
|
140 | - 'post_excerpt'=>'',// wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters |
|
141 | - 'post_modified'=>current_time('mysql'),// VNU_modified |
|
142 | - 'post_modified_gmt'=>current_time('mysql', true), |
|
143 | - 'post_author'=>$old_venue['wp_user'],// VNU_wp_user |
|
144 | - 'post_parent'=>0,// parent |
|
145 | - 'menu_order'=>0,// VNU_order |
|
146 | - 'post_type'=>'espresso_venues'// post_type |
|
147 | - ); |
|
148 | - $datatypes_array = array( |
|
149 | - '%s',// VNU_name |
|
150 | - '%s',// VNU_desc |
|
151 | - '%s',// VNU_identifier |
|
152 | - '%s',// VNU_created |
|
153 | - '%s', |
|
154 | - '%s',// VNU_short_desc |
|
155 | - '%s',// VNU_modified |
|
156 | - '%s', |
|
157 | - '%d',// VNU_wp_user |
|
158 | - '%d',// parent |
|
159 | - '%d',// VNU_order |
|
160 | - '%s',// post_type |
|
161 | - ); |
|
162 | - $success = $wpdb->insert( |
|
163 | - $this->_new_table, |
|
164 | - $insertion_array, |
|
165 | - $datatypes_array |
|
166 | - ); |
|
167 | - if (! $success) { |
|
168 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array)); |
|
169 | - return 0; |
|
170 | - } |
|
171 | - return $wpdb->insert_id; |
|
172 | - } |
|
124 | + /** |
|
125 | + * Inserts the CPT |
|
126 | + * @param array $old_venue keys are cols, values are col values |
|
127 | + * @return int |
|
128 | + */ |
|
129 | + private function _insert_into_posts($old_venue) |
|
130 | + { |
|
131 | + global $wpdb; |
|
132 | + $meta = maybe_unserialize($old_venue['meta']); |
|
133 | + $slug = $this->_find_unique_slug($old_venue['name'], $old_venue['identifier']); |
|
134 | + $insertion_array = array( |
|
135 | + 'post_title'=>stripslashes($old_venue['name']),// VNU_name |
|
136 | + 'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '',// VNU_desc |
|
137 | + 'post_name'=> $slug,// VNU_identifier |
|
138 | + 'post_date'=>current_time('mysql'),// VNU_created |
|
139 | + 'post_date_gmt'=> current_time('mysql', true), |
|
140 | + 'post_excerpt'=>'',// wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters |
|
141 | + 'post_modified'=>current_time('mysql'),// VNU_modified |
|
142 | + 'post_modified_gmt'=>current_time('mysql', true), |
|
143 | + 'post_author'=>$old_venue['wp_user'],// VNU_wp_user |
|
144 | + 'post_parent'=>0,// parent |
|
145 | + 'menu_order'=>0,// VNU_order |
|
146 | + 'post_type'=>'espresso_venues'// post_type |
|
147 | + ); |
|
148 | + $datatypes_array = array( |
|
149 | + '%s',// VNU_name |
|
150 | + '%s',// VNU_desc |
|
151 | + '%s',// VNU_identifier |
|
152 | + '%s',// VNU_created |
|
153 | + '%s', |
|
154 | + '%s',// VNU_short_desc |
|
155 | + '%s',// VNU_modified |
|
156 | + '%s', |
|
157 | + '%d',// VNU_wp_user |
|
158 | + '%d',// parent |
|
159 | + '%d',// VNU_order |
|
160 | + '%s',// post_type |
|
161 | + ); |
|
162 | + $success = $wpdb->insert( |
|
163 | + $this->_new_table, |
|
164 | + $insertion_array, |
|
165 | + $datatypes_array |
|
166 | + ); |
|
167 | + if (! $success) { |
|
168 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array)); |
|
169 | + return 0; |
|
170 | + } |
|
171 | + return $wpdb->insert_id; |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * Finds a unique slug for this venue, given its name (we could have simply used |
|
176 | - * the old unique_identifier column, but it added a long string of seemingly random characters onto the end |
|
177 | - * and really wasn't that pretty for a slug, so we decided we'd make our own slug again) |
|
178 | - * @param string $post_name |
|
179 | - * @return string |
|
180 | - */ |
|
181 | - private function _find_unique_slug($post_name, $old_identifier = '') |
|
182 | - { |
|
183 | - $count = 0; |
|
184 | - $original_name = $post_name ? sanitize_title($post_name) : $old_identifier; |
|
185 | - $event_slug = $original_name; |
|
186 | - while ($this->_other_post_exists_with_that_slug($event_slug) && $count<50) { |
|
187 | - $event_slug = sanitize_title($original_name."-".++$count); |
|
188 | - } |
|
189 | - return $event_slug; |
|
190 | - } |
|
174 | + /** |
|
175 | + * Finds a unique slug for this venue, given its name (we could have simply used |
|
176 | + * the old unique_identifier column, but it added a long string of seemingly random characters onto the end |
|
177 | + * and really wasn't that pretty for a slug, so we decided we'd make our own slug again) |
|
178 | + * @param string $post_name |
|
179 | + * @return string |
|
180 | + */ |
|
181 | + private function _find_unique_slug($post_name, $old_identifier = '') |
|
182 | + { |
|
183 | + $count = 0; |
|
184 | + $original_name = $post_name ? sanitize_title($post_name) : $old_identifier; |
|
185 | + $event_slug = $original_name; |
|
186 | + while ($this->_other_post_exists_with_that_slug($event_slug) && $count<50) { |
|
187 | + $event_slug = sanitize_title($original_name."-".++$count); |
|
188 | + } |
|
189 | + return $event_slug; |
|
190 | + } |
|
191 | 191 | |
192 | - /** |
|
193 | - * returns whether or not there is a post that has this same slug (post_title) |
|
194 | - * @global type $wpdb |
|
195 | - * @param type $slug |
|
196 | - * @return boolean |
|
197 | - */ |
|
198 | - private function _other_post_exists_with_that_slug($slug) |
|
199 | - { |
|
200 | - global $wpdb; |
|
201 | - $query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s", $slug); |
|
202 | - $count = $wpdb->get_var($query); |
|
203 | - return (boolean) intval($count); |
|
204 | - } |
|
192 | + /** |
|
193 | + * returns whether or not there is a post that has this same slug (post_title) |
|
194 | + * @global type $wpdb |
|
195 | + * @param type $slug |
|
196 | + * @return boolean |
|
197 | + */ |
|
198 | + private function _other_post_exists_with_that_slug($slug) |
|
199 | + { |
|
200 | + global $wpdb; |
|
201 | + $query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s", $slug); |
|
202 | + $count = $wpdb->get_var($query); |
|
203 | + return (boolean) intval($count); |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
207 | - * Inserts into the venue_meta table |
|
208 | - * @param type $cpt_id |
|
209 | - * @param type $old_venue |
|
210 | - * @return int |
|
211 | - */ |
|
212 | - private function _insert_into_meta_table($cpt_id, $old_venue) |
|
213 | - { |
|
214 | - global $wpdb; |
|
215 | - // get a country with the same name, or insert one |
|
216 | - try { |
|
217 | - $country = $this->get_migration_script()->get_or_create_country(stripslashes($old_venue['country'])); |
|
218 | - $country_iso = $country['CNT_ISO']; |
|
219 | - } catch (EE_Error $e) { |
|
220 | - $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue))); |
|
221 | - $country_iso = null; |
|
222 | - } |
|
223 | - // get a state with the same name, if possible |
|
224 | - try { |
|
225 | - $state = $this->get_migration_script()->get_or_create_state(stripslashes($old_venue['state']), isset($country['CNT_name']) ? $country['CNT_name'] : strip_tags($old_venue['country'])); |
|
226 | - $state_id = $state['STA_ID']; |
|
227 | - } catch (EE_Error $e) { |
|
228 | - $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue))); |
|
229 | - $state_id = 0; |
|
230 | - } |
|
231 | - $meta = maybe_unserialize($old_venue['meta']); |
|
232 | - // now insert into meta table |
|
233 | - $insertion_array = array( |
|
234 | - 'VNU_ID'=>$cpt_id,// VNU_ID_fk |
|
235 | - 'VNU_address'=>stripslashes($old_venue['address']),// VNU_address |
|
236 | - 'VNU_address2'=>stripslashes($old_venue['address2']),// VNU_address2 |
|
237 | - 'VNU_city'=>stripslashes($old_venue['city']),// VNU_city |
|
238 | - 'STA_ID'=>$state_id,// STA_ID |
|
239 | - 'CNT_ISO'=>$country_iso,// CNT_ISO |
|
240 | - 'VNU_zip'=>stripslashes($old_venue['zip']),// VNU_zip |
|
241 | - 'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '',// VNU_phone |
|
242 | - 'VNU_capacity'=>-1,// VNU_capacity |
|
243 | - 'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '',// VNU_url |
|
244 | - 'VNU_virtual_phone'=>'',// VNU_virtual_phone |
|
245 | - 'VNU_virtual_url'=>'',// VNU_virtual_url |
|
246 | - 'VNU_google_map_link'=>'',// VNU_google_map_link |
|
247 | - 'VNU_enable_for_gmap'=>true // VNU_enable_for_gmap |
|
248 | - ); |
|
249 | - $datatypes = array( |
|
250 | - '%d',// VNU_ID_fk |
|
251 | - '%s',// VNU_address |
|
252 | - '%s',// VNU_address2 |
|
253 | - '%s',// VNU_city |
|
254 | - '%d',// STA_ID |
|
255 | - '%s',// CNT_ISO |
|
256 | - '%s',// VNU_zip |
|
257 | - '%s',// VNU_phone |
|
258 | - '%d',// VNU_capacity |
|
259 | - '%s',// VNU_url |
|
260 | - '%s',// VNU_virtual_phone |
|
261 | - '%s',// VNU_virtual_url |
|
262 | - '%s',// VNU_google_map_link |
|
263 | - '%d',// VNU_enable_for_gmap |
|
264 | - ); |
|
265 | - $success = $wpdb->insert($this->_new_meta_table, $insertion_array, $datatypes); |
|
266 | - if (! $success) { |
|
267 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_meta_table, $insertion_array, $datatypes)); |
|
268 | - return 0; |
|
269 | - } |
|
270 | - return $wpdb->insert_id; |
|
271 | - } |
|
206 | + /** |
|
207 | + * Inserts into the venue_meta table |
|
208 | + * @param type $cpt_id |
|
209 | + * @param type $old_venue |
|
210 | + * @return int |
|
211 | + */ |
|
212 | + private function _insert_into_meta_table($cpt_id, $old_venue) |
|
213 | + { |
|
214 | + global $wpdb; |
|
215 | + // get a country with the same name, or insert one |
|
216 | + try { |
|
217 | + $country = $this->get_migration_script()->get_or_create_country(stripslashes($old_venue['country'])); |
|
218 | + $country_iso = $country['CNT_ISO']; |
|
219 | + } catch (EE_Error $e) { |
|
220 | + $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue))); |
|
221 | + $country_iso = null; |
|
222 | + } |
|
223 | + // get a state with the same name, if possible |
|
224 | + try { |
|
225 | + $state = $this->get_migration_script()->get_or_create_state(stripslashes($old_venue['state']), isset($country['CNT_name']) ? $country['CNT_name'] : strip_tags($old_venue['country'])); |
|
226 | + $state_id = $state['STA_ID']; |
|
227 | + } catch (EE_Error $e) { |
|
228 | + $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue))); |
|
229 | + $state_id = 0; |
|
230 | + } |
|
231 | + $meta = maybe_unserialize($old_venue['meta']); |
|
232 | + // now insert into meta table |
|
233 | + $insertion_array = array( |
|
234 | + 'VNU_ID'=>$cpt_id,// VNU_ID_fk |
|
235 | + 'VNU_address'=>stripslashes($old_venue['address']),// VNU_address |
|
236 | + 'VNU_address2'=>stripslashes($old_venue['address2']),// VNU_address2 |
|
237 | + 'VNU_city'=>stripslashes($old_venue['city']),// VNU_city |
|
238 | + 'STA_ID'=>$state_id,// STA_ID |
|
239 | + 'CNT_ISO'=>$country_iso,// CNT_ISO |
|
240 | + 'VNU_zip'=>stripslashes($old_venue['zip']),// VNU_zip |
|
241 | + 'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '',// VNU_phone |
|
242 | + 'VNU_capacity'=>-1,// VNU_capacity |
|
243 | + 'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '',// VNU_url |
|
244 | + 'VNU_virtual_phone'=>'',// VNU_virtual_phone |
|
245 | + 'VNU_virtual_url'=>'',// VNU_virtual_url |
|
246 | + 'VNU_google_map_link'=>'',// VNU_google_map_link |
|
247 | + 'VNU_enable_for_gmap'=>true // VNU_enable_for_gmap |
|
248 | + ); |
|
249 | + $datatypes = array( |
|
250 | + '%d',// VNU_ID_fk |
|
251 | + '%s',// VNU_address |
|
252 | + '%s',// VNU_address2 |
|
253 | + '%s',// VNU_city |
|
254 | + '%d',// STA_ID |
|
255 | + '%s',// CNT_ISO |
|
256 | + '%s',// VNU_zip |
|
257 | + '%s',// VNU_phone |
|
258 | + '%d',// VNU_capacity |
|
259 | + '%s',// VNU_url |
|
260 | + '%s',// VNU_virtual_phone |
|
261 | + '%s',// VNU_virtual_url |
|
262 | + '%s',// VNU_google_map_link |
|
263 | + '%d',// VNU_enable_for_gmap |
|
264 | + ); |
|
265 | + $success = $wpdb->insert($this->_new_meta_table, $insertion_array, $datatypes); |
|
266 | + if (! $success) { |
|
267 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_meta_table, $insertion_array, $datatypes)); |
|
268 | + return 0; |
|
269 | + } |
|
270 | + return $wpdb->insert_id; |
|
271 | + } |
|
272 | 272 | } |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
74 | 74 | $items_actually_migrated = 0; |
75 | 75 | foreach ($rows as $old_venue) { |
76 | - if (! $new_id = $this->_insert_into_posts($old_venue)) { |
|
76 | + if ( ! $new_id = $this->_insert_into_posts($old_venue)) { |
|
77 | 77 | $items_actually_migrated++; |
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_table, $new_id); |
81 | - if (! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) { |
|
81 | + if ( ! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) { |
|
82 | 82 | $items_actually_migrated++; |
83 | 83 | continue; |
84 | 84 | } |
@@ -132,39 +132,39 @@ discard block |
||
132 | 132 | $meta = maybe_unserialize($old_venue['meta']); |
133 | 133 | $slug = $this->_find_unique_slug($old_venue['name'], $old_venue['identifier']); |
134 | 134 | $insertion_array = array( |
135 | - 'post_title'=>stripslashes($old_venue['name']),// VNU_name |
|
136 | - 'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '',// VNU_desc |
|
137 | - 'post_name'=> $slug,// VNU_identifier |
|
138 | - 'post_date'=>current_time('mysql'),// VNU_created |
|
135 | + 'post_title'=>stripslashes($old_venue['name']), // VNU_name |
|
136 | + 'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '', // VNU_desc |
|
137 | + 'post_name'=> $slug, // VNU_identifier |
|
138 | + 'post_date'=>current_time('mysql'), // VNU_created |
|
139 | 139 | 'post_date_gmt'=> current_time('mysql', true), |
140 | - 'post_excerpt'=>'',// wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters |
|
141 | - 'post_modified'=>current_time('mysql'),// VNU_modified |
|
140 | + 'post_excerpt'=>'', // wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters |
|
141 | + 'post_modified'=>current_time('mysql'), // VNU_modified |
|
142 | 142 | 'post_modified_gmt'=>current_time('mysql', true), |
143 | - 'post_author'=>$old_venue['wp_user'],// VNU_wp_user |
|
144 | - 'post_parent'=>0,// parent |
|
145 | - 'menu_order'=>0,// VNU_order |
|
143 | + 'post_author'=>$old_venue['wp_user'], // VNU_wp_user |
|
144 | + 'post_parent'=>0, // parent |
|
145 | + 'menu_order'=>0, // VNU_order |
|
146 | 146 | 'post_type'=>'espresso_venues'// post_type |
147 | 147 | ); |
148 | 148 | $datatypes_array = array( |
149 | - '%s',// VNU_name |
|
150 | - '%s',// VNU_desc |
|
151 | - '%s',// VNU_identifier |
|
152 | - '%s',// VNU_created |
|
149 | + '%s', // VNU_name |
|
150 | + '%s', // VNU_desc |
|
151 | + '%s', // VNU_identifier |
|
152 | + '%s', // VNU_created |
|
153 | 153 | '%s', |
154 | - '%s',// VNU_short_desc |
|
155 | - '%s',// VNU_modified |
|
154 | + '%s', // VNU_short_desc |
|
155 | + '%s', // VNU_modified |
|
156 | 156 | '%s', |
157 | - '%d',// VNU_wp_user |
|
158 | - '%d',// parent |
|
159 | - '%d',// VNU_order |
|
160 | - '%s',// post_type |
|
157 | + '%d', // VNU_wp_user |
|
158 | + '%d', // parent |
|
159 | + '%d', // VNU_order |
|
160 | + '%s', // post_type |
|
161 | 161 | ); |
162 | 162 | $success = $wpdb->insert( |
163 | 163 | $this->_new_table, |
164 | 164 | $insertion_array, |
165 | 165 | $datatypes_array |
166 | 166 | ); |
167 | - if (! $success) { |
|
167 | + if ( ! $success) { |
|
168 | 168 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array)); |
169 | 169 | return 0; |
170 | 170 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $count = 0; |
184 | 184 | $original_name = $post_name ? sanitize_title($post_name) : $old_identifier; |
185 | 185 | $event_slug = $original_name; |
186 | - while ($this->_other_post_exists_with_that_slug($event_slug) && $count<50) { |
|
186 | + while ($this->_other_post_exists_with_that_slug($event_slug) && $count < 50) { |
|
187 | 187 | $event_slug = sanitize_title($original_name."-".++$count); |
188 | 188 | } |
189 | 189 | return $event_slug; |
@@ -231,39 +231,39 @@ discard block |
||
231 | 231 | $meta = maybe_unserialize($old_venue['meta']); |
232 | 232 | // now insert into meta table |
233 | 233 | $insertion_array = array( |
234 | - 'VNU_ID'=>$cpt_id,// VNU_ID_fk |
|
235 | - 'VNU_address'=>stripslashes($old_venue['address']),// VNU_address |
|
236 | - 'VNU_address2'=>stripslashes($old_venue['address2']),// VNU_address2 |
|
237 | - 'VNU_city'=>stripslashes($old_venue['city']),// VNU_city |
|
238 | - 'STA_ID'=>$state_id,// STA_ID |
|
239 | - 'CNT_ISO'=>$country_iso,// CNT_ISO |
|
240 | - 'VNU_zip'=>stripslashes($old_venue['zip']),// VNU_zip |
|
241 | - 'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '',// VNU_phone |
|
242 | - 'VNU_capacity'=>-1,// VNU_capacity |
|
243 | - 'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '',// VNU_url |
|
244 | - 'VNU_virtual_phone'=>'',// VNU_virtual_phone |
|
245 | - 'VNU_virtual_url'=>'',// VNU_virtual_url |
|
246 | - 'VNU_google_map_link'=>'',// VNU_google_map_link |
|
234 | + 'VNU_ID'=>$cpt_id, // VNU_ID_fk |
|
235 | + 'VNU_address'=>stripslashes($old_venue['address']), // VNU_address |
|
236 | + 'VNU_address2'=>stripslashes($old_venue['address2']), // VNU_address2 |
|
237 | + 'VNU_city'=>stripslashes($old_venue['city']), // VNU_city |
|
238 | + 'STA_ID'=>$state_id, // STA_ID |
|
239 | + 'CNT_ISO'=>$country_iso, // CNT_ISO |
|
240 | + 'VNU_zip'=>stripslashes($old_venue['zip']), // VNU_zip |
|
241 | + 'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '', // VNU_phone |
|
242 | + 'VNU_capacity'=>-1, // VNU_capacity |
|
243 | + 'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '', // VNU_url |
|
244 | + 'VNU_virtual_phone'=>'', // VNU_virtual_phone |
|
245 | + 'VNU_virtual_url'=>'', // VNU_virtual_url |
|
246 | + 'VNU_google_map_link'=>'', // VNU_google_map_link |
|
247 | 247 | 'VNU_enable_for_gmap'=>true // VNU_enable_for_gmap |
248 | 248 | ); |
249 | 249 | $datatypes = array( |
250 | - '%d',// VNU_ID_fk |
|
251 | - '%s',// VNU_address |
|
252 | - '%s',// VNU_address2 |
|
253 | - '%s',// VNU_city |
|
254 | - '%d',// STA_ID |
|
255 | - '%s',// CNT_ISO |
|
256 | - '%s',// VNU_zip |
|
257 | - '%s',// VNU_phone |
|
258 | - '%d',// VNU_capacity |
|
259 | - '%s',// VNU_url |
|
260 | - '%s',// VNU_virtual_phone |
|
261 | - '%s',// VNU_virtual_url |
|
262 | - '%s',// VNU_google_map_link |
|
263 | - '%d',// VNU_enable_for_gmap |
|
250 | + '%d', // VNU_ID_fk |
|
251 | + '%s', // VNU_address |
|
252 | + '%s', // VNU_address2 |
|
253 | + '%s', // VNU_city |
|
254 | + '%d', // STA_ID |
|
255 | + '%s', // CNT_ISO |
|
256 | + '%s', // VNU_zip |
|
257 | + '%s', // VNU_phone |
|
258 | + '%d', // VNU_capacity |
|
259 | + '%s', // VNU_url |
|
260 | + '%s', // VNU_virtual_phone |
|
261 | + '%s', // VNU_virtual_url |
|
262 | + '%s', // VNU_google_map_link |
|
263 | + '%d', // VNU_enable_for_gmap |
|
264 | 264 | ); |
265 | 265 | $success = $wpdb->insert($this->_new_meta_table, $insertion_array, $datatypes); |
266 | - if (! $success) { |
|
266 | + if ( ! $success) { |
|
267 | 267 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_meta_table, $insertion_array, $datatypes)); |
268 | 268 | return 0; |
269 | 269 | } |