@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | $stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*'); |
11 | 11 | $class_to_filepath = []; |
12 | 12 | foreach ($stages as $filepath) { |
13 | - $matches = []; |
|
14 | - preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
13 | + $matches = []; |
|
14 | + preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
15 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
16 | 16 | } |
17 | 17 | // give addons a chance to autoload their stages too |
18 | 18 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath); |
@@ -30,70 +30,70 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base |
32 | 32 | { |
33 | - /** |
|
34 | - * EE_DMS_Core_4_5_0 constructor. |
|
35 | - * |
|
36 | - * @param TableManager|null $table_manager |
|
37 | - * @param TableAnalysis|null $table_analysis |
|
38 | - */ |
|
39 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
40 | - { |
|
41 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.5.0", "event_espresso"); |
|
42 | - $this->_priority = 10; |
|
43 | - $this->_migration_stages = [ |
|
44 | - new EE_DMS_4_5_0_update_wp_user_for_tickets(), |
|
45 | - new EE_DMS_4_5_0_update_wp_user_for_prices(), |
|
46 | - new EE_DMS_4_5_0_update_wp_user_for_price_types(), |
|
47 | - new EE_DMS_4_5_0_update_wp_user_for_question_groups(), |
|
48 | - new EE_DMS_4_5_0_invoice_settings(), |
|
49 | - ]; |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - public function can_migrate_from_version($version_array) |
|
55 | - { |
|
56 | - $version_string = $version_array['Core']; |
|
57 | - if ( |
|
58 | - version_compare($version_string, '4.5.0.decaf', '<') && version_compare( |
|
59 | - $version_string, |
|
60 | - '4.3.0.decaf', |
|
61 | - '>=' |
|
62 | - ) |
|
63 | - ) { |
|
64 | - // echo "$version_string can be migrated from"; |
|
65 | - return true; |
|
66 | - } elseif (! $version_string) { |
|
67 | - // echo "no version string provided: $version_string"; |
|
68 | - // no version string provided... this must be pre 4.3 |
|
69 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | - } else { |
|
71 | - // echo "$version_string doesnt apply"; |
|
72 | - return false; |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @return true |
|
79 | - * @throws EE_Error |
|
80 | - * @throws ReflectionException |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - // relies on 4.1's EEH_Activation::create_table |
|
85 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
86 | - |
|
87 | - $table_name = 'esp_answer'; |
|
88 | - $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
33 | + /** |
|
34 | + * EE_DMS_Core_4_5_0 constructor. |
|
35 | + * |
|
36 | + * @param TableManager|null $table_manager |
|
37 | + * @param TableAnalysis|null $table_analysis |
|
38 | + */ |
|
39 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
40 | + { |
|
41 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.5.0", "event_espresso"); |
|
42 | + $this->_priority = 10; |
|
43 | + $this->_migration_stages = [ |
|
44 | + new EE_DMS_4_5_0_update_wp_user_for_tickets(), |
|
45 | + new EE_DMS_4_5_0_update_wp_user_for_prices(), |
|
46 | + new EE_DMS_4_5_0_update_wp_user_for_price_types(), |
|
47 | + new EE_DMS_4_5_0_update_wp_user_for_question_groups(), |
|
48 | + new EE_DMS_4_5_0_invoice_settings(), |
|
49 | + ]; |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + public function can_migrate_from_version($version_array) |
|
55 | + { |
|
56 | + $version_string = $version_array['Core']; |
|
57 | + if ( |
|
58 | + version_compare($version_string, '4.5.0.decaf', '<') && version_compare( |
|
59 | + $version_string, |
|
60 | + '4.3.0.decaf', |
|
61 | + '>=' |
|
62 | + ) |
|
63 | + ) { |
|
64 | + // echo "$version_string can be migrated from"; |
|
65 | + return true; |
|
66 | + } elseif (! $version_string) { |
|
67 | + // echo "no version string provided: $version_string"; |
|
68 | + // no version string provided... this must be pre 4.3 |
|
69 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + } else { |
|
71 | + // echo "$version_string doesnt apply"; |
|
72 | + return false; |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @return true |
|
79 | + * @throws EE_Error |
|
80 | + * @throws ReflectionException |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + // relies on 4.1's EEH_Activation::create_table |
|
85 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
86 | + |
|
87 | + $table_name = 'esp_answer'; |
|
88 | + $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
89 | 89 | REG_ID int(10) unsigned NOT NULL, |
90 | 90 | QST_ID int(10) unsigned NOT NULL, |
91 | 91 | ANS_value text NOT NULL, |
92 | 92 | PRIMARY KEY (ANS_ID)"; |
93 | - $this->_table_should_exist_previously($table_name, $sql); |
|
93 | + $this->_table_should_exist_previously($table_name, $sql); |
|
94 | 94 | |
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
97 | 97 | ATT_ID bigint(20) unsigned NOT NULL, |
98 | 98 | ATT_fname varchar(45) NOT NULL, |
99 | 99 | ATT_lname varchar(45) NOT NULL, |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | KEY ATT_fname (ATT_fname), |
110 | 110 | KEY ATT_lname (ATT_lname), |
111 | 111 | KEY ATT_email (ATT_email(191))"; |
112 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
112 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
113 | 113 | |
114 | - $table_name = 'esp_country'; |
|
115 | - $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
114 | + $table_name = 'esp_country'; |
|
115 | + $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
|
116 | 116 | CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL, |
117 | 117 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
118 | 118 | CNT_name varchar(45) COLLATE utf8_bin NOT NULL, |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | CNT_is_EU tinyint(1) DEFAULT '0', |
129 | 129 | CNT_active tinyint(1) DEFAULT '0', |
130 | 130 | PRIMARY KEY (CNT_ISO)"; |
131 | - $this->_table_should_exist_previously($table_name, $sql); |
|
131 | + $this->_table_should_exist_previously($table_name, $sql); |
|
132 | 132 | |
133 | - $table_name = 'esp_datetime'; |
|
134 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
133 | + $table_name = 'esp_datetime'; |
|
134 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
135 | 135 | EVT_ID bigint(20) unsigned NOT NULL, |
136 | 136 | DTT_name varchar(255) NOT NULL DEFAULT '', |
137 | 137 | DTT_description text NOT NULL, |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | PRIMARY KEY (DTT_ID), |
147 | 147 | KEY EVT_ID (EVT_ID), |
148 | 148 | KEY DTT_is_primary (DTT_is_primary)"; |
149 | - $this->_table_should_exist_previously($table_name, $sql); |
|
149 | + $this->_table_should_exist_previously($table_name, $sql); |
|
150 | 150 | |
151 | - $table_name = 'esp_event_meta'; |
|
152 | - $sql = " |
|
151 | + $table_name = 'esp_event_meta'; |
|
152 | + $sql = " |
|
153 | 153 | EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
154 | 154 | EVT_ID bigint(20) unsigned NOT NULL, |
155 | 155 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -164,35 +164,35 @@ discard block |
||
164 | 164 | EVT_external_URL varchar(200) NULL, |
165 | 165 | EVT_donations tinyint(1) NULL, |
166 | 166 | PRIMARY KEY (EVTM_ID)"; |
167 | - $this->_table_should_exist_previously($table_name, $sql); |
|
167 | + $this->_table_should_exist_previously($table_name, $sql); |
|
168 | 168 | |
169 | - $table_name = 'esp_event_question_group'; |
|
170 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
169 | + $table_name = 'esp_event_question_group'; |
|
170 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
171 | 171 | EVT_ID bigint(20) unsigned NOT NULL, |
172 | 172 | QSG_ID int(10) unsigned NOT NULL, |
173 | 173 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
174 | 174 | PRIMARY KEY (EQG_ID)"; |
175 | - $this->_table_should_exist_previously($table_name, $sql); |
|
175 | + $this->_table_should_exist_previously($table_name, $sql); |
|
176 | 176 | |
177 | - $table_name = 'esp_event_venue'; |
|
178 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
177 | + $table_name = 'esp_event_venue'; |
|
178 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
179 | 179 | EVT_ID bigint(20) unsigned NOT NULL, |
180 | 180 | VNU_ID bigint(20) unsigned NOT NULL, |
181 | 181 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
182 | 182 | PRIMARY KEY (EVV_ID)"; |
183 | - $this->_table_should_exist_previously($table_name, $sql); |
|
183 | + $this->_table_should_exist_previously($table_name, $sql); |
|
184 | 184 | |
185 | - $table_name = 'esp_extra_meta'; |
|
186 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
185 | + $table_name = 'esp_extra_meta'; |
|
186 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
187 | 187 | OBJ_ID int(11) DEFAULT NULL, |
188 | 188 | EXM_type varchar(45) DEFAULT NULL, |
189 | 189 | EXM_key varchar(45) DEFAULT NULL, |
190 | 190 | EXM_value text, |
191 | 191 | PRIMARY KEY (EXM_ID)"; |
192 | - $this->_table_should_exist_previously($table_name, $sql); |
|
192 | + $this->_table_should_exist_previously($table_name, $sql); |
|
193 | 193 | |
194 | - $table_name = 'esp_line_item'; |
|
195 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
194 | + $table_name = 'esp_line_item'; |
|
195 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
196 | 196 | LIN_code varchar(245) NOT NULL DEFAULT '', |
197 | 197 | TXN_ID int(11) DEFAULT NULL, |
198 | 198 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -208,21 +208,21 @@ discard block |
||
208 | 208 | OBJ_ID int(11) DEFAULT NULL, |
209 | 209 | OBJ_type varchar(45)DEFAULT NULL, |
210 | 210 | PRIMARY KEY (LIN_ID)"; |
211 | - $this->_table_should_exist_previously($table_name, $sql); |
|
211 | + $this->_table_should_exist_previously($table_name, $sql); |
|
212 | 212 | |
213 | - $table_name = 'esp_message_template'; |
|
214 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
213 | + $table_name = 'esp_message_template'; |
|
214 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
215 | 215 | GRP_ID int(10) unsigned NOT NULL, |
216 | 216 | MTP_context varchar(50) NOT NULL, |
217 | 217 | MTP_template_field varchar(30) NOT NULL, |
218 | 218 | MTP_content text NOT NULL, |
219 | 219 | PRIMARY KEY (MTP_ID), |
220 | 220 | KEY GRP_ID (GRP_ID)"; |
221 | - $this->_table_should_exist_previously($table_name, $sql); |
|
222 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
221 | + $this->_table_should_exist_previously($table_name, $sql); |
|
222 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
223 | 223 | |
224 | - $table_name = 'esp_message_template_group'; |
|
225 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
224 | + $table_name = 'esp_message_template_group'; |
|
225 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
226 | 226 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
227 | 227 | MTP_name varchar(245) NOT NULL DEFAULT '', |
228 | 228 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -234,19 +234,19 @@ discard block |
||
234 | 234 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
235 | 235 | PRIMARY KEY (GRP_ID), |
236 | 236 | KEY MTP_user_id (MTP_user_id)"; |
237 | - $this->_table_should_exist_previously($table_name, $sql); |
|
237 | + $this->_table_should_exist_previously($table_name, $sql); |
|
238 | 238 | |
239 | - $table_name = 'esp_event_message_template'; |
|
240 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
239 | + $table_name = 'esp_event_message_template'; |
|
240 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
241 | 241 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
242 | 242 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
243 | 243 | PRIMARY KEY (EMT_ID), |
244 | 244 | KEY EVT_ID (EVT_ID), |
245 | 245 | KEY GRP_ID (GRP_ID)"; |
246 | - $this->_table_should_exist_previously($table_name, $sql); |
|
246 | + $this->_table_should_exist_previously($table_name, $sql); |
|
247 | 247 | |
248 | - $table_name = 'esp_payment'; |
|
249 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
248 | + $table_name = 'esp_payment'; |
|
249 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
250 | 250 | TXN_ID int(10) unsigned DEFAULT NULL, |
251 | 251 | STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL, |
252 | 252 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -262,32 +262,32 @@ discard block |
||
262 | 262 | PRIMARY KEY (PAY_ID), |
263 | 263 | KEY TXN_ID (TXN_ID), |
264 | 264 | KEY PAY_timestamp (PAY_timestamp)"; |
265 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
265 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | 266 | |
267 | - $table_name = "esp_ticket_price"; |
|
268 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
267 | + $table_name = "esp_ticket_price"; |
|
268 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
269 | 269 | TKT_ID int(10) unsigned NOT NULL, |
270 | 270 | PRC_ID int(10) unsigned NOT NULL, |
271 | 271 | PRIMARY KEY (TKP_ID)"; |
272 | - $this->_table_should_exist_previously($table_name, $sql); |
|
272 | + $this->_table_should_exist_previously($table_name, $sql); |
|
273 | 273 | |
274 | - $table_name = "esp_datetime_ticket"; |
|
275 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
274 | + $table_name = "esp_datetime_ticket"; |
|
275 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
276 | 276 | DTT_ID int(10) unsigned NOT NULL, |
277 | 277 | TKT_ID int(10) unsigned NOT NULL, |
278 | 278 | PRIMARY KEY (DTK_ID)"; |
279 | - $this->_table_should_exist_previously($table_name, $sql); |
|
279 | + $this->_table_should_exist_previously($table_name, $sql); |
|
280 | 280 | |
281 | - $table_name = "esp_ticket_template"; |
|
282 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
281 | + $table_name = "esp_ticket_template"; |
|
282 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
283 | 283 | TTM_name varchar(45) NOT NULL, |
284 | 284 | TTM_description text, |
285 | 285 | TTM_file varchar(45), |
286 | 286 | PRIMARY KEY (TTM_ID)"; |
287 | - $this->_table_should_exist_previously($table_name, $sql); |
|
287 | + $this->_table_should_exist_previously($table_name, $sql); |
|
288 | 288 | |
289 | - $table_name = 'esp_question'; |
|
290 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
289 | + $table_name = 'esp_question'; |
|
290 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
291 | 291 | QST_display_text text NOT NULL, |
292 | 292 | QST_admin_label varchar(255) NOT NULL, |
293 | 293 | QST_system varchar(25) DEFAULT NULL, |
@@ -299,28 +299,28 @@ discard block |
||
299 | 299 | QST_wp_user bigint(20) unsigned NULL, |
300 | 300 | QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
301 | 301 | PRIMARY KEY (QST_ID)'; |
302 | - $this->_table_should_exist_previously($table_name, $sql); |
|
302 | + $this->_table_should_exist_previously($table_name, $sql); |
|
303 | 303 | |
304 | - $table_name = 'esp_question_group_question'; |
|
305 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
304 | + $table_name = 'esp_question_group_question'; |
|
305 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
306 | 306 | QSG_ID int(10) unsigned NOT NULL, |
307 | 307 | QST_ID int(10) unsigned NOT NULL, |
308 | 308 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
309 | 309 | PRIMARY KEY (QGQ_ID) "; |
310 | - $this->_table_should_exist_previously($table_name, $sql); |
|
310 | + $this->_table_should_exist_previously($table_name, $sql); |
|
311 | 311 | |
312 | - $table_name = 'esp_question_option'; |
|
313 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
312 | + $table_name = 'esp_question_option'; |
|
313 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
314 | 314 | QSO_value varchar(255) NOT NULL, |
315 | 315 | QSO_desc text NOT NULL, |
316 | 316 | QST_ID int(10) unsigned NOT NULL, |
317 | 317 | QSO_order int(10) unsigned NOT NULL DEFAULT 0, |
318 | 318 | QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0, |
319 | 319 | PRIMARY KEY (QSO_ID)"; |
320 | - $this->_table_should_exist_previously($table_name, $sql); |
|
320 | + $this->_table_should_exist_previously($table_name, $sql); |
|
321 | 321 | |
322 | - $table_name = 'esp_registration'; |
|
323 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
322 | + $table_name = 'esp_registration'; |
|
323 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
324 | 324 | EVT_ID bigint(20) unsigned NOT NULL, |
325 | 325 | ATT_ID bigint(20) unsigned NOT NULL, |
326 | 326 | TXN_ID int(10) unsigned NOT NULL, |
@@ -343,28 +343,28 @@ discard block |
||
343 | 343 | KEY STS_ID (STS_ID), |
344 | 344 | KEY REG_url_link (REG_url_link), |
345 | 345 | KEY REG_code (REG_code)"; |
346 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
346 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
347 | 347 | |
348 | - $table_name = 'esp_checkin'; |
|
349 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
348 | + $table_name = 'esp_checkin'; |
|
349 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
350 | 350 | REG_ID int(10) unsigned NOT NULL, |
351 | 351 | DTT_ID int(10) unsigned NOT NULL, |
352 | 352 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
353 | 353 | CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
354 | 354 | PRIMARY KEY (CHK_ID)"; |
355 | - $this->_table_should_exist_previously($table_name, $sql); |
|
355 | + $this->_table_should_exist_previously($table_name, $sql); |
|
356 | 356 | |
357 | - $table_name = 'esp_state'; |
|
358 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
357 | + $table_name = 'esp_state'; |
|
358 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
359 | 359 | CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL, |
360 | 360 | STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL, |
361 | 361 | STA_name varchar(100) COLLATE utf8_bin NOT NULL, |
362 | 362 | STA_active tinyint(1) DEFAULT '1', |
363 | 363 | PRIMARY KEY (STA_ID)"; |
364 | - $this->_table_should_exist_previously($table_name, $sql); |
|
364 | + $this->_table_should_exist_previously($table_name, $sql); |
|
365 | 365 | |
366 | - $table_name = 'esp_status'; |
|
367 | - $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
366 | + $table_name = 'esp_status'; |
|
367 | + $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL, |
|
368 | 368 | STS_code varchar(45) COLLATE utf8_bin NOT NULL, |
369 | 369 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
370 | 370 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
373 | 373 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
374 | 374 | KEY STS_type (STS_type)"; |
375 | - $this->_table_should_exist_previously($table_name, $sql); |
|
375 | + $this->_table_should_exist_previously($table_name, $sql); |
|
376 | 376 | |
377 | - $table_name = 'esp_transaction'; |
|
378 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
377 | + $table_name = 'esp_transaction'; |
|
378 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
379 | 379 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
380 | 380 | TXN_total decimal(10,3) DEFAULT '0.00', |
381 | 381 | TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00', |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | PRIMARY KEY (TXN_ID), |
387 | 387 | KEY TXN_timestamp (TXN_timestamp), |
388 | 388 | KEY STS_ID (STS_ID)"; |
389 | - $this->_table_should_exist_previously($table_name, $sql); |
|
389 | + $this->_table_should_exist_previously($table_name, $sql); |
|
390 | 390 | |
391 | - $table_name = 'esp_venue_meta'; |
|
392 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
391 | + $table_name = 'esp_venue_meta'; |
|
392 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
393 | 393 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
394 | 394 | VNU_address varchar(255) DEFAULT NULL, |
395 | 395 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | PRIMARY KEY (VNUM_ID), |
408 | 408 | KEY STA_ID (STA_ID), |
409 | 409 | KEY CNT_ISO (CNT_ISO)"; |
410 | - $this->_table_should_exist_previously($table_name, $sql); |
|
411 | - // modified tables |
|
412 | - $table_name = "esp_price"; |
|
413 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
410 | + $this->_table_should_exist_previously($table_name, $sql); |
|
411 | + // modified tables |
|
412 | + $table_name = "esp_price"; |
|
413 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | 414 | PRT_ID tinyint(3) unsigned NOT NULL, |
415 | 415 | PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00', |
416 | 416 | PRC_name varchar(245) NOT NULL, |
@@ -422,10 +422,10 @@ discard block |
||
422 | 422 | PRC_wp_user bigint(20) unsigned NULL, |
423 | 423 | PRC_parent int(10) unsigned DEFAULT 0, |
424 | 424 | PRIMARY KEY (PRC_ID)"; |
425 | - $this->_table_should_exist_previously($table_name, $sql); |
|
425 | + $this->_table_should_exist_previously($table_name, $sql); |
|
426 | 426 | |
427 | - $table_name = "esp_price_type"; |
|
428 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
427 | + $table_name = "esp_price_type"; |
|
428 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
429 | 429 | PRT_name varchar(45) NOT NULL, |
430 | 430 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
431 | 431 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -434,10 +434,10 @@ discard block |
||
434 | 434 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
435 | 435 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
436 | 436 | PRIMARY KEY (PRT_ID)"; |
437 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
437 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
438 | 438 | |
439 | - $table_name = "esp_ticket"; |
|
440 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
439 | + $table_name = "esp_ticket"; |
|
440 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
441 | 441 | TTM_ID int(10) unsigned NOT NULL, |
442 | 442 | TKT_name varchar(245) NOT NULL DEFAULT '', |
443 | 443 | TKT_description text NOT NULL, |
@@ -458,11 +458,11 @@ discard block |
||
458 | 458 | TKT_parent int(10) unsigned DEFAULT '0', |
459 | 459 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
460 | 460 | PRIMARY KEY (TKT_ID)"; |
461 | - $this->_table_should_exist_previously($table_name, $sql); |
|
462 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
461 | + $this->_table_should_exist_previously($table_name, $sql); |
|
462 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
463 | 463 | |
464 | - $table_name = 'esp_question_group'; |
|
465 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
464 | + $table_name = 'esp_question_group'; |
|
465 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
466 | 466 | QSG_name varchar(255) NOT NULL, |
467 | 467 | QSG_identifier varchar(100) NOT NULL, |
468 | 468 | QSG_desc text NULL, |
@@ -474,137 +474,137 @@ discard block |
||
474 | 474 | QSG_wp_user bigint(20) unsigned NULL, |
475 | 475 | PRIMARY KEY (QSG_ID), |
476 | 476 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
477 | - $this->_table_should_exist_previously($table_name, $sql); |
|
478 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
479 | - // (because many need to convert old string states to foreign keys into the states table) |
|
480 | - $script_4_1_defaults->insert_default_states(); |
|
481 | - $script_4_1_defaults->insert_default_countries(); |
|
482 | - // schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later. |
|
483 | - $this->insert_default_price_types(); |
|
484 | - $this->insert_default_prices(); |
|
485 | - $this->insert_default_tickets(); |
|
486 | - // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
487 | - EE_Config::instance()->update_espresso_config(); |
|
488 | - return true; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * @return boolean |
|
494 | - */ |
|
495 | - public function schema_changes_after_migration() |
|
496 | - { |
|
497 | - return true; |
|
498 | - } |
|
499 | - |
|
500 | - |
|
501 | - public function migration_page_hooks() |
|
502 | - { |
|
503 | - } |
|
504 | - |
|
505 | - |
|
506 | - /** |
|
507 | - * insert_default_price_types |
|
508 | - * |
|
509 | - * @return void |
|
510 | - * @throws EE_Error |
|
511 | - * @throws ReflectionException |
|
512 | - * @since 4.5.0 |
|
513 | - */ |
|
514 | - public function insert_default_price_types() |
|
515 | - { |
|
516 | - global $wpdb; |
|
517 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
518 | - if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
519 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
520 | - $price_types_exist = $wpdb->get_var($SQL); |
|
521 | - if (! $price_types_exist) { |
|
522 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
523 | - $user_id = $user_id ?: 0; |
|
524 | - $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
|
477 | + $this->_table_should_exist_previously($table_name, $sql); |
|
478 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
479 | + // (because many need to convert old string states to foreign keys into the states table) |
|
480 | + $script_4_1_defaults->insert_default_states(); |
|
481 | + $script_4_1_defaults->insert_default_countries(); |
|
482 | + // schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later. |
|
483 | + $this->insert_default_price_types(); |
|
484 | + $this->insert_default_prices(); |
|
485 | + $this->insert_default_tickets(); |
|
486 | + // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
487 | + EE_Config::instance()->update_espresso_config(); |
|
488 | + return true; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * @return boolean |
|
494 | + */ |
|
495 | + public function schema_changes_after_migration() |
|
496 | + { |
|
497 | + return true; |
|
498 | + } |
|
499 | + |
|
500 | + |
|
501 | + public function migration_page_hooks() |
|
502 | + { |
|
503 | + } |
|
504 | + |
|
505 | + |
|
506 | + /** |
|
507 | + * insert_default_price_types |
|
508 | + * |
|
509 | + * @return void |
|
510 | + * @throws EE_Error |
|
511 | + * @throws ReflectionException |
|
512 | + * @since 4.5.0 |
|
513 | + */ |
|
514 | + public function insert_default_price_types() |
|
515 | + { |
|
516 | + global $wpdb; |
|
517 | + $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
518 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
519 | + $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table; |
|
520 | + $price_types_exist = $wpdb->get_var($SQL); |
|
521 | + if (! $price_types_exist) { |
|
522 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
523 | + $user_id = $user_id ?: 0; |
|
524 | + $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES |
|
525 | 525 | (1, '" . esc_html__('Base Price', 'event_espresso') . "', 1, 0, 0, $user_id, 0), |
526 | 526 | (2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2, 1, 20, $user_id, 0), |
527 | 527 | (3, '" . esc_html__('Dollar Discount', 'event_espresso') . "', 2, 0, 30, $user_id, 0), |
528 | 528 | (4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3, 1, 40, $user_id, 0), |
529 | 529 | (5, '" . esc_html__('Dollar Surcharge', 'event_espresso') . "', 3, 0, 50, $user_id, 0);"; |
530 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
531 | - $wpdb->query($SQL); |
|
532 | - } |
|
533 | - } |
|
534 | - } |
|
535 | - |
|
536 | - |
|
537 | - /** |
|
538 | - * insert DEFAULT prices. |
|
539 | - * If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices |
|
540 | - * when EEH_Activation's initialize_db_content is called via a hook in |
|
541 | - * EE_Brewing_regular |
|
542 | - * |
|
543 | - * @return void |
|
544 | - * @throws EE_Error |
|
545 | - * @throws ReflectionException |
|
546 | - * @since 4.5.0 |
|
547 | - */ |
|
548 | - public function insert_default_prices() |
|
549 | - { |
|
550 | - global $wpdb; |
|
551 | - $price_table = $wpdb->prefix . "esp_price"; |
|
552 | - if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
553 | - $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
554 | - $prices_exist = $wpdb->get_var($SQL); |
|
555 | - if (! $prices_exist) { |
|
556 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
557 | - $user_id = $user_id ?: 0; |
|
558 | - $SQL = "INSERT INTO $price_table |
|
530 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL); |
|
531 | + $wpdb->query($SQL); |
|
532 | + } |
|
533 | + } |
|
534 | + } |
|
535 | + |
|
536 | + |
|
537 | + /** |
|
538 | + * insert DEFAULT prices. |
|
539 | + * If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices |
|
540 | + * when EEH_Activation's initialize_db_content is called via a hook in |
|
541 | + * EE_Brewing_regular |
|
542 | + * |
|
543 | + * @return void |
|
544 | + * @throws EE_Error |
|
545 | + * @throws ReflectionException |
|
546 | + * @since 4.5.0 |
|
547 | + */ |
|
548 | + public function insert_default_prices() |
|
549 | + { |
|
550 | + global $wpdb; |
|
551 | + $price_table = $wpdb->prefix . "esp_price"; |
|
552 | + if ($this->_get_table_analysis()->tableExists($price_table)) { |
|
553 | + $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table; |
|
554 | + $prices_exist = $wpdb->get_var($SQL); |
|
555 | + if (! $prices_exist) { |
|
556 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
557 | + $user_id = $user_id ?: 0; |
|
558 | + $SQL = "INSERT INTO $price_table |
|
559 | 559 | (PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc, PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES |
560 | 560 | (1, 1, '0.00', 'Admission', '', 1, NULL, $user_id, 0, 0, 0);"; |
561 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
562 | - $wpdb->query($SQL); |
|
563 | - } |
|
564 | - } |
|
565 | - } |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * insert DEFAULT ticket |
|
570 | - * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field |
|
571 | - * |
|
572 | - * @return void |
|
573 | - * @throws EE_Error |
|
574 | - * @throws ReflectionException |
|
575 | - * @since 4.5.0 |
|
576 | - */ |
|
577 | - public function insert_default_tickets() |
|
578 | - { |
|
579 | - global $wpdb; |
|
580 | - $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
581 | - if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
582 | - $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
583 | - $tickets_exist = $wpdb->get_var($SQL); |
|
584 | - if (! $tickets_exist) { |
|
585 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
586 | - $user_id = $user_id ?: 0; |
|
587 | - $SQL = "INSERT INTO $ticket_table |
|
561 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL); |
|
562 | + $wpdb->query($SQL); |
|
563 | + } |
|
564 | + } |
|
565 | + } |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * insert DEFAULT ticket |
|
570 | + * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field |
|
571 | + * |
|
572 | + * @return void |
|
573 | + * @throws EE_Error |
|
574 | + * @throws ReflectionException |
|
575 | + * @since 4.5.0 |
|
576 | + */ |
|
577 | + public function insert_default_tickets() |
|
578 | + { |
|
579 | + global $wpdb; |
|
580 | + $ticket_table = $wpdb->prefix . "esp_ticket"; |
|
581 | + if ($this->_get_table_analysis()->tableExists($ticket_table)) { |
|
582 | + $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table; |
|
583 | + $tickets_exist = $wpdb->get_var($SQL); |
|
584 | + if (! $tickets_exist) { |
|
585 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
586 | + $user_id = $user_id ?: 0; |
|
587 | + $SQL = "INSERT INTO $ticket_table |
|
588 | 588 | ( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES |
589 | 589 | ( 1, 0, '" . |
590 | - esc_html__("Free Ticket", "event_espresso") . |
|
591 | - "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
592 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
593 | - $wpdb->query($SQL); |
|
594 | - } |
|
595 | - } |
|
596 | - $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
597 | - if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
598 | - $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
599 | - $ticket_prc_exist = $wpdb->get_var($SQL); |
|
600 | - if (! $ticket_prc_exist) { |
|
601 | - $SQL = "INSERT INTO $ticket_price_table |
|
590 | + esc_html__("Free Ticket", "event_espresso") . |
|
591 | + "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);"; |
|
592 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL); |
|
593 | + $wpdb->query($SQL); |
|
594 | + } |
|
595 | + } |
|
596 | + $ticket_price_table = $wpdb->prefix . "esp_ticket_price"; |
|
597 | + if ($this->_get_table_analysis()->tableExists($ticket_price_table)) { |
|
598 | + $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table; |
|
599 | + $ticket_prc_exist = $wpdb->get_var($SQL); |
|
600 | + if (! $ticket_prc_exist) { |
|
601 | + $SQL = "INSERT INTO $ticket_price_table |
|
602 | 602 | ( TKP_ID, TKT_ID, PRC_ID ) VALUES |
603 | 603 | ( 1, 1, 1 ) |
604 | 604 | "; |
605 | - $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
606 | - $wpdb->query($SQL); |
|
607 | - } |
|
608 | - } |
|
609 | - } |
|
605 | + $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL); |
|
606 | + $wpdb->query($SQL); |
|
607 | + } |
|
608 | + } |
|
609 | + } |
|
610 | 610 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = []; |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = []; |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[ $matches[1] ] = $filepath; |
|
15 | + $matches = []; |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[ $matches[1] ] = $filepath; |
|
18 | 18 | } |
19 | 19 | // give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -32,73 +32,73 @@ discard block |
||
32 | 32 | */ |
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | - /** |
|
36 | - * return EE_DMS_Core_4_9_0 |
|
37 | - * |
|
38 | - * @param TableManager|null $table_manager |
|
39 | - * @param TableAnalysis|null $table_analysis |
|
40 | - */ |
|
41 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
42 | - { |
|
43 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
44 | - $this->_priority = 10; |
|
45 | - $this->_migration_stages = [ |
|
46 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
47 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
48 | - ]; |
|
49 | - parent::__construct($table_manager, $table_analysis); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Whether to migrate or not. |
|
55 | - * |
|
56 | - * @param array $version_array |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - public function can_migrate_from_version($version_array) |
|
60 | - { |
|
61 | - $version_string = $version_array['Core']; |
|
62 | - if ( |
|
63 | - version_compare($version_string, '4.9.0.decaf', '<') && |
|
64 | - version_compare($version_string, '4.8.0.decaf', '>=') |
|
65 | - ) { |
|
66 | - // echo "$version_string can be migrated from"; |
|
67 | - return true; |
|
68 | - } elseif (! $version_string) { |
|
69 | - // echo "no version string provided: $version_string"; |
|
70 | - // no version string provided... this must be pre 4.3 |
|
71 | - return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
72 | - } else { |
|
73 | - // echo "$version_string doesnt apply"; |
|
74 | - return false; |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return bool |
|
81 | - * @throws EE_Error |
|
82 | - * @throws ReflectionException |
|
83 | - */ |
|
84 | - public function schema_changes_before_migration() |
|
85 | - { |
|
86 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
87 | - $now_in_mysql = current_time('mysql', true); |
|
88 | - |
|
89 | - $table_name = 'esp_answer'; |
|
90 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
35 | + /** |
|
36 | + * return EE_DMS_Core_4_9_0 |
|
37 | + * |
|
38 | + * @param TableManager|null $table_manager |
|
39 | + * @param TableAnalysis|null $table_analysis |
|
40 | + */ |
|
41 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
42 | + { |
|
43 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
44 | + $this->_priority = 10; |
|
45 | + $this->_migration_stages = [ |
|
46 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
47 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
48 | + ]; |
|
49 | + parent::__construct($table_manager, $table_analysis); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Whether to migrate or not. |
|
55 | + * |
|
56 | + * @param array $version_array |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + public function can_migrate_from_version($version_array) |
|
60 | + { |
|
61 | + $version_string = $version_array['Core']; |
|
62 | + if ( |
|
63 | + version_compare($version_string, '4.9.0.decaf', '<') && |
|
64 | + version_compare($version_string, '4.8.0.decaf', '>=') |
|
65 | + ) { |
|
66 | + // echo "$version_string can be migrated from"; |
|
67 | + return true; |
|
68 | + } elseif (! $version_string) { |
|
69 | + // echo "no version string provided: $version_string"; |
|
70 | + // no version string provided... this must be pre 4.3 |
|
71 | + return false;// changed mind. dont want people thinking they should migrate yet because they cant |
|
72 | + } else { |
|
73 | + // echo "$version_string doesnt apply"; |
|
74 | + return false; |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + * @throws EE_Error |
|
82 | + * @throws ReflectionException |
|
83 | + */ |
|
84 | + public function schema_changes_before_migration() |
|
85 | + { |
|
86 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
87 | + $now_in_mysql = current_time('mysql', true); |
|
88 | + |
|
89 | + $table_name = 'esp_answer'; |
|
90 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
91 | 91 | REG_ID int(10) unsigned NOT NULL, |
92 | 92 | QST_ID int(10) unsigned NOT NULL, |
93 | 93 | ANS_value text NOT NULL, |
94 | 94 | PRIMARY KEY (ANS_ID), |
95 | 95 | KEY REG_ID (REG_ID), |
96 | 96 | KEY QST_ID (QST_ID)"; |
97 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
97 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
98 | 98 | |
99 | - $table_name = 'esp_attendee_meta'; |
|
100 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
101 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
99 | + $table_name = 'esp_attendee_meta'; |
|
100 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
101 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
102 | 102 | ATT_ID bigint(20) unsigned NOT NULL, |
103 | 103 | ATT_fname varchar(45) NOT NULL, |
104 | 104 | ATT_lname varchar(45) NOT NULL, |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | KEY ATT_email (ATT_email(191)), |
116 | 116 | KEY ATT_lname (ATT_lname), |
117 | 117 | KEY ATT_fname (ATT_fname)"; |
118 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
118 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
119 | 119 | |
120 | - $table_name = 'esp_checkin'; |
|
121 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
120 | + $table_name = 'esp_checkin'; |
|
121 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
122 | 122 | REG_ID int(10) unsigned NOT NULL, |
123 | 123 | DTT_ID int(10) unsigned NOT NULL, |
124 | 124 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | PRIMARY KEY (CHK_ID), |
127 | 127 | KEY REG_ID (REG_ID), |
128 | 128 | KEY DTT_ID (DTT_ID)"; |
129 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
129 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
130 | 130 | |
131 | - $table_name = 'esp_country'; |
|
132 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
131 | + $table_name = 'esp_country'; |
|
132 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
133 | 133 | CNT_ISO3 varchar(3) NOT NULL, |
134 | 134 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
135 | 135 | CNT_name varchar(45) NOT NULL, |
@@ -145,20 +145,20 @@ discard block |
||
145 | 145 | CNT_is_EU tinyint(1) DEFAULT '0', |
146 | 146 | CNT_active tinyint(1) DEFAULT '0', |
147 | 147 | PRIMARY KEY (CNT_ISO)"; |
148 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
148 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
149 | 149 | |
150 | - $table_name = 'esp_currency'; |
|
151 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
150 | + $table_name = 'esp_currency'; |
|
151 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
152 | 152 | CUR_single varchar(45) DEFAULT 'dollar', |
153 | 153 | CUR_plural varchar(45) DEFAULT 'dollars', |
154 | 154 | CUR_sign varchar(45) DEFAULT '$', |
155 | 155 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
156 | 156 | CUR_active tinyint(1) DEFAULT '0', |
157 | 157 | PRIMARY KEY (CUR_code)"; |
158 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
158 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
159 | 159 | |
160 | - $table_name = 'esp_datetime'; |
|
161 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
160 | + $table_name = 'esp_datetime'; |
|
161 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
162 | 162 | EVT_ID bigint(20) unsigned NOT NULL, |
163 | 163 | DTT_name varchar(255) NOT NULL DEFAULT '', |
164 | 164 | DTT_description text NOT NULL, |
@@ -175,28 +175,28 @@ discard block |
||
175 | 175 | KEY DTT_EVT_start (DTT_EVT_start), |
176 | 176 | KEY EVT_ID (EVT_ID), |
177 | 177 | KEY DTT_is_primary (DTT_is_primary)"; |
178 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
178 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
179 | 179 | |
180 | - $table_name = "esp_datetime_ticket"; |
|
181 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
180 | + $table_name = "esp_datetime_ticket"; |
|
181 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
182 | 182 | DTT_ID int(10) unsigned NOT NULL, |
183 | 183 | TKT_ID int(10) unsigned NOT NULL, |
184 | 184 | PRIMARY KEY (DTK_ID), |
185 | 185 | KEY DTT_ID (DTT_ID), |
186 | 186 | KEY TKT_ID (TKT_ID)"; |
187 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
187 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
188 | 188 | |
189 | - $table_name = 'esp_event_message_template'; |
|
190 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
189 | + $table_name = 'esp_event_message_template'; |
|
190 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
191 | 191 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
192 | 192 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
193 | 193 | PRIMARY KEY (EMT_ID), |
194 | 194 | KEY EVT_ID (EVT_ID), |
195 | 195 | KEY GRP_ID (GRP_ID)"; |
196 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
196 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
197 | 197 | |
198 | - $table_name = 'esp_event_meta'; |
|
199 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
198 | + $table_name = 'esp_event_meta'; |
|
199 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | EVT_ID bigint(20) unsigned NOT NULL, |
201 | 201 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
202 | 202 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -211,38 +211,38 @@ discard block |
||
211 | 211 | EVT_donations tinyint(1) NULL, |
212 | 212 | PRIMARY KEY (EVTM_ID), |
213 | 213 | KEY EVT_ID (EVT_ID)"; |
214 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
214 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
215 | 215 | |
216 | - $table_name = 'esp_event_question_group'; |
|
217 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
216 | + $table_name = 'esp_event_question_group'; |
|
217 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
218 | 218 | EVT_ID bigint(20) unsigned NOT NULL, |
219 | 219 | QSG_ID int(10) unsigned NOT NULL, |
220 | 220 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
221 | 221 | PRIMARY KEY (EQG_ID), |
222 | 222 | KEY EVT_ID (EVT_ID), |
223 | 223 | KEY QSG_ID (QSG_ID)"; |
224 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
224 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
225 | 225 | |
226 | - $table_name = 'esp_event_venue'; |
|
227 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
226 | + $table_name = 'esp_event_venue'; |
|
227 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
228 | 228 | EVT_ID bigint(20) unsigned NOT NULL, |
229 | 229 | VNU_ID bigint(20) unsigned NOT NULL, |
230 | 230 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
231 | 231 | PRIMARY KEY (EVV_ID)"; |
232 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
232 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
233 | 233 | |
234 | - $table_name = 'esp_extra_meta'; |
|
235 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
234 | + $table_name = 'esp_extra_meta'; |
|
235 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
236 | 236 | OBJ_ID int(11) DEFAULT NULL, |
237 | 237 | EXM_type varchar(45) DEFAULT NULL, |
238 | 238 | EXM_key varchar(45) DEFAULT NULL, |
239 | 239 | EXM_value text, |
240 | 240 | PRIMARY KEY (EXM_ID), |
241 | 241 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
242 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
242 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
243 | 243 | |
244 | - $table_name = 'esp_extra_join'; |
|
245 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
244 | + $table_name = 'esp_extra_join'; |
|
245 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
246 | 246 | EXJ_first_model_id varchar(6) NOT NULL, |
247 | 247 | EXJ_first_model_name varchar(20) NOT NULL, |
248 | 248 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | PRIMARY KEY (EXJ_ID), |
251 | 251 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
252 | 252 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
253 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
253 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
254 | 254 | |
255 | - $table_name = 'esp_line_item'; |
|
256 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
255 | + $table_name = 'esp_line_item'; |
|
256 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
257 | 257 | LIN_code varchar(245) NOT NULL DEFAULT '', |
258 | 258 | TXN_ID int(11) DEFAULT NULL, |
259 | 259 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp), |
275 | 275 | KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type), |
276 | 276 | KEY obj_id_obj_type (OBJ_ID,OBJ_type)"; |
277 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
278 | - $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
279 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
277 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID'); |
|
278 | + $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code'); |
|
279 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
280 | 280 | |
281 | - $table_name = 'esp_log'; |
|
282 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
281 | + $table_name = 'esp_log'; |
|
282 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
283 | 283 | LOG_time datetime DEFAULT NULL, |
284 | 284 | OBJ_ID varchar(45) DEFAULT NULL, |
285 | 285 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | KEY LOG_time (LOG_time), |
291 | 291 | KEY OBJ (OBJ_type,OBJ_ID), |
292 | 292 | KEY LOG_type (LOG_type)"; |
293 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
293 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
294 | 294 | |
295 | - $table_name = 'esp_message'; |
|
296 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
297 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
298 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
299 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
295 | + $table_name = 'esp_message'; |
|
296 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
297 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
298 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
299 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
300 | 300 | GRP_ID int(10) unsigned NULL, |
301 | 301 | MSG_token varchar(255) NULL, |
302 | 302 | TXN_ID int(10) unsigned NULL, |
@@ -328,20 +328,20 @@ discard block |
||
328 | 328 | KEY STS_ID (STS_ID), |
329 | 329 | KEY MSG_created (MSG_created), |
330 | 330 | KEY MSG_modified (MSG_modified)"; |
331 | - $this->_table_is_new_in_this_version($table_name, $sql); |
|
331 | + $this->_table_is_new_in_this_version($table_name, $sql); |
|
332 | 332 | |
333 | - $table_name = 'esp_message_template'; |
|
334 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
333 | + $table_name = 'esp_message_template'; |
|
334 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
335 | 335 | GRP_ID int(10) unsigned NOT NULL, |
336 | 336 | MTP_context varchar(50) NOT NULL, |
337 | 337 | MTP_template_field varchar(30) NOT NULL, |
338 | 338 | MTP_content text NOT NULL, |
339 | 339 | PRIMARY KEY (MTP_ID), |
340 | 340 | KEY GRP_ID (GRP_ID)"; |
341 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
341 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
342 | 342 | |
343 | - $table_name = 'esp_message_template_group'; |
|
344 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
343 | + $table_name = 'esp_message_template_group'; |
|
344 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
345 | 345 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
346 | 346 | MTP_name varchar(245) NOT NULL DEFAULT '', |
347 | 347 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -353,10 +353,10 @@ discard block |
||
353 | 353 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
354 | 354 | PRIMARY KEY (GRP_ID), |
355 | 355 | KEY MTP_user_id (MTP_user_id)"; |
356 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
356 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
357 | 357 | |
358 | - $table_name = 'esp_payment'; |
|
359 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
358 | + $table_name = 'esp_payment'; |
|
359 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
360 | 360 | TXN_ID int(10) unsigned DEFAULT NULL, |
361 | 361 | STS_ID varchar(3) DEFAULT NULL, |
362 | 362 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | PRIMARY KEY (PAY_ID), |
374 | 374 | KEY PAY_timestamp (PAY_timestamp), |
375 | 375 | KEY TXN_ID (TXN_ID)"; |
376 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
376 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
377 | 377 | |
378 | - $table_name = 'esp_payment_method'; |
|
379 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
378 | + $table_name = 'esp_payment_method'; |
|
379 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
380 | 380 | PMD_type varchar(124) DEFAULT NULL, |
381 | 381 | PMD_name varchar(255) DEFAULT NULL, |
382 | 382 | PMD_desc text, |
@@ -392,27 +392,27 @@ discard block |
||
392 | 392 | PRIMARY KEY (PMD_ID), |
393 | 393 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
394 | 394 | KEY PMD_type (PMD_type)"; |
395 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
395 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
396 | 396 | |
397 | - $table_name = "esp_ticket_price"; |
|
398 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
397 | + $table_name = "esp_ticket_price"; |
|
398 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
399 | 399 | TKT_ID int(10) unsigned NOT NULL, |
400 | 400 | PRC_ID int(10) unsigned NOT NULL, |
401 | 401 | PRIMARY KEY (TKP_ID), |
402 | 402 | KEY TKT_ID (TKT_ID), |
403 | 403 | KEY PRC_ID (PRC_ID)"; |
404 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
404 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
405 | 405 | |
406 | - $table_name = "esp_ticket_template"; |
|
407 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
406 | + $table_name = "esp_ticket_template"; |
|
407 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
408 | 408 | TTM_name varchar(45) NOT NULL, |
409 | 409 | TTM_description text, |
410 | 410 | TTM_file varchar(45), |
411 | 411 | PRIMARY KEY (TTM_ID)"; |
412 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
412 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
413 | 413 | |
414 | - $table_name = 'esp_question'; |
|
415 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
414 | + $table_name = 'esp_question'; |
|
415 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | 416 | QST_display_text text NOT NULL, |
417 | 417 | QST_admin_label varchar(255) NOT NULL, |
418 | 418 | QST_system varchar(25) DEFAULT NULL, |
@@ -426,20 +426,20 @@ discard block |
||
426 | 426 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
427 | 427 | PRIMARY KEY (QST_ID), |
428 | 428 | KEY QST_order (QST_order)'; |
429 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
429 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
430 | 430 | |
431 | - $table_name = 'esp_question_group_question'; |
|
432 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
431 | + $table_name = 'esp_question_group_question'; |
|
432 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
433 | 433 | QSG_ID int(10) unsigned NOT NULL, |
434 | 434 | QST_ID int(10) unsigned NOT NULL, |
435 | 435 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
436 | 436 | PRIMARY KEY (QGQ_ID), |
437 | 437 | KEY QST_ID (QST_ID), |
438 | 438 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
439 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
439 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
440 | 440 | |
441 | - $table_name = 'esp_question_option'; |
|
442 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
441 | + $table_name = 'esp_question_option'; |
|
442 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
443 | 443 | QSO_value varchar(255) NOT NULL, |
444 | 444 | QSO_desc text NOT NULL, |
445 | 445 | QST_ID int(10) unsigned NOT NULL, |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | PRIMARY KEY (QSO_ID), |
450 | 450 | KEY QST_ID (QST_ID), |
451 | 451 | KEY QSO_order (QSO_order)"; |
452 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
452 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
453 | 453 | |
454 | - $table_name = 'esp_registration'; |
|
455 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
454 | + $table_name = 'esp_registration'; |
|
455 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
456 | 456 | EVT_ID bigint(20) unsigned NOT NULL, |
457 | 457 | ATT_ID bigint(20) unsigned NOT NULL, |
458 | 458 | TXN_ID int(10) unsigned NOT NULL, |
@@ -476,20 +476,20 @@ discard block |
||
476 | 476 | KEY TKT_ID (TKT_ID), |
477 | 477 | KEY EVT_ID (EVT_ID), |
478 | 478 | KEY STS_ID (STS_ID)"; |
479 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
479 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
480 | 480 | |
481 | - $table_name = 'esp_registration_payment'; |
|
482 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
481 | + $table_name = 'esp_registration_payment'; |
|
482 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
483 | 483 | REG_ID int(10) unsigned NOT NULL, |
484 | 484 | PAY_ID int(10) unsigned NULL, |
485 | 485 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
486 | 486 | PRIMARY KEY (RPY_ID), |
487 | 487 | KEY REG_ID (REG_ID), |
488 | 488 | KEY PAY_ID (PAY_ID)"; |
489 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
489 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
490 | 490 | |
491 | - $table_name = 'esp_state'; |
|
492 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
491 | + $table_name = 'esp_state'; |
|
492 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
493 | 493 | CNT_ISO varchar(2) NOT NULL, |
494 | 494 | STA_abbrev varchar(24) NOT NULL, |
495 | 495 | STA_name varchar(100) NOT NULL, |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | PRIMARY KEY (STA_ID), |
498 | 498 | KEY STA_abbrev (STA_abbrev), |
499 | 499 | KEY CNT_ISO (CNT_ISO)"; |
500 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
500 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
501 | 501 | |
502 | - $table_name = 'esp_status'; |
|
503 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
502 | + $table_name = 'esp_status'; |
|
503 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
504 | 504 | STS_code varchar(45) NOT NULL, |
505 | 505 | STS_type varchar(45) NOT NULL, |
506 | 506 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
509 | 509 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
510 | 510 | KEY STS_type (STS_type)"; |
511 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
511 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
512 | 512 | |
513 | - $table_name = 'esp_transaction'; |
|
514 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
513 | + $table_name = 'esp_transaction'; |
|
514 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
515 | 515 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
516 | 516 | TXN_total decimal(12,3) DEFAULT '0.00', |
517 | 517 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -523,10 +523,10 @@ discard block |
||
523 | 523 | PRIMARY KEY (TXN_ID), |
524 | 524 | KEY TXN_timestamp (TXN_timestamp), |
525 | 525 | KEY STS_ID (STS_ID)"; |
526 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
526 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
527 | 527 | |
528 | - $table_name = 'esp_venue_meta'; |
|
529 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
528 | + $table_name = 'esp_venue_meta'; |
|
529 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
530 | 530 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
531 | 531 | VNU_address varchar(255) DEFAULT NULL, |
532 | 532 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -545,10 +545,10 @@ discard block |
||
545 | 545 | KEY VNU_ID (VNU_ID), |
546 | 546 | KEY STA_ID (STA_ID), |
547 | 547 | KEY CNT_ISO (CNT_ISO)"; |
548 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
549 | - // modified tables |
|
550 | - $table_name = "esp_price"; |
|
551 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
548 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
549 | + // modified tables |
|
550 | + $table_name = "esp_price"; |
|
551 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
552 | 552 | PRT_ID tinyint(3) unsigned NOT NULL, |
553 | 553 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
554 | 554 | PRC_name varchar(245) NOT NULL, |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | PRC_parent int(10) unsigned DEFAULT 0, |
562 | 562 | PRIMARY KEY (PRC_ID), |
563 | 563 | KEY PRT_ID (PRT_ID)"; |
564 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
564 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
565 | 565 | |
566 | - $table_name = "esp_price_type"; |
|
567 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
566 | + $table_name = "esp_price_type"; |
|
567 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
568 | 568 | PRT_name varchar(45) NOT NULL, |
569 | 569 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
570 | 570 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
574 | 574 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
575 | 575 | PRIMARY KEY (PRT_ID)"; |
576 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
576 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
577 | 577 | |
578 | - $table_name = "esp_ticket"; |
|
579 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
578 | + $table_name = "esp_ticket"; |
|
579 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
580 | 580 | TTM_ID int(10) unsigned NOT NULL, |
581 | 581 | TKT_name varchar(245) NOT NULL DEFAULT '', |
582 | 582 | TKT_description text NOT NULL, |
@@ -599,10 +599,10 @@ discard block |
||
599 | 599 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
600 | 600 | PRIMARY KEY (TKT_ID), |
601 | 601 | KEY TKT_start_date (TKT_start_date)"; |
602 | - $this->_table_is_changed_in_this_version($table_name, $sql); |
|
602 | + $this->_table_is_changed_in_this_version($table_name, $sql); |
|
603 | 603 | |
604 | - $table_name = 'esp_question_group'; |
|
605 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
604 | + $table_name = 'esp_question_group'; |
|
605 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
606 | 606 | QSG_name varchar(255) NOT NULL, |
607 | 607 | QSG_identifier varchar(100) NOT NULL, |
608 | 608 | QSG_desc text NULL, |
@@ -615,169 +615,169 @@ discard block |
||
615 | 615 | PRIMARY KEY (QSG_ID), |
616 | 616 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
617 | 617 | KEY QSG_order (QSG_order)'; |
618 | - $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
619 | - $this->insert_default_data(); |
|
620 | - return true; |
|
621 | - } |
|
622 | - |
|
623 | - |
|
624 | - /** |
|
625 | - * Inserts default data after parent was called. |
|
626 | - * |
|
627 | - * @throws EE_Error |
|
628 | - * @throws InvalidArgumentException |
|
629 | - * @throws ReflectionException |
|
630 | - * @throws InvalidDataTypeException |
|
631 | - * @throws InvalidInterfaceException |
|
632 | - * @since 4.10.0.p |
|
633 | - */ |
|
634 | - public function insert_default_data() |
|
635 | - { |
|
636 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
637 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
638 | - // (because many need to convert old string states to foreign keys into the states table) |
|
639 | - $script_4_1_defaults->insert_default_states(); |
|
640 | - $script_4_1_defaults->insert_default_countries(); |
|
641 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
642 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
643 | - $script_4_5_defaults->insert_default_price_types(); |
|
644 | - $script_4_5_defaults->insert_default_prices(); |
|
645 | - $script_4_5_defaults->insert_default_tickets(); |
|
646 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
647 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
648 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
649 | - $script_4_6_defaults->insert_default_currencies(); |
|
650 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
651 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
652 | - $script_4_8_defaults->verify_new_countries(); |
|
653 | - $script_4_8_defaults->verify_new_currencies(); |
|
654 | - $this->verify_db_collations(); |
|
655 | - $this->verify_db_collations_again(); |
|
656 | - } |
|
657 | - |
|
658 | - |
|
659 | - /** |
|
660 | - * @return boolean |
|
661 | - */ |
|
662 | - public function schema_changes_after_migration() |
|
663 | - { |
|
664 | - return true; |
|
665 | - } |
|
666 | - |
|
667 | - |
|
668 | - public function migration_page_hooks() |
|
669 | - { |
|
670 | - } |
|
671 | - |
|
672 | - |
|
673 | - /** |
|
674 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
675 | - * |
|
676 | - * @return void |
|
677 | - */ |
|
678 | - public function verify_db_collations() |
|
679 | - { |
|
680 | - global $wpdb; |
|
681 | - // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
682 | - if ( |
|
683 | - 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations', false) |
|
684 | - ) { |
|
685 | - return; |
|
686 | - } |
|
687 | - // grab tables from each model |
|
688 | - $tables_to_check = []; |
|
689 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
690 | - if (method_exists($model_name, 'instance')) { |
|
691 | - $model_obj = call_user_func([$model_name, 'instance']); |
|
692 | - if ($model_obj instanceof EEM_Base) { |
|
693 | - foreach ($model_obj->get_tables() as $table) { |
|
694 | - if ( |
|
695 | - strpos($table->get_table_name(), 'esp_') && |
|
696 | - (is_main_site() |
|
697 | - // for main tables, verify global tables |
|
698 | - || |
|
699 | - ! $table->is_global( |
|
700 | - )// if not the main site, then only verify non-global tables (avoid doubling up) |
|
701 | - ) && |
|
702 | - function_exists('maybe_convert_table_to_utf8mb4') |
|
703 | - ) { |
|
704 | - $tables_to_check[] = $table->get_table_name(); |
|
705 | - } |
|
706 | - } |
|
707 | - } |
|
708 | - } |
|
709 | - } |
|
710 | - // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
711 | - // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
712 | - // of hard-coding this |
|
713 | - $addon_tables = [ |
|
714 | - // mailchimp |
|
715 | - 'esp_event_mailchimp_list_group', |
|
716 | - 'esp_event_question_mailchimp_field', |
|
717 | - // multisite |
|
718 | - 'esp_blog_meta', |
|
719 | - // people |
|
720 | - 'esp_people_to_post', |
|
721 | - // promotions |
|
722 | - 'esp_promotion', |
|
723 | - 'esp_promotion_object', |
|
724 | - ]; |
|
725 | - foreach ($addon_tables as $table_name) { |
|
726 | - $tables_to_check[] = $table_name; |
|
727 | - } |
|
728 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
729 | - // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
730 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
731 | - // seeing how this ran with the fix from 10435, no need to check again |
|
732 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
733 | - } |
|
734 | - |
|
735 | - |
|
736 | - /** |
|
737 | - * Verifies DB collations because a bug was discovered on |
|
738 | - * https://events.codebasehq.com/projects/event-espresso/tickets/10435 which meant some DB collations might not |
|
739 | - * have been updated |
|
740 | - * |
|
741 | - * @return void |
|
742 | - */ |
|
743 | - public function verify_db_collations_again() |
|
744 | - { |
|
745 | - global $wpdb; |
|
746 | - // double-check we haven't already done this or that the DB doesn't support it |
|
747 | - // compare to how WordPress' upgrade_430() function does this check |
|
748 | - if ( |
|
749 | - 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations_again', false) |
|
750 | - ) { |
|
751 | - return; |
|
752 | - } |
|
753 | - $tables_to_check = [ |
|
754 | - 'esp_attendee_meta', |
|
755 | - 'esp_message', |
|
756 | - ]; |
|
757 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
758 | - add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
759 | - } |
|
760 | - |
|
761 | - |
|
762 | - /** |
|
763 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
764 | - * |
|
765 | - * @param $tables_to_check |
|
766 | - * @return boolean true if logic ran, false if it didn't |
|
767 | - */ |
|
768 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
769 | - { |
|
770 | - foreach ($tables_to_check as $table_name) { |
|
771 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
772 | - if ( |
|
773 | - ! apply_filters( |
|
774 | - 'FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', |
|
775 | - false, |
|
776 | - $table_name |
|
777 | - ) && $this->_get_table_analysis()->tableExists($table_name) |
|
778 | - ) { |
|
779 | - maybe_convert_table_to_utf8mb4($table_name); |
|
780 | - } |
|
781 | - } |
|
782 | - } |
|
618 | + $this->_table_has_not_changed_since_previous($table_name, $sql); |
|
619 | + $this->insert_default_data(); |
|
620 | + return true; |
|
621 | + } |
|
622 | + |
|
623 | + |
|
624 | + /** |
|
625 | + * Inserts default data after parent was called. |
|
626 | + * |
|
627 | + * @throws EE_Error |
|
628 | + * @throws InvalidArgumentException |
|
629 | + * @throws ReflectionException |
|
630 | + * @throws InvalidDataTypeException |
|
631 | + * @throws InvalidInterfaceException |
|
632 | + * @since 4.10.0.p |
|
633 | + */ |
|
634 | + public function insert_default_data() |
|
635 | + { |
|
636 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
637 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
638 | + // (because many need to convert old string states to foreign keys into the states table) |
|
639 | + $script_4_1_defaults->insert_default_states(); |
|
640 | + $script_4_1_defaults->insert_default_countries(); |
|
641 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
642 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
643 | + $script_4_5_defaults->insert_default_price_types(); |
|
644 | + $script_4_5_defaults->insert_default_prices(); |
|
645 | + $script_4_5_defaults->insert_default_tickets(); |
|
646 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
647 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
648 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
649 | + $script_4_6_defaults->insert_default_currencies(); |
|
650 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
651 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
652 | + $script_4_8_defaults->verify_new_countries(); |
|
653 | + $script_4_8_defaults->verify_new_currencies(); |
|
654 | + $this->verify_db_collations(); |
|
655 | + $this->verify_db_collations_again(); |
|
656 | + } |
|
657 | + |
|
658 | + |
|
659 | + /** |
|
660 | + * @return boolean |
|
661 | + */ |
|
662 | + public function schema_changes_after_migration() |
|
663 | + { |
|
664 | + return true; |
|
665 | + } |
|
666 | + |
|
667 | + |
|
668 | + public function migration_page_hooks() |
|
669 | + { |
|
670 | + } |
|
671 | + |
|
672 | + |
|
673 | + /** |
|
674 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
675 | + * |
|
676 | + * @return void |
|
677 | + */ |
|
678 | + public function verify_db_collations() |
|
679 | + { |
|
680 | + global $wpdb; |
|
681 | + // double-check we haven't already done it or that that the DB doesn't support utf8mb4 |
|
682 | + if ( |
|
683 | + 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations', false) |
|
684 | + ) { |
|
685 | + return; |
|
686 | + } |
|
687 | + // grab tables from each model |
|
688 | + $tables_to_check = []; |
|
689 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
690 | + if (method_exists($model_name, 'instance')) { |
|
691 | + $model_obj = call_user_func([$model_name, 'instance']); |
|
692 | + if ($model_obj instanceof EEM_Base) { |
|
693 | + foreach ($model_obj->get_tables() as $table) { |
|
694 | + if ( |
|
695 | + strpos($table->get_table_name(), 'esp_') && |
|
696 | + (is_main_site() |
|
697 | + // for main tables, verify global tables |
|
698 | + || |
|
699 | + ! $table->is_global( |
|
700 | + )// if not the main site, then only verify non-global tables (avoid doubling up) |
|
701 | + ) && |
|
702 | + function_exists('maybe_convert_table_to_utf8mb4') |
|
703 | + ) { |
|
704 | + $tables_to_check[] = $table->get_table_name(); |
|
705 | + } |
|
706 | + } |
|
707 | + } |
|
708 | + } |
|
709 | + } |
|
710 | + // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
711 | + // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
712 | + // of hard-coding this |
|
713 | + $addon_tables = [ |
|
714 | + // mailchimp |
|
715 | + 'esp_event_mailchimp_list_group', |
|
716 | + 'esp_event_question_mailchimp_field', |
|
717 | + // multisite |
|
718 | + 'esp_blog_meta', |
|
719 | + // people |
|
720 | + 'esp_people_to_post', |
|
721 | + // promotions |
|
722 | + 'esp_promotion', |
|
723 | + 'esp_promotion_object', |
|
724 | + ]; |
|
725 | + foreach ($addon_tables as $table_name) { |
|
726 | + $tables_to_check[] = $table_name; |
|
727 | + } |
|
728 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
729 | + // ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
730 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
731 | + // seeing how this ran with the fix from 10435, no need to check again |
|
732 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
733 | + } |
|
734 | + |
|
735 | + |
|
736 | + /** |
|
737 | + * Verifies DB collations because a bug was discovered on |
|
738 | + * https://events.codebasehq.com/projects/event-espresso/tickets/10435 which meant some DB collations might not |
|
739 | + * have been updated |
|
740 | + * |
|
741 | + * @return void |
|
742 | + */ |
|
743 | + public function verify_db_collations_again() |
|
744 | + { |
|
745 | + global $wpdb; |
|
746 | + // double-check we haven't already done this or that the DB doesn't support it |
|
747 | + // compare to how WordPress' upgrade_430() function does this check |
|
748 | + if ( |
|
749 | + 'utf8mb4' !== $wpdb->charset || get_option('ee_verified_db_collations_again', false) |
|
750 | + ) { |
|
751 | + return; |
|
752 | + } |
|
753 | + $tables_to_check = [ |
|
754 | + 'esp_attendee_meta', |
|
755 | + 'esp_message', |
|
756 | + ]; |
|
757 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
758 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
759 | + } |
|
760 | + |
|
761 | + |
|
762 | + /** |
|
763 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
764 | + * |
|
765 | + * @param $tables_to_check |
|
766 | + * @return boolean true if logic ran, false if it didn't |
|
767 | + */ |
|
768 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
769 | + { |
|
770 | + foreach ($tables_to_check as $table_name) { |
|
771 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
772 | + if ( |
|
773 | + ! apply_filters( |
|
774 | + 'FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', |
|
775 | + false, |
|
776 | + $table_name |
|
777 | + ) && $this->_get_table_analysis()->tableExists($table_name) |
|
778 | + ) { |
|
779 | + maybe_convert_table_to_utf8mb4($table_name); |
|
780 | + } |
|
781 | + } |
|
782 | + } |
|
783 | 783 | } |
@@ -9,46 +9,46 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - public function __construct() |
|
13 | - { |
|
14 | - global $wpdb; |
|
15 | - $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso'); |
|
16 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
17 | - $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
|
18 | - parent::__construct(); |
|
19 | - } |
|
12 | + public function __construct() |
|
13 | + { |
|
14 | + global $wpdb; |
|
15 | + $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso'); |
|
16 | + $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
17 | + $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
|
18 | + parent::__construct(); |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * updates the question with the new question type |
|
24 | - * |
|
25 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - protected function _migrate_old_row($old_row) |
|
29 | - { |
|
30 | - if ($old_row['QST_ID'] && $old_row['QST_system'] == 'country') { |
|
31 | - global $wpdb; |
|
32 | - $success = $wpdb->update( |
|
33 | - $this->_old_table, |
|
34 | - ['QST_type' => 'COUNTRY'], // data |
|
35 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
36 | - ['%s'], // data format |
|
37 | - ['%d'] // where format |
|
38 | - ); |
|
39 | - if (! $success) { |
|
40 | - $this->add_error( |
|
41 | - sprintf( |
|
42 | - esc_html__( |
|
43 | - 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - wp_json_encode($old_row['QST_system']), |
|
47 | - $old_row['QST_ID'], |
|
48 | - $wpdb->last_error |
|
49 | - ) |
|
50 | - ); |
|
51 | - } |
|
52 | - } |
|
53 | - } |
|
22 | + /** |
|
23 | + * updates the question with the new question type |
|
24 | + * |
|
25 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + protected function _migrate_old_row($old_row) |
|
29 | + { |
|
30 | + if ($old_row['QST_ID'] && $old_row['QST_system'] == 'country') { |
|
31 | + global $wpdb; |
|
32 | + $success = $wpdb->update( |
|
33 | + $this->_old_table, |
|
34 | + ['QST_type' => 'COUNTRY'], // data |
|
35 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
36 | + ['%s'], // data format |
|
37 | + ['%d'] // where format |
|
38 | + ); |
|
39 | + if (! $success) { |
|
40 | + $this->add_error( |
|
41 | + sprintf( |
|
42 | + esc_html__( |
|
43 | + 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + wp_json_encode($old_row['QST_system']), |
|
47 | + $old_row['QST_ID'], |
|
48 | + $wpdb->last_error |
|
49 | + ) |
|
50 | + ); |
|
51 | + } |
|
52 | + } |
|
53 | + } |
|
54 | 54 | } |
@@ -9,46 +9,46 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_6_0_state_system_question extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - public function __construct() |
|
13 | - { |
|
14 | - global $wpdb; |
|
15 | - $this->_pretty_name = esc_html__('State - System Question', 'event_espresso'); |
|
16 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
17 | - $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
|
18 | - parent::__construct(); |
|
19 | - } |
|
12 | + public function __construct() |
|
13 | + { |
|
14 | + global $wpdb; |
|
15 | + $this->_pretty_name = esc_html__('State - System Question', 'event_espresso'); |
|
16 | + $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
17 | + $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
|
18 | + parent::__construct(); |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * updates the question with the new question type |
|
24 | - * |
|
25 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - protected function _migrate_old_row($old_row) |
|
29 | - { |
|
30 | - if ($old_row['QST_ID'] && $old_row['QST_system'] == 'state') { |
|
31 | - global $wpdb; |
|
32 | - $success = $wpdb->update( |
|
33 | - $this->_old_table, |
|
34 | - ['QST_type' => 'STATE'], // data |
|
35 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
36 | - ['%s'], // data format |
|
37 | - ['%d'] // where format |
|
38 | - ); |
|
39 | - if (! $success) { |
|
40 | - $this->add_error( |
|
41 | - sprintf( |
|
42 | - esc_html__( |
|
43 | - 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - wp_json_encode($old_row['QST_system']), |
|
47 | - $old_row['QST_ID'], |
|
48 | - $wpdb->last_error |
|
49 | - ) |
|
50 | - ); |
|
51 | - } |
|
52 | - } |
|
53 | - } |
|
22 | + /** |
|
23 | + * updates the question with the new question type |
|
24 | + * |
|
25 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + protected function _migrate_old_row($old_row) |
|
29 | + { |
|
30 | + if ($old_row['QST_ID'] && $old_row['QST_system'] == 'state') { |
|
31 | + global $wpdb; |
|
32 | + $success = $wpdb->update( |
|
33 | + $this->_old_table, |
|
34 | + ['QST_type' => 'STATE'], // data |
|
35 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
36 | + ['%s'], // data format |
|
37 | + ['%d'] // where format |
|
38 | + ); |
|
39 | + if (! $success) { |
|
40 | + $this->add_error( |
|
41 | + sprintf( |
|
42 | + esc_html__( |
|
43 | + 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + wp_json_encode($old_row['QST_system']), |
|
47 | + $old_row['QST_ID'], |
|
48 | + $wpdb->last_error |
|
49 | + ) |
|
50 | + ); |
|
51 | + } |
|
52 | + } |
|
53 | + } |
|
54 | 54 | } |
@@ -9,78 +9,78 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - protected string $_transaction_table; |
|
12 | + protected string $_transaction_table; |
|
13 | 13 | |
14 | - protected string $_payment_method_table; |
|
14 | + protected string $_payment_method_table; |
|
15 | 15 | |
16 | 16 | |
17 | - public function __construct() |
|
18 | - { |
|
19 | - global $wpdb; |
|
20 | - $this->_old_table = $wpdb->prefix . 'esp_extra_meta'; |
|
21 | - $this->_transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
22 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
23 | - $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso'); |
|
24 | - $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'"; |
|
25 | - parent::__construct(); |
|
26 | - } |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + global $wpdb; |
|
20 | + $this->_old_table = $wpdb->prefix . 'esp_extra_meta'; |
|
21 | + $this->_transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
22 | + $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
23 | + $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso'); |
|
24 | + $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'"; |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - protected function _migrate_old_row($old_row) |
|
30 | - { |
|
31 | - global $wpdb; |
|
32 | - // get the payment method's ID |
|
33 | - $PMD_ID = $this->_get_payment_method_id_by_gateway_name($old_row['EXM_value']); |
|
34 | - if (! $PMD_ID) { |
|
35 | - $this->add_error( |
|
36 | - sprintf( |
|
37 | - esc_html__( |
|
38 | - 'Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', |
|
39 | - 'event_espresso' |
|
40 | - ), |
|
41 | - $old_row['EXM_value'], |
|
42 | - $this->_json_encode($old_row) |
|
43 | - ) |
|
44 | - ); |
|
45 | - return; |
|
46 | - } |
|
47 | - $new_values = ['PMD_ID' => $PMD_ID]; |
|
48 | - $wheres = ['TXN_ID' => $old_row['OBJ_ID']]; |
|
49 | - $new_value_data_types = ['%d']; |
|
50 | - $where_data_types = ['%d']; |
|
51 | - $success = $wpdb->update( |
|
52 | - $this->_transaction_table, |
|
53 | - $new_values, |
|
54 | - $wheres, |
|
55 | - $new_value_data_types, |
|
56 | - $where_data_types |
|
57 | - ); |
|
58 | - if (! $success) { |
|
59 | - $this->add_error( |
|
60 | - sprintf( |
|
61 | - esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
62 | - $this->_json_encode($new_values), |
|
63 | - $this->_transaction_table, |
|
64 | - $this->_json_encode($wheres) |
|
65 | - ) |
|
66 | - ); |
|
67 | - } |
|
68 | - } |
|
29 | + protected function _migrate_old_row($old_row) |
|
30 | + { |
|
31 | + global $wpdb; |
|
32 | + // get the payment method's ID |
|
33 | + $PMD_ID = $this->_get_payment_method_id_by_gateway_name($old_row['EXM_value']); |
|
34 | + if (! $PMD_ID) { |
|
35 | + $this->add_error( |
|
36 | + sprintf( |
|
37 | + esc_html__( |
|
38 | + 'Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', |
|
39 | + 'event_espresso' |
|
40 | + ), |
|
41 | + $old_row['EXM_value'], |
|
42 | + $this->_json_encode($old_row) |
|
43 | + ) |
|
44 | + ); |
|
45 | + return; |
|
46 | + } |
|
47 | + $new_values = ['PMD_ID' => $PMD_ID]; |
|
48 | + $wheres = ['TXN_ID' => $old_row['OBJ_ID']]; |
|
49 | + $new_value_data_types = ['%d']; |
|
50 | + $where_data_types = ['%d']; |
|
51 | + $success = $wpdb->update( |
|
52 | + $this->_transaction_table, |
|
53 | + $new_values, |
|
54 | + $wheres, |
|
55 | + $new_value_data_types, |
|
56 | + $where_data_types |
|
57 | + ); |
|
58 | + if (! $success) { |
|
59 | + $this->add_error( |
|
60 | + sprintf( |
|
61 | + esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
62 | + $this->_json_encode($new_values), |
|
63 | + $this->_transaction_table, |
|
64 | + $this->_json_encode($wheres) |
|
65 | + ) |
|
66 | + ); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @param string $gateway_name |
|
73 | - * @return string |
|
74 | - * @global wpdb $wpdb |
|
75 | - */ |
|
76 | - protected function _get_payment_method_id_by_gateway_name(string $gateway_name): string |
|
77 | - { |
|
78 | - global $wpdb; |
|
79 | - return $wpdb->get_var( |
|
80 | - $wpdb->prepare( |
|
81 | - "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", |
|
82 | - $gateway_name |
|
83 | - ) |
|
84 | - ); |
|
85 | - } |
|
71 | + /** |
|
72 | + * @param string $gateway_name |
|
73 | + * @return string |
|
74 | + * @global wpdb $wpdb |
|
75 | + */ |
|
76 | + protected function _get_payment_method_id_by_gateway_name(string $gateway_name): string |
|
77 | + { |
|
78 | + global $wpdb; |
|
79 | + return $wpdb->get_var( |
|
80 | + $wpdb->prepare( |
|
81 | + "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", |
|
82 | + $gateway_name |
|
83 | + ) |
|
84 | + ); |
|
85 | + } |
|
86 | 86 | } |
@@ -12,67 +12,67 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_DMS_4_6_0_invoice_settings extends EE_Data_Migration_Script_Stage |
14 | 14 | { |
15 | - /** |
|
16 | - * Just initializes the status of the migration |
|
17 | - */ |
|
18 | - public function __construct() |
|
19 | - { |
|
20 | - $this->_pretty_name = esc_html__('Update Invoice Settings', 'event_espresso'); |
|
21 | - parent::__construct(); |
|
22 | - } |
|
15 | + /** |
|
16 | + * Just initializes the status of the migration |
|
17 | + */ |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | + $this->_pretty_name = esc_html__('Update Invoice Settings', 'event_espresso'); |
|
21 | + parent::__construct(); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * _count_records_to_migrate |
|
27 | - * Counts the records to migrate; the public version may cache it |
|
28 | - * |
|
29 | - * @access protected |
|
30 | - * @return int |
|
31 | - */ |
|
32 | - protected function _count_records_to_migrate(): int |
|
33 | - { |
|
34 | - return 1; |
|
35 | - } |
|
25 | + /** |
|
26 | + * _count_records_to_migrate |
|
27 | + * Counts the records to migrate; the public version may cache it |
|
28 | + * |
|
29 | + * @access protected |
|
30 | + * @return int |
|
31 | + */ |
|
32 | + protected function _count_records_to_migrate(): int |
|
33 | + { |
|
34 | + return 1; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * _migration_step |
|
40 | - * |
|
41 | - * @access protected |
|
42 | - * @param int $num_items_to_migrate |
|
43 | - * @return int number of items ACTUALLY migrated |
|
44 | - * @throws InvalidDataTypeException |
|
45 | - */ |
|
46 | - protected function _migration_step($num_items_to_migrate = 1) |
|
47 | - { |
|
48 | - $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
49 | - $overridden_invoice_body = EEH_Template::locate_template( |
|
50 | - $templates_relative_path . 'invoice_body.template.php', |
|
51 | - [], |
|
52 | - false, |
|
53 | - false, |
|
54 | - true |
|
55 | - ); |
|
56 | - $overridden_receipt_body = EEH_Template::locate_template( |
|
57 | - $templates_relative_path . 'receipt_body.template.php', |
|
58 | - [], |
|
59 | - false, |
|
60 | - false, |
|
61 | - true |
|
62 | - ); |
|
63 | - if ($overridden_invoice_body || $overridden_receipt_body) { |
|
64 | - new PersistentAdminNotice( |
|
65 | - 'invoice_overriding_templates', |
|
66 | - esc_html__( |
|
67 | - 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
68 | - 'event_espresso' |
|
69 | - ), |
|
70 | - true |
|
71 | - ); |
|
72 | - } |
|
38 | + /** |
|
39 | + * _migration_step |
|
40 | + * |
|
41 | + * @access protected |
|
42 | + * @param int $num_items_to_migrate |
|
43 | + * @return int number of items ACTUALLY migrated |
|
44 | + * @throws InvalidDataTypeException |
|
45 | + */ |
|
46 | + protected function _migration_step($num_items_to_migrate = 1) |
|
47 | + { |
|
48 | + $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
49 | + $overridden_invoice_body = EEH_Template::locate_template( |
|
50 | + $templates_relative_path . 'invoice_body.template.php', |
|
51 | + [], |
|
52 | + false, |
|
53 | + false, |
|
54 | + true |
|
55 | + ); |
|
56 | + $overridden_receipt_body = EEH_Template::locate_template( |
|
57 | + $templates_relative_path . 'receipt_body.template.php', |
|
58 | + [], |
|
59 | + false, |
|
60 | + false, |
|
61 | + true |
|
62 | + ); |
|
63 | + if ($overridden_invoice_body || $overridden_receipt_body) { |
|
64 | + new PersistentAdminNotice( |
|
65 | + 'invoice_overriding_templates', |
|
66 | + esc_html__( |
|
67 | + 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
68 | + 'event_espresso' |
|
69 | + ), |
|
70 | + true |
|
71 | + ); |
|
72 | + } |
|
73 | 73 | |
74 | - // regardless of whether it worked or not, we ought to continue the migration |
|
75 | - $this->set_completed(); |
|
76 | - return 1; |
|
77 | - } |
|
74 | + // regardless of whether it worked or not, we ought to continue the migration |
|
75 | + $this->set_completed(); |
|
76 | + return 1; |
|
77 | + } |
|
78 | 78 | } |
@@ -9,58 +9,58 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_6_0_question_types extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - protected array $_question_type_conversions = []; |
|
12 | + protected array $_question_type_conversions = []; |
|
13 | 13 | |
14 | 14 | |
15 | - public function __construct() |
|
16 | - { |
|
17 | - global $wpdb; |
|
18 | - $this->_pretty_name = esc_html__('Question Types', 'event_espresso'); |
|
19 | - $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
20 | - $this->_question_type_conversions = [ |
|
21 | - 'MULTIPLE' => 'CHECKBOX', |
|
22 | - 'SINGLE' => 'RADIO_BTN', |
|
23 | - ]; |
|
24 | - // when fetching rows, because we automatically use a limit and offset |
|
25 | - // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
|
26 | - // so we need to include both the migrated rows as well as the non-migrated rows |
|
27 | - $QST_types_to_count = array_merge( |
|
28 | - array_keys($this->_question_type_conversions), |
|
29 | - $this->_question_type_conversions |
|
30 | - ); |
|
31 | - $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')"; |
|
32 | - parent::__construct(); |
|
33 | - } |
|
15 | + public function __construct() |
|
16 | + { |
|
17 | + global $wpdb; |
|
18 | + $this->_pretty_name = esc_html__('Question Types', 'event_espresso'); |
|
19 | + $this->_old_table = $wpdb->prefix . 'esp_question'; |
|
20 | + $this->_question_type_conversions = [ |
|
21 | + 'MULTIPLE' => 'CHECKBOX', |
|
22 | + 'SINGLE' => 'RADIO_BTN', |
|
23 | + ]; |
|
24 | + // when fetching rows, because we automatically use a limit and offset |
|
25 | + // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
|
26 | + // so we need to include both the migrated rows as well as the non-migrated rows |
|
27 | + $QST_types_to_count = array_merge( |
|
28 | + array_keys($this->_question_type_conversions), |
|
29 | + $this->_question_type_conversions |
|
30 | + ); |
|
31 | + $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')"; |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @param array $old_row an associative array where keys are column names and values are their values. |
|
38 | - * @return void |
|
39 | - */ |
|
40 | - protected function _migrate_old_row($old_row) |
|
41 | - { |
|
42 | - global $wpdb; |
|
43 | - if ($old_row['QST_ID'] && isset($this->_question_type_conversions[ $old_row['QST_type'] ])) { |
|
44 | - $success = $wpdb->update( |
|
45 | - $this->_old_table, |
|
46 | - ['QST_type' => $this->_question_type_conversions[ $old_row['QST_type'] ]], // data |
|
47 | - ['QST_ID' => $old_row['QST_ID']], // where |
|
48 | - ['%s'], // data format |
|
49 | - ['%d'] // where format |
|
50 | - ); |
|
51 | - if (! $success) { |
|
52 | - $this->add_error( |
|
53 | - sprintf( |
|
54 | - esc_html__( |
|
55 | - 'Could not update question type %1$s for question ID=%2$d because "%3$s"', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - wp_json_encode($old_row['QST_type']), |
|
59 | - $old_row['QST_ID'], |
|
60 | - $wpdb->last_error |
|
61 | - ) |
|
62 | - ); |
|
63 | - } |
|
64 | - } |
|
65 | - } |
|
36 | + /** |
|
37 | + * @param array $old_row an associative array where keys are column names and values are their values. |
|
38 | + * @return void |
|
39 | + */ |
|
40 | + protected function _migrate_old_row($old_row) |
|
41 | + { |
|
42 | + global $wpdb; |
|
43 | + if ($old_row['QST_ID'] && isset($this->_question_type_conversions[ $old_row['QST_type'] ])) { |
|
44 | + $success = $wpdb->update( |
|
45 | + $this->_old_table, |
|
46 | + ['QST_type' => $this->_question_type_conversions[ $old_row['QST_type'] ]], // data |
|
47 | + ['QST_ID' => $old_row['QST_ID']], // where |
|
48 | + ['%s'], // data format |
|
49 | + ['%d'] // where format |
|
50 | + ); |
|
51 | + if (! $success) { |
|
52 | + $this->add_error( |
|
53 | + sprintf( |
|
54 | + esc_html__( |
|
55 | + 'Could not update question type %1$s for question ID=%2$d because "%3$s"', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + wp_json_encode($old_row['QST_type']), |
|
59 | + $old_row['QST_ID'], |
|
60 | + $wpdb->last_error |
|
61 | + ) |
|
62 | + ); |
|
63 | + } |
|
64 | + } |
|
65 | + } |
|
66 | 66 | } |
@@ -11,346 +11,346 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_DMS_4_6_0_gateways extends EE_Data_Migration_Script_Stage |
13 | 13 | { |
14 | - protected string $_new_table_name; |
|
14 | + protected string $_new_table_name; |
|
15 | 15 | |
16 | - protected string $_extra_meta_table_name; |
|
16 | + protected string $_extra_meta_table_name; |
|
17 | 17 | |
18 | - protected string $_currency_table_name; |
|
18 | + protected string $_currency_table_name; |
|
19 | 19 | |
20 | - protected string $_currency_payment_method_table_name; |
|
20 | + protected string $_currency_payment_method_table_name; |
|
21 | 21 | |
22 | - /** |
|
23 | - * each key is the name of a 4.1-style gateway we know how to migrate to 4.6 |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected array $_gateway_we_know_to_migrate = [ |
|
28 | - 'Aim', |
|
29 | - 'Bank', |
|
30 | - 'Check', |
|
31 | - 'Invoice', |
|
32 | - 'Mijireh', |
|
33 | - 'Paypal_Pro', |
|
34 | - 'Paypal_Standard', |
|
35 | - ]; |
|
22 | + /** |
|
23 | + * each key is the name of a 4.1-style gateway we know how to migrate to 4.6 |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected array $_gateway_we_know_to_migrate = [ |
|
28 | + 'Aim', |
|
29 | + 'Bank', |
|
30 | + 'Check', |
|
31 | + 'Invoice', |
|
32 | + 'Mijireh', |
|
33 | + 'Paypal_Pro', |
|
34 | + 'Paypal_Standard', |
|
35 | + ]; |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * Just initializes the status of the migration |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - global $wpdb; |
|
44 | - $this->_new_table_name = $wpdb->prefix . "esp_payment_method"; |
|
45 | - $this->_extra_meta_table_name = $wpdb->prefix . "esp_extra_meta"; |
|
46 | - $this->_currency_table_name = $wpdb->prefix . "esp_currency"; |
|
47 | - $this->_pretty_name = esc_html__('Gateways', 'event_espresso'); |
|
48 | - parent::__construct(); |
|
49 | - } |
|
38 | + /** |
|
39 | + * Just initializes the status of the migration |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + global $wpdb; |
|
44 | + $this->_new_table_name = $wpdb->prefix . "esp_payment_method"; |
|
45 | + $this->_extra_meta_table_name = $wpdb->prefix . "esp_extra_meta"; |
|
46 | + $this->_currency_table_name = $wpdb->prefix . "esp_currency"; |
|
47 | + $this->_pretty_name = esc_html__('Gateways', 'event_espresso'); |
|
48 | + parent::__construct(); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Counts the records to migrate; the public version may cache it |
|
54 | - * |
|
55 | - * @return int |
|
56 | - */ |
|
57 | - protected function _count_records_to_migrate(): int |
|
58 | - { |
|
59 | - return count(EE_Config::instance()->gateway->payment_settings); |
|
60 | - } |
|
52 | + /** |
|
53 | + * Counts the records to migrate; the public version may cache it |
|
54 | + * |
|
55 | + * @return int |
|
56 | + */ |
|
57 | + protected function _count_records_to_migrate(): int |
|
58 | + { |
|
59 | + return count(EE_Config::instance()->gateway->payment_settings); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
65 | - * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
66 | - * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
67 | - * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
68 | - * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
69 | - * very least we MUST report/return 50 items migrated) |
|
70 | - * |
|
71 | - * @param int $num_items_to_migrate |
|
72 | - * @return int number of items ACTUALLY migrated |
|
73 | - * @throws EE_Error |
|
74 | - */ |
|
75 | - protected function _migration_step($num_items_to_migrate = 50) |
|
76 | - { |
|
77 | - $items_actually_migrated = 0; |
|
78 | - $gateways_to_deal_with = array_slice( |
|
79 | - EE_Config::instance()->gateway->payment_settings, |
|
80 | - $this->count_records_migrated(), |
|
81 | - $num_items_to_migrate |
|
82 | - ); |
|
83 | - foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) { |
|
84 | - if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) { |
|
85 | - if (! $old_gateway_settings) { |
|
86 | - // no settings existed for this gateway anyways... weird... |
|
87 | - $items_actually_migrated++; |
|
88 | - continue; |
|
89 | - } |
|
90 | - // now prepare the settings to make sure they're in the 4.1 format |
|
91 | - $success = $this->_convert_gateway_settings( |
|
92 | - $old_gateway_slug, |
|
93 | - $old_gateway_settings, |
|
94 | - isset(EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ]) |
|
95 | - ); |
|
96 | - if ($success) { |
|
97 | - EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated'; |
|
98 | - } |
|
99 | - } |
|
100 | - $items_actually_migrated++; |
|
101 | - } |
|
63 | + /** |
|
64 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property |
|
65 | + * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that |
|
66 | + * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the |
|
67 | + * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees |
|
68 | + * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at |
|
69 | + * very least we MUST report/return 50 items migrated) |
|
70 | + * |
|
71 | + * @param int $num_items_to_migrate |
|
72 | + * @return int number of items ACTUALLY migrated |
|
73 | + * @throws EE_Error |
|
74 | + */ |
|
75 | + protected function _migration_step($num_items_to_migrate = 50) |
|
76 | + { |
|
77 | + $items_actually_migrated = 0; |
|
78 | + $gateways_to_deal_with = array_slice( |
|
79 | + EE_Config::instance()->gateway->payment_settings, |
|
80 | + $this->count_records_migrated(), |
|
81 | + $num_items_to_migrate |
|
82 | + ); |
|
83 | + foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) { |
|
84 | + if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) { |
|
85 | + if (! $old_gateway_settings) { |
|
86 | + // no settings existed for this gateway anyways... weird... |
|
87 | + $items_actually_migrated++; |
|
88 | + continue; |
|
89 | + } |
|
90 | + // now prepare the settings to make sure they're in the 4.1 format |
|
91 | + $success = $this->_convert_gateway_settings( |
|
92 | + $old_gateway_slug, |
|
93 | + $old_gateway_settings, |
|
94 | + isset(EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ]) |
|
95 | + ); |
|
96 | + if ($success) { |
|
97 | + EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated'; |
|
98 | + } |
|
99 | + } |
|
100 | + $items_actually_migrated++; |
|
101 | + } |
|
102 | 102 | |
103 | - EE_Config::instance()->update_espresso_config(false, false); |
|
104 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
105 | - $this->set_completed(); |
|
106 | - } |
|
107 | - return $items_actually_migrated; |
|
108 | - } |
|
103 | + EE_Config::instance()->update_espresso_config(false, false); |
|
104 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
105 | + $this->set_completed(); |
|
106 | + } |
|
107 | + return $items_actually_migrated; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * Converts the 4.1-style gateway to a 4.6-style payment method and saves it to the DB |
|
113 | - * |
|
114 | - * @param string $old_gateway_slug |
|
115 | - * @param array $old_gateway_settings |
|
116 | - * @param boolean $active indicates the gateway is currently active |
|
117 | - * @return boolean success |
|
118 | - * @throws EE_Error |
|
119 | - */ |
|
120 | - protected function _convert_gateway_settings( |
|
121 | - string $old_gateway_slug, |
|
122 | - array $old_gateway_settings, |
|
123 | - bool $active |
|
124 | - ): bool { |
|
125 | - switch ($old_gateway_slug) { |
|
126 | - case 'Aim': |
|
127 | - $extra_meta_key_values = [ |
|
128 | - 'login_id' => $old_gateway_settings['authnet_aim_login_id'], |
|
129 | - 'transaction_key' => $old_gateway_settings['authnet_aim_transaction_key'], |
|
130 | - 'test_transactions' => $old_gateway_settings['test_transactions'], |
|
131 | - ]; |
|
132 | - $desc = |
|
133 | - esc_html__('Please provide the following billing information.', 'event_espresso'); |
|
134 | - break; |
|
135 | - case 'Bank': |
|
136 | - $extra_meta_key_values = [ |
|
137 | - 'page_title' => $old_gateway_settings['page_title'], |
|
138 | - 'payment_instructions' => sprintf( |
|
139 | - esc_html__( |
|
140 | - '%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', |
|
141 | - 'event_espresso' |
|
142 | - ), |
|
143 | - $old_gateway_settings['bank_instructions'], |
|
144 | - $old_gateway_settings['account_name'], |
|
145 | - $old_gateway_settings['account_number'], |
|
146 | - $old_gateway_settings['bank_name'], |
|
147 | - $old_gateway_settings['bank_address'] |
|
148 | - ), |
|
149 | - ]; |
|
150 | - $desc = |
|
151 | - esc_html__('Make payment using an electronic funds transfer from your bank.', 'event_espresso'); |
|
152 | - break; |
|
153 | - case 'Check': |
|
154 | - $extra_meta_key_values = [ |
|
155 | - 'check_title' => $old_gateway_settings['check_title'], |
|
156 | - 'payment_instructions' => $old_gateway_settings['check_instructions'], |
|
157 | - 'address_to_send_payment' => $old_gateway_settings['payment_address'], |
|
158 | - ]; |
|
159 | - $desc = esc_html__( |
|
160 | - 'On the next page you will be given instructions on how to make a payment by check.', |
|
161 | - 'event_espresso' |
|
162 | - ); |
|
163 | - break; |
|
164 | - case 'Invoice': |
|
165 | - $extra_meta_key_values = [ |
|
166 | - 'pdf_payee_name' => $old_gateway_settings['template_invoice_payee_name'], |
|
167 | - 'pdf_payee_email' => $old_gateway_settings['template_invoice_email'], |
|
168 | - 'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'], |
|
169 | - 'pdf_payee_address' => $old_gateway_settings['template_invoice_address'], |
|
170 | - 'pdf_instructions' => $old_gateway_settings['template_payment_instructions'], |
|
171 | - 'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'], |
|
172 | - 'page_confirmation_text' => $old_gateway_settings['page_instructions'] ?? '', |
|
173 | - 'page_extra_info' => $old_gateway_settings['payment_address'] ?? '', |
|
174 | - 'legacy_invoice_css' => $old_gateway_settings['invoice_css'] ?? '', |
|
175 | - ]; |
|
176 | - // if they didnt want the invoice gateway to show, pretend it was inactive |
|
177 | - if (! $old_gateway_settings['show']) { |
|
178 | - $active = false; |
|
179 | - } |
|
180 | - $desc = esc_html__( |
|
181 | - 'On the next page you will be able to access your invoice and instructions on how to pay it.', |
|
182 | - 'event_espresso' |
|
183 | - ); |
|
184 | - break; |
|
185 | - case 'Mijireh': |
|
186 | - $extra_meta_key_values = [ |
|
187 | - 'access_key' => $old_gateway_settings['access_key'], |
|
188 | - ]; |
|
189 | - $desc = esc_html__( |
|
190 | - 'On the next page you will be able to enter your billing information to make the payment.', |
|
191 | - 'event_espresso' |
|
192 | - ); |
|
193 | - break; |
|
194 | - case 'Paypal_Pro': |
|
195 | - $extra_meta_key_values = [ |
|
196 | - 'username' => $old_gateway_settings['username'], |
|
197 | - 'password' => $old_gateway_settings['password'], |
|
198 | - 'signature' => $old_gateway_settings['signature'], |
|
199 | - 'credit_card_types' => $old_gateway_settings['credit_cards'], |
|
200 | - ]; |
|
201 | - $desc = |
|
202 | - esc_html__('Please provide the following billing information.', 'event_espresso'); |
|
203 | - break; |
|
204 | - case 'Paypal_Standard': |
|
205 | - $extra_meta_key_values = [ |
|
206 | - 'paypal_id' => $old_gateway_settings['paypal_id'], |
|
207 | - 'image_url' => $old_gateway_settings['image_url'], |
|
208 | - 'shipping_details' => $old_gateway_settings['no_shipping'] ?? false, |
|
111 | + /** |
|
112 | + * Converts the 4.1-style gateway to a 4.6-style payment method and saves it to the DB |
|
113 | + * |
|
114 | + * @param string $old_gateway_slug |
|
115 | + * @param array $old_gateway_settings |
|
116 | + * @param boolean $active indicates the gateway is currently active |
|
117 | + * @return boolean success |
|
118 | + * @throws EE_Error |
|
119 | + */ |
|
120 | + protected function _convert_gateway_settings( |
|
121 | + string $old_gateway_slug, |
|
122 | + array $old_gateway_settings, |
|
123 | + bool $active |
|
124 | + ): bool { |
|
125 | + switch ($old_gateway_slug) { |
|
126 | + case 'Aim': |
|
127 | + $extra_meta_key_values = [ |
|
128 | + 'login_id' => $old_gateway_settings['authnet_aim_login_id'], |
|
129 | + 'transaction_key' => $old_gateway_settings['authnet_aim_transaction_key'], |
|
130 | + 'test_transactions' => $old_gateway_settings['test_transactions'], |
|
131 | + ]; |
|
132 | + $desc = |
|
133 | + esc_html__('Please provide the following billing information.', 'event_espresso'); |
|
134 | + break; |
|
135 | + case 'Bank': |
|
136 | + $extra_meta_key_values = [ |
|
137 | + 'page_title' => $old_gateway_settings['page_title'], |
|
138 | + 'payment_instructions' => sprintf( |
|
139 | + esc_html__( |
|
140 | + '%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', |
|
141 | + 'event_espresso' |
|
142 | + ), |
|
143 | + $old_gateway_settings['bank_instructions'], |
|
144 | + $old_gateway_settings['account_name'], |
|
145 | + $old_gateway_settings['account_number'], |
|
146 | + $old_gateway_settings['bank_name'], |
|
147 | + $old_gateway_settings['bank_address'] |
|
148 | + ), |
|
149 | + ]; |
|
150 | + $desc = |
|
151 | + esc_html__('Make payment using an electronic funds transfer from your bank.', 'event_espresso'); |
|
152 | + break; |
|
153 | + case 'Check': |
|
154 | + $extra_meta_key_values = [ |
|
155 | + 'check_title' => $old_gateway_settings['check_title'], |
|
156 | + 'payment_instructions' => $old_gateway_settings['check_instructions'], |
|
157 | + 'address_to_send_payment' => $old_gateway_settings['payment_address'], |
|
158 | + ]; |
|
159 | + $desc = esc_html__( |
|
160 | + 'On the next page you will be given instructions on how to make a payment by check.', |
|
161 | + 'event_espresso' |
|
162 | + ); |
|
163 | + break; |
|
164 | + case 'Invoice': |
|
165 | + $extra_meta_key_values = [ |
|
166 | + 'pdf_payee_name' => $old_gateway_settings['template_invoice_payee_name'], |
|
167 | + 'pdf_payee_email' => $old_gateway_settings['template_invoice_email'], |
|
168 | + 'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'], |
|
169 | + 'pdf_payee_address' => $old_gateway_settings['template_invoice_address'], |
|
170 | + 'pdf_instructions' => $old_gateway_settings['template_payment_instructions'], |
|
171 | + 'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'], |
|
172 | + 'page_confirmation_text' => $old_gateway_settings['page_instructions'] ?? '', |
|
173 | + 'page_extra_info' => $old_gateway_settings['payment_address'] ?? '', |
|
174 | + 'legacy_invoice_css' => $old_gateway_settings['invoice_css'] ?? '', |
|
175 | + ]; |
|
176 | + // if they didnt want the invoice gateway to show, pretend it was inactive |
|
177 | + if (! $old_gateway_settings['show']) { |
|
178 | + $active = false; |
|
179 | + } |
|
180 | + $desc = esc_html__( |
|
181 | + 'On the next page you will be able to access your invoice and instructions on how to pay it.', |
|
182 | + 'event_espresso' |
|
183 | + ); |
|
184 | + break; |
|
185 | + case 'Mijireh': |
|
186 | + $extra_meta_key_values = [ |
|
187 | + 'access_key' => $old_gateway_settings['access_key'], |
|
188 | + ]; |
|
189 | + $desc = esc_html__( |
|
190 | + 'On the next page you will be able to enter your billing information to make the payment.', |
|
191 | + 'event_espresso' |
|
192 | + ); |
|
193 | + break; |
|
194 | + case 'Paypal_Pro': |
|
195 | + $extra_meta_key_values = [ |
|
196 | + 'username' => $old_gateway_settings['username'], |
|
197 | + 'password' => $old_gateway_settings['password'], |
|
198 | + 'signature' => $old_gateway_settings['signature'], |
|
199 | + 'credit_card_types' => $old_gateway_settings['credit_cards'], |
|
200 | + ]; |
|
201 | + $desc = |
|
202 | + esc_html__('Please provide the following billing information.', 'event_espresso'); |
|
203 | + break; |
|
204 | + case 'Paypal_Standard': |
|
205 | + $extra_meta_key_values = [ |
|
206 | + 'paypal_id' => $old_gateway_settings['paypal_id'], |
|
207 | + 'image_url' => $old_gateway_settings['image_url'], |
|
208 | + 'shipping_details' => $old_gateway_settings['no_shipping'] ?? false, |
|
209 | 209 | |
210 | - ]; |
|
211 | - $desc = sprintf( |
|
212 | - esc_html__( |
|
213 | - 'After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', |
|
214 | - 'event_espresso' |
|
215 | - ), |
|
216 | - '<strong>', |
|
217 | - '</strong>' |
|
218 | - ); |
|
219 | - break; |
|
220 | - default: |
|
221 | - // if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere |
|
222 | - $extra_meta_key_values = $old_gateway_settings; |
|
223 | - $desc = ''; |
|
224 | - } |
|
225 | - $pretty_name = $old_gateway_settings['display_name'] ?? $old_gateway_slug; |
|
226 | - $offline_gateways = ['Bank', 'Check', 'Invoice']; |
|
227 | - if ($active && in_array($old_gateway_slug, $offline_gateways)) { |
|
228 | - $scope = ['CART', 'ADMIN']; |
|
229 | - } elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) { |
|
230 | - $scope = ['CART']; |
|
231 | - } elseif (! $active && in_array($old_gateway_slug, $offline_gateways)) { |
|
232 | - $scope = ['ADMIN']; |
|
233 | - } else { |
|
234 | - $scope = []; |
|
235 | - } |
|
236 | - $payment_method_col_values = [ |
|
237 | - 'PMD_type' => $old_gateway_slug, |
|
238 | - 'PMD_name' => $pretty_name, |
|
239 | - 'PMD_desc' => $desc, |
|
240 | - 'PMD_admin_name' => $pretty_name, |
|
241 | - 'PMD_slug' => sanitize_key($old_gateway_slug), |
|
242 | - 'PMD_debug_mode' => $old_gateway_settings['use_sandbox'] ?? false, |
|
243 | - 'PMD_button_url' => $old_gateway_settings['button_url'] ?? null, |
|
244 | - 'PMD_scope' => serialize($scope), |
|
245 | - ]; |
|
246 | - $db_types = [ |
|
247 | - '%s',// PMD_type |
|
248 | - '%s',// PMD_name |
|
249 | - '%s',// PMD_desc |
|
250 | - '%s',// PMD_admin_name |
|
251 | - '%s',// PMD_slug |
|
252 | - '%d',// PMD_debug_mode |
|
253 | - '%s',// PMD_button_url |
|
254 | - '%s',// PMD_scope |
|
255 | - ]; |
|
256 | - global $wpdb; |
|
257 | - // first: check if it already exists |
|
258 | - $id = $wpdb->get_var( |
|
259 | - $wpdb->prepare( |
|
260 | - "SELECT PMD_ID FROM $this->_new_table_name WHERE PMD_slug=%s", |
|
261 | - $payment_method_col_values['PMD_slug'] |
|
262 | - ) |
|
263 | - ); |
|
264 | - if ($id) { |
|
265 | - // just update that payment method instead of creating a new one |
|
266 | - $success = $wpdb->update( |
|
267 | - $this->_new_table_name, |
|
268 | - $payment_method_col_values, |
|
269 | - [ |
|
270 | - 'PMD_ID' => $id, |
|
271 | - ], |
|
272 | - $db_types, |
|
273 | - [ |
|
274 | - '%d',// PMD_ID |
|
275 | - ] |
|
276 | - ); |
|
277 | - if (! $success) { |
|
278 | - $this->add_error( |
|
279 | - sprintf( |
|
280 | - esc_html__( |
|
281 | - 'Could not update payment method %d with properties %s because %s', |
|
282 | - "event_espresso" |
|
283 | - ), |
|
284 | - $id, |
|
285 | - wp_json_encode($payment_method_col_values), |
|
286 | - $wpdb->last_error |
|
287 | - ) |
|
288 | - ); |
|
289 | - } |
|
290 | - } else { |
|
291 | - $success = $wpdb->insert( |
|
292 | - $this->_new_table_name, |
|
293 | - $payment_method_col_values, |
|
294 | - $db_types |
|
295 | - ); |
|
296 | - if (! $success) { |
|
297 | - $this->add_error($wpdb->last_error); |
|
298 | - return false; |
|
299 | - } else { |
|
300 | - $id = $wpdb->insert_id; |
|
301 | - } |
|
302 | - } |
|
210 | + ]; |
|
211 | + $desc = sprintf( |
|
212 | + esc_html__( |
|
213 | + 'After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', |
|
214 | + 'event_espresso' |
|
215 | + ), |
|
216 | + '<strong>', |
|
217 | + '</strong>' |
|
218 | + ); |
|
219 | + break; |
|
220 | + default: |
|
221 | + // if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere |
|
222 | + $extra_meta_key_values = $old_gateway_settings; |
|
223 | + $desc = ''; |
|
224 | + } |
|
225 | + $pretty_name = $old_gateway_settings['display_name'] ?? $old_gateway_slug; |
|
226 | + $offline_gateways = ['Bank', 'Check', 'Invoice']; |
|
227 | + if ($active && in_array($old_gateway_slug, $offline_gateways)) { |
|
228 | + $scope = ['CART', 'ADMIN']; |
|
229 | + } elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) { |
|
230 | + $scope = ['CART']; |
|
231 | + } elseif (! $active && in_array($old_gateway_slug, $offline_gateways)) { |
|
232 | + $scope = ['ADMIN']; |
|
233 | + } else { |
|
234 | + $scope = []; |
|
235 | + } |
|
236 | + $payment_method_col_values = [ |
|
237 | + 'PMD_type' => $old_gateway_slug, |
|
238 | + 'PMD_name' => $pretty_name, |
|
239 | + 'PMD_desc' => $desc, |
|
240 | + 'PMD_admin_name' => $pretty_name, |
|
241 | + 'PMD_slug' => sanitize_key($old_gateway_slug), |
|
242 | + 'PMD_debug_mode' => $old_gateway_settings['use_sandbox'] ?? false, |
|
243 | + 'PMD_button_url' => $old_gateway_settings['button_url'] ?? null, |
|
244 | + 'PMD_scope' => serialize($scope), |
|
245 | + ]; |
|
246 | + $db_types = [ |
|
247 | + '%s',// PMD_type |
|
248 | + '%s',// PMD_name |
|
249 | + '%s',// PMD_desc |
|
250 | + '%s',// PMD_admin_name |
|
251 | + '%s',// PMD_slug |
|
252 | + '%d',// PMD_debug_mode |
|
253 | + '%s',// PMD_button_url |
|
254 | + '%s',// PMD_scope |
|
255 | + ]; |
|
256 | + global $wpdb; |
|
257 | + // first: check if it already exists |
|
258 | + $id = $wpdb->get_var( |
|
259 | + $wpdb->prepare( |
|
260 | + "SELECT PMD_ID FROM $this->_new_table_name WHERE PMD_slug=%s", |
|
261 | + $payment_method_col_values['PMD_slug'] |
|
262 | + ) |
|
263 | + ); |
|
264 | + if ($id) { |
|
265 | + // just update that payment method instead of creating a new one |
|
266 | + $success = $wpdb->update( |
|
267 | + $this->_new_table_name, |
|
268 | + $payment_method_col_values, |
|
269 | + [ |
|
270 | + 'PMD_ID' => $id, |
|
271 | + ], |
|
272 | + $db_types, |
|
273 | + [ |
|
274 | + '%d',// PMD_ID |
|
275 | + ] |
|
276 | + ); |
|
277 | + if (! $success) { |
|
278 | + $this->add_error( |
|
279 | + sprintf( |
|
280 | + esc_html__( |
|
281 | + 'Could not update payment method %d with properties %s because %s', |
|
282 | + "event_espresso" |
|
283 | + ), |
|
284 | + $id, |
|
285 | + wp_json_encode($payment_method_col_values), |
|
286 | + $wpdb->last_error |
|
287 | + ) |
|
288 | + ); |
|
289 | + } |
|
290 | + } else { |
|
291 | + $success = $wpdb->insert( |
|
292 | + $this->_new_table_name, |
|
293 | + $payment_method_col_values, |
|
294 | + $db_types |
|
295 | + ); |
|
296 | + if (! $success) { |
|
297 | + $this->add_error($wpdb->last_error); |
|
298 | + return false; |
|
299 | + } else { |
|
300 | + $id = $wpdb->insert_id; |
|
301 | + } |
|
302 | + } |
|
303 | 303 | |
304 | - if ($id) { |
|
305 | - $this->_convert_extra_meta_values($id, $extra_meta_key_values); |
|
306 | - $this->get_migration_script()->set_mapping( |
|
307 | - 'EE_Gateway_Config', |
|
308 | - $old_gateway_slug, |
|
309 | - $this->_new_table_name, |
|
310 | - $id |
|
311 | - ); |
|
312 | - return true; |
|
313 | - } |
|
314 | - return false; |
|
315 | - } |
|
304 | + if ($id) { |
|
305 | + $this->_convert_extra_meta_values($id, $extra_meta_key_values); |
|
306 | + $this->get_migration_script()->set_mapping( |
|
307 | + 'EE_Gateway_Config', |
|
308 | + $old_gateway_slug, |
|
309 | + $this->_new_table_name, |
|
310 | + $id |
|
311 | + ); |
|
312 | + return true; |
|
313 | + } |
|
314 | + return false; |
|
315 | + } |
|
316 | 316 | |
317 | 317 | |
318 | - /** |
|
319 | - * Converts old gateway settings which don't map onto the Payment_Method model |
|
320 | - * to extra meta fields |
|
321 | - * |
|
322 | - * @param int $id |
|
323 | - * @param array $extra_meta_key_values |
|
324 | - */ |
|
325 | - private function _convert_extra_meta_values(int $id, array $extra_meta_key_values) |
|
326 | - { |
|
327 | - global $wpdb; |
|
328 | - foreach ($extra_meta_key_values as $key => $value) { |
|
329 | - $exm_args = [ |
|
330 | - 'OBJ_ID' => $id, |
|
331 | - 'EXM_type' => 'Payment_Method', |
|
332 | - 'EXM_key' => $key, |
|
333 | - 'EXM_value' => maybe_serialize($value), |
|
334 | - ]; |
|
335 | - $success = $wpdb->insert( |
|
336 | - $this->_extra_meta_table_name, |
|
337 | - $exm_args, |
|
338 | - [ |
|
339 | - '%d',// OBJ_ID |
|
340 | - '%s',// EXM_type |
|
341 | - '%s',// EXM_key |
|
342 | - '%s',// EXM_value |
|
343 | - ] |
|
344 | - ); |
|
345 | - if (! $success) { |
|
346 | - $this->add_error( |
|
347 | - sprintf( |
|
348 | - esc_html__('Could not insert extra meta key with values %s. %s', "event_espresso"), |
|
349 | - wp_json_encode($exm_args), |
|
350 | - $wpdb->last_error |
|
351 | - ) |
|
352 | - ); |
|
353 | - } |
|
354 | - } |
|
355 | - } |
|
318 | + /** |
|
319 | + * Converts old gateway settings which don't map onto the Payment_Method model |
|
320 | + * to extra meta fields |
|
321 | + * |
|
322 | + * @param int $id |
|
323 | + * @param array $extra_meta_key_values |
|
324 | + */ |
|
325 | + private function _convert_extra_meta_values(int $id, array $extra_meta_key_values) |
|
326 | + { |
|
327 | + global $wpdb; |
|
328 | + foreach ($extra_meta_key_values as $key => $value) { |
|
329 | + $exm_args = [ |
|
330 | + 'OBJ_ID' => $id, |
|
331 | + 'EXM_type' => 'Payment_Method', |
|
332 | + 'EXM_key' => $key, |
|
333 | + 'EXM_value' => maybe_serialize($value), |
|
334 | + ]; |
|
335 | + $success = $wpdb->insert( |
|
336 | + $this->_extra_meta_table_name, |
|
337 | + $exm_args, |
|
338 | + [ |
|
339 | + '%d',// OBJ_ID |
|
340 | + '%s',// EXM_type |
|
341 | + '%s',// EXM_key |
|
342 | + '%s',// EXM_value |
|
343 | + ] |
|
344 | + ); |
|
345 | + if (! $success) { |
|
346 | + $this->add_error( |
|
347 | + sprintf( |
|
348 | + esc_html__('Could not insert extra meta key with values %s. %s', "event_espresso"), |
|
349 | + wp_json_encode($exm_args), |
|
350 | + $wpdb->last_error |
|
351 | + ) |
|
352 | + ); |
|
353 | + } |
|
354 | + } |
|
355 | + } |
|
356 | 356 | } |
@@ -9,125 +9,125 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_DMS_4_6_0_payments extends EE_Data_Migration_Script_Stage_Table |
11 | 11 | { |
12 | - protected string $_payment_method_table; |
|
12 | + protected string $_payment_method_table; |
|
13 | 13 | |
14 | 14 | |
15 | - public function __construct() |
|
16 | - { |
|
17 | - global $wpdb; |
|
18 | - $this->_old_table = $wpdb->prefix . 'esp_payment'; |
|
19 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
20 | - $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso'); |
|
21 | - parent::__construct(); |
|
22 | - } |
|
15 | + public function __construct() |
|
16 | + { |
|
17 | + global $wpdb; |
|
18 | + $this->_old_table = $wpdb->prefix . 'esp_payment'; |
|
19 | + $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
20 | + $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso'); |
|
21 | + parent::__construct(); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - protected function _migrate_old_row($old_row) |
|
26 | - { |
|
27 | - global $wpdb; |
|
28 | - // get the payment method's ID |
|
29 | - $PMD_ID = apply_filters( |
|
30 | - 'FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', |
|
31 | - $this->_get_payment_method_id_by_gateway_name($old_row['PAY_gateway'], $old_row['PAY_method']) |
|
32 | - ); |
|
33 | - if (! $PMD_ID) { |
|
34 | - $this->add_error( |
|
35 | - sprintf( |
|
36 | - esc_html__( |
|
37 | - 'Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - $old_row['PAY_gateway'], |
|
41 | - $this->_json_encode($old_row) |
|
42 | - ) |
|
43 | - ); |
|
44 | - $PMD_ID = 0; |
|
45 | - } |
|
46 | - $new_values = [ |
|
47 | - 'PMD_ID' => $PMD_ID, |
|
48 | - 'PAY_source' => ($old_row['PAY_via_admin'] ? 'ADMIN' : 'CART'), |
|
49 | - ]; |
|
50 | - $wheres = ['PAY_ID' => $old_row['PAY_ID']]; |
|
51 | - $new_value_datatypes = ['%d', '%s']; |
|
52 | - $where_datatypes = ['%d']; |
|
53 | - $success = $wpdb->update( |
|
54 | - $this->_old_table, |
|
55 | - $new_values, |
|
56 | - $wheres, |
|
57 | - $new_value_datatypes, |
|
58 | - $where_datatypes |
|
59 | - ); |
|
60 | - if (! $success) { |
|
61 | - $this->add_error( |
|
62 | - sprintf( |
|
63 | - esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
64 | - $this->_json_encode($new_values), |
|
65 | - $this->_old_table, |
|
66 | - $this->_json_encode($wheres) |
|
67 | - ) |
|
68 | - ); |
|
69 | - } |
|
70 | - } |
|
25 | + protected function _migrate_old_row($old_row) |
|
26 | + { |
|
27 | + global $wpdb; |
|
28 | + // get the payment method's ID |
|
29 | + $PMD_ID = apply_filters( |
|
30 | + 'FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', |
|
31 | + $this->_get_payment_method_id_by_gateway_name($old_row['PAY_gateway'], $old_row['PAY_method']) |
|
32 | + ); |
|
33 | + if (! $PMD_ID) { |
|
34 | + $this->add_error( |
|
35 | + sprintf( |
|
36 | + esc_html__( |
|
37 | + 'Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + $old_row['PAY_gateway'], |
|
41 | + $this->_json_encode($old_row) |
|
42 | + ) |
|
43 | + ); |
|
44 | + $PMD_ID = 0; |
|
45 | + } |
|
46 | + $new_values = [ |
|
47 | + 'PMD_ID' => $PMD_ID, |
|
48 | + 'PAY_source' => ($old_row['PAY_via_admin'] ? 'ADMIN' : 'CART'), |
|
49 | + ]; |
|
50 | + $wheres = ['PAY_ID' => $old_row['PAY_ID']]; |
|
51 | + $new_value_datatypes = ['%d', '%s']; |
|
52 | + $where_datatypes = ['%d']; |
|
53 | + $success = $wpdb->update( |
|
54 | + $this->_old_table, |
|
55 | + $new_values, |
|
56 | + $wheres, |
|
57 | + $new_value_datatypes, |
|
58 | + $where_datatypes |
|
59 | + ); |
|
60 | + if (! $success) { |
|
61 | + $this->add_error( |
|
62 | + sprintf( |
|
63 | + esc_html__('Couldn\'t set %1$s row in table %2$s where %3$s', 'event_espresso'), |
|
64 | + $this->_json_encode($new_values), |
|
65 | + $this->_old_table, |
|
66 | + $this->_json_encode($wheres) |
|
67 | + ) |
|
68 | + ); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * array( |
|
75 | - * 'PP' => esc_html__( 'PayPal', 'event_espresso' ), |
|
76 | - * 'CC' => esc_html__( 'Credit Card', 'event_espresso' ), |
|
77 | - * 'DB'=> esc_html__("Debit Card", 'event_espresso'), |
|
78 | - * 'CHQ' => esc_html__( 'Cheque', 'event_espresso' ), |
|
79 | - * 'CSH' => esc_html__( 'Cash', 'event_espresso' ), |
|
80 | - * 'BK'=> esc_html__("Bank", 'event_espresso'), |
|
81 | - * 'IV'=> esc_html__("Invoice", 'event_espresso'), |
|
82 | - * 'MO'=> esc_html__("Money Order", 'event_espresso'), |
|
83 | - * |
|
84 | - * @param string $gateway_name |
|
85 | - * @param string $old_pay_method_column |
|
86 | - * @return string|null |
|
87 | - * @global wpdb $wpdb |
|
88 | - */ |
|
89 | - protected function _get_payment_method_id_by_gateway_name( |
|
90 | - string $gateway_name, |
|
91 | - string $old_pay_method_column |
|
92 | - ): ?string { |
|
93 | - global $wpdb; |
|
94 | - // convert from old known PAY_method values to their corresponding |
|
95 | - // PMD_type or default PMD_name |
|
96 | - switch ($old_pay_method_column) { |
|
97 | - case 'PP': |
|
98 | - $pmd_type = 'Paypal_Standard'; |
|
99 | - break; |
|
100 | - case 'CC': |
|
101 | - $pmd_type = 'Credit_Card'; |
|
102 | - break; |
|
103 | - case 'DB': |
|
104 | - $pmd_type = 'Debit_Card'; |
|
105 | - break; |
|
106 | - case 'CHQ': |
|
107 | - $pmd_type = 'Check'; |
|
108 | - break; |
|
109 | - case 'CSH': |
|
110 | - $pmd_type = 'Cash'; |
|
111 | - break; |
|
112 | - case 'BK': |
|
113 | - $pmd_type = 'Bank'; |
|
114 | - break; |
|
115 | - case 'IV': |
|
116 | - $pmd_type = 'Invoice'; |
|
117 | - break; |
|
118 | - case 'MO': |
|
119 | - $pmd_type = 'Money_Order'; |
|
120 | - break; |
|
121 | - default: |
|
122 | - $pmd_type = $gateway_name; |
|
123 | - } |
|
124 | - $pmd_name = str_replace("_", " ", $pmd_type); |
|
125 | - return $wpdb->get_var( |
|
126 | - $wpdb->prepare( |
|
127 | - "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", |
|
128 | - $pmd_type, |
|
129 | - $pmd_name |
|
130 | - ) |
|
131 | - ); |
|
132 | - } |
|
73 | + /** |
|
74 | + * array( |
|
75 | + * 'PP' => esc_html__( 'PayPal', 'event_espresso' ), |
|
76 | + * 'CC' => esc_html__( 'Credit Card', 'event_espresso' ), |
|
77 | + * 'DB'=> esc_html__("Debit Card", 'event_espresso'), |
|
78 | + * 'CHQ' => esc_html__( 'Cheque', 'event_espresso' ), |
|
79 | + * 'CSH' => esc_html__( 'Cash', 'event_espresso' ), |
|
80 | + * 'BK'=> esc_html__("Bank", 'event_espresso'), |
|
81 | + * 'IV'=> esc_html__("Invoice", 'event_espresso'), |
|
82 | + * 'MO'=> esc_html__("Money Order", 'event_espresso'), |
|
83 | + * |
|
84 | + * @param string $gateway_name |
|
85 | + * @param string $old_pay_method_column |
|
86 | + * @return string|null |
|
87 | + * @global wpdb $wpdb |
|
88 | + */ |
|
89 | + protected function _get_payment_method_id_by_gateway_name( |
|
90 | + string $gateway_name, |
|
91 | + string $old_pay_method_column |
|
92 | + ): ?string { |
|
93 | + global $wpdb; |
|
94 | + // convert from old known PAY_method values to their corresponding |
|
95 | + // PMD_type or default PMD_name |
|
96 | + switch ($old_pay_method_column) { |
|
97 | + case 'PP': |
|
98 | + $pmd_type = 'Paypal_Standard'; |
|
99 | + break; |
|
100 | + case 'CC': |
|
101 | + $pmd_type = 'Credit_Card'; |
|
102 | + break; |
|
103 | + case 'DB': |
|
104 | + $pmd_type = 'Debit_Card'; |
|
105 | + break; |
|
106 | + case 'CHQ': |
|
107 | + $pmd_type = 'Check'; |
|
108 | + break; |
|
109 | + case 'CSH': |
|
110 | + $pmd_type = 'Cash'; |
|
111 | + break; |
|
112 | + case 'BK': |
|
113 | + $pmd_type = 'Bank'; |
|
114 | + break; |
|
115 | + case 'IV': |
|
116 | + $pmd_type = 'Invoice'; |
|
117 | + break; |
|
118 | + case 'MO': |
|
119 | + $pmd_type = 'Money_Order'; |
|
120 | + break; |
|
121 | + default: |
|
122 | + $pmd_type = $gateway_name; |
|
123 | + } |
|
124 | + $pmd_name = str_replace("_", " ", $pmd_type); |
|
125 | + return $wpdb->get_var( |
|
126 | + $wpdb->prepare( |
|
127 | + "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", |
|
128 | + $pmd_type, |
|
129 | + $pmd_name |
|
130 | + ) |
|
131 | + ); |
|
132 | + } |
|
133 | 133 | } |