Completed
Branch BUG/303/g-recaptcha-response-p... (a85f32)
by
unknown
35:35 queued 27:22
created
core/data_migration_scripts/EE_DMS_Core_4_6_0.dms.php 2 patches
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 foreach ($stages as $filepath) {
17
-    $matches = array();
18
-    preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
-    $class_to_filepath[ $matches[1] ] = $filepath;
17
+	$matches = array();
18
+	preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
+	$class_to_filepath[ $matches[1] ] = $filepath;
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
@@ -35,69 +35,69 @@  discard block
 block discarded – undo
35 35
 class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base
36 36
 {
37 37
 
38
-    /**
39
-     * return EE_DMS_Core_4_6_0
40
-     *
41
-     * @param TableManager  $table_manager
42
-     * @param TableAnalysis $table_analysis
43
-     */
44
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
-    {
46
-        $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
-        $this->_priority = 10;
48
-        $this->_migration_stages = array(
49
-            new EE_DMS_4_6_0_gateways(),
50
-            new EE_DMS_4_6_0_question_types(),
51
-            new EE_DMS_4_6_0_country_system_question(),
52
-            new EE_DMS_4_6_0_state_system_question(),
53
-            new EE_DMS_4_6_0_billing_info(),
54
-            new EE_DMS_4_6_0_transactions(),
55
-            new EE_DMS_4_6_0_payments(),
56
-            new EE_DMS_4_6_0_invoice_settings(),
57
-        );
58
-        parent::__construct($table_manager, $table_analysis);
59
-    }
38
+	/**
39
+	 * return EE_DMS_Core_4_6_0
40
+	 *
41
+	 * @param TableManager  $table_manager
42
+	 * @param TableAnalysis $table_analysis
43
+	 */
44
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
45
+	{
46
+		$this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso");
47
+		$this->_priority = 10;
48
+		$this->_migration_stages = array(
49
+			new EE_DMS_4_6_0_gateways(),
50
+			new EE_DMS_4_6_0_question_types(),
51
+			new EE_DMS_4_6_0_country_system_question(),
52
+			new EE_DMS_4_6_0_state_system_question(),
53
+			new EE_DMS_4_6_0_billing_info(),
54
+			new EE_DMS_4_6_0_transactions(),
55
+			new EE_DMS_4_6_0_payments(),
56
+			new EE_DMS_4_6_0_invoice_settings(),
57
+		);
58
+		parent::__construct($table_manager, $table_analysis);
59
+	}
60 60
 
61 61
 
62 62
 
63
-    /**
64
-     * @param array $version_array
65
-     * @return bool
66
-     */
67
-    public function can_migrate_from_version($version_array)
68
-    {
69
-        $version_string = $version_array['Core'];
70
-        if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) {
63
+	/**
64
+	 * @param array $version_array
65
+	 * @return bool
66
+	 */
67
+	public function can_migrate_from_version($version_array)
68
+	{
69
+		$version_string = $version_array['Core'];
70
+		if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) {
71 71
 //          echo "$version_string can be migrated from";
72
-            return true;
73
-        } elseif (! $version_string) {
72
+			return true;
73
+		} elseif (! $version_string) {
74 74
 //          echo "no version string provided: $version_string";
75
-            // no version string provided... this must be pre 4.3
76
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
-        } else {
75
+			// no version string provided... this must be pre 4.3
76
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
77
+		} else {
78 78
 //          echo "$version_string doesnt apply";
79
-            return false;
80
-        }
81
-    }
79
+			return false;
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     * @return bool
87
-     */
88
-    public function schema_changes_before_migration()
89
-    {
90
-        // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
-        $table_name = 'esp_answer';
93
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
85
+	/**
86
+	 * @return bool
87
+	 */
88
+	public function schema_changes_before_migration()
89
+	{
90
+		// relies on 4.1's EEH_Activation::create_table
91
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
92
+		$table_name = 'esp_answer';
93
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID int(10) unsigned NOT NULL,
95 95
 					QST_ID int(10) unsigned NOT NULL,
96 96
 					ANS_value text NOT NULL,
97 97
 					PRIMARY KEY  (ANS_ID)";
98
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
-        $table_name = 'esp_attendee_meta';
100
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
98
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
99
+		$table_name = 'esp_attendee_meta';
100
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
101 101
 						ATT_ID bigint(20) unsigned NOT NULL,
102 102
 						ATT_fname varchar(45) NOT NULL,
103 103
 						ATT_lname varchar(45) NOT	NULL,
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 								KEY ATT_fname (ATT_fname),
114 114
 								KEY ATT_lname (ATT_lname),
115 115
 								KEY ATT_email (ATT_email(191))";
116
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
-        $table_name = 'esp_country';
118
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
116
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
117
+		$table_name = 'esp_country';
118
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
119 119
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
120 120
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
121 121
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 					  CNT_is_EU tinyint(1) DEFAULT '0',
132 132
 					  CNT_active tinyint(1) DEFAULT '0',
133 133
 					  PRIMARY KEY  (CNT_ISO)";
134
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
-        $table_name = 'esp_currency';
136
-        $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
134
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
135
+		$table_name = 'esp_currency';
136
+		$sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
137 137
 				CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar',
138 138
 				CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars',
139 139
 				CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$',
140 140
 				CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
141 141
 				CUR_active tinyint(1) DEFAULT '0',
142 142
 				PRIMARY KEY  (CUR_code)";
143
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
-        $table_name = 'esp_currency_payment_method';
145
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
143
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
144
+		$table_name = 'esp_currency_payment_method';
145
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
146 146
 				CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
147 147
 				PMD_ID int(11) NOT NULL,
148 148
 				PRIMARY KEY  (CPM_ID)";
149
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
-        $table_name = 'esp_datetime';
151
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
149
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
150
+		$table_name = 'esp_datetime';
151
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
152 152
 				  EVT_ID bigint(20) unsigned NOT NULL,
153 153
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
154 154
 				  DTT_description text NOT NULL,
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 						PRIMARY KEY  (DTT_ID),
164 164
 						KEY EVT_ID (EVT_ID),
165 165
 						KEY DTT_is_primary (DTT_is_primary)";
166
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
-        $table_name = 'esp_event_meta';
168
-        $sql = "
166
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
167
+		$table_name = 'esp_event_meta';
168
+		$sql = "
169 169
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
170 170
 			EVT_ID bigint(20) unsigned NOT NULL,
171 171
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
 			EVT_external_URL varchar(200) NULL,
181 181
 			EVT_donations tinyint(1) NULL,
182 182
 			PRIMARY KEY  (EVTM_ID)";
183
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
-        $table_name = 'esp_event_question_group';
185
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
183
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
184
+		$table_name = 'esp_event_question_group';
185
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
186 186
 					EVT_ID bigint(20) unsigned NOT NULL,
187 187
 					QSG_ID int(10) unsigned NOT NULL,
188 188
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
189 189
 					PRIMARY KEY  (EQG_ID)";
190
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_venue';
192
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
190
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_venue';
192
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
193 193
 				EVT_ID bigint(20) unsigned NOT NULL,
194 194
 				VNU_ID bigint(20) unsigned NOT NULL,
195 195
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
196 196
 				PRIMARY KEY  (EVV_ID)";
197
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_extra_meta';
199
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
197
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_extra_meta';
199
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
200 200
 				OBJ_ID int(11) DEFAULT NULL,
201 201
 				EXM_type varchar(45) DEFAULT NULL,
202 202
 				EXM_key varchar(45) DEFAULT NULL,
203 203
 				EXM_value text,
204 204
 				PRIMARY KEY  (EXM_ID)";
205
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
-        $table_name = 'esp_line_item';
207
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
205
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
206
+		$table_name = 'esp_line_item';
207
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
208 208
 				LIN_code varchar(245) NOT NULL DEFAULT '',
209 209
 				TXN_ID int(11) DEFAULT NULL,
210 210
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 				OBJ_ID int(11) DEFAULT NULL,
221 221
 				OBJ_type varchar(45)DEFAULT NULL,
222 222
 				PRIMARY KEY  (LIN_ID)";
223
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_log';
225
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
223
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_log';
225
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
226 226
 				LOG_time datetime DEFAULT NULL,
227 227
 				OBJ_ID varchar(45) DEFAULT NULL,
228 228
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -230,19 +230,19 @@  discard block
 block discarded – undo
230 230
 				LOG_message text,
231 231
 				LOG_wp_user int(11) DEFAULT NULL,
232 232
 				PRIMARY KEY  (LOG_ID)";
233
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
-        $table_name = 'esp_message_template';
235
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
233
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
234
+		$table_name = 'esp_message_template';
235
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
236 236
 					GRP_ID int(10) unsigned NOT NULL,
237 237
 					MTP_context varchar(50) NOT NULL,
238 238
 					MTP_template_field varchar(30) NOT NULL,
239 239
 					MTP_content text NOT NULL,
240 240
 					PRIMARY KEY  (MTP_ID),
241 241
 					KEY GRP_ID (GRP_ID)";
242
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
-        $table_name = 'esp_message_template_group';
245
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
242
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
243
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
244
+		$table_name = 'esp_message_template_group';
245
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
246 246
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
247 247
 					MTP_name varchar(245) NOT NULL DEFAULT '',
248 248
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
255 255
 					PRIMARY KEY  (GRP_ID),
256 256
 					KEY MTP_user_id (MTP_user_id)";
257
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
-        $table_name = 'esp_event_message_template';
259
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
257
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
258
+		$table_name = 'esp_event_message_template';
259
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
260 260
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
261 261
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
262 262
 					PRIMARY KEY  (EMT_ID),
263 263
 					KEY EVT_ID (EVT_ID),
264 264
 					KEY GRP_ID (GRP_ID)";
265
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
-        $table_name = 'esp_payment';
267
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
265
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
266
+		$table_name = 'esp_payment';
267
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
268 268
 					TXN_ID int(10) unsigned DEFAULT NULL,
269 269
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
270 270
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 					PRIMARY KEY  (PAY_ID),
282 282
 					KEY TXN_ID (TXN_ID),
283 283
 					KEY PAY_timestamp (PAY_timestamp)";
284
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
-        $table_name = 'esp_payment_method';
286
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
284
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
285
+		$table_name = 'esp_payment_method';
286
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
287 287
 				PMD_type varchar(124) DEFAULT NULL,
288 288
 				PMD_name varchar(255) DEFAULT NULL,
289 289
 				PMD_desc text,
@@ -298,28 +298,28 @@  discard block
 block discarded – undo
298 298
 				PMD_scope varchar(255) NULL DEFAULT 'frontend',
299 299
 				PRIMARY KEY  (PMD_ID),
300 300
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)";
301
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
-        $table_name = "esp_ticket_price";
303
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
301
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
302
+		$table_name = "esp_ticket_price";
303
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
304 304
 					  TKT_ID int(10) unsigned NOT NULL,
305 305
 					  PRC_ID int(10) unsigned NOT NULL,
306 306
 					  PRIMARY KEY  (TKP_ID)";
307
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
-        $table_name = "esp_datetime_ticket";
309
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
307
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
308
+		$table_name = "esp_datetime_ticket";
309
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
310 310
 					  DTT_ID int(10) unsigned NOT NULL,
311 311
 					  TKT_ID int(10) unsigned NOT NULL,
312 312
 					  PRIMARY KEY  (DTK_ID)";
313
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
-        $table_name = "esp_ticket_template";
315
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
313
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
314
+		$table_name = "esp_ticket_template";
315
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316 316
 					  TTM_name varchar(45) NOT NULL,
317 317
 					  TTM_description text,
318 318
 					  TTM_file varchar(45),
319 319
 					  PRIMARY KEY  (TTM_ID)";
320
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
-        $table_name = 'esp_question';
322
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
320
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
321
+		$table_name = 'esp_question';
322
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
323 323
 					QST_display_text text NOT NULL,
324 324
 					QST_admin_label varchar(255) NOT NULL,
325 325
 					QST_system varchar(25) DEFAULT NULL,
@@ -331,25 +331,25 @@  discard block
 block discarded – undo
331 331
 					QST_wp_user bigint(20) unsigned NULL,
332 332
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
333 333
 					PRIMARY KEY  (QST_ID)';
334
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
-        $table_name = 'esp_question_group_question';
336
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
334
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
335
+		$table_name = 'esp_question_group_question';
336
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
337 337
 					QSG_ID int(10) unsigned NOT NULL,
338 338
 					QST_ID int(10) unsigned NOT NULL,
339 339
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
340 340
 					PRIMARY KEY  (QGQ_ID) ";
341
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
-        $table_name = 'esp_question_option';
343
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question_option';
343
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
344 344
 					QSO_value varchar(255) NOT NULL,
345 345
 					QSO_desc text NOT NULL,
346 346
 					QST_ID int(10) unsigned NOT NULL,
347 347
 					QSO_order int(10) unsigned NOT NULL DEFAULT 0,
348 348
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
349 349
 					PRIMARY KEY  (QSO_ID)";
350
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_registration';
352
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_registration';
352
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 					  EVT_ID bigint(20) unsigned NOT NULL,
354 354
 					  ATT_ID bigint(20) unsigned NOT NULL,
355 355
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -372,25 +372,25 @@  discard block
 block discarded – undo
372 372
 					  KEY STS_ID (STS_ID),
373 373
 					  KEY REG_url_link (REG_url_link),
374 374
 					  KEY REG_code (REG_code)";
375
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
-        $table_name = 'esp_checkin';
377
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
375
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
376
+		$table_name = 'esp_checkin';
377
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
378 378
 					REG_ID int(10) unsigned NOT NULL,
379 379
 					DTT_ID int(10) unsigned NOT NULL,
380 380
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
381 381
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
382 382
 					PRIMARY KEY  (CHK_ID)";
383
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
-        $table_name = 'esp_state';
385
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
383
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
384
+		$table_name = 'esp_state';
385
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
386 386
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
387 387
 					  STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL,
388 388
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
389 389
 					  STA_active tinyint(1) DEFAULT '1',
390 390
 					  PRIMARY KEY  (STA_ID)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = 'esp_status';
393
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = 'esp_status';
393
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
394 394
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
395 395
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
396 396
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
399 399
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
400 400
 					  KEY STS_type (STS_type)";
401
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
-        $table_name = 'esp_transaction';
403
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
401
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
402
+		$table_name = 'esp_transaction';
403
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
404 404
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
405 405
 					  TXN_total decimal(10,3) DEFAULT '0.00',
406 406
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 					  PRIMARY KEY  (TXN_ID),
413 413
 					  KEY TXN_timestamp (TXN_timestamp),
414 414
 					  KEY STS_ID (STS_ID)";
415
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
-        $table_name = 'esp_venue_meta';
417
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
415
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
416
+		$table_name = 'esp_venue_meta';
417
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
418 418
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
419 419
 			VNU_address varchar(255) DEFAULT NULL,
420 420
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -432,10 +432,10 @@  discard block
 block discarded – undo
432 432
 			PRIMARY KEY  (VNUM_ID),
433 433
 			KEY STA_ID (STA_ID),
434 434
 			KEY CNT_ISO (CNT_ISO)";
435
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
-        // modified tables
437
-        $table_name = "esp_price";
438
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
435
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
436
+		// modified tables
437
+		$table_name = "esp_price";
438
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439 439
 					  PRT_ID tinyint(3) unsigned NOT NULL,
440 440
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
441 441
 					  PRC_name varchar(245) NOT NULL,
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 					  PRC_wp_user bigint(20) unsigned NULL,
448 448
 					  PRC_parent int(10) unsigned DEFAULT 0,
449 449
 					  PRIMARY KEY  (PRC_ID)";
450
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
-        $table_name = "esp_price_type";
452
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
450
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
451
+		$table_name = "esp_price_type";
452
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
453 453
 				  PRT_name varchar(45) NOT NULL,
454 454
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
455 455
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
459 459
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
460 460
 				  PRIMARY KEY  (PRT_ID)";
461
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
-        $table_name = "esp_ticket";
463
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
461
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
462
+		$table_name = "esp_ticket";
463
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
464 464
 					  TTM_ID int(10) unsigned NOT NULL,
465 465
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
466 466
 					  TKT_description text NOT NULL,
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 					  TKT_parent int(10) unsigned DEFAULT '0',
482 482
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
483 483
 					  PRIMARY KEY  (TKT_ID)";
484
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
-        $table_name = 'esp_question_group';
487
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
484
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
485
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
486
+		$table_name = 'esp_question_group';
487
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
488 488
 					QSG_name varchar(255) NOT NULL,
489 489
 					QSG_identifier varchar(100) NOT NULL,
490 490
 					QSG_desc text NULL,
@@ -496,124 +496,124 @@  discard block
 block discarded – undo
496 496
 					QSG_wp_user bigint(20) unsigned NULL,
497 497
 					PRIMARY KEY  (QSG_ID),
498 498
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
499
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
-        // (because many need to convert old string states to foreign keys into the states table)
503
-        $script_4_1_defaults->insert_default_states();
504
-        $script_4_1_defaults->insert_default_countries();
505
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
-        $script_4_5_defaults->insert_default_price_types();
508
-        $script_4_5_defaults->insert_default_prices();
509
-        $script_4_5_defaults->insert_default_tickets();
510
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
-        EE_Config::instance()->update_espresso_config(false, true);
512
-        $this->add_default_admin_only_payments();
513
-        $this->insert_default_currencies();
514
-        return true;
515
-    }
499
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
500
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
501
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
502
+		// (because many need to convert old string states to foreign keys into the states table)
503
+		$script_4_1_defaults->insert_default_states();
504
+		$script_4_1_defaults->insert_default_countries();
505
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
506
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
507
+		$script_4_5_defaults->insert_default_price_types();
508
+		$script_4_5_defaults->insert_default_prices();
509
+		$script_4_5_defaults->insert_default_tickets();
510
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen here
511
+		EE_Config::instance()->update_espresso_config(false, true);
512
+		$this->add_default_admin_only_payments();
513
+		$this->insert_default_currencies();
514
+		return true;
515
+	}
516 516
 
517 517
 
518 518
 
519
-    /**
520
-     * @return boolean
521
-     */
522
-    public function schema_changes_after_migration()
523
-    {
524
-        return true;
525
-    }
519
+	/**
520
+	 * @return boolean
521
+	 */
522
+	public function schema_changes_after_migration()
523
+	{
524
+		return true;
525
+	}
526 526
 
527 527
 
528 528
 
529
-    public function migration_page_hooks()
530
-    {
531
-    }
529
+	public function migration_page_hooks()
530
+	{
531
+	}
532 532
 
533 533
 
534 534
 
535
-    public function add_default_admin_only_payments()
536
-    {
537
-        global $wpdb;
538
-        $table_name = $wpdb->prefix . "esp_payment_method";
539
-        $user_id = EEH_Activation::get_default_creator_id();
540
-        if ($this->_get_table_analysis()->tableExists($table_name)) {
541
-            $SQL = "SELECT COUNT( * ) FROM $table_name";
542
-            $existing_payment_methods = $wpdb->get_var($SQL);
543
-            $default_admin_only_payment_methods = apply_filters(
544
-                'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
-                array(
546
-                    (string) __("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
-                    (string) __("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
-                    (string) __("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
-                    (string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
-                    (string) __("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
-                    (string) __("Invoice", 'event_espresso')     => __(
552
-                        "Invoice received with monies included",
553
-                        'event_espresso'
554
-                    ),
555
-                    (string) __("Money Order", 'event_espresso') => '',
556
-                    (string) __("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
-                    (string) __('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
-                )
559
-            );
560
-            // make sure we hae payment method records for the following
561
-            // so admins can record payments for them from the admin page
562
-            foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
-                $slug = sanitize_key($nicename);
564
-                // check that such a payment method exists
565
-                $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
-                if (! $exists) {
567
-                    $values = array(
568
-                        'PMD_type'       => 'Admin_Only',
569
-                        'PMD_name'       => $nicename,
570
-                        'PMD_admin_name' => $nicename,
571
-                        'PMD_admin_desc' => $description,
572
-                        'PMD_slug'       => $slug,
573
-                        'PMD_wp_user'    => $user_id,
574
-                        'PMD_scope'      => serialize(array('ADMIN')),
575
-                    );
576
-                    $success = $wpdb->insert(
577
-                        $table_name,
578
-                        $values,
579
-                        array(
580
-                            '%s',// PMD_type
581
-                            '%s',// PMD_name
582
-                            '%s',// PMD_admin_name
583
-                            '%s',// PMD_admin_desc
584
-                            '%s',// PMD_slug
585
-                            '%d',// PMD_wp_user
586
-                            '%s',// PMD_scope
587
-                        )
588
-                    );
589
-                    if (! $success) {
590
-                        $this->add_error(sprintf(__(
591
-                            "Could not insert new admin-only payment method with values %s during migration",
592
-                            "event_espresso"
593
-                        ), $this->_json_encode($values)));
594
-                    }
595
-                }
596
-            }
597
-        }
598
-    }
535
+	public function add_default_admin_only_payments()
536
+	{
537
+		global $wpdb;
538
+		$table_name = $wpdb->prefix . "esp_payment_method";
539
+		$user_id = EEH_Activation::get_default_creator_id();
540
+		if ($this->_get_table_analysis()->tableExists($table_name)) {
541
+			$SQL = "SELECT COUNT( * ) FROM $table_name";
542
+			$existing_payment_methods = $wpdb->get_var($SQL);
543
+			$default_admin_only_payment_methods = apply_filters(
544
+				'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods',
545
+				array(
546
+					(string) __("Bank", 'event_espresso')        => __("Bank Draft", 'event_espresso'),
547
+					(string) __("Cash", 'event_espresso')        => __("Cash Delivered Physically", 'event_espresso'),
548
+					(string) __("Check", 'event_espresso')       => __("Paper Check", 'event_espresso'),
549
+					(string) __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'),
550
+					(string) __("Debit Card", 'event_espresso')  => __("Offline Debit Payment", 'event_espresso'),
551
+					(string) __("Invoice", 'event_espresso')     => __(
552
+						"Invoice received with monies included",
553
+						'event_espresso'
554
+					),
555
+					(string) __("Money Order", 'event_espresso') => '',
556
+					(string) __("Paypal", 'event_espresso')      => __("Paypal eCheck, Invoice, etc", 'event_espresso'),
557
+					(string) __('Other', 'event_espresso')       => __('Other method of payment', 'event_espresso'),
558
+				)
559
+			);
560
+			// make sure we hae payment method records for the following
561
+			// so admins can record payments for them from the admin page
562
+			foreach ($default_admin_only_payment_methods as $nicename => $description) {
563
+				$slug = sanitize_key($nicename);
564
+				// check that such a payment method exists
565
+				$exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
+				if (! $exists) {
567
+					$values = array(
568
+						'PMD_type'       => 'Admin_Only',
569
+						'PMD_name'       => $nicename,
570
+						'PMD_admin_name' => $nicename,
571
+						'PMD_admin_desc' => $description,
572
+						'PMD_slug'       => $slug,
573
+						'PMD_wp_user'    => $user_id,
574
+						'PMD_scope'      => serialize(array('ADMIN')),
575
+					);
576
+					$success = $wpdb->insert(
577
+						$table_name,
578
+						$values,
579
+						array(
580
+							'%s',// PMD_type
581
+							'%s',// PMD_name
582
+							'%s',// PMD_admin_name
583
+							'%s',// PMD_admin_desc
584
+							'%s',// PMD_slug
585
+							'%d',// PMD_wp_user
586
+							'%s',// PMD_scope
587
+						)
588
+					);
589
+					if (! $success) {
590
+						$this->add_error(sprintf(__(
591
+							"Could not insert new admin-only payment method with values %s during migration",
592
+							"event_espresso"
593
+						), $this->_json_encode($values)));
594
+					}
595
+				}
596
+			}
597
+		}
598
+	}
599 599
 
600 600
 
601 601
 
602
-    /**
603
-     * insert_default_countries
604
-     *
605
-     * @static
606
-     * @return void
607
-     */
608
-    public function insert_default_currencies()
609
-    {
610
-        global $wpdb;
611
-        $currency_table = $wpdb->prefix . "esp_currency";
612
-        if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
-            $SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
-            $countries = $wpdb->get_var($SQL);
615
-            if (! $countries) {
616
-                $SQL = "INSERT INTO $currency_table
602
+	/**
603
+	 * insert_default_countries
604
+	 *
605
+	 * @static
606
+	 * @return void
607
+	 */
608
+	public function insert_default_currencies()
609
+	{
610
+		global $wpdb;
611
+		$currency_table = $wpdb->prefix . "esp_currency";
612
+		if ($this->_get_table_analysis()->tableExists($currency_table)) {
613
+			$SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614
+			$countries = $wpdb->get_var($SQL);
615
+			if (! $countries) {
616
+				$SQL = "INSERT INTO $currency_table
617 617
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
618 618
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
619 619
 				( 'AED',  'Dirham',  'Dirhams', 'د.إ',2,1),
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 				( 'ZAR',  'Rand',  'Rands',  'R',  2,1),
768 768
 				( 'ZMK',  'Kwacha',  'Kwachas',  '',  2,1),
769 769
 				( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);";
770
-                $wpdb->query($SQL);
771
-            }
772
-        }
773
-    }
770
+				$wpdb->query($SQL);
771
+			}
772
+		}
773
+	}
774 774
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 // unfortunately, this needs to be done upon INCLUSION of this file,
12 12
 // instead of construction, because it only gets constructed on first page load
13 13
 // (all other times it gets resurrected from a wordpress option)
14
-$stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*');
14
+$stages = glob(EE_CORE.'data_migration_scripts/4_6_0_stages/*');
15 15
 $class_to_filepath = array();
16 16
 foreach ($stages as $filepath) {
17 17
     $matches = array();
18 18
     preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches);
19
-    $class_to_filepath[ $matches[1] ] = $filepath;
19
+    $class_to_filepath[$matches[1]] = $filepath;
20 20
 }
21 21
 // give addons a chance to autoload their stages too
22 22
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath);
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
         if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) {
71 71
 //          echo "$version_string can be migrated from";
72 72
             return true;
73
-        } elseif (! $version_string) {
73
+        } elseif ( ! $version_string) {
74 74
 //          echo "no version string provided: $version_string";
75 75
             // no version string provided... this must be pre 4.3
76
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
76
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
77 77
         } else {
78 78
 //          echo "$version_string doesnt apply";
79 79
             return false;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     public function schema_changes_before_migration()
89 89
     {
90 90
         // relies on 4.1's EEH_Activation::create_table
91
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
91
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
92 92
         $table_name = 'esp_answer';
93 93
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94 94
 					REG_ID int(10) unsigned NOT NULL,
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     public function add_default_admin_only_payments()
536 536
     {
537 537
         global $wpdb;
538
-        $table_name = $wpdb->prefix . "esp_payment_method";
538
+        $table_name = $wpdb->prefix."esp_payment_method";
539 539
         $user_id = EEH_Activation::get_default_creator_id();
540 540
         if ($this->_get_table_analysis()->tableExists($table_name)) {
541 541
             $SQL = "SELECT COUNT( * ) FROM $table_name";
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
                 $slug = sanitize_key($nicename);
564 564
                 // check that such a payment method exists
565 565
                 $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug));
566
-                if (! $exists) {
566
+                if ( ! $exists) {
567 567
                     $values = array(
568 568
                         'PMD_type'       => 'Admin_Only',
569 569
                         'PMD_name'       => $nicename,
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
                         $table_name,
578 578
                         $values,
579 579
                         array(
580
-                            '%s',// PMD_type
581
-                            '%s',// PMD_name
582
-                            '%s',// PMD_admin_name
583
-                            '%s',// PMD_admin_desc
584
-                            '%s',// PMD_slug
585
-                            '%d',// PMD_wp_user
586
-                            '%s',// PMD_scope
580
+                            '%s', // PMD_type
581
+                            '%s', // PMD_name
582
+                            '%s', // PMD_admin_name
583
+                            '%s', // PMD_admin_desc
584
+                            '%s', // PMD_slug
585
+                            '%d', // PMD_wp_user
586
+                            '%s', // PMD_scope
587 587
                         )
588 588
                     );
589
-                    if (! $success) {
589
+                    if ( ! $success) {
590 590
                         $this->add_error(sprintf(__(
591 591
                             "Could not insert new admin-only payment method with values %s during migration",
592 592
                             "event_espresso"
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
     public function insert_default_currencies()
609 609
     {
610 610
         global $wpdb;
611
-        $currency_table = $wpdb->prefix . "esp_currency";
611
+        $currency_table = $wpdb->prefix."esp_currency";
612 612
         if ($this->_get_table_analysis()->tableExists($currency_table)) {
613 613
             $SQL = "SELECT COUNT('CUR_code') FROM $currency_table";
614 614
             $countries = $wpdb->get_var($SQL);
615
-            if (! $countries) {
615
+            if ( ! $countries) {
616 616
                 $SQL = "INSERT INTO $currency_table
617 617
 				( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES
618 618
 				( 'EUR',  'Euro',  'Euros',  '€',  2,1),
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 // unfortunately, this needs to be done upon INCLUSION of this file,
16 16
 // instead of construction, because it only gets constructed on first page load
17 17
 // (all other times it gets resurrected from a wordpress option)
18
-$stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*');
18
+$stages = glob(EE_CORE.'data_migration_scripts/4_7_0_stages/*');
19 19
 $class_to_filepath = array();
20 20
 foreach ($stages as $filepath) {
21 21
     $matches = array();
22 22
     preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23
-    $class_to_filepath[ $matches[1] ] = $filepath;
23
+    $class_to_filepath[$matches[1]] = $filepath;
24 24
 }
25 25
 // give addons a chance to autoload their stages too
26 26
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
             )
77 77
         ) {
78 78
             return true;
79
-        } elseif (! $version_string) {
79
+        } elseif ( ! $version_string) {
80 80
             // no version string provided... this must be pre 4.3
81
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
81
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
82 82
         } else {
83 83
             return false;
84 84
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public function schema_changes_before_migration()
93 93
     {
94 94
         // relies on 4.1's EEH_Activation::create_table
95
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
96 96
         $table_name = 'esp_answer';
97 97
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 98
 					REG_ID int(10) unsigned NOT NULL,
Please login to merge, or discard this patch.
Indentation   +180 added lines, -181 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@  discard block
 block discarded – undo
9 9
  * and recalculates esp_registration.REG_final_price to actually be the final price
10 10
  * for that registration (before this it was just the ticket's price, NOT including
11 11
  * taxes or other price modifiers)
12
-
13 12
  */
14 13
 // make sure we have all the stages loaded too
15 14
 // unfortunately, this needs to be done upon INCLUSION of this file,
@@ -18,9 +17,9 @@  discard block
 block discarded – undo
18 17
 $stages = glob(EE_CORE . 'data_migration_scripts/4_7_0_stages/*');
19 18
 $class_to_filepath = array();
20 19
 foreach ($stages as $filepath) {
21
-    $matches = array();
22
-    preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+	$matches = array();
21
+	preg_match('~4_7_0_stages/(.*).dmsstage.php~', $filepath, $matches);
22
+	$class_to_filepath[ $matches[1] ] = $filepath;
24 23
 }
25 24
 // give addons a chance to autoload their stages too
26 25
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_7_0__autoloaded_stages', $class_to_filepath);
@@ -39,71 +38,71 @@  discard block
 block discarded – undo
39 38
 class EE_DMS_Core_4_7_0 extends EE_Data_Migration_Script_Base
40 39
 {
41 40
 
42
-    /**
43
-     * return EE_DMS_Core_4_7_0
44
-     *
45
-     * @param TableManager  $table_manager
46
-     * @param TableAnalysis $table_analysis
47
-     */
48
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
49
-    {
50
-        $this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso");
51
-        $this->_priority = 10;
52
-        $this->_migration_stages = array(
53
-            new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
54
-            new EE_DMS_4_7_0_Registration_Payments(),
55
-        );
56
-        parent::__construct($table_manager, $table_analysis);
57
-    }
41
+	/**
42
+	 * return EE_DMS_Core_4_7_0
43
+	 *
44
+	 * @param TableManager  $table_manager
45
+	 * @param TableAnalysis $table_analysis
46
+	 */
47
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
48
+	{
49
+		$this->_pretty_name = __("Data Update to Event Espresso 4.7.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_7_0_Add_Taxes_To_REG_Final_Price(),
53
+			new EE_DMS_4_7_0_Registration_Payments(),
54
+		);
55
+		parent::__construct($table_manager, $table_analysis);
56
+	}
58 57
 
59 58
 
60 59
 
61
-    /**
62
-     * @param array $version_array
63
-     * @return bool
64
-     */
65
-    public function can_migrate_from_version($version_array)
66
-    {
67
-        $version_string = $version_array['Core'];
68
-        if ((
69
-                version_compare($version_string, '4.7.0', '<=')
70
-                && version_compare($version_string, '4.6.0', '>=')
71
-            )
72
-            || (
73
-                version_compare($version_string, '4.7.0', '>=')
74
-                && ! $this->_get_table_analysis()->tableExists('esp_registration_payment')
75
-                && $this->_get_table_analysis()->tableExists('esp_registration')
76
-            )
77
-        ) {
78
-            return true;
79
-        } elseif (! $version_string) {
80
-            // no version string provided... this must be pre 4.3
81
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
82
-        } else {
83
-            return false;
84
-        }
85
-    }
60
+	/**
61
+	 * @param array $version_array
62
+	 * @return bool
63
+	 */
64
+	public function can_migrate_from_version($version_array)
65
+	{
66
+		$version_string = $version_array['Core'];
67
+		if ((
68
+				version_compare($version_string, '4.7.0', '<=')
69
+				&& version_compare($version_string, '4.6.0', '>=')
70
+			)
71
+			|| (
72
+				version_compare($version_string, '4.7.0', '>=')
73
+				&& ! $this->_get_table_analysis()->tableExists('esp_registration_payment')
74
+				&& $this->_get_table_analysis()->tableExists('esp_registration')
75
+			)
76
+		) {
77
+			return true;
78
+		} elseif (! $version_string) {
79
+			// no version string provided... this must be pre 4.3
80
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
81
+		} else {
82
+			return false;
83
+		}
84
+	}
86 85
 
87 86
 
88 87
 
89
-    /**
90
-     * @return bool
91
-     */
92
-    public function schema_changes_before_migration()
93
-    {
94
-        // relies on 4.1's EEH_Activation::create_table
95
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
96
-        $table_name = 'esp_answer';
97
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
88
+	/**
89
+	 * @return bool
90
+	 */
91
+	public function schema_changes_before_migration()
92
+	{
93
+		// relies on 4.1's EEH_Activation::create_table
94
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
95
+		$table_name = 'esp_answer';
96
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 97
 					REG_ID int(10) unsigned NOT NULL,
99 98
 					QST_ID int(10) unsigned NOT NULL,
100 99
 					ANS_value text NOT NULL,
101 100
 					PRIMARY KEY  (ANS_ID),
102 101
 					KEY REG_ID (REG_ID),
103 102
 					KEY QST_ID (QST_ID)";
104
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
105
-        $table_name = 'esp_attendee_meta';
106
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
103
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
104
+		$table_name = 'esp_attendee_meta';
105
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
107 106
 						ATT_ID bigint(20) unsigned NOT NULL,
108 107
 						ATT_fname varchar(45) NOT NULL,
109 108
 						ATT_lname varchar(45) NOT	NULL,
@@ -120,9 +119,9 @@  discard block
 block discarded – undo
120 119
 								KEY ATT_email (ATT_email(191)),
121 120
 								KEY ATT_lname (ATT_lname),
122 121
 								KEY ATT_fname (ATT_fname)";
123
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
124
-        $table_name = 'esp_country';
125
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
122
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
123
+		$table_name = 'esp_country';
124
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
126 125
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
127 126
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
128 127
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -138,25 +137,25 @@  discard block
 block discarded – undo
138 137
 					  CNT_is_EU tinyint(1) DEFAULT '0',
139 138
 					  CNT_active tinyint(1) DEFAULT '0',
140 139
 					  PRIMARY KEY  (CNT_ISO)";
141
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
142
-        $table_name = 'esp_currency';
143
-        $sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
140
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
141
+		$table_name = 'esp_currency';
142
+		$sql = "CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
144 143
 				CUR_single varchar(45) COLLATE utf8_bin DEFAULT 'dollar',
145 144
 				CUR_plural varchar(45) COLLATE utf8_bin DEFAULT 'dollars',
146 145
 				CUR_sign varchar(45) COLLATE utf8_bin DEFAULT '$',
147 146
 				CUR_dec_plc varchar(1) COLLATE utf8_bin NOT NULL DEFAULT '2',
148 147
 				CUR_active tinyint(1) DEFAULT '0',
149 148
 				PRIMARY KEY  (CUR_code)";
150
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
151
-        $table_name = 'esp_currency_payment_method';
152
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
149
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
150
+		$table_name = 'esp_currency_payment_method';
151
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
153 152
 				CUR_code varchar(6) COLLATE utf8_bin NOT NULL,
154 153
 				PMD_ID int(11) NOT NULL,
155 154
 				PRIMARY KEY  (CPM_ID),
156 155
 				KEY PMD_ID (PMD_ID)";
157
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
158
-        $table_name = 'esp_datetime';
159
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
156
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
157
+		$table_name = 'esp_datetime';
158
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
160 159
 				  EVT_ID bigint(20) unsigned NOT NULL,
161 160
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
162 161
 				  DTT_description text NOT NULL,
@@ -172,9 +171,9 @@  discard block
 block discarded – undo
172 171
 						KEY DTT_EVT_start (DTT_EVT_start),
173 172
 						KEY EVT_ID (EVT_ID),
174 173
 						KEY DTT_is_primary (DTT_is_primary)";
175
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
176
-        $table_name = 'esp_event_meta';
177
-        $sql = "
174
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
175
+		$table_name = 'esp_event_meta';
176
+		$sql = "
178 177
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
179 178
 			EVT_ID bigint(20) unsigned NOT NULL,
180 179
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -190,34 +189,34 @@  discard block
 block discarded – undo
190 189
 			EVT_donations tinyint(1) NULL,
191 190
 			PRIMARY KEY  (EVTM_ID),
192 191
 			KEY EVT_ID (EVT_ID)";
193
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
194
-        $table_name = 'esp_event_question_group';
195
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
192
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
193
+		$table_name = 'esp_event_question_group';
194
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
196 195
 					EVT_ID bigint(20) unsigned NOT NULL,
197 196
 					QSG_ID int(10) unsigned NOT NULL,
198 197
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
199 198
 					PRIMARY KEY  (EQG_ID),
200 199
 					KEY EVT_ID (EVT_ID),
201 200
 					KEY QSG_ID (QSG_ID)";
202
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
203
-        $table_name = 'esp_event_venue';
204
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
201
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
202
+		$table_name = 'esp_event_venue';
203
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
205 204
 				EVT_ID bigint(20) unsigned NOT NULL,
206 205
 				VNU_ID bigint(20) unsigned NOT NULL,
207 206
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
208 207
 				PRIMARY KEY  (EVV_ID)";
209
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
210
-        $table_name = 'esp_extra_meta';
211
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
208
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
209
+		$table_name = 'esp_extra_meta';
210
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
212 211
 				OBJ_ID int(11) DEFAULT NULL,
213 212
 				EXM_type varchar(45) DEFAULT NULL,
214 213
 				EXM_key varchar(45) DEFAULT NULL,
215 214
 				EXM_value text,
216 215
 				PRIMARY KEY  (EXM_ID),
217 216
 				KEY EXM_type (EXM_type, OBJ_ID, EXM_key(45))";
218
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
219
-        $table_name = 'esp_line_item';
220
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
217
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
218
+		$table_name = 'esp_line_item';
219
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
221 220
 				LIN_code varchar(245) NOT NULL DEFAULT '',
222 221
 				TXN_ID int(11) DEFAULT NULL,
223 222
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -235,9 +234,9 @@  discard block
 block discarded – undo
235 234
 				PRIMARY KEY  (LIN_ID),
236 235
 				KEY LIN_code (LIN_code(191)),
237 236
 				KEY TXN_ID (TXN_ID)";
238
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
239
-        $table_name = 'esp_log';
240
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
237
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
238
+		$table_name = 'esp_log';
239
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
241 240
 				LOG_time datetime DEFAULT NULL,
242 241
 				OBJ_ID varchar(45) DEFAULT NULL,
243 242
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -248,18 +247,18 @@  discard block
 block discarded – undo
248 247
 				KEY LOG_time (LOG_time),
249 248
 				KEY OBJ (OBJ_type,OBJ_ID),
250 249
 				KEY LOG_type (LOG_type)";
251
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
252
-        $table_name = 'esp_message_template';
253
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
250
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
251
+		$table_name = 'esp_message_template';
252
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
254 253
 					GRP_ID int(10) unsigned NOT NULL,
255 254
 					MTP_context varchar(50) NOT NULL,
256 255
 					MTP_template_field varchar(30) NOT NULL,
257 256
 					MTP_content text NOT NULL,
258 257
 					PRIMARY KEY  (MTP_ID),
259 258
 					KEY GRP_ID (GRP_ID)";
260
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
261
-        $table_name = 'esp_message_template_group';
262
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
259
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
260
+		$table_name = 'esp_message_template_group';
261
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
263 262
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
264 263
 					MTP_name varchar(245) NOT NULL DEFAULT '',
265 264
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -271,17 +270,17 @@  discard block
 block discarded – undo
271 270
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
272 271
 					PRIMARY KEY  (GRP_ID),
273 272
 					KEY MTP_user_id (MTP_user_id)";
274
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
275
-        $table_name = 'esp_event_message_template';
276
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
273
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
274
+		$table_name = 'esp_event_message_template';
275
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
277 276
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
278 277
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
279 278
 					PRIMARY KEY  (EMT_ID),
280 279
 					KEY EVT_ID (EVT_ID),
281 280
 					KEY GRP_ID (GRP_ID)";
282
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
283
-        $table_name = 'esp_payment';
284
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
281
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
282
+		$table_name = 'esp_payment';
283
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
285 284
 					TXN_ID int(10) unsigned DEFAULT NULL,
286 285
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
287 286
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -298,9 +297,9 @@  discard block
 block discarded – undo
298 297
 					PRIMARY KEY  (PAY_ID),
299 298
 					KEY PAY_timestamp (PAY_timestamp),
300 299
 					KEY TXN_ID (TXN_ID)";
301
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
302
-        $table_name = 'esp_payment_method';
303
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
300
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
301
+		$table_name = 'esp_payment_method';
302
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
304 303
 				PMD_type varchar(124) DEFAULT NULL,
305 304
 				PMD_name varchar(255) DEFAULT NULL,
306 305
 				PMD_desc text,
@@ -316,32 +315,32 @@  discard block
 block discarded – undo
316 315
 				PRIMARY KEY  (PMD_ID),
317 316
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
318 317
 				KEY PMD_type (PMD_type)";
319
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
320
-        $table_name = "esp_ticket_price";
321
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
318
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
319
+		$table_name = "esp_ticket_price";
320
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
322 321
 					  TKT_ID int(10) unsigned NOT NULL,
323 322
 					  PRC_ID int(10) unsigned NOT NULL,
324 323
 					  PRIMARY KEY  (TKP_ID),
325 324
 					  KEY TKT_ID (TKT_ID),
326 325
 					  KEY PRC_ID (PRC_ID)";
327
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
-        $table_name = "esp_datetime_ticket";
329
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
326
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
327
+		$table_name = "esp_datetime_ticket";
328
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 329
 					  DTT_ID int(10) unsigned NOT NULL,
331 330
 					  TKT_ID int(10) unsigned NOT NULL,
332 331
 					  PRIMARY KEY  (DTK_ID),
333 332
 					  KEY DTT_ID (DTT_ID),
334 333
 					  KEY TKT_ID (TKT_ID)";
335
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
336
-        $table_name = "esp_ticket_template";
337
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
334
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
335
+		$table_name = "esp_ticket_template";
336
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
338 337
 					  TTM_name varchar(45) NOT NULL,
339 338
 					  TTM_description text,
340 339
 					  TTM_file varchar(45),
341 340
 					  PRIMARY KEY  (TTM_ID)";
342
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
343
-        $table_name = 'esp_question';
344
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
341
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
342
+		$table_name = 'esp_question';
343
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
345 344
 					QST_display_text text NOT NULL,
346 345
 					QST_admin_label varchar(255) NOT NULL,
347 346
 					QST_system varchar(25) DEFAULT NULL,
@@ -354,18 +353,18 @@  discard block
 block discarded – undo
354 353
 					QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
355 354
 					PRIMARY KEY  (QST_ID),
356 355
 					KEY QST_order (QST_order)';
357
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
358
-        $table_name = 'esp_question_group_question';
359
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
356
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
357
+		$table_name = 'esp_question_group_question';
358
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
360 359
 					QSG_ID int(10) unsigned NOT NULL,
361 360
 					QST_ID int(10) unsigned NOT NULL,
362 361
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
363 362
 					PRIMARY KEY  (QGQ_ID),
364 363
 					KEY QST_ID (QST_ID),
365 364
 					KEY QSG_ID_order (QSG_ID, QGQ_order)";
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
367
-        $table_name = 'esp_question_option';
368
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
365
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
366
+		$table_name = 'esp_question_option';
367
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
369 368
 					QSO_value varchar(255) NOT NULL,
370 369
 					QSO_desc text NOT NULL,
371 370
 					QST_ID int(10) unsigned NOT NULL,
@@ -374,9 +373,9 @@  discard block
 block discarded – undo
374 373
 					PRIMARY KEY  (QSO_ID),
375 374
 					KEY QST_ID (QST_ID),
376 375
 					KEY QSO_order (QSO_order)";
377
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
378
-        $table_name = 'esp_registration';
379
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
376
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
377
+		$table_name = 'esp_registration';
378
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
380 379
 					  EVT_ID bigint(20) unsigned NOT NULL,
381 380
 					  ATT_ID bigint(20) unsigned NOT NULL,
382 381
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -400,18 +399,18 @@  discard block
 block discarded – undo
400 399
 					  KEY TKT_ID (TKT_ID),
401 400
 					  KEY EVT_ID (EVT_ID),
402 401
 					  KEY STS_ID (STS_ID)";
403
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
404
-        $table_name = 'esp_registration_payment';
405
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
403
+		$table_name = 'esp_registration_payment';
404
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
406 405
 					  REG_ID int(10) unsigned NOT NULL,
407 406
 					  PAY_ID int(10) unsigned NULL,
408 407
 					  RPY_amount decimal(10,3) NOT NULL DEFAULT '0.00',
409 408
 					  PRIMARY KEY  (RPY_ID),
410 409
 					  KEY REG_ID (REG_ID),
411 410
 					  KEY PAY_ID (PAY_ID)";
412
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
413
-        $table_name = 'esp_checkin';
414
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
411
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
412
+		$table_name = 'esp_checkin';
413
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
415 414
 					REG_ID int(10) unsigned NOT NULL,
416 415
 					DTT_ID int(10) unsigned NOT NULL,
417 416
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -419,9 +418,9 @@  discard block
 block discarded – undo
419 418
 					PRIMARY KEY  (CHK_ID),
420 419
 					KEY REG_ID (REG_ID),
421 420
 					KEY DTT_ID (DTT_ID)";
422
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
423
-        $table_name = 'esp_state';
424
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
421
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
422
+		$table_name = 'esp_state';
423
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
425 424
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
426 425
 					  STA_abbrev varchar(24) COLLATE utf8_bin NOT NULL,
427 426
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
@@ -429,9 +428,9 @@  discard block
 block discarded – undo
429 428
 					  PRIMARY KEY  (STA_ID),
430 429
 					  KEY STA_abbrev (STA_abbrev),
431 430
 					  KEY CNT_ISO (CNT_ISO)";
432
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
433
-        $table_name = 'esp_status';
434
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
431
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
432
+		$table_name = 'esp_status';
433
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
435 434
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
436 435
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
437 436
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -439,9 +438,9 @@  discard block
 block discarded – undo
439 438
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
440 439
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
441 440
 					  KEY STS_type (STS_type)";
442
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
443
-        $table_name = 'esp_transaction';
444
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
441
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
442
+		$table_name = 'esp_transaction';
443
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
445 444
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
446 445
 					  TXN_total decimal(10,3) DEFAULT '0.00',
447 446
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -453,9 +452,9 @@  discard block
 block discarded – undo
453 452
 					  PRIMARY KEY  (TXN_ID),
454 453
 					  KEY TXN_timestamp (TXN_timestamp),
455 454
 					  KEY STS_ID (STS_ID)";
456
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
457
-        $table_name = 'esp_venue_meta';
458
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
455
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
456
+		$table_name = 'esp_venue_meta';
457
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
459 458
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
460 459
 			VNU_address varchar(255) DEFAULT NULL,
461 460
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -474,10 +473,10 @@  discard block
 block discarded – undo
474 473
 			KEY VNU_ID (VNU_ID),
475 474
 			KEY STA_ID (STA_ID),
476 475
 			KEY CNT_ISO (CNT_ISO)";
477
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
478
-        // modified tables
479
-        $table_name = "esp_price";
480
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
476
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
477
+		// modified tables
478
+		$table_name = "esp_price";
479
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
481 480
 					  PRT_ID tinyint(3) unsigned NOT NULL,
482 481
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
483 482
 					  PRC_name varchar(245) NOT NULL,
@@ -490,9 +489,9 @@  discard block
 block discarded – undo
490 489
 					  PRC_parent int(10) unsigned DEFAULT 0,
491 490
 					  PRIMARY KEY  (PRC_ID),
492 491
 					  KEY PRT_ID (PRT_ID)";
493
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
494
-        $table_name = "esp_price_type";
495
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
492
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
493
+		$table_name = "esp_price_type";
494
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
496 495
 				  PRT_name varchar(45) NOT NULL,
497 496
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
498 497
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -501,9 +500,9 @@  discard block
 block discarded – undo
501 500
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
502 501
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
503 502
 				  PRIMARY KEY  (PRT_ID)";
504
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
505
-        $table_name = "esp_ticket";
506
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
503
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
504
+		$table_name = "esp_ticket";
505
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
507 506
 					  TTM_ID int(10) unsigned NOT NULL,
508 507
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
509 508
 					  TKT_description text NOT NULL,
@@ -525,9 +524,9 @@  discard block
 block discarded – undo
525 524
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
526 525
 					  PRIMARY KEY  (TKT_ID),
527 526
 					  KEY TKT_start_date (TKT_start_date)";
528
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
529
-        $table_name = 'esp_question_group';
530
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
527
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
528
+		$table_name = 'esp_question_group';
529
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
531 530
 					QSG_name varchar(255) NOT NULL,
532 531
 					QSG_identifier varchar(100) NOT NULL,
533 532
 					QSG_desc text NULL,
@@ -540,38 +539,38 @@  discard block
 block discarded – undo
540 539
 					PRIMARY KEY  (QSG_ID),
541 540
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
542 541
 					KEY QSG_order (QSG_order)';
543
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
544
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
545
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
546
-        // (because many need to convert old string states to foreign keys into the states table)
547
-        $script_4_1_defaults->insert_default_states();
548
-        $script_4_1_defaults->insert_default_countries();
549
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
550
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
551
-        $script_4_5_defaults->insert_default_price_types();
552
-        $script_4_5_defaults->insert_default_prices();
553
-        $script_4_5_defaults->insert_default_tickets();
554
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
555
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
556
-        $script_4_6_defaults->add_default_admin_only_payments();
557
-        $script_4_6_defaults->insert_default_currencies();
558
-        return true;
559
-    }
542
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
543
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
544
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
545
+		// (because many need to convert old string states to foreign keys into the states table)
546
+		$script_4_1_defaults->insert_default_states();
547
+		$script_4_1_defaults->insert_default_countries();
548
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
549
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
550
+		$script_4_5_defaults->insert_default_price_types();
551
+		$script_4_5_defaults->insert_default_prices();
552
+		$script_4_5_defaults->insert_default_tickets();
553
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
554
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
555
+		$script_4_6_defaults->add_default_admin_only_payments();
556
+		$script_4_6_defaults->insert_default_currencies();
557
+		return true;
558
+	}
560 559
 
561 560
 
562 561
 
563
-    /**
564
-     * @return boolean
565
-     */
566
-    public function schema_changes_after_migration()
567
-    {
568
-        return true;
569
-    }
562
+	/**
563
+	 * @return boolean
564
+	 */
565
+	public function schema_changes_after_migration()
566
+	{
567
+		return true;
568
+	}
570 569
 
571 570
 
572 571
 
573
-    public function migration_page_hooks()
574
-    {
575
-    }
572
+	public function migration_page_hooks()
573
+	{
574
+	}
576 575
 }
577 576
 // end of file: /core/data_migration_scripts/EE_DMS_Core_4_7_0.dms.php
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_9_0.dms.php 1 patch
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 foreach ($stages as $filepath) {
15
-    $matches = array();
16
-    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
17
-    $class_to_filepath[ $matches[1] ] = $filepath;
15
+	$matches = array();
16
+	preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
17
+	$class_to_filepath[ $matches[1] ] = $filepath;
18 18
 }
19 19
 // give addons a chance to autoload their stages too
20 20
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -33,68 +33,68 @@  discard block
 block discarded – undo
33 33
 class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
34 34
 {
35 35
 
36
-    /**
37
-     * return EE_DMS_Core_4_9_0
38
-     *
39
-     * @param TableManager  $table_manager
40
-     * @param TableAnalysis $table_analysis
41
-     */
42
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
43
-    {
44
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
45
-        $this->_priority = 10;
46
-        $this->_migration_stages = array(
47
-            new EE_DMS_4_9_0_Email_System_Question(),
48
-            new EE_DMS_4_9_0_Answers_With_No_Registration(),
49
-        );
50
-        parent::__construct($table_manager, $table_analysis);
51
-    }
36
+	/**
37
+	 * return EE_DMS_Core_4_9_0
38
+	 *
39
+	 * @param TableManager  $table_manager
40
+	 * @param TableAnalysis $table_analysis
41
+	 */
42
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
43
+	{
44
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
45
+		$this->_priority = 10;
46
+		$this->_migration_stages = array(
47
+			new EE_DMS_4_9_0_Email_System_Question(),
48
+			new EE_DMS_4_9_0_Answers_With_No_Registration(),
49
+		);
50
+		parent::__construct($table_manager, $table_analysis);
51
+	}
52 52
 
53 53
 
54 54
 
55
-    /**
56
-     * Whether to migrate or not.
57
-     *
58
-     * @param array $version_array
59
-     * @return bool
60
-     */
61
-    public function can_migrate_from_version($version_array)
62
-    {
63
-        $version_string = $version_array['Core'];
64
-        if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
65
-            //          echo "$version_string can be migrated from";
66
-            return true;
67
-        } elseif (! $version_string) {
68
-            //          echo "no version string provided: $version_string";
69
-            // no version string provided... this must be pre 4.3
70
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
71
-        } else {
72
-            //          echo "$version_string doesnt apply";
73
-            return false;
74
-        }
75
-    }
55
+	/**
56
+	 * Whether to migrate or not.
57
+	 *
58
+	 * @param array $version_array
59
+	 * @return bool
60
+	 */
61
+	public function can_migrate_from_version($version_array)
62
+	{
63
+		$version_string = $version_array['Core'];
64
+		if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
65
+			//          echo "$version_string can be migrated from";
66
+			return true;
67
+		} elseif (! $version_string) {
68
+			//          echo "no version string provided: $version_string";
69
+			// no version string provided... this must be pre 4.3
70
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
71
+		} else {
72
+			//          echo "$version_string doesnt apply";
73
+			return false;
74
+		}
75
+	}
76 76
 
77 77
 
78 78
 
79
-    /**
80
-     * @return bool
81
-     */
82
-    public function schema_changes_before_migration()
83
-    {
84
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
85
-        $now_in_mysql = current_time('mysql', true);
86
-        $table_name = 'esp_answer';
87
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79
+	/**
80
+	 * @return bool
81
+	 */
82
+	public function schema_changes_before_migration()
83
+	{
84
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
85
+		$now_in_mysql = current_time('mysql', true);
86
+		$table_name = 'esp_answer';
87
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
88 88
 					REG_ID int(10) unsigned NOT NULL,
89 89
 					QST_ID int(10) unsigned NOT NULL,
90 90
 					ANS_value text NOT NULL,
91 91
 					PRIMARY KEY  (ANS_ID),
92 92
 					KEY REG_ID (REG_ID),
93 93
 					KEY QST_ID (QST_ID)";
94
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
95
-        $table_name = 'esp_attendee_meta';
96
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
97
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
95
+		$table_name = 'esp_attendee_meta';
96
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
97
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 98
 				ATT_ID bigint(20) unsigned NOT NULL,
99 99
 				ATT_fname varchar(45) NOT NULL,
100 100
 				ATT_lname varchar(45) NOT NULL,
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 				KEY ATT_email (ATT_email(191)),
112 112
 				KEY ATT_lname (ATT_lname),
113 113
 				KEY ATT_fname (ATT_fname)";
114
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
115
-        $table_name = 'esp_checkin';
116
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
114
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
115
+		$table_name = 'esp_checkin';
116
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117 117
 				REG_ID int(10) unsigned NOT NULL,
118 118
 				DTT_ID int(10) unsigned NOT NULL,
119 119
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 				PRIMARY KEY  (CHK_ID),
122 122
 				KEY REG_ID (REG_ID),
123 123
 				KEY DTT_ID (DTT_ID)";
124
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
-        $table_name = 'esp_country';
126
-        $sql = "CNT_ISO varchar(2) NOT NULL,
124
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
+		$table_name = 'esp_country';
126
+		$sql = "CNT_ISO varchar(2) NOT NULL,
127 127
 				CNT_ISO3 varchar(3) NOT NULL,
128 128
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
129 129
 				CNT_name varchar(45) NOT NULL,
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
 				CNT_is_EU tinyint(1) DEFAULT '0',
140 140
 				CNT_active tinyint(1) DEFAULT '0',
141 141
 				PRIMARY KEY  (CNT_ISO)";
142
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
-        $table_name = 'esp_currency';
144
-        $sql = "CUR_code varchar(6) NOT NULL,
142
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
+		$table_name = 'esp_currency';
144
+		$sql = "CUR_code varchar(6) NOT NULL,
145 145
 				CUR_single varchar(45) DEFAULT 'dollar',
146 146
 				CUR_plural varchar(45) DEFAULT 'dollars',
147 147
 				CUR_sign varchar(45) DEFAULT '$',
148 148
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
149 149
 				CUR_active tinyint(1) DEFAULT '0',
150 150
 				PRIMARY KEY  (CUR_code)";
151
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
-        // note: although this table is no longer in use,
153
-        // it hasn't been removed because then queries to the model will have errors.
154
-        // but you should expect this table and its corresponding model to be removed in
155
-        // the next few months
156
-        $table_name = 'esp_currency_payment_method';
157
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
151
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
+		// note: although this table is no longer in use,
153
+		// it hasn't been removed because then queries to the model will have errors.
154
+		// but you should expect this table and its corresponding model to be removed in
155
+		// the next few months
156
+		$table_name = 'esp_currency_payment_method';
157
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
158 158
 				CUR_code varchar(6) NOT NULL,
159 159
 				PMD_ID int(11) NOT NULL,
160 160
 				PRIMARY KEY  (CPM_ID),
161 161
 				KEY PMD_ID (PMD_ID)";
162
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
163
-        $table_name = 'esp_datetime';
164
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
162
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
163
+		$table_name = 'esp_datetime';
164
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
165 165
 				EVT_ID bigint(20) unsigned NOT NULL,
166 166
 				DTT_name varchar(255) NOT NULL DEFAULT '',
167 167
 				DTT_description text NOT NULL,
@@ -178,25 +178,25 @@  discard block
 block discarded – undo
178 178
 				KEY DTT_EVT_start (DTT_EVT_start),
179 179
 				KEY EVT_ID (EVT_ID),
180 180
 				KEY DTT_is_primary (DTT_is_primary)";
181
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
182
-        $table_name = "esp_datetime_ticket";
183
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
181
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
182
+		$table_name = "esp_datetime_ticket";
183
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
184 184
 				DTT_ID int(10) unsigned NOT NULL,
185 185
 				TKT_ID int(10) unsigned NOT NULL,
186 186
 				PRIMARY KEY  (DTK_ID),
187 187
 				KEY DTT_ID (DTT_ID),
188 188
 				KEY TKT_ID (TKT_ID)";
189
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
190
-        $table_name = 'esp_event_message_template';
191
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
189
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
190
+		$table_name = 'esp_event_message_template';
191
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
192 192
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
193 193
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
194 194
 				PRIMARY KEY  (EMT_ID),
195 195
 				KEY EVT_ID (EVT_ID),
196 196
 				KEY GRP_ID (GRP_ID)";
197
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_event_meta';
199
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
197
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
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,34 +211,34 @@  discard block
 block discarded – undo
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, 'ENGINE=InnoDB');
215
-        $table_name = 'esp_event_question_group';
216
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
214
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
215
+		$table_name = 'esp_event_question_group';
216
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
217 217
 				EVT_ID bigint(20) unsigned NOT NULL,
218 218
 				QSG_ID int(10) unsigned NOT NULL,
219 219
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
220 220
 				PRIMARY KEY  (EQG_ID),
221 221
 				KEY EVT_ID (EVT_ID),
222 222
 				KEY QSG_ID (QSG_ID)";
223
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
-        $table_name = 'esp_event_venue';
225
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
223
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
224
+		$table_name = 'esp_event_venue';
225
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
226 226
 				EVT_ID bigint(20) unsigned NOT NULL,
227 227
 				VNU_ID bigint(20) unsigned NOT NULL,
228 228
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
229 229
 				PRIMARY KEY  (EVV_ID)";
230
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
231
-        $table_name = 'esp_extra_meta';
232
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
230
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
231
+		$table_name = 'esp_extra_meta';
232
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
233 233
 				OBJ_ID int(11) DEFAULT NULL,
234 234
 				EXM_type varchar(45) DEFAULT NULL,
235 235
 				EXM_key varchar(45) DEFAULT NULL,
236 236
 				EXM_value text,
237 237
 				PRIMARY KEY  (EXM_ID),
238 238
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
239
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
240
-        $table_name = 'esp_extra_join';
241
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
239
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
240
+		$table_name = 'esp_extra_join';
241
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
242 242
 				EXJ_first_model_id varchar(6) NOT NULL,
243 243
 				EXJ_first_model_name varchar(20) NOT NULL,
244 244
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 				PRIMARY KEY  (EXJ_ID),
247 247
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
248 248
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
249
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
250
-        $table_name = 'esp_line_item';
251
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
249
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
250
+		$table_name = 'esp_line_item';
251
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
252 252
 				LIN_code varchar(245) NOT NULL DEFAULT '',
253 253
 				TXN_ID int(11) DEFAULT NULL,
254 254
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
270 270
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
271 271
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
272
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
273
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
274
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
275
-        $table_name = 'esp_log';
276
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
272
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
273
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
274
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
275
+		$table_name = 'esp_log';
276
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
277 277
 				LOG_time datetime DEFAULT NULL,
278 278
 				OBJ_ID varchar(45) DEFAULT NULL,
279 279
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 				KEY LOG_time (LOG_time),
285 285
 				KEY OBJ (OBJ_type,OBJ_ID),
286 286
 				KEY LOG_type (LOG_type)";
287
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
288
-        $table_name = 'esp_message';
289
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
290
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
291
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
292
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
287
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
288
+		$table_name = 'esp_message';
289
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
290
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
291
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
292
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
293 293
 				GRP_ID int(10) unsigned NULL,
294 294
 				MSG_token varchar(255) NULL,
295 295
 				TXN_ID int(10) unsigned NULL,
@@ -321,18 +321,18 @@  discard block
 block discarded – undo
321 321
 				KEY STS_ID (STS_ID),
322 322
 				KEY MSG_created (MSG_created),
323 323
 				KEY MSG_modified (MSG_modified)";
324
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
325
-        $table_name = 'esp_message_template';
326
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
324
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
325
+		$table_name = 'esp_message_template';
326
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327 327
 				GRP_ID int(10) unsigned NOT NULL,
328 328
 				MTP_context varchar(50) NOT NULL,
329 329
 				MTP_template_field varchar(30) NOT NULL,
330 330
 				MTP_content text NOT NULL,
331 331
 				PRIMARY KEY  (MTP_ID),
332 332
 				KEY GRP_ID (GRP_ID)";
333
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
334
-        $table_name = 'esp_message_template_group';
335
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
333
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
334
+		$table_name = 'esp_message_template_group';
335
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
336 336
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
337 337
 				MTP_name varchar(245) NOT NULL DEFAULT '',
338 338
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
345 345
 				PRIMARY KEY  (GRP_ID),
346 346
 				KEY MTP_user_id (MTP_user_id)";
347
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
348
-        $table_name = 'esp_payment';
349
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
347
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
348
+		$table_name = 'esp_payment';
349
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350 350
 				TXN_ID int(10) unsigned DEFAULT NULL,
351 351
 				STS_ID varchar(3) DEFAULT NULL,
352 352
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 				PRIMARY KEY  (PAY_ID),
364 364
 				KEY PAY_timestamp (PAY_timestamp),
365 365
 				KEY TXN_ID (TXN_ID)";
366
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
367
-        $table_name = 'esp_payment_method';
368
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
366
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
367
+		$table_name = 'esp_payment_method';
368
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
369 369
 				PMD_type varchar(124) DEFAULT NULL,
370 370
 				PMD_name varchar(255) DEFAULT NULL,
371 371
 				PMD_desc text,
@@ -381,24 +381,24 @@  discard block
 block discarded – undo
381 381
 				PRIMARY KEY  (PMD_ID),
382 382
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
383 383
 				KEY PMD_type (PMD_type)";
384
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
385
-        $table_name = "esp_ticket_price";
386
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
384
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
385
+		$table_name = "esp_ticket_price";
386
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387 387
 				TKT_ID int(10) unsigned NOT NULL,
388 388
 				PRC_ID int(10) unsigned NOT NULL,
389 389
 				PRIMARY KEY  (TKP_ID),
390 390
 				KEY TKT_ID (TKT_ID),
391 391
 				KEY PRC_ID (PRC_ID)";
392
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
393
-        $table_name = "esp_ticket_template";
394
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
392
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
393
+		$table_name = "esp_ticket_template";
394
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
395 395
 				TTM_name varchar(45) NOT NULL,
396 396
 				TTM_description text,
397 397
 				TTM_file varchar(45),
398 398
 				PRIMARY KEY  (TTM_ID)";
399
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
400
-        $table_name = 'esp_question';
401
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
399
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
400
+		$table_name = 'esp_question';
401
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402 402
 				QST_display_text text NOT NULL,
403 403
 				QST_admin_label varchar(255) NOT NULL,
404 404
 				QST_system varchar(25) DEFAULT NULL,
@@ -412,18 +412,18 @@  discard block
 block discarded – undo
412 412
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
413 413
 				PRIMARY KEY  (QST_ID),
414 414
 				KEY QST_order (QST_order)';
415
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
416
-        $table_name = 'esp_question_group_question';
417
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
415
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
416
+		$table_name = 'esp_question_group_question';
417
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
418 418
 				QSG_ID int(10) unsigned NOT NULL,
419 419
 				QST_ID int(10) unsigned NOT NULL,
420 420
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
421 421
 				PRIMARY KEY  (QGQ_ID),
422 422
 				KEY QST_ID (QST_ID),
423 423
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
424
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
425
-        $table_name = 'esp_question_option';
426
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
424
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
425
+		$table_name = 'esp_question_option';
426
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
427 427
 				QSO_value varchar(255) NOT NULL,
428 428
 				QSO_desc text NOT NULL,
429 429
 				QST_ID int(10) unsigned NOT NULL,
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 				PRIMARY KEY  (QSO_ID),
434 434
 				KEY QST_ID (QST_ID),
435 435
 				KEY QSO_order (QSO_order)";
436
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
437
-        $table_name = 'esp_registration';
438
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
436
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
437
+		$table_name = 'esp_registration';
438
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439 439
 				EVT_ID bigint(20) unsigned NOT NULL,
440 440
 				ATT_ID bigint(20) unsigned NOT NULL,
441 441
 				TXN_ID int(10) unsigned NOT NULL,
@@ -459,18 +459,18 @@  discard block
 block discarded – undo
459 459
 				KEY TKT_ID (TKT_ID),
460 460
 				KEY EVT_ID (EVT_ID),
461 461
 				KEY STS_ID (STS_ID)";
462
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
463
-        $table_name = 'esp_registration_payment';
464
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
462
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
463
+		$table_name = 'esp_registration_payment';
464
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
465 465
 					  REG_ID int(10) unsigned NOT NULL,
466 466
 					  PAY_ID int(10) unsigned NULL,
467 467
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
468 468
 					  PRIMARY KEY  (RPY_ID),
469 469
 					  KEY REG_ID (REG_ID),
470 470
 					  KEY PAY_ID (PAY_ID)";
471
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
472
-        $table_name = 'esp_state';
473
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
471
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
472
+		$table_name = 'esp_state';
473
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
474 474
 				CNT_ISO varchar(2) NOT NULL,
475 475
 				STA_abbrev varchar(24) NOT NULL,
476 476
 				STA_name varchar(100) NOT NULL,
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
 				PRIMARY KEY  (STA_ID),
479 479
 				KEY STA_abbrev (STA_abbrev),
480 480
 				KEY CNT_ISO (CNT_ISO)";
481
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
482
-        $table_name = 'esp_status';
483
-        $sql = "STS_ID varchar(3) NOT NULL,
481
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
482
+		$table_name = 'esp_status';
483
+		$sql = "STS_ID varchar(3) NOT NULL,
484 484
 				STS_code varchar(45) NOT NULL,
485 485
 				STS_type varchar(45) NOT NULL,
486 486
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -488,9 +488,9 @@  discard block
 block discarded – undo
488 488
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
489 489
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
490 490
 				KEY STS_type (STS_type)";
491
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
492
-        $table_name = 'esp_transaction';
493
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
491
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
492
+		$table_name = 'esp_transaction';
493
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
494 494
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
495 495
 				TXN_total decimal(12,3) DEFAULT '0.00',
496 496
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 				PRIMARY KEY  (TXN_ID),
503 503
 				KEY TXN_timestamp (TXN_timestamp),
504 504
 				KEY STS_ID (STS_ID)";
505
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
506
-        $table_name = 'esp_venue_meta';
507
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
505
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
506
+		$table_name = 'esp_venue_meta';
507
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
508 508
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
509 509
 			VNU_address varchar(255) DEFAULT NULL,
510 510
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 			KEY VNU_ID (VNU_ID),
524 524
 			KEY STA_ID (STA_ID),
525 525
 			KEY CNT_ISO (CNT_ISO)";
526
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
527
-        // modified tables
528
-        $table_name = "esp_price";
529
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
526
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
527
+		// modified tables
528
+		$table_name = "esp_price";
529
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
530 530
 				PRT_ID tinyint(3) unsigned NOT NULL,
531 531
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
532 532
 				PRC_name varchar(245) NOT NULL,
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
 				PRC_parent int(10) unsigned DEFAULT 0,
540 540
 				PRIMARY KEY  (PRC_ID),
541 541
 				KEY PRT_ID (PRT_ID)";
542
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
543
-        $table_name = "esp_price_type";
544
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
542
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
543
+		$table_name = "esp_price_type";
544
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
545 545
 				PRT_name varchar(45) NOT NULL,
546 546
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
547 547
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
551 551
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
552 552
 				PRIMARY KEY  (PRT_ID)";
553
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
554
-        $table_name = "esp_ticket";
555
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
553
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
554
+		$table_name = "esp_ticket";
555
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
556 556
 				TTM_ID int(10) unsigned NOT NULL,
557 557
 				TKT_name varchar(245) NOT NULL DEFAULT '',
558 558
 				TKT_description text NOT NULL,
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
576 576
 				PRIMARY KEY  (TKT_ID),
577 577
 				KEY TKT_start_date (TKT_start_date)";
578
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
579
-        $table_name = 'esp_question_group';
580
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
578
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
579
+		$table_name = 'esp_question_group';
580
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
581 581
 				QSG_name varchar(255) NOT NULL,
582 582
 				QSG_identifier varchar(100) NOT NULL,
583 583
 				QSG_desc text NULL,
@@ -590,145 +590,145 @@  discard block
 block discarded – undo
590 590
 				PRIMARY KEY  (QSG_ID),
591 591
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
592 592
 				KEY QSG_order (QSG_order)';
593
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
594
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
595
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
596
-        // (because many need to convert old string states to foreign keys into the states table)
597
-        $script_4_1_defaults->insert_default_states();
598
-        $script_4_1_defaults->insert_default_countries();
599
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
600
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
601
-        $script_4_5_defaults->insert_default_price_types();
602
-        $script_4_5_defaults->insert_default_prices();
603
-        $script_4_5_defaults->insert_default_tickets();
604
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
605
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
606
-        $script_4_6_defaults->add_default_admin_only_payments();
607
-        $script_4_6_defaults->insert_default_currencies();
608
-        /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
609
-        $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
610
-        $script_4_8_defaults->verify_new_countries();
611
-        $script_4_8_defaults->verify_new_currencies();
612
-        $this->verify_db_collations();
613
-        $this->verify_db_collations_again();
614
-        return true;
615
-    }
593
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
594
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
595
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
596
+		// (because many need to convert old string states to foreign keys into the states table)
597
+		$script_4_1_defaults->insert_default_states();
598
+		$script_4_1_defaults->insert_default_countries();
599
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
600
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
601
+		$script_4_5_defaults->insert_default_price_types();
602
+		$script_4_5_defaults->insert_default_prices();
603
+		$script_4_5_defaults->insert_default_tickets();
604
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
605
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
606
+		$script_4_6_defaults->add_default_admin_only_payments();
607
+		$script_4_6_defaults->insert_default_currencies();
608
+		/** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
609
+		$script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
610
+		$script_4_8_defaults->verify_new_countries();
611
+		$script_4_8_defaults->verify_new_currencies();
612
+		$this->verify_db_collations();
613
+		$this->verify_db_collations_again();
614
+		return true;
615
+	}
616 616
 
617 617
 
618 618
 
619
-    /**
620
-     * @return boolean
621
-     */
622
-    public function schema_changes_after_migration()
623
-    {
624
-        return true;
625
-    }
619
+	/**
620
+	 * @return boolean
621
+	 */
622
+	public function schema_changes_after_migration()
623
+	{
624
+		return true;
625
+	}
626 626
 
627 627
 
628 628
 
629
-    public function migration_page_hooks()
630
-    {
631
-    }
629
+	public function migration_page_hooks()
630
+	{
631
+	}
632 632
 
633 633
 
634 634
 
635
-    /**
636
-     * Verify all EE4 models' tables use utf8mb4 collation
637
-     *
638
-     * @return void
639
-     */
640
-    public function verify_db_collations()
641
-    {
642
-        global $wpdb;
643
-        // double-check we haven't already done it or that that the DB doesn't support utf8mb4
644
-        if ('utf8mb4' !== $wpdb->charset
645
-            || get_option('ee_verified_db_collations', false)) {
646
-            return;
647
-        }
648
-        // grab tables from each model
649
-        $tables_to_check = array();
650
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
651
-            if (method_exists($model_name, 'instance')) {
652
-                $model_obj = call_user_func(array($model_name, 'instance'));
653
-                if ($model_obj instanceof EEM_Base) {
654
-                    foreach ($model_obj->get_tables() as $table) {
655
-                        if (strpos($table->get_table_name(), 'esp_')
656
-                            && (is_main_site()// for main tables, verify global tables
657
-                                || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
658
-                            )
659
-                            && function_exists('maybe_convert_table_to_utf8mb4')
660
-                        ) {
661
-                            $tables_to_check[] = $table->get_table_name();
662
-                        }
663
-                    }
664
-                }
665
-            }
666
-        }
667
-        // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
668
-        // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
669
-        // of hard-coding this
670
-        $addon_tables = array(
671
-            // mailchimp
672
-            'esp_event_mailchimp_list_group',
673
-            'esp_event_question_mailchimp_field',
674
-            // multisite
675
-            'esp_blog_meta',
676
-            // people
677
-            'esp_people_to_post',
678
-            // promotions
679
-            'esp_promotion',
680
-            'esp_promotion_object',
681
-        );
682
-        foreach ($addon_tables as $table_name) {
683
-                $tables_to_check[] = $table_name;
684
-        }
685
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
686
-        // ok and now let's remember this was done (without needing to check the db schemas all over again)
687
-        add_option('ee_verified_db_collations', true, null, 'no');
688
-        // seeing how this ran with the fix from 10435, no need to check again
689
-        add_option('ee_verified_db_collations_again', true, null, 'no');
690
-    }
635
+	/**
636
+	 * Verify all EE4 models' tables use utf8mb4 collation
637
+	 *
638
+	 * @return void
639
+	 */
640
+	public function verify_db_collations()
641
+	{
642
+		global $wpdb;
643
+		// double-check we haven't already done it or that that the DB doesn't support utf8mb4
644
+		if ('utf8mb4' !== $wpdb->charset
645
+			|| get_option('ee_verified_db_collations', false)) {
646
+			return;
647
+		}
648
+		// grab tables from each model
649
+		$tables_to_check = array();
650
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
651
+			if (method_exists($model_name, 'instance')) {
652
+				$model_obj = call_user_func(array($model_name, 'instance'));
653
+				if ($model_obj instanceof EEM_Base) {
654
+					foreach ($model_obj->get_tables() as $table) {
655
+						if (strpos($table->get_table_name(), 'esp_')
656
+							&& (is_main_site()// for main tables, verify global tables
657
+								|| ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
658
+							)
659
+							&& function_exists('maybe_convert_table_to_utf8mb4')
660
+						) {
661
+							$tables_to_check[] = $table->get_table_name();
662
+						}
663
+					}
664
+				}
665
+			}
666
+		}
667
+		// and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
668
+		// when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
669
+		// of hard-coding this
670
+		$addon_tables = array(
671
+			// mailchimp
672
+			'esp_event_mailchimp_list_group',
673
+			'esp_event_question_mailchimp_field',
674
+			// multisite
675
+			'esp_blog_meta',
676
+			// people
677
+			'esp_people_to_post',
678
+			// promotions
679
+			'esp_promotion',
680
+			'esp_promotion_object',
681
+		);
682
+		foreach ($addon_tables as $table_name) {
683
+				$tables_to_check[] = $table_name;
684
+		}
685
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
686
+		// ok and now let's remember this was done (without needing to check the db schemas all over again)
687
+		add_option('ee_verified_db_collations', true, null, 'no');
688
+		// seeing how this ran with the fix from 10435, no need to check again
689
+		add_option('ee_verified_db_collations_again', true, null, 'no');
690
+	}
691 691
 
692 692
 
693 693
 
694
-    /**
695
-     * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
696
-     * which meant some DB collations might not have been updated
697
-     * @return void
698
-     */
699
-    public function verify_db_collations_again()
700
-    {
701
-        global $wpdb;
702
-        // double-check we haven't already done this or that the DB doesn't support it
703
-        // compare to how WordPress' upgrade_430() function does this check
704
-        if ('utf8mb4' !== $wpdb->charset
705
-            || get_option('ee_verified_db_collations_again', false)) {
706
-            return;
707
-        }
708
-        $tables_to_check = array(
709
-            'esp_attendee_meta',
710
-            'esp_message'
711
-        );
712
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
713
-        add_option('ee_verified_db_collations_again', true, null, 'no');
714
-    }
694
+	/**
695
+	 * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
696
+	 * which meant some DB collations might not have been updated
697
+	 * @return void
698
+	 */
699
+	public function verify_db_collations_again()
700
+	{
701
+		global $wpdb;
702
+		// double-check we haven't already done this or that the DB doesn't support it
703
+		// compare to how WordPress' upgrade_430() function does this check
704
+		if ('utf8mb4' !== $wpdb->charset
705
+			|| get_option('ee_verified_db_collations_again', false)) {
706
+			return;
707
+		}
708
+		$tables_to_check = array(
709
+			'esp_attendee_meta',
710
+			'esp_message'
711
+		);
712
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
713
+		add_option('ee_verified_db_collations_again', true, null, 'no');
714
+	}
715 715
 
716 716
 
717 717
 
718
-    /**
719
-     * Runs maybe_convert_table_to_utf8mb4 on the specified tables
720
-     * @param $tables_to_check
721
-     * @return boolean true if logic ran, false if it didn't
722
-     */
723
-    protected function _verify_db_collations_for_tables($tables_to_check)
724
-    {
725
-        foreach ($tables_to_check as $table_name) {
726
-            $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
727
-            if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
728
-                && $this->_get_table_analysis()->tableExists($table_name)
729
-            ) {
730
-                maybe_convert_table_to_utf8mb4($table_name);
731
-            }
732
-        }
733
-    }
718
+	/**
719
+	 * Runs maybe_convert_table_to_utf8mb4 on the specified tables
720
+	 * @param $tables_to_check
721
+	 * @return boolean true if logic ran, false if it didn't
722
+	 */
723
+	protected function _verify_db_collations_for_tables($tables_to_check)
724
+	{
725
+		foreach ($tables_to_check as $table_name) {
726
+			$table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
727
+			if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
728
+				&& $this->_get_table_analysis()->tableExists($table_name)
729
+			) {
730
+				maybe_convert_table_to_utf8mb4($table_name);
731
+			}
732
+		}
733
+	}
734 734
 }
Please login to merge, or discard this patch.
caffeinated/brewing_regular.php 2 patches
Indentation   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -27,322 +27,322 @@
 block discarded – undo
27 27
 class EE_Brewing_Regular extends EE_BASE implements InterminableInterface
28 28
 {
29 29
 
30
-    /**
31
-     * @var TableAnalysis $table_analysis
32
-     */
33
-    protected $_table_analysis;
34
-
35
-
36
-    /**
37
-     * EE_Brewing_Regular constructor.
38
-     *
39
-     * @param TableAnalysis $table_analysis
40
-     */
41
-    public function __construct(TableAnalysis $table_analysis)
42
-    {
43
-        $this->_table_analysis = $table_analysis;
44
-        if (defined('EE_CAFF_PATH')) {
45
-            $this->setInitializationHooks();
46
-            $this->setApiRegistrationHooks();
47
-            $this->setSwitchHooks();
48
-            $this->setDefaultFilterHooks();
49
-            // caffeinated constructed
50
-            do_action('AHEE__EE_Brewing_Regular__construct__complete');
51
-        }
52
-    }
53
-
54
-
55
-    /**
56
-     * Various hooks used for extending features via registration of modules or extensions.
57
-     */
58
-    private function setApiRegistrationHooks()
59
-    {
60
-        add_filter(
61
-            'FHEE__EE_Config__register_modules__modules_to_register',
62
-            array($this, 'caffeinated_modules_to_register')
63
-        );
64
-        add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
65
-        add_filter(
66
-            'AHEE__EE_System__load_core_configuration__complete',
67
-            function () {
68
-                EE_Register_Payment_Method::register(
69
-                    'caffeinated_payment_methods',
70
-                    array(
71
-                        'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
72
-                    )
73
-                );
74
-            }
75
-        );
76
-    }
77
-
78
-
79
-    /**
80
-     * Various hooks used for modifying initialization or activation processes.
81
-     */
82
-    private function setInitializationHooks()
83
-    {
84
-        // activation
85
-        add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
86
-        // load caff init
87
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
88
-        // load caff scripts
89
-        add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
90
-    }
91
-
92
-
93
-    /**
94
-     * Various hooks used for switch (on/off) type filters.
95
-     */
96
-    private function setSwitchHooks()
97
-    {
98
-        // remove the "powered by" credit link from receipts and invoices
99
-        add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
100
-        // seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
101
-        add_filter('FHEE__ee_show_affiliate_links', '__return_false');
102
-    }
103
-
104
-
105
-    /**
106
-     * Various filters for affecting default configuration values in the caffeinated
107
-     * context.
108
-     */
109
-    private function setDefaultFilterHooks()
110
-    {
111
-        add_filter(
112
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
113
-            '__return_true'
114
-        );
115
-    }
116
-
117
-
118
-    /**
119
-     * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
120
-     *
121
-     * @param array $paths original helper paths array
122
-     * @return array             new array of paths
123
-     */
124
-    public function caf_helper_paths($paths)
125
-    {
126
-        $paths[] = EE_CAF_CORE . 'helpers' . DS;
127
-        return $paths;
128
-    }
129
-
130
-
131
-    /**
132
-     * Upon brand-new activation, if this is a new activation of CAF, we want to add
133
-     * some global prices that will show off EE4's capabilities. However, if they're upgrading
134
-     * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
135
-     * This action should only be called when EE 4.x.0.P is initially activated.
136
-     * Right now the only CAF content are these global prices. If there's more in the future, then
137
-     * we should probably create a caf file to contain it all instead just a function like this.
138
-     * Right now, we ASSUME the only price types in the system are default ones
139
-     *
140
-     * @global wpdb $wpdb
141
-     */
142
-    public function initialize_caf_db_content()
143
-    {
144
-        global $wpdb;
145
-        // use same method of getting creator id as the version introducing the change
146
-        $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
147
-        $price_type_table = $wpdb->prefix . "esp_price_type";
148
-        $price_table = $wpdb->prefix . "esp_price";
149
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
150
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
151
-            $tax_price_type_count = $wpdb->get_var($SQL);
152
-            if ($tax_price_type_count <= 1) {
153
-                $wpdb->insert(
154
-                    $price_type_table,
155
-                    array(
156
-                        'PRT_name'       => __("Regional Tax", "event_espresso"),
157
-                        'PBT_ID'         => 4,
158
-                        'PRT_is_percent' => true,
159
-                        'PRT_order'      => 60,
160
-                        'PRT_deleted'    => false,
161
-                        'PRT_wp_user'    => $default_creator_id,
162
-                    ),
163
-                    array(
164
-                        '%s',// PRT_name
165
-                        '%d',// PBT_id
166
-                        '%d',// PRT_is_percent
167
-                        '%d',// PRT_order
168
-                        '%d',// PRT_deleted
169
-                        '%d', // PRT_wp_user
170
-                    )
171
-                );
172
-                // federal tax
173
-                $result = $wpdb->insert(
174
-                    $price_type_table,
175
-                    array(
176
-                        'PRT_name'       => __("Federal Tax", "event_espresso"),
177
-                        'PBT_ID'         => 4,
178
-                        'PRT_is_percent' => true,
179
-                        'PRT_order'      => 70,
180
-                        'PRT_deleted'    => false,
181
-                        'PRT_wp_user'    => $default_creator_id,
182
-                    ),
183
-                    array(
184
-                        '%s',// PRT_name
185
-                        '%d',// PBT_id
186
-                        '%d',// PRT_is_percent
187
-                        '%d',// PRT_order
188
-                        '%d',// PRT_deleted
189
-                        '%d' // PRT_wp_user
190
-                    )
191
-                );
192
-                if ($result) {
193
-                    $wpdb->insert(
194
-                        $price_table,
195
-                        array(
196
-                            'PRT_ID'         => $wpdb->insert_id,
197
-                            'PRC_amount'     => 15.00,
198
-                            'PRC_name'       => __("Sales Tax", "event_espresso"),
199
-                            'PRC_desc'       => '',
200
-                            'PRC_is_default' => true,
201
-                            'PRC_overrides'  => null,
202
-                            'PRC_deleted'    => false,
203
-                            'PRC_order'      => 50,
204
-                            'PRC_parent'     => null,
205
-                            'PRC_wp_user'    => $default_creator_id,
206
-                        ),
207
-                        array(
208
-                            '%d',// PRT_id
209
-                            '%f',// PRC_amount
210
-                            '%s',// PRC_name
211
-                            '%s',// PRC_desc
212
-                            '%d',// PRC_is_default
213
-                            '%d',// PRC_overrides
214
-                            '%d',// PRC_deleted
215
-                            '%d',// PRC_order
216
-                            '%d',// PRC_parent
217
-                            '%d' // PRC_wp_user
218
-                        )
219
-                    );
220
-                }
221
-            }
222
-        }
223
-    }
224
-
225
-
226
-    /**
227
-     *    caffeinated_modules_to_register
228
-     *
229
-     * @access public
230
-     * @param array $modules_to_register
231
-     * @return array
232
-     */
233
-    public function caffeinated_modules_to_register($modules_to_register = array())
234
-    {
235
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
236
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
237
-            if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
238
-                $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
239
-            }
240
-        }
241
-        return $modules_to_register;
242
-    }
243
-
244
-
245
-    /**
246
-     * @throws EE_Error
247
-     * @throws InvalidArgumentException
248
-     * @throws ReflectionException
249
-     * @throws InvalidDataTypeException
250
-     * @throws InvalidInterfaceException
251
-     */
252
-    public function caffeinated_init()
253
-    {
254
-        // Custom Post Type hooks
255
-        add_filter(
256
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
257
-            array($this, 'filter_taxonomies')
258
-        );
259
-        add_filter(
260
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
261
-            array($this, 'filter_cpts')
262
-        );
263
-        add_filter(
264
-            'FHEE__EE_Admin__get_extra_nav_menu_pages_items',
265
-            array($this, 'nav_metabox_items')
266
-        );
267
-        EE_Registry::instance()->load_file(
268
-            EE_CAFF_PATH,
269
-            'EE_Caf_Messages',
270
-            'class',
271
-            array(),
272
-            false
273
-        );
274
-        // caffeinated_init__complete hook
275
-        do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
276
-    }
277
-
278
-
279
-    public function enqueue_caffeinated_scripts()
280
-    {
281
-        // sound of crickets...
282
-    }
283
-
284
-
285
-    /**
286
-     * callbacks below here
287
-     *
288
-     * @param array $taxonomy_array
289
-     * @return array
290
-     */
291
-    public function filter_taxonomies(array $taxonomy_array)
292
-    {
293
-        $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
294
-        return $taxonomy_array;
295
-    }
296
-
297
-
298
-    /**
299
-     * @param array $cpt_array
300
-     * @return mixed
301
-     */
302
-    public function filter_cpts(array $cpt_array)
303
-    {
304
-        $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
305
-        return $cpt_array;
306
-    }
307
-
308
-
309
-    /**
310
-     * @param array $menuitems
311
-     * @return array
312
-     */
313
-    public function nav_metabox_items(array $menuitems)
314
-    {
315
-        $menuitems[] = array(
316
-            'title'       => __('Venue List', 'event_espresso'),
317
-            'url'         => get_post_type_archive_link('espresso_venues'),
318
-            'description' => __('Archive page for all venues.', 'event_espresso'),
319
-        );
320
-        return $menuitems;
321
-    }
322
-
323
-
324
-    /**
325
-     * Gets the injected table analyzer, or throws an exception
326
-     *
327
-     * @return TableAnalysis
328
-     * @throws \EE_Error
329
-     */
330
-    protected function _get_table_analysis()
331
-    {
332
-        if ($this->_table_analysis instanceof TableAnalysis) {
333
-            return $this->_table_analysis;
334
-        } else {
335
-            throw new \EE_Error(
336
-                sprintf(
337
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
338
-                    get_class($this)
339
-                )
340
-            );
341
-        }
342
-    }
30
+	/**
31
+	 * @var TableAnalysis $table_analysis
32
+	 */
33
+	protected $_table_analysis;
34
+
35
+
36
+	/**
37
+	 * EE_Brewing_Regular constructor.
38
+	 *
39
+	 * @param TableAnalysis $table_analysis
40
+	 */
41
+	public function __construct(TableAnalysis $table_analysis)
42
+	{
43
+		$this->_table_analysis = $table_analysis;
44
+		if (defined('EE_CAFF_PATH')) {
45
+			$this->setInitializationHooks();
46
+			$this->setApiRegistrationHooks();
47
+			$this->setSwitchHooks();
48
+			$this->setDefaultFilterHooks();
49
+			// caffeinated constructed
50
+			do_action('AHEE__EE_Brewing_Regular__construct__complete');
51
+		}
52
+	}
53
+
54
+
55
+	/**
56
+	 * Various hooks used for extending features via registration of modules or extensions.
57
+	 */
58
+	private function setApiRegistrationHooks()
59
+	{
60
+		add_filter(
61
+			'FHEE__EE_Config__register_modules__modules_to_register',
62
+			array($this, 'caffeinated_modules_to_register')
63
+		);
64
+		add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
65
+		add_filter(
66
+			'AHEE__EE_System__load_core_configuration__complete',
67
+			function () {
68
+				EE_Register_Payment_Method::register(
69
+					'caffeinated_payment_methods',
70
+					array(
71
+						'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
72
+					)
73
+				);
74
+			}
75
+		);
76
+	}
77
+
78
+
79
+	/**
80
+	 * Various hooks used for modifying initialization or activation processes.
81
+	 */
82
+	private function setInitializationHooks()
83
+	{
84
+		// activation
85
+		add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
86
+		// load caff init
87
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
88
+		// load caff scripts
89
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
90
+	}
91
+
92
+
93
+	/**
94
+	 * Various hooks used for switch (on/off) type filters.
95
+	 */
96
+	private function setSwitchHooks()
97
+	{
98
+		// remove the "powered by" credit link from receipts and invoices
99
+		add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
100
+		// seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
101
+		add_filter('FHEE__ee_show_affiliate_links', '__return_false');
102
+	}
103
+
104
+
105
+	/**
106
+	 * Various filters for affecting default configuration values in the caffeinated
107
+	 * context.
108
+	 */
109
+	private function setDefaultFilterHooks()
110
+	{
111
+		add_filter(
112
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
113
+			'__return_true'
114
+		);
115
+	}
116
+
117
+
118
+	/**
119
+	 * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
120
+	 *
121
+	 * @param array $paths original helper paths array
122
+	 * @return array             new array of paths
123
+	 */
124
+	public function caf_helper_paths($paths)
125
+	{
126
+		$paths[] = EE_CAF_CORE . 'helpers' . DS;
127
+		return $paths;
128
+	}
129
+
130
+
131
+	/**
132
+	 * Upon brand-new activation, if this is a new activation of CAF, we want to add
133
+	 * some global prices that will show off EE4's capabilities. However, if they're upgrading
134
+	 * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
135
+	 * This action should only be called when EE 4.x.0.P is initially activated.
136
+	 * Right now the only CAF content are these global prices. If there's more in the future, then
137
+	 * we should probably create a caf file to contain it all instead just a function like this.
138
+	 * Right now, we ASSUME the only price types in the system are default ones
139
+	 *
140
+	 * @global wpdb $wpdb
141
+	 */
142
+	public function initialize_caf_db_content()
143
+	{
144
+		global $wpdb;
145
+		// use same method of getting creator id as the version introducing the change
146
+		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
147
+		$price_type_table = $wpdb->prefix . "esp_price_type";
148
+		$price_table = $wpdb->prefix . "esp_price";
149
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
150
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
151
+			$tax_price_type_count = $wpdb->get_var($SQL);
152
+			if ($tax_price_type_count <= 1) {
153
+				$wpdb->insert(
154
+					$price_type_table,
155
+					array(
156
+						'PRT_name'       => __("Regional Tax", "event_espresso"),
157
+						'PBT_ID'         => 4,
158
+						'PRT_is_percent' => true,
159
+						'PRT_order'      => 60,
160
+						'PRT_deleted'    => false,
161
+						'PRT_wp_user'    => $default_creator_id,
162
+					),
163
+					array(
164
+						'%s',// PRT_name
165
+						'%d',// PBT_id
166
+						'%d',// PRT_is_percent
167
+						'%d',// PRT_order
168
+						'%d',// PRT_deleted
169
+						'%d', // PRT_wp_user
170
+					)
171
+				);
172
+				// federal tax
173
+				$result = $wpdb->insert(
174
+					$price_type_table,
175
+					array(
176
+						'PRT_name'       => __("Federal Tax", "event_espresso"),
177
+						'PBT_ID'         => 4,
178
+						'PRT_is_percent' => true,
179
+						'PRT_order'      => 70,
180
+						'PRT_deleted'    => false,
181
+						'PRT_wp_user'    => $default_creator_id,
182
+					),
183
+					array(
184
+						'%s',// PRT_name
185
+						'%d',// PBT_id
186
+						'%d',// PRT_is_percent
187
+						'%d',// PRT_order
188
+						'%d',// PRT_deleted
189
+						'%d' // PRT_wp_user
190
+					)
191
+				);
192
+				if ($result) {
193
+					$wpdb->insert(
194
+						$price_table,
195
+						array(
196
+							'PRT_ID'         => $wpdb->insert_id,
197
+							'PRC_amount'     => 15.00,
198
+							'PRC_name'       => __("Sales Tax", "event_espresso"),
199
+							'PRC_desc'       => '',
200
+							'PRC_is_default' => true,
201
+							'PRC_overrides'  => null,
202
+							'PRC_deleted'    => false,
203
+							'PRC_order'      => 50,
204
+							'PRC_parent'     => null,
205
+							'PRC_wp_user'    => $default_creator_id,
206
+						),
207
+						array(
208
+							'%d',// PRT_id
209
+							'%f',// PRC_amount
210
+							'%s',// PRC_name
211
+							'%s',// PRC_desc
212
+							'%d',// PRC_is_default
213
+							'%d',// PRC_overrides
214
+							'%d',// PRC_deleted
215
+							'%d',// PRC_order
216
+							'%d',// PRC_parent
217
+							'%d' // PRC_wp_user
218
+						)
219
+					);
220
+				}
221
+			}
222
+		}
223
+	}
224
+
225
+
226
+	/**
227
+	 *    caffeinated_modules_to_register
228
+	 *
229
+	 * @access public
230
+	 * @param array $modules_to_register
231
+	 * @return array
232
+	 */
233
+	public function caffeinated_modules_to_register($modules_to_register = array())
234
+	{
235
+		if (is_readable(EE_CAFF_PATH . 'modules')) {
236
+			$caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
237
+			if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
238
+				$modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
239
+			}
240
+		}
241
+		return $modules_to_register;
242
+	}
243
+
244
+
245
+	/**
246
+	 * @throws EE_Error
247
+	 * @throws InvalidArgumentException
248
+	 * @throws ReflectionException
249
+	 * @throws InvalidDataTypeException
250
+	 * @throws InvalidInterfaceException
251
+	 */
252
+	public function caffeinated_init()
253
+	{
254
+		// Custom Post Type hooks
255
+		add_filter(
256
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
257
+			array($this, 'filter_taxonomies')
258
+		);
259
+		add_filter(
260
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
261
+			array($this, 'filter_cpts')
262
+		);
263
+		add_filter(
264
+			'FHEE__EE_Admin__get_extra_nav_menu_pages_items',
265
+			array($this, 'nav_metabox_items')
266
+		);
267
+		EE_Registry::instance()->load_file(
268
+			EE_CAFF_PATH,
269
+			'EE_Caf_Messages',
270
+			'class',
271
+			array(),
272
+			false
273
+		);
274
+		// caffeinated_init__complete hook
275
+		do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
276
+	}
277
+
278
+
279
+	public function enqueue_caffeinated_scripts()
280
+	{
281
+		// sound of crickets...
282
+	}
283
+
284
+
285
+	/**
286
+	 * callbacks below here
287
+	 *
288
+	 * @param array $taxonomy_array
289
+	 * @return array
290
+	 */
291
+	public function filter_taxonomies(array $taxonomy_array)
292
+	{
293
+		$taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
294
+		return $taxonomy_array;
295
+	}
296
+
297
+
298
+	/**
299
+	 * @param array $cpt_array
300
+	 * @return mixed
301
+	 */
302
+	public function filter_cpts(array $cpt_array)
303
+	{
304
+		$cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
305
+		return $cpt_array;
306
+	}
307
+
308
+
309
+	/**
310
+	 * @param array $menuitems
311
+	 * @return array
312
+	 */
313
+	public function nav_metabox_items(array $menuitems)
314
+	{
315
+		$menuitems[] = array(
316
+			'title'       => __('Venue List', 'event_espresso'),
317
+			'url'         => get_post_type_archive_link('espresso_venues'),
318
+			'description' => __('Archive page for all venues.', 'event_espresso'),
319
+		);
320
+		return $menuitems;
321
+	}
322
+
323
+
324
+	/**
325
+	 * Gets the injected table analyzer, or throws an exception
326
+	 *
327
+	 * @return TableAnalysis
328
+	 * @throws \EE_Error
329
+	 */
330
+	protected function _get_table_analysis()
331
+	{
332
+		if ($this->_table_analysis instanceof TableAnalysis) {
333
+			return $this->_table_analysis;
334
+		} else {
335
+			throw new \EE_Error(
336
+				sprintf(
337
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
338
+					get_class($this)
339
+				)
340
+			);
341
+		}
342
+	}
343 343
 }
344 344
 
345 345
 
346 346
 $brewing = new EE_Brewing_Regular(
347
-    EE_Registry::instance()->create('TableAnalysis', array(), true)
347
+	EE_Registry::instance()->create('TableAnalysis', array(), true)
348 348
 );
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
  * define and use the hook in a specific caffeinated/whatever class or file.
12 12
  */
13 13
 // defined some new constants related to caffeinated folder
14
-define('EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/');
15
-define('EE_CAF_CORE', EE_CAFF_PATH . 'core' . DS);
16
-define('EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries' . DS);
17
-define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods' . DS);
14
+define('EE_CAF_URL', EE_PLUGIN_DIR_URL.'caffeinated/');
15
+define('EE_CAF_CORE', EE_CAFF_PATH.'core'.DS);
16
+define('EE_CAF_LIBRARIES', EE_CAF_CORE.'libraries'.DS);
17
+define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH.'payment_methods'.DS);
18 18
 
19 19
 
20 20
 /**
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
         add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
65 65
         add_filter(
66 66
             'AHEE__EE_System__load_core_configuration__complete',
67
-            function () {
67
+            function() {
68 68
                 EE_Register_Payment_Method::register(
69 69
                     'caffeinated_payment_methods',
70 70
                     array(
71
-                        'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR),
71
+                        'payment_method_paths' => glob(EE_CAF_PAYMENT_METHODS.'*', GLOB_ONLYDIR),
72 72
                     )
73 73
                 );
74 74
             }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function caf_helper_paths($paths)
125 125
     {
126
-        $paths[] = EE_CAF_CORE . 'helpers' . DS;
126
+        $paths[] = EE_CAF_CORE.'helpers'.DS;
127 127
         return $paths;
128 128
     }
129 129
 
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
         global $wpdb;
145 145
         // use same method of getting creator id as the version introducing the change
146 146
         $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
147
-        $price_type_table = $wpdb->prefix . "esp_price_type";
148
-        $price_table = $wpdb->prefix . "esp_price";
147
+        $price_type_table = $wpdb->prefix."esp_price_type";
148
+        $price_table = $wpdb->prefix."esp_price";
149 149
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
150
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';// include trashed price types
150
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table.' WHERE PBT_ID=4'; // include trashed price types
151 151
             $tax_price_type_count = $wpdb->get_var($SQL);
152 152
             if ($tax_price_type_count <= 1) {
153 153
                 $wpdb->insert(
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
                         'PRT_wp_user'    => $default_creator_id,
162 162
                     ),
163 163
                     array(
164
-                        '%s',// PRT_name
165
-                        '%d',// PBT_id
166
-                        '%d',// PRT_is_percent
167
-                        '%d',// PRT_order
168
-                        '%d',// PRT_deleted
164
+                        '%s', // PRT_name
165
+                        '%d', // PBT_id
166
+                        '%d', // PRT_is_percent
167
+                        '%d', // PRT_order
168
+                        '%d', // PRT_deleted
169 169
                         '%d', // PRT_wp_user
170 170
                     )
171 171
                 );
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
                         'PRT_wp_user'    => $default_creator_id,
182 182
                     ),
183 183
                     array(
184
-                        '%s',// PRT_name
185
-                        '%d',// PBT_id
186
-                        '%d',// PRT_is_percent
187
-                        '%d',// PRT_order
188
-                        '%d',// PRT_deleted
184
+                        '%s', // PRT_name
185
+                        '%d', // PBT_id
186
+                        '%d', // PRT_is_percent
187
+                        '%d', // PRT_order
188
+                        '%d', // PRT_deleted
189 189
                         '%d' // PRT_wp_user
190 190
                     )
191 191
                 );
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
                             'PRC_wp_user'    => $default_creator_id,
206 206
                         ),
207 207
                         array(
208
-                            '%d',// PRT_id
209
-                            '%f',// PRC_amount
210
-                            '%s',// PRC_name
211
-                            '%s',// PRC_desc
212
-                            '%d',// PRC_is_default
213
-                            '%d',// PRC_overrides
214
-                            '%d',// PRC_deleted
215
-                            '%d',// PRC_order
216
-                            '%d',// PRC_parent
208
+                            '%d', // PRT_id
209
+                            '%f', // PRC_amount
210
+                            '%s', // PRC_name
211
+                            '%s', // PRC_desc
212
+                            '%d', // PRC_is_default
213
+                            '%d', // PRC_overrides
214
+                            '%d', // PRC_deleted
215
+                            '%d', // PRC_order
216
+                            '%d', // PRC_parent
217 217
                             '%d' // PRC_wp_user
218 218
                         )
219 219
                     );
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function caffeinated_modules_to_register($modules_to_register = array())
234 234
     {
235
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
236
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
235
+        if (is_readable(EE_CAFF_PATH.'modules')) {
236
+            $caffeinated_modules_to_register = glob(EE_CAFF_PATH.'modules'.DS.'*', GLOB_ONLYDIR);
237 237
             if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
238 238
                 $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
239 239
             }
Please login to merge, or discard this patch.
core/data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_gateways.dmsstage.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -14,68 +14,68 @@  discard block
 block discarded – undo
14 14
 class EE_DMS_4_1_0_gateways extends EE_Data_Migration_Script_Stage
15 15
 {
16 16
 
17
-    private $_converted_active_gateways = false;
17
+	private $_converted_active_gateways = false;
18 18
 
19
-    public function _migration_step($num_items = 50)
20
-    {
21
-        // loads existing EE_CONfig from DB, if it exists
22
-        $new_gateway_config_obj = EE_Config::instance()->gateway;
23
-        $items_actually_migrated = 0;
24
-        // convert settings
25
-        $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone);
26
-        // just do a part of them on this request
27
-        $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate;
28
-        foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) {
29
-            $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug);
30
-            if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) {
31
-                // determine the old option's name
32
-                $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug);
33
-                if (! $old_gateway_settings) {
34
-                    // no settings existed for this gateway anyways... weird...
35
-                    $items_actually_migrated++;
36
-                    continue;
37
-                }
38
-                // now prepare the settings to make sure they're in the 4.1 format
39
-                $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug);
40
-                $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings;
41
-                // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but
42
-                // I think it's ok to do right away this time (we wont need gateway settings elsewhere)
43
-                delete_option($old_gateway_wp_option_name);
44
-            } else {// it must be one of the ones we mostly leave alone
45
-                global $wpdb;
46
-                // yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll
47
-                // only be saving users 50 milliseconds the one time this runs...
48
-                $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->options." SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name));
49
-            }
19
+	public function _migration_step($num_items = 50)
20
+	{
21
+		// loads existing EE_CONfig from DB, if it exists
22
+		$new_gateway_config_obj = EE_Config::instance()->gateway;
23
+		$items_actually_migrated = 0;
24
+		// convert settings
25
+		$gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone);
26
+		// just do a part of them on this request
27
+		$gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate;
28
+		foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) {
29
+			$old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug);
30
+			if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) {
31
+				// determine the old option's name
32
+				$old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug);
33
+				if (! $old_gateway_settings) {
34
+					// no settings existed for this gateway anyways... weird...
35
+					$items_actually_migrated++;
36
+					continue;
37
+				}
38
+				// now prepare the settings to make sure they're in the 4.1 format
39
+				$new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug);
40
+				$new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings;
41
+				// and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but
42
+				// I think it's ok to do right away this time (we wont need gateway settings elsewhere)
43
+				delete_option($old_gateway_wp_option_name);
44
+			} else {// it must be one of the ones we mostly leave alone
45
+				global $wpdb;
46
+				// yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll
47
+				// only be saving users 50 milliseconds the one time this runs...
48
+				$wpdb->query($wpdb->prepare("UPDATE ".$wpdb->options." SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name));
49
+			}
50 50
         
51
-            $items_actually_migrated++;
52
-        }
53
-        // if we can keep going, and it hasn' tbeen done yet, convert active gateways
54
-        if ($items_actually_migrated < $num_items &&  ! $this->_converted_active_gateways) {
55
-            $this->_convert_active_gateways();
56
-            $this->_converted_active_gateways = true;
57
-            $items_actually_migrated++;
58
-        }
51
+			$items_actually_migrated++;
52
+		}
53
+		// if we can keep going, and it hasn' tbeen done yet, convert active gateways
54
+		if ($items_actually_migrated < $num_items &&  ! $this->_converted_active_gateways) {
55
+			$this->_convert_active_gateways();
56
+			$this->_converted_active_gateways = true;
57
+			$items_actually_migrated++;
58
+		}
59 59
     
60
-        EE_Config::instance()->update_espresso_config(false, false);
61
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
62
-            $this->set_completed();
63
-        }
64
-        return $items_actually_migrated;
65
-    }
66
-    public function _count_records_to_migrate()
67
-    {
68
-        $count_of_gateways_to_convert = count($this->_gateways_we_know_how_to_migrate);
69
-        $step_of_setting_active_gateways = 1;
70
-        $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone);
71
-    //  $button_images_to_update =
72
-        return $count_of_gateways_to_convert +  $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone;
73
-    }
74
-    public function __construct()
75
-    {
76
-        $this->_pretty_name = __("Gateways", "event_espresso");
77
-        parent::__construct();
78
-    }
60
+		EE_Config::instance()->update_espresso_config(false, false);
61
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
62
+			$this->set_completed();
63
+		}
64
+		return $items_actually_migrated;
65
+	}
66
+	public function _count_records_to_migrate()
67
+	{
68
+		$count_of_gateways_to_convert = count($this->_gateways_we_know_how_to_migrate);
69
+		$step_of_setting_active_gateways = 1;
70
+		$count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone);
71
+	//  $button_images_to_update =
72
+		return $count_of_gateways_to_convert +  $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone;
73
+	}
74
+	public function __construct()
75
+	{
76
+		$this->_pretty_name = __("Gateways", "event_espresso");
77
+		parent::__construct();
78
+	}
79 79
 
80 80
 /**
81 81
  * Takes the old array of 3.1 gateway settings for this gateway and converts it
@@ -85,148 +85,148 @@  discard block
 block discarded – undo
85 85
  * @param string $new_gateway_slug
86 86
  * @return array
87 87
  */
88
-    private function _convert_gateway_settings($old_gateway_settings, $new_gateway_slug)
89
-    {
90
-        $new_gateway_settings = $old_gateway_settings;
91
-        switch ($new_gateway_slug) {
92
-            case 'Bank':
93
-                $new_gateway_settings['account_number'] = $old_gateway_settings['bank_account'];
94
-                $new_gateway_settings['page_title'] = $old_gateway_settings['bank_title'];
95
-                break;
96
-            case 'Invoice':
97
-                $new_gateway_settings['invoice_logo_url'] = $old_gateway_settings['image_url'];
98
-                // Dont' migrate the old invoice payee address. It was usually given dummy data. And in EE4
99
-                // it gets used in the receipts which are available to everyone. So usually it's best to not
100
-                // migrate this.
101
-                unset($new_gateway_settings['payment_address']);
102
-                break;
103
-            case 'Paypal_Pro':
104
-                $new_gateway_settings['email'] = $old_gateway_settings['paypal_pro_email'];
105
-                $new_gateway_settings['username'] = $old_gateway_settings['paypal_api_username'];
106
-                $new_gateway_settings['password'] = $old_gateway_settings['paypal_api_password'];
107
-                $new_gateway_settings['signature'] = $old_gateway_settings['paypal_api_signature'];
108
-                $new_gateway_settings['credit_cards'] = explode(",", $old_gateway_settings['paypal_api_credit_cards']);
109
-                $new_gateway_settings['use_sandbox'] = $old_gateway_settings['paypal_pro_use_sandbox'];
110
-                break;
111
-        }
112
-        return $new_gateway_settings;
113
-    }
88
+	private function _convert_gateway_settings($old_gateway_settings, $new_gateway_slug)
89
+	{
90
+		$new_gateway_settings = $old_gateway_settings;
91
+		switch ($new_gateway_slug) {
92
+			case 'Bank':
93
+				$new_gateway_settings['account_number'] = $old_gateway_settings['bank_account'];
94
+				$new_gateway_settings['page_title'] = $old_gateway_settings['bank_title'];
95
+				break;
96
+			case 'Invoice':
97
+				$new_gateway_settings['invoice_logo_url'] = $old_gateway_settings['image_url'];
98
+				// Dont' migrate the old invoice payee address. It was usually given dummy data. And in EE4
99
+				// it gets used in the receipts which are available to everyone. So usually it's best to not
100
+				// migrate this.
101
+				unset($new_gateway_settings['payment_address']);
102
+				break;
103
+			case 'Paypal_Pro':
104
+				$new_gateway_settings['email'] = $old_gateway_settings['paypal_pro_email'];
105
+				$new_gateway_settings['username'] = $old_gateway_settings['paypal_api_username'];
106
+				$new_gateway_settings['password'] = $old_gateway_settings['paypal_api_password'];
107
+				$new_gateway_settings['signature'] = $old_gateway_settings['paypal_api_signature'];
108
+				$new_gateway_settings['credit_cards'] = explode(",", $old_gateway_settings['paypal_api_credit_cards']);
109
+				$new_gateway_settings['use_sandbox'] = $old_gateway_settings['paypal_pro_use_sandbox'];
110
+				break;
111
+		}
112
+		return $new_gateway_settings;
113
+	}
114 114
 /**
115
- * Figures out the correct 3.1 gateway settings option name for the given 4.1 gateway
116
- * @param string $new_gateway_slug
117
- * @return string
118
- */
119
-    private function _get_old_gateway_option($new_gateway_slug)
120
-    {
121
-        $option_name = $this->_get_old_gateway_option_name($new_gateway_slug);
122
-        $settings =  get_option($option_name, null);
123
-    //  if( ! $settings){
124
-    //      $this->add_error(sprintf(__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug));
125
-    //  }
126
-        return $settings;
127
-    }
115
+	 * Figures out the correct 3.1 gateway settings option name for the given 4.1 gateway
116
+	 * @param string $new_gateway_slug
117
+	 * @return string
118
+	 */
119
+	private function _get_old_gateway_option($new_gateway_slug)
120
+	{
121
+		$option_name = $this->_get_old_gateway_option_name($new_gateway_slug);
122
+		$settings =  get_option($option_name, null);
123
+	//  if( ! $settings){
124
+	//      $this->add_error(sprintf(__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug));
125
+	//  }
126
+		return $settings;
127
+	}
128 128
 
129 129
 /**
130 130
  * Just gets the old gateways slug
131 131
  * @param string $new_gateway_slug
132 132
  * @return string
133 133
  */
134
-    private function _get_old_gateway_option_name($new_gateway_slug)
135
-    {
136
-        $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone));
137
-        $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ];
138
-        $normal_option_prefix = 'event_espresso_';
139
-        $normal_option_postfix = '_settings';
140
-        switch ($new_gateway_slug) {
141
-            case 'Bank':
142
-                $option_name = $normal_option_prefix.'bank_deposit'.$normal_option_postfix;
143
-                break;
144
-            case 'Aim':
145
-                $option_name = $normal_option_prefix.'authnet_aim'.$normal_option_postfix;
146
-                break;
147
-            case 'Check':
148
-                $option_name = $normal_option_prefix.'check_payment'.$normal_option_postfix;
149
-                break;
150
-            case 'Ideal':
151
-                $option_name = $normal_option_prefix.'ideal_mollie'.$normal_option_postfix;
152
-                break;
153
-            case 'Invoice':
154
-                $option_name = $normal_option_prefix.'invoice_payment'.$normal_option_postfix;
155
-                break;
156
-            case 'Purchase_Order':
157
-                $option_name = $normal_option_prefix.'purchase_order_payment'.$normal_option_postfix;
158
-                break;
159
-            case 'USAePay_Offsite':
160
-                $option_name = 'espresso_usaepay_offsite'.$normal_option_postfix;
161
-                break;
162
-            case 'USAePay_Onsite':
163
-                $option_name = 'espresso_usaepay_onsite'.$normal_option_postfix;
164
-                break;
165
-            default:
166
-                $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix.$old_gateway_slug.$normal_option_postfix);
167
-        }
168
-        return $option_name;
169
-    }
134
+	private function _get_old_gateway_option_name($new_gateway_slug)
135
+	{
136
+		$new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone));
137
+		$old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ];
138
+		$normal_option_prefix = 'event_espresso_';
139
+		$normal_option_postfix = '_settings';
140
+		switch ($new_gateway_slug) {
141
+			case 'Bank':
142
+				$option_name = $normal_option_prefix.'bank_deposit'.$normal_option_postfix;
143
+				break;
144
+			case 'Aim':
145
+				$option_name = $normal_option_prefix.'authnet_aim'.$normal_option_postfix;
146
+				break;
147
+			case 'Check':
148
+				$option_name = $normal_option_prefix.'check_payment'.$normal_option_postfix;
149
+				break;
150
+			case 'Ideal':
151
+				$option_name = $normal_option_prefix.'ideal_mollie'.$normal_option_postfix;
152
+				break;
153
+			case 'Invoice':
154
+				$option_name = $normal_option_prefix.'invoice_payment'.$normal_option_postfix;
155
+				break;
156
+			case 'Purchase_Order':
157
+				$option_name = $normal_option_prefix.'purchase_order_payment'.$normal_option_postfix;
158
+				break;
159
+			case 'USAePay_Offsite':
160
+				$option_name = 'espresso_usaepay_offsite'.$normal_option_postfix;
161
+				break;
162
+			case 'USAePay_Onsite':
163
+				$option_name = 'espresso_usaepay_onsite'.$normal_option_postfix;
164
+				break;
165
+			default:
166
+				$option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix.$old_gateway_slug.$normal_option_postfix);
167
+		}
168
+		return $option_name;
169
+	}
170 170
 
171
-    private function _convert_active_gateways()
172
-    {
173
-        // just does it all one big swoop
174
-        $old_active_gateways = get_option('event_espresso_active_gateways');
175
-        $new_active_gateways = EE_Config::instance()->gateway->active_gateways;
176
-        foreach ($old_active_gateways as $old_gateway_slug => $filepath) {
177
-            if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) {
178
-                $this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug));
179
-                continue;
180
-            }
181
-            $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ];
171
+	private function _convert_active_gateways()
172
+	{
173
+		// just does it all one big swoop
174
+		$old_active_gateways = get_option('event_espresso_active_gateways');
175
+		$new_active_gateways = EE_Config::instance()->gateway->active_gateways;
176
+		foreach ($old_active_gateways as $old_gateway_slug => $filepath) {
177
+			if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) {
178
+				$this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug));
179
+				continue;
180
+			}
181
+			$new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ];
182 182
         
183
-            // in the new format we can also upload gateways to the uploads directory and
184
-            $new_active_gateways[ $new_gateway_slug ] = false;
185
-        }
186
-        EE_Config::instance()->gateway->active_gateways = $new_active_gateways;
187
-    }
183
+			// in the new format we can also upload gateways to the uploads directory and
184
+			$new_active_gateways[ $new_gateway_slug ] = false;
185
+		}
186
+		EE_Config::instance()->gateway->active_gateways = $new_active_gateways;
187
+	}
188 188
     
189
-    protected $_gateways_we_know_how_to_migrate = array(
190
-        'aim'=>'Aim',
191
-        'bank'=>'Bank',
192
-        'check'=>'Check',
193
-        'invoice'=>'Invoice',
194
-        'paypal'=>'Paypal_Standard',
195
-        'paypal_pro'=>'Paypal_Pro',
189
+	protected $_gateways_we_know_how_to_migrate = array(
190
+		'aim'=>'Aim',
191
+		'bank'=>'Bank',
192
+		'check'=>'Check',
193
+		'invoice'=>'Invoice',
194
+		'paypal'=>'Paypal_Standard',
195
+		'paypal_pro'=>'Paypal_Pro',
196 196
 
197
-    );
197
+	);
198 198
     
199
-    protected $_gateways_we_leave_alone = array(
200
-        '2checkout'=>'2checkout',
201
-        'anz'=>'Anz',
202
-        'atos'=>'Atos',
203
-        'authnet'=>'Authnet',
204
-        'beanstream'=>'Beanstream',
205
-        'evertec'=>'Evertec',
206
-        'eway'=>'Eway',
207
-        'eway_rapid3'=>'Eway_Rapid3',
208
-        'exact'=>'Exact',
209
-        'firstdata'=>'Firstdata',
210
-        'firstdat_e4'=>'Firstdata_E4',
211
-        'ideal'=>'Ideal',
212
-        'infusion_payment'=>'InfusionSoft',
213
-        'luottokunta'=>'Luottokunta',
214
-        'megasoft'=>'Megasoft',
215
-        'moneris_hpp'=>'Moneris_HPP',
216
-        'mwarrior'=>'Mwarrior',
217
-        'nab'=>'NAB',
218
-        'paychoice'=>'Paychoice',
219
-        'paytrace'=>'Paytrace',
220
-        'psigate'=>'Psigate',
221
-        'purchase_order'=>'Purchase_Order',
222
-        'qbms'=>'QBMS',
223
-        'quickpay'=>'Quickpay',
224
-        'realauth'=>'Realauth',
225
-        'securepay_aus'=>'Securepay_Aus',
226
-        'stripe'=>'Stripe',
227
-        'usaepay_offsite'=>'USAePay_Offsite',
228
-        'usaepay_onsite'=>'USAePay_Onsite',
229
-        'wepay'=>'Wepay',
230
-        'worldpay'=>'Worldpay'
231
-    );
199
+	protected $_gateways_we_leave_alone = array(
200
+		'2checkout'=>'2checkout',
201
+		'anz'=>'Anz',
202
+		'atos'=>'Atos',
203
+		'authnet'=>'Authnet',
204
+		'beanstream'=>'Beanstream',
205
+		'evertec'=>'Evertec',
206
+		'eway'=>'Eway',
207
+		'eway_rapid3'=>'Eway_Rapid3',
208
+		'exact'=>'Exact',
209
+		'firstdata'=>'Firstdata',
210
+		'firstdat_e4'=>'Firstdata_E4',
211
+		'ideal'=>'Ideal',
212
+		'infusion_payment'=>'InfusionSoft',
213
+		'luottokunta'=>'Luottokunta',
214
+		'megasoft'=>'Megasoft',
215
+		'moneris_hpp'=>'Moneris_HPP',
216
+		'mwarrior'=>'Mwarrior',
217
+		'nab'=>'NAB',
218
+		'paychoice'=>'Paychoice',
219
+		'paytrace'=>'Paytrace',
220
+		'psigate'=>'Psigate',
221
+		'purchase_order'=>'Purchase_Order',
222
+		'qbms'=>'QBMS',
223
+		'quickpay'=>'Quickpay',
224
+		'realauth'=>'Realauth',
225
+		'securepay_aus'=>'Securepay_Aus',
226
+		'stripe'=>'Stripe',
227
+		'usaepay_offsite'=>'USAePay_Offsite',
228
+		'usaepay_onsite'=>'USAePay_Onsite',
229
+		'wepay'=>'Wepay',
230
+		'worldpay'=>'Worldpay'
231
+	);
232 232
 }
Please login to merge, or discard this patch.
core/EE_Data_Migration_Manager.core.php 2 patches
Indentation   +1234 added lines, -1234 removed lines patch added patch discarded remove patch
@@ -32,1238 +32,1238 @@
 block discarded – undo
32 32
 class EE_Data_Migration_Manager implements ResettableInterface
33 33
 {
34 34
 
35
-    /**
36
-     *
37
-     * @var EE_Registry
38
-     */
39
-    // protected $EE;
40
-    /**
41
-     * name of the wordpress option which stores an array of data about
42
-     */
43
-    const data_migrations_option_name = 'ee_data_migration';
44
-
45
-
46
-    const data_migration_script_option_prefix = 'ee_data_migration_script_';
47
-
48
-    const data_migration_script_mapping_option_prefix = 'ee_dms_map_';
49
-
50
-    /**
51
-     * name of the wordpress option which stores the database' current version. IE, the code may be at version 4.2.0,
52
-     * but as migrations are performed the database will progress from 3.1.35 to 4.1.0 etc.
53
-     */
54
-    const current_database_state = 'ee_data_migration_current_db_state';
55
-
56
-    /**
57
-     * Special status string returned when we're positive there are no more data migration
58
-     * scripts that can be run.
59
-     */
60
-    const status_no_more_migration_scripts = 'no_more_migration_scripts';
61
-    /**
62
-     * string indicating the migration should continue
63
-     */
64
-    const status_continue = 'status_continue';
65
-    /**
66
-     * string indicating the migration has completed and should be ended
67
-     */
68
-    const status_completed = 'status_completed';
69
-    /**
70
-     * string indicating a fatal error occurred and the data migration should be completely aborted
71
-     */
72
-    const status_fatal_error = 'status_fatal_error';
73
-
74
-    /**
75
-     * the number of 'items' (usually DB rows) to migrate on each 'step' (ajax request sent
76
-     * during migration)
77
-     */
78
-    const step_size = 50;
79
-
80
-    /**
81
-     * option name that stores the queue of ee plugins needing to have
82
-     * their data initialized (or re-initialized) once we are done migrations
83
-     */
84
-    const db_init_queue_option_name = 'ee_db_init_queue';
85
-    /**
86
-     * Array of information concerning data migrations that have ran in the history
87
-     * of this EE installation. Keys should be the name of the version the script upgraded to
88
-     *
89
-     * @var EE_Data_Migration_Script_Base[]
90
-     */
91
-    private $_data_migrations_ran = null;
92
-    /**
93
-     * The last ran script. It's nice to store this somewhere accessible, as its easiest
94
-     * to know which was the last run by which is the newest wp option; but in most of the code
95
-     * we just use the local $_data_migration_ran array, which organized the scripts differently
96
-     *
97
-     * @var EE_Data_Migration_Script_Base
98
-     */
99
-    private $_last_ran_script = null;
100
-
101
-    /**
102
-     * Similarly to _last_ran_script, but this is the last INCOMPLETE migration script.
103
-     *
104
-     * @var EE_Data_Migration_Script_Base
105
-     */
106
-    private $_last_ran_incomplete_script = null;
107
-    /**
108
-     * array where keys are classnames, and values are filepaths of all the known migration scripts
109
-     *
110
-     * @var array
111
-     */
112
-    private $_data_migration_class_to_filepath_map;
113
-
114
-    /**
115
-     * the following 4 properties are fully set on construction.
116
-     * Note: the first two apply to whether to continue running ALL migration scripts (ie, even though we're finished
117
-     * one, we may want to start the next one); whereas the last two indicate whether to continue running a single
118
-     * data migration script
119
-     *
120
-     * @var array
121
-     */
122
-    public $stati_that_indicate_to_continue_migrations = array();
123
-
124
-    public $stati_that_indicate_to_stop_migrations = array();
125
-
126
-    public $stati_that_indicate_to_continue_single_migration_script = array();
127
-
128
-    public $stati_that_indicate_to_stop_single_migration_script = array();
129
-
130
-    /**
131
-     * @var \EventEspresso\core\services\database\TableManager $table_manager
132
-     */
133
-    protected $_table_manager;
134
-
135
-    /**
136
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
137
-     */
138
-    protected $_table_analysis;
139
-
140
-    /**
141
-     * @var array $script_migration_versions
142
-     */
143
-    protected $script_migration_versions;
144
-
145
-    /**
146
-     * @var EE_Data_Migration_Manager $_instance
147
-     * @access    private
148
-     */
149
-    private static $_instance = null;
150
-
151
-
152
-    /**
153
-     * @singleton method used to instantiate class object
154
-     * @access    public
155
-     * @return EE_Data_Migration_Manager instance
156
-     */
157
-    public static function instance()
158
-    {
159
-        // check if class object is instantiated
160
-        if (! self::$_instance instanceof EE_Data_Migration_Manager) {
161
-            self::$_instance = new self();
162
-        }
163
-        return self::$_instance;
164
-    }
165
-
166
-    /**
167
-     * resets the singleton to its brand-new state (but does NOT delete old references to the old singleton. Meaning,
168
-     * all new usages of the singleton should be made with Classname::instance()) and returns it
169
-     *
170
-     * @return EE_Data_Migration_Manager
171
-     */
172
-    public static function reset()
173
-    {
174
-        self::$_instance = null;
175
-        return self::instance();
176
-    }
177
-
178
-
179
-    /**
180
-     * constructor
181
-     */
182
-    private function __construct()
183
-    {
184
-        $this->stati_that_indicate_to_continue_migrations = array(
185
-            self::status_continue,
186
-            self::status_completed,
187
-        );
188
-        $this->stati_that_indicate_to_stop_migrations = array(
189
-            self::status_fatal_error,
190
-            self::status_no_more_migration_scripts,
191
-        );
192
-        $this->stati_that_indicate_to_continue_single_migration_script = array(
193
-            self::status_continue,
194
-        );
195
-        $this->stati_that_indicate_to_stop_single_migration_script = array(
196
-            self::status_completed,
197
-            self::status_fatal_error
198
-            // note: status_no_more_migration_scripts doesn't apply
199
-        );
200
-        // make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class
201
-        // to be defined, because right now it doesn't get autoloaded on its own
202
-        EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), true);
203
-        EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), true);
204
-        EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), true);
205
-        EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), true);
206
-        EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), true);
207
-        $this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true);
208
-        $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
209
-    }
210
-
211
-
212
-    /**
213
-     * Deciphers, from an option's name, what plugin and version it relates to (see _save_migrations_ran to see what
214
-     * the option names are like, but generally they're like
215
-     * 'ee_data_migration_script_Core.4.1.0' in 4.2 or 'ee_data_migration_script_4.1.0' before that).
216
-     * The option name shouldn't ever be like 'ee_data_migration_script_Core.4.1.0.reg' because it's derived,
217
-     * indirectly, from the data migration's classname, which should always be like EE_DMS_%s_%d_%d_%d.dms.php (eg
218
-     * EE_DMS_Core_4_1_0.dms.php)
219
-     *
220
-     * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set)
221
-     * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of
222
-     *               that plugin (eg '4.1.0')
223
-     */
224
-    private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name)
225
-    {
226
-        $plugin_slug_and_version_string = str_replace(
227
-            EE_Data_Migration_Manager::data_migration_script_option_prefix,
228
-            "",
229
-            $option_name
230
-        );
231
-        // check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style)
232
-        $parts = explode(".", $plugin_slug_and_version_string);
233
-
234
-        if (count($parts) == 4) {
235
-            // it's 4.2-style.eg Core.4.1.0
236
-            $plugin_slug = $parts[0];// eg Core
237
-            $version_string = $parts[1] . "." . $parts[2] . "." . $parts[3]; // eg 4.1.0
238
-        } else {
239
-            // it's 4.1-style: eg 4.1.0
240
-            $plugin_slug = 'Core';
241
-            $version_string = $plugin_slug_and_version_string;// eg 4.1.0
242
-        }
243
-        return array($plugin_slug, $version_string);
244
-    }
245
-
246
-    /**
247
-     * Gets the DMS class from the wordpress option, otherwise throws an EE_Error if it's not
248
-     * for a known DMS class.
249
-     *
250
-     * @param string $dms_option_name
251
-     * @param string $dms_option_value (serialized)
252
-     * @return EE_Data_Migration_Script_Base
253
-     * @throws EE_Error
254
-     */
255
-    private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value)
256
-    {
257
-        $data_migration_data = maybe_unserialize($dms_option_value);
258
-        if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) {
259
-            $class = new $data_migration_data['class'];
260
-            if ($class instanceof EE_Data_Migration_Script_Base) {
261
-                $class->instantiate_from_array_of_properties($data_migration_data);
262
-                return $class;
263
-            } else {
264
-                // huh, so its an object but not a data migration script?? that shouldn't happen
265
-                // just leave it as an array (which will probably just get ignored)
266
-                throw new EE_Error(
267
-                    sprintf(
268
-                        __(
269
-                            "Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists",
270
-                            'event_espresso'
271
-                        ),
272
-                        $data_migration_data['class']
273
-                    )
274
-                );
275
-            }
276
-        } else {
277
-            // so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
278
-            throw new EE_Error(
279
-                sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)
280
-            );
281
-        }
282
-    }
283
-
284
-    /**
285
-     * Gets the array describing what data migrations have run. Also has a side-effect of recording which was the last
286
-     * ran, and which was the last ran which hasn't finished yet
287
-     *
288
-     * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy
289
-     *               arrays in there - which should probably be ignored)
290
-     */
291
-    public function get_data_migrations_ran()
292
-    {
293
-        if (! $this->_data_migrations_ran) {
294
-            // setup autoloaders for each of the scripts in there
295
-            $this->get_all_data_migration_scripts_available();
296
-            $data_migrations_options = $this->get_all_migration_script_options(
297
-            );// get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
298
-
299
-            $data_migrations_ran = array();
300
-            // convert into data migration script classes where possible
301
-            foreach ($data_migrations_options as $data_migration_option) {
302
-                list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name(
303
-                    $data_migration_option['option_name']
304
-                );
305
-
306
-                try {
307
-                    $class = $this->_get_dms_class_from_wp_option(
308
-                        $data_migration_option['option_name'],
309
-                        $data_migration_option['option_value']
310
-                    );
311
-                    $data_migrations_ran[ $plugin_slug ][ $version_string ] = $class;
312
-                    // ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
313
-                    $this->_last_ran_script = $class;
314
-                    if (! $class->is_completed()) {
315
-                        // sometimes we also like to know which was the last incomplete script (or if there are any at all)
316
-                        $this->_last_ran_incomplete_script = $class;
317
-                    }
318
-                } catch (EE_Error $e) {
319
-                    // ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
320
-                    $data_migrations_ran[ $plugin_slug ][ $version_string ] = maybe_unserialize(
321
-                        $data_migration_option['option_value']
322
-                    );
323
-                }
324
-            }
325
-            // so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
326
-            $this->_data_migrations_ran = $data_migrations_ran;
327
-            if (! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
328
-                $this->_data_migrations_ran = array();
329
-            }
330
-        }
331
-        return $this->_data_migrations_ran;
332
-    }
333
-
334
-
335
-    /**
336
-     *
337
-     * @param string $script_name eg 'DMS_Core_4_1_0'
338
-     * @param string $old_table   eg 'wp_events_detail'
339
-     * @param string $old_pk      eg 'wp_esp_posts'
340
-     * @param        $new_table
341
-     * @return mixed string or int
342
-     */
343
-    public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table)
344
-    {
345
-        $script = EE_Registry::instance()->load_dms($script_name);
346
-        $mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table);
347
-        return $mapping;
348
-    }
349
-
350
-    /**
351
-     * Gets all the options containing migration scripts that have been run. Ordering is important: it's assumed that
352
-     * the last option returned in this array is the most-recently ran DMS option
353
-     *
354
-     * @return array
355
-     */
356
-    public function get_all_migration_script_options()
357
-    {
358
-        global $wpdb;
359
-        return $wpdb->get_results(
360
-            "SELECT * FROM {$wpdb->options} WHERE option_name like '" . EE_Data_Migration_Manager::data_migration_script_option_prefix . "%' ORDER BY option_id ASC",
361
-            ARRAY_A
362
-        );
363
-    }
364
-
365
-    /**
366
-     * Gets the array of folders which contain data migration scripts. Also adds them to be auto-loaded
367
-     *
368
-     * @return array where each value is the full folder path of a folder containing data migration scripts, WITH
369
-     *               slashes at the end of the folder name.
370
-     */
371
-    public function get_data_migration_script_folders()
372
-    {
373
-        return apply_filters(
374
-            'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
375
-            array('Core' => EE_CORE . 'data_migration_scripts')
376
-        );
377
-    }
378
-
379
-    /**
380
-     * Gets the version the migration script upgrades to
381
-     *
382
-     * @param string $migration_script_name eg 'EE_DMS_Core_4_1_0'
383
-     * @return array {
384
-     * @type string  $slug                  like 'Core','Calendar',etc
385
-     * @type string  $version               like 4.3.0
386
-     *                                      }
387
-     * @throws EE_Error
388
-     */
389
-    public function script_migrates_to_version($migration_script_name, $eeAddonClass = '')
390
-    {
391
-        if (isset($this->script_migration_versions[ $migration_script_name ])) {
392
-            return $this->script_migration_versions[ $migration_script_name ];
393
-        }
394
-        $dms_info = $this->parse_dms_classname($migration_script_name);
395
-        $this->script_migration_versions[ $migration_script_name ] = array(
396
-            'slug'    => $eeAddonClass !== '' ? $eeAddonClass : $dms_info['slug'],
397
-            'version' => $dms_info['major_version'] . "." . $dms_info['minor_version'] . "." . $dms_info['micro_version'],
398
-        );
399
-        return $this->script_migration_versions[ $migration_script_name ];
400
-    }
401
-
402
-    /**
403
-     * Gets the juicy details out of a dms filename like 'EE_DMS_Core_4_1_0'
404
-     *
405
-     * @param string $classname
406
-     * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints)
407
-     * @throws EE_Error
408
-     */
409
-    public function parse_dms_classname($classname)
410
-    {
411
-        $matches = array();
412
-        preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
413
-        if (! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
414
-            throw new EE_Error(
415
-                sprintf(
416
-                    __(
417
-                        "%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ",
418
-                        "event_espresso"
419
-                    ),
420
-                    $classname
421
-                )
422
-            );
423
-        }
424
-        return array(
425
-            'slug'          => $matches[1],
426
-            'major_version' => intval($matches[2]),
427
-            'minor_version' => intval($matches[3]),
428
-            'micro_version' => intval($matches[4]),
429
-        );
430
-    }
431
-
432
-    /**
433
-     * Ensures that the option indicating the current DB version is set. This should only be
434
-     * a concern when activating EE for the first time, THEORETICALLY.
435
-     * If we detect that we're activating EE4 over top of EE3.1, then we set the current db state to 3.1.x, otherwise
436
-     * to 4.1.x.
437
-     *
438
-     * @return string of current db state
439
-     */
440
-    public function ensure_current_database_state_is_set()
441
-    {
442
-        $espresso_db_core_updates = get_option('espresso_db_update', array());
443
-        $db_state = get_option(EE_Data_Migration_Manager::current_database_state);
444
-        if (! $db_state) {
445
-            // mark the DB as being in the state as the last version in there.
446
-            // this is done to trigger maintenance mode and do data migration scripts
447
-            // if the admin installed this version of EE over 3.1.x or 4.0.x
448
-            // otherwise, the normal maintenance mode code is fine
449
-            $previous_versions_installed = array_keys($espresso_db_core_updates);
450
-            $previous_version_installed = end($previous_versions_installed);
451
-            if (version_compare('4.1.0', $previous_version_installed)) {
452
-                // last installed version was less than 4.1
453
-                // so we want the data migrations to happen. SO, we're going to say the DB is at that state
454
-                $db_state = array('Core' => $previous_version_installed);
455
-            } else {
456
-                $db_state = array('Core' => EVENT_ESPRESSO_VERSION);
457
-            }
458
-            update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
459
-        }
460
-        // in 4.1, $db_state would have only been a simple string like '4.1.0',
461
-        // but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
462
-        // db, and possibly other keys for other addons like 'Calendar','Permissions',etc
463
-        if (! is_array($db_state)) {
464
-            $db_state = array('Core' => $db_state);
465
-            update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
466
-        }
467
-        return $db_state;
468
-    }
469
-
470
-    /**
471
-     * Checks if there are any data migration scripts that ought to be run. If found,
472
-     * returns the instantiated classes. If none are found (ie, they've all already been run
473
-     * or they don't apply), returns an empty array
474
-     *
475
-     * @return EE_Data_Migration_Script_Base[]
476
-     */
477
-    public function check_for_applicable_data_migration_scripts()
478
-    {
479
-        // get the option describing what options have already run
480
-        $scripts_ran = $this->get_data_migrations_ran();
481
-        // $scripts_ran = array('4.1.0.core'=>array('monkey'=>null));
482
-        $script_class_and_filepaths_available = $this->get_all_data_migration_scripts_available();
483
-
484
-
485
-        $current_database_state = $this->ensure_current_database_state_is_set();
486
-        // determine which have already been run
487
-        $script_classes_that_should_run_per_iteration = array();
488
-        $iteration = 0;
489
-        $next_database_state_to_consider = $current_database_state;
490
-        $theoretical_database_state = null;
491
-        do {
492
-            // the next state after the currently-considered one will start off looking the same as the current, but we may make additions...
493
-            $theoretical_database_state = $next_database_state_to_consider;
494
-            // the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?)
495
-            foreach ($script_class_and_filepaths_available as $classname => $filepath) {
496
-                $migrates_to_version = $this->script_migrates_to_version($classname);
497
-                $script_converts_plugin_slug = $migrates_to_version['slug'];
498
-                $script_converts_to_version = $migrates_to_version['version'];
499
-                // check if this version script is DONE or not; or if it's never been ran
500
-                if (! $scripts_ran ||
501
-                    ! isset($scripts_ran[ $script_converts_plugin_slug ]) ||
502
-                    ! isset($scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ])) {
503
-                    // we haven't ran this conversion script before
504
-                    // now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
505
-                    $script = new $classname($this->_get_table_manager(), $this->_get_table_analysis());
506
-                    /* @var $script EE_Data_Migration_Script_Base */
507
-                    $can_migrate = $script->can_migrate_from_version($theoretical_database_state);
508
-                    if ($can_migrate) {
509
-                        $script_classes_that_should_run_per_iteration[ $iteration ][ $script->priority() ][] = $script;
510
-                        $migrates_to_version = $script->migrates_to_version();
511
-                        $next_database_state_to_consider[ $migrates_to_version['slug'] ] = $migrates_to_version['version'];
512
-                        unset($script_class_and_filepaths_available[ $classname ]);
513
-                    }
514
-                } elseif ($scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ] instanceof EE_Data_Migration_Script_Base) {
515
-                    // this script has been ran, or at least started
516
-                    $script = $scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ];
517
-                    if ($script->get_status() != self::status_completed) {
518
-                        // this script is already underway... keep going with it
519
-                        $script_classes_that_should_run_per_iteration[ $iteration ][ $script->priority() ][] = $script;
520
-                        $migrates_to_version = $script->migrates_to_version();
521
-                        $next_database_state_to_consider[ $migrates_to_version['slug'] ] = $migrates_to_version['version'];
522
-                        unset($script_class_and_filepaths_available[ $classname ]);
523
-                    } else {
524
-                        // it must have a status that indicates it has finished, so we don't want to try and run it again
525
-                    }
526
-                } else {
527
-                    // it exists but it's not  a proper data migration script
528
-                    // maybe the script got renamed? or was simply removed from EE?
529
-                    // either way, its certainly not runnable!
530
-                }
531
-            }
532
-            $iteration++;
533
-        } while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
534
-        // ok we have all the scripts that should run, now let's make them into flat array
535
-        $scripts_that_should_run = array();
536
-        foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
537
-            ksort($scripts_at_priority);
538
-            foreach ($scripts_at_priority as $scripts) {
539
-                foreach ($scripts as $script) {
540
-                    $scripts_that_should_run[ get_class($script) ] = $script;
541
-                }
542
-            }
543
-        }
544
-
545
-        do_action(
546
-            'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run',
547
-            $scripts_that_should_run
548
-        );
549
-        return $scripts_that_should_run;
550
-    }
551
-
552
-
553
-    /**
554
-     * Gets the script which is currently being ran, if there is one. If $include_completed_scripts is set to TRUE
555
-     * it will return the last ran script even if its complete.
556
-     * This means: if you want to find the currently-executing script, leave it as FALSE.
557
-     * If you really just want to find the script which ran most recently, regardless of status, leave it as TRUE.
558
-     *
559
-     * @param bool $include_completed_scripts
560
-     * @return EE_Data_Migration_Script_Base
561
-     */
562
-    public function get_last_ran_script($include_completed_scripts = false)
563
-    {
564
-        // make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
565
-        if (! $this->_data_migrations_ran) {
566
-            $this->get_data_migrations_ran();
567
-        }
568
-        if ($include_completed_scripts) {
569
-            return $this->_last_ran_script;
570
-        } else {
571
-            return $this->_last_ran_incomplete_script;
572
-        }
573
-    }
574
-
575
-
576
-    /**
577
-     * Runs the data migration scripts (well, each request to this method calls one of the
578
-     * data migration scripts' migration_step() functions).
579
-     *
580
-     * @param int   $step_size
581
-     * @throws EE_Error
582
-     * @return array {
583
-     *                                  // where the first item is one EE_Data_Migration_Script_Base's stati,
584
-     *                                  //and the second item is a string describing what was done
585
-     * @type int    $records_to_migrate from the current migration script
586
-     * @type int    $records_migrated
587
-     * @type string $status             one of EE_Data_Migration_Manager::status_*
588
-     * @type string $script             verbose name of the current DMS
589
-     * @type string $message            string describing what was done during this step
590
-     *                                  }
591
-     */
592
-    public function migration_step($step_size = 0)
593
-    {
594
-
595
-        // bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535
596
-        if (class_exists('EE_CPT_Strategy')) {
597
-            remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5);
598
-        }
599
-
600
-        try {
601
-            $currently_executing_script = $this->get_last_ran_script();
602
-            if (! $currently_executing_script) {
603
-                // Find the next script that needs to execute
604
-                $scripts = $this->check_for_applicable_data_migration_scripts();
605
-                if (! $scripts) {
606
-                    // huh, no more scripts to run... apparently we're done!
607
-                    // but dont forget to make sure initial data is there
608
-                    // we should be good to allow them to exit maintenance mode now
609
-                    EE_Maintenance_Mode::instance()->set_maintenance_level(
610
-                        intval(EE_Maintenance_Mode::level_0_not_in_maintenance)
611
-                    );
612
-                    // saving migrations ran should actually be unnecessary, but leaving in place just in case
613
-                    // remember this migration was finished (even if we timeout initing db for core and plugins)
614
-                    $this->_save_migrations_ran();
615
-                    // make sure DB was updated AFTER we've recorded the migration was done
616
-                    $this->initialize_db_for_enqueued_ee_plugins();
617
-                    return array(
618
-                        'records_to_migrate' => 1,
619
-                        'records_migrated'   => 1,
620
-                        'status'             => self::status_no_more_migration_scripts,
621
-                        'script'             => __("Data Migration Completed Successfully", "event_espresso"),
622
-                        'message'            => __("All done!", "event_espresso"),
623
-                    );
624
-                }
625
-                $currently_executing_script = array_shift($scripts);
626
-                // and add to the array/wp option showing the scripts ran
627
-
628
-                $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
629
-                $plugin_slug = $migrates_to['slug'];
630
-                $version = $migrates_to['version'];
631
-                $this->_data_migrations_ran[ $plugin_slug ][ $version ] = $currently_executing_script;
632
-            }
633
-            $current_script_name = get_class($currently_executing_script);
634
-        } catch (Exception $e) {
635
-            // an exception occurred while trying to get migration scripts
636
-
637
-            $message = sprintf(
638
-                __("Error Message: %sStack Trace:%s", "event_espresso"),
639
-                $e->getMessage() . '<br>',
640
-                $e->getTraceAsString()
641
-            );
642
-            // record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
643
-            // but that's ok-- it's just an FYI to support that we couldn't even run any data migrations
644
-            $this->add_error_to_migrations_ran(
645
-                sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)
646
-            );
647
-            return array(
648
-                'records_to_migrate' => 1,
649
-                'records_migrated'   => 0,
650
-                'status'             => self::status_fatal_error,
651
-                'script'             => __("Error loading data migration scripts", "event_espresso"),
652
-                'message'            => $message,
653
-            );
654
-        }
655
-        // ok so we definitely have a data migration script
656
-        try {
657
-            // how big of a bite do we want to take? Allow users to easily override via their wp-config
658
-            if (absint($step_size) < 1) {
659
-                $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE)
660
-                    ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
661
-            }
662
-            // do what we came to do!
663
-            $currently_executing_script->migration_step($step_size);
664
-            // can we wrap it up and verify default data?
665
-            $init_dbs = false;
666
-            switch ($currently_executing_script->get_status()) {
667
-                case EE_Data_Migration_Manager::status_continue:
668
-                    $response_array = array(
669
-                        'records_to_migrate' => $currently_executing_script->count_records_to_migrate(),
670
-                        'records_migrated'   => $currently_executing_script->count_records_migrated(),
671
-                        'status'             => EE_Data_Migration_Manager::status_continue,
672
-                        'message'            => $currently_executing_script->get_feedback_message(),
673
-                        'script'             => $currently_executing_script->pretty_name(),
674
-                    );
675
-                    break;
676
-                case EE_Data_Migration_Manager::status_completed:
677
-                    // ok so THAT script has completed
678
-                    $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name));
679
-                    $response_array = array(
680
-                        'records_to_migrate' => $currently_executing_script->count_records_to_migrate(),
681
-                        'records_migrated'   => $currently_executing_script->count_records_migrated(),
682
-                        'status'             => EE_Data_Migration_Manager::status_completed,
683
-                        'message'            => $currently_executing_script->get_feedback_message(),
684
-                        'script'             => sprintf(
685
-                            __("%s Completed", 'event_espresso'),
686
-                            $currently_executing_script->pretty_name()
687
-                        ),
688
-                    );
689
-                    // check if there are any more after this one.
690
-                    $scripts_remaining = $this->check_for_applicable_data_migration_scripts();
691
-                    if (! $scripts_remaining) {
692
-                        // we should be good to allow them to exit maintenance mode now
693
-                        EE_Maintenance_Mode::instance()->set_maintenance_level(
694
-                            intval(EE_Maintenance_Mode::level_0_not_in_maintenance)
695
-                        );
696
-                        // huh, no more scripts to run... apparently we're done!
697
-                        // but dont forget to make sure initial data is there
698
-                        $init_dbs = true;
699
-                        $response_array['status'] = self::status_no_more_migration_scripts;
700
-                    }
701
-                    break;
702
-                default:
703
-                    $response_array = array(
704
-                        'records_to_migrate' => $currently_executing_script->count_records_to_migrate(),
705
-                        'records_migrated'   => $currently_executing_script->count_records_migrated(),
706
-                        'status'             => $currently_executing_script->get_status(),
707
-                        'message'            => sprintf(
708
-                            __("Minor errors occurred during %s: %s", "event_espresso"),
709
-                            $currently_executing_script->pretty_name(),
710
-                            implode(", ", $currently_executing_script->get_errors())
711
-                        ),
712
-                        'script'             => $currently_executing_script->pretty_name(),
713
-                    );
714
-                    break;
715
-            }
716
-        } catch (Exception $e) {
717
-            // ok so some exception was thrown which killed the data migration script
718
-            // double-check we have a real script
719
-            if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) {
720
-                $script_name = $currently_executing_script->pretty_name();
721
-                $currently_executing_script->set_broken();
722
-                $currently_executing_script->add_error($e->getMessage());
723
-            } else {
724
-                $script_name = __("Error getting Migration Script", "event_espresso");
725
-            }
726
-            $response_array = array(
727
-                'records_to_migrate' => 1,
728
-                'records_migrated'   => 0,
729
-                'status'             => self::status_fatal_error,
730
-                'message'            => sprintf(
731
-                    __("A fatal error occurred during the migration: %s", "event_espresso"),
732
-                    $e->getMessage()
733
-                ),
734
-                'script'             => $script_name,
735
-            );
736
-        }
737
-        $successful_save = $this->_save_migrations_ran();
738
-        if ($successful_save !== true) {
739
-            // ok so the current wp option didn't save. that's tricky, because we'd like to update it
740
-            // and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION!
741
-            // however, if we throw an exception, and return that, then the next request
742
-            // won't have as much info in it, and it may be able to save
743
-            throw new EE_Error(
744
-                sprintf(
745
-                    __(
746
-                        "The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.",
747
-                        "event_espresso"
748
-                    ),
749
-                    $successful_save
750
-                )
751
-            );
752
-        }
753
-        // if we're all done, initialize EE plugins' default data etc.
754
-        if ($init_dbs) {
755
-            $this->initialize_db_for_enqueued_ee_plugins();
756
-        }
757
-        return $response_array;
758
-    }
759
-
760
-
761
-    /**
762
-     * Echo out JSON response to migration script AJAX requests. Takes precautions
763
-     * to buffer output so that we don't throw junk into our json.
764
-     *
765
-     * @return array with keys:
766
-     * 'records_to_migrate' which counts ALL the records for the current migration, and should remain constant. (ie,
767
-     * it's NOT the count of hwo many remain)
768
-     * 'records_migrated' which also counts ALL the records which have been migrated (ie, percent_complete =
769
-     * records_migrated/records_to_migrate)
770
-     * 'status'=>a string, one of EE_Data_migration_Manager::status_*
771
-     * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into
772
-     * errors, notifications, and successes
773
-     * 'script'=>a pretty name of the script currently running
774
-     */
775
-    public function response_to_migration_ajax_request()
776
-    {
777
-        ob_start();
778
-        try {
779
-            $response = $this->migration_step();
780
-        } catch (Exception $e) {
781
-            $response = array(
782
-                'records_to_migrate' => 0,
783
-                'records_migrated'   => 0,
784
-                'status'             => EE_Data_Migration_Manager::status_fatal_error,
785
-                'message'            => sprintf(
786
-                    __("Unknown fatal error occurred: %s", "event_espresso"),
787
-                    $e->getMessage()
788
-                ),
789
-                'script'             => 'Unknown',
790
-            );
791
-            $this->add_error_to_migrations_ran($e->getMessage() . "; Stack trace:" . $e->getTraceAsString());
792
-        }
793
-        $warnings_etc = @ob_get_contents();
794
-        ob_end_clean();
795
-        $response['message'] .= $warnings_etc;
796
-        return $response;
797
-    }
798
-
799
-    /**
800
-     * Updates the wordpress option that keeps track of which which EE version the database
801
-     * is at (ie, the code may be at 4.1.0, but the database is still at 3.1.35)
802
-     *
803
-     * @param array $slug_and_version {
804
-     * @type string $slug             like 'Core' or 'Calendar',
805
-     * @type string $version          like '4.1.0'
806
-     *                                }
807
-     * @return void
808
-     */
809
-    public function update_current_database_state_to($slug_and_version = null)
810
-    {
811
-        if (! $slug_and_version) {
812
-            // no version was provided, assume it should be at the current code version
813
-            $slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
814
-        }
815
-        $current_database_state = get_option(self::current_database_state);
816
-        $current_database_state[ $slug_and_version['slug'] ] = $slug_and_version['version'];
817
-        update_option(self::current_database_state, $current_database_state);
818
-    }
819
-
820
-    /**
821
-     * Determines if the database is currently at a state matching what's indicated in $slug and $version.
822
-     *
823
-     * @param array $slug_and_version {
824
-     * @type string $slug             like 'Core' or 'Calendar',
825
-     * @type string $version          like '4.1.0'
826
-     *                                }
827
-     * @return boolean
828
-     */
829
-    public function database_needs_updating_to($slug_and_version)
830
-    {
831
-
832
-        $slug = $slug_and_version['slug'];
833
-        $version = $slug_and_version['version'];
834
-        $current_database_state = get_option(self::current_database_state);
835
-        if (! isset($current_database_state[ $slug ])) {
836
-            return true;
837
-        } else {
838
-            // just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
839
-            $version_parts_current_db_state = array_slice(explode('.', $current_database_state[ $slug ]), 0, 3);
840
-            $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
841
-            $needs_updating = false;
842
-            foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
843
-                if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ]) {
844
-                    $needs_updating = true;
845
-                    break;
846
-                }
847
-            }
848
-            return $needs_updating;
849
-        }
850
-    }
851
-
852
-
853
-    /**
854
-     * Gets all the data migration scripts available in the core folder and folders
855
-     * in addons. Has the side effect of adding them for autoloading
856
-     *
857
-     * @return array keys are expected classnames, values are their filepaths
858
-     * @throws InvalidInterfaceException
859
-     * @throws InvalidDataTypeException
860
-     * @throws EE_Error
861
-     * @throws InvalidArgumentException
862
-     */
863
-    public function get_all_data_migration_scripts_available()
864
-    {
865
-        if (! $this->_data_migration_class_to_filepath_map) {
866
-            $this->_data_migration_class_to_filepath_map = array();
867
-            foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
868
-                // strip any placeholders added to classname to make it a unique array key
869
-                $eeAddonClass = trim($eeAddonClass, '*');
870
-                $eeAddonClass = $eeAddonClass === 'Core' || class_exists($eeAddonClass)
871
-                    ? $eeAddonClass
872
-                    : '';
873
-                $folder_path = EEH_File::end_with_directory_separator($folder_path);
874
-                $files = glob($folder_path . '*.dms.php');
875
-                if (empty($files)) {
876
-                    continue;
877
-                }
878
-                foreach ($files as $file) {
879
-                    $pos_of_last_slash = strrpos($file, DS);
880
-                    $classname = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1));
881
-                    $migrates_to = $this->script_migrates_to_version($classname, $eeAddonClass);
882
-                    $slug = $migrates_to['slug'];
883
-                    // check that the slug as contained in the DMS is associated with
884
-                    // the slug of an addon or core
885
-                    if ($slug !== 'Core' && EE_Registry::instance()->get_addon_by_name($slug) === null) {
886
-                        EE_Error::doing_it_wrong(
887
-                            __FUNCTION__,
888
-                            sprintf(
889
-                                esc_html__(
890
-                                    'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ',
891
-                                    'event_espresso'
892
-                                ),
893
-                                $classname,
894
-                                $slug,
895
-                                implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name()))
896
-                            ),
897
-                            '4.3.0.alpha.019'
898
-                        );
899
-                    }
900
-                    $this->_data_migration_class_to_filepath_map[ $classname ] = $file;
901
-                }
902
-            }
903
-            EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
904
-        }
905
-        return $this->_data_migration_class_to_filepath_map;
906
-    }
907
-
908
-
909
-    /**
910
-     * Once we have an addon that works with EE4.1, we will actually want to fetch the PUE slugs
911
-     * from each addon, and check if they need updating,
912
-     *
913
-     * @return boolean
914
-     */
915
-    public function addons_need_updating()
916
-    {
917
-        return false;
918
-    }
919
-
920
-    /**
921
-     * Adds this error string to the data_migrations_ran array, but we dont necessarily know
922
-     * where to put it, so we just throw it in there... better than nothing...
923
-     *
924
-     * @param string $error_message
925
-     * @throws EE_Error
926
-     */
927
-    public function add_error_to_migrations_ran($error_message)
928
-    {
929
-        // get last-ran migration script
930
-        global $wpdb;
931
-        $last_migration_script_option = $wpdb->get_row(
932
-            "SELECT * FROM $wpdb->options WHERE option_name like '" . EE_Data_Migration_Manager::data_migration_script_option_prefix . "%' ORDER BY option_id DESC LIMIT 1",
933
-            ARRAY_A
934
-        );
935
-
936
-        $last_ran_migration_script_properties = isset($last_migration_script_option['option_value'])
937
-            ? maybe_unserialize($last_migration_script_option['option_value']) : null;
938
-        // now, tread lightly because we're here because a FATAL non-catchable error
939
-        // was thrown last time when we were trying to run a data migration script
940
-        // so the fatal error could have happened while getting the migration script
941
-        // or doing running it...
942
-        $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(
943
-            EE_Data_Migration_Manager::data_migration_script_option_prefix,
944
-            "",
945
-            $last_migration_script_option['option_name']
946
-        ) : null;
947
-
948
-        // check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet
949
-        // because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done)
950
-        if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) {
951
-            // ok then just add this error to its list of errors
952
-            $last_ran_migration_script_properties['_errors'][] = $error_message;
953
-            $last_ran_migration_script_properties['_status'] = self::status_fatal_error;
954
-        } else {
955
-            // so we don't even know which script was last running
956
-            // use the data migration error stub, which is designed specifically for this type of thing
957
-            $general_migration_error = new EE_DMS_Unknown_1_0_0();
958
-            $general_migration_error->add_error($error_message);
959
-            $general_migration_error->set_broken();
960
-            $last_ran_migration_script_properties = $general_migration_error->properties_as_array();
961
-            $versions_migrated_to = 'Unknown.1.0.0';
962
-            // now just to make sure appears as last (in case the were previously a fatal error like this)
963
-            // delete the old one
964
-            delete_option(self::data_migration_script_option_prefix . $versions_migrated_to);
965
-        }
966
-        update_option(
967
-            self::data_migration_script_option_prefix . $versions_migrated_to,
968
-            $last_ran_migration_script_properties
969
-        );
970
-    }
971
-
972
-    /**
973
-     * saves what data migrations have ran to the database
974
-     *
975
-     * @return mixed TRUE if successfully saved migrations ran, string if an error occurred
976
-     */
977
-    protected function _save_migrations_ran()
978
-    {
979
-        if ($this->_data_migrations_ran == null) {
980
-            $this->get_data_migrations_ran();
981
-        }
982
-        // now, we don't want to save actual classes to the DB because that's messy
983
-        $successful_updates = true;
984
-        foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
985
-            foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
986
-                $plugin_slug_for_use_in_option_name = $plugin_slug . ".";
987
-                $option_name = self::data_migration_script_option_prefix . $plugin_slug_for_use_in_option_name . $version_string;
988
-                $old_option_value = get_option($option_name);
989
-                if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
990
-                    $script_array_for_saving = $array_or_migration_obj->properties_as_array();
991
-                    if ($old_option_value != $script_array_for_saving) {
992
-                        $successful_updates = update_option($option_name, $script_array_for_saving);
993
-                    }
994
-                } else {// we don't know what this array-thing is. So just save it as-is
995
-                    if ($old_option_value != $array_or_migration_obj) {
996
-                        $successful_updates = update_option($option_name, $array_or_migration_obj);
997
-                    }
998
-                }
999
-                if (! $successful_updates) {
1000
-                    global $wpdb;
1001
-                    return $wpdb->last_error;
1002
-                }
1003
-            }
1004
-        }
1005
-        return true;
1006
-        // $updated = update_option(self::data_migrations_option_name, $array_of_migrations);
1007
-        // if ($updated !== true) {
1008
-        //     global $wpdb;
1009
-        //     return $wpdb->last_error;
1010
-        // } else {
1011
-        //     return true;
1012
-        // }
1013
-        // wp_mail(
1014
-        //     "[email protected]",
1015
-        //     time() . " price debug info",
1016
-        //     "updated: $updated, last error: $last_error, byte length of option: " . strlen(
1017
-        //         serialize($array_of_migrations)
1018
-        //     )
1019
-        // );
1020
-    }
1021
-
1022
-    /**
1023
-     * Takes an array of data migration script properties and re-creates the class from
1024
-     * them. The argument $properties_array is assumed to have been made by
1025
-     * EE_Data_Migration_Script_Base::properties_as_array()
1026
-     *
1027
-     * @param array $properties_array
1028
-     * @return EE_Data_Migration_Script_Base
1029
-     * @throws EE_Error
1030
-     */
1031
-    public function _instantiate_script_from_properties_array($properties_array)
1032
-    {
1033
-        if (! isset($properties_array['class'])) {
1034
-            throw new EE_Error(
1035
-                sprintf(
1036
-                    __("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),
1037
-                    implode(",", $properties_array)
1038
-                )
1039
-            );
1040
-        }
1041
-        $class_name = $properties_array['class'];
1042
-        if (! class_exists($class_name)) {
1043
-            throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
1044
-        }
1045
-        $class = new $class_name;
1046
-        if (! $class instanceof EE_Data_Migration_Script_Base) {
1047
-            throw new EE_Error(
1048
-                sprintf(
1049
-                    __("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),
1050
-                    $class_name,
1051
-                    get_class($class)
1052
-                )
1053
-            );
1054
-        }
1055
-        $class->instantiate_from_array_of_properties($properties_array);
1056
-        return $class;
1057
-    }
1058
-
1059
-    /**
1060
-     * Gets the classname for the most up-to-date DMS (ie, the one that will finally
1061
-     * leave the DB in a state usable by the current plugin code).
1062
-     *
1063
-     * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core'
1064
-     * @return string
1065
-     */
1066
-    public function get_most_up_to_date_dms($plugin_slug = 'Core')
1067
-    {
1068
-        $class_to_filepath_map = $this->get_all_data_migration_scripts_available();
1069
-        $most_up_to_date_dms_classname = null;
1070
-        foreach ($class_to_filepath_map as $classname => $filepath) {
1071
-            if ($most_up_to_date_dms_classname === null) {
1072
-                $migrates_to = $this->script_migrates_to_version($classname);
1073
-                $this_plugin_slug = $migrates_to['slug'];
1074
-                if ($this_plugin_slug == $plugin_slug) {
1075
-                    // if it's for core, it wins
1076
-                    $most_up_to_date_dms_classname = $classname;
1077
-                }
1078
-                // if it wasn't for core, we must keep searching for one that is!
1079
-                continue;
1080
-            } else {
1081
-                $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname);
1082
-                $contender_migrates_to = $this->script_migrates_to_version($classname);
1083
-                if ($contender_migrates_to['slug'] == $plugin_slug
1084
-                    && version_compare(
1085
-                        $champion_migrates_to['version'],
1086
-                        $contender_migrates_to['version'],
1087
-                        '<'
1088
-                    )) {
1089
-                    // so the contenders version is higher and its for Core
1090
-                    $most_up_to_date_dms_classname = $classname;
1091
-                }
1092
-            }
1093
-        }
1094
-        return $most_up_to_date_dms_classname;
1095
-    }
1096
-
1097
-    /**
1098
-     * Gets the migration script specified but ONLY if it has already ran.
1099
-     *
1100
-     * Eg, if you wanted to see if 'EE_DMS_Core_4_1_0' has ran, you would run the following code:
1101
-     * <code> $core_4_1_0_dms_ran = EE_Data_Migration_Manager::instance()->get_migration_ran( '4.1.0', 'Core' ) !==
1102
-     * NULL;</code> This is especially useful in addons' data migration scripts, this way they can tell if a core (or
1103
-     * other addon) DMS has ran, in case the current DMS depends on it.
1104
-     *
1105
-     * @param string $version     the version the DMS searched for migrates to. Usually just the content before the 3rd
1106
-     *                            period. Eg '4.1.0'
1107
-     * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
1108
-     * @return EE_Data_Migration_Script_Base
1109
-     */
1110
-    public function get_migration_ran($version, $plugin_slug = 'Core')
1111
-    {
1112
-        $migrations_ran = $this->get_data_migrations_ran();
1113
-        if (isset($migrations_ran[ $plugin_slug ]) && isset($migrations_ran[ $plugin_slug ][ $version ])) {
1114
-            return $migrations_ran[ $plugin_slug ][ $version ];
1115
-        } else {
1116
-            return null;
1117
-        }
1118
-    }
1119
-
1120
-    /**
1121
-     * Resets the borked data migration scripts so they're no longer borked
1122
-     * so we can again attempt to migrate
1123
-     *
1124
-     * @return bool
1125
-     * @throws EE_Error
1126
-     */
1127
-    public function reattempt()
1128
-    {
1129
-        // find if the last-ran script was borked
1130
-        // set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
1131
-        // add an 'error' saying that we attempted to reset
1132
-        // does it have a stage that was borked too? if so make it no longer borked
1133
-        // add an 'error' saying we attempted to reset
1134
-        $last_ran_script = $this->get_last_ran_script();
1135
-        if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) {
1136
-            // if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
1137
-            $last_ran_script->set_completed();
1138
-        } elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) {
1139
-            $last_ran_script->reattempt();
1140
-        } else {
1141
-            throw new EE_Error(
1142
-                sprintf(
1143
-                    __(
1144
-                        'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s',
1145
-                        'event_espresso'
1146
-                    ),
1147
-                    print_r($last_ran_script, true)
1148
-                )
1149
-            );
1150
-        }
1151
-        return $this->_save_migrations_ran();
1152
-    }
1153
-
1154
-    /**
1155
-     * Gets whether or not this particular migration has run or not
1156
-     *
1157
-     * @param string $version     the version the DMS searched for migrates to. Usually just the content before the 3rd
1158
-     *                            period. Eg '4.1.0'
1159
-     * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
1160
-     * @return boolean
1161
-     */
1162
-    public function migration_has_ran($version, $plugin_slug = 'Core')
1163
-    {
1164
-        return $this->get_migration_ran($version, $plugin_slug) !== null;
1165
-    }
1166
-
1167
-    /**
1168
-     * Enqueues this ee plugin to have its data initialized
1169
-     *
1170
-     * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value
1171
-     */
1172
-    public function enqueue_db_initialization_for($plugin_slug)
1173
-    {
1174
-        $queue = $this->get_db_initialization_queue();
1175
-        if (! in_array($plugin_slug, $queue)) {
1176
-            $queue[] = $plugin_slug;
1177
-        }
1178
-        update_option(self::db_init_queue_option_name, $queue);
1179
-    }
1180
-
1181
-    /**
1182
-     * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
1183
-     * specified in EE_Data_Migration_Manager::get_db_init_queue(), and if 'Core' is
1184
-     * in the queue, calls EE_System::initialize_db_if_no_migrations_required().
1185
-     */
1186
-    public function initialize_db_for_enqueued_ee_plugins()
1187
-    {
1188
-        $queue = $this->get_db_initialization_queue();
1189
-        foreach ($queue as $plugin_slug) {
1190
-            $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
1191
-            if (! $most_up_to_date_dms) {
1192
-                // if there is NO DMS for this plugin, obviously there's no schema to verify anyways
1193
-                $verify_db = false;
1194
-            } else {
1195
-                $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
1196
-                $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
1197
-            }
1198
-            if ($plugin_slug == 'Core') {
1199
-                EE_System::instance()->initialize_db_if_no_migrations_required(
1200
-                    false,
1201
-                    $verify_db
1202
-                );
1203
-            } else {
1204
-                // just loop through the addons to make sure their database is setup
1205
-                foreach (EE_Registry::instance()->addons as $addon) {
1206
-                    if ($addon->name() == $plugin_slug) {
1207
-                        $addon->initialize_db_if_no_migrations_required($verify_db);
1208
-                        break;
1209
-                    }
1210
-                }
1211
-            }
1212
-        }
1213
-        // because we just initialized the DBs for the enqueued ee plugins
1214
-        // we don't need to keep remembering which ones needed to be initialized
1215
-        delete_option(self::db_init_queue_option_name);
1216
-    }
1217
-
1218
-    /**
1219
-     * Gets a numerically-indexed array of plugin slugs that need to have their databases
1220
-     * (re-)initialized after migrations are complete. ie, each element should be either
1221
-     * 'Core', or the return value of EE_Addon::name() for an addon
1222
-     *
1223
-     * @return array
1224
-     */
1225
-    public function get_db_initialization_queue()
1226
-    {
1227
-        return get_option(self::db_init_queue_option_name, array());
1228
-    }
1229
-
1230
-    /**
1231
-     * Gets the injected table analyzer, or throws an exception
1232
-     *
1233
-     * @return TableAnalysis
1234
-     * @throws EE_Error
1235
-     */
1236
-    protected function _get_table_analysis()
1237
-    {
1238
-        if ($this->_table_analysis instanceof TableAnalysis) {
1239
-            return $this->_table_analysis;
1240
-        } else {
1241
-            throw new EE_Error(
1242
-                sprintf(
1243
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1244
-                    get_class($this)
1245
-                )
1246
-            );
1247
-        }
1248
-    }
1249
-
1250
-    /**
1251
-     * Gets the injected table manager, or throws an exception
1252
-     *
1253
-     * @return TableManager
1254
-     * @throws EE_Error
1255
-     */
1256
-    protected function _get_table_manager()
1257
-    {
1258
-        if ($this->_table_manager instanceof TableManager) {
1259
-            return $this->_table_manager;
1260
-        } else {
1261
-            throw new EE_Error(
1262
-                sprintf(
1263
-                    __('Table manager class on class %1$s is not set properly.', 'event_espresso'),
1264
-                    get_class($this)
1265
-                )
1266
-            );
1267
-        }
1268
-    }
35
+	/**
36
+	 *
37
+	 * @var EE_Registry
38
+	 */
39
+	// protected $EE;
40
+	/**
41
+	 * name of the wordpress option which stores an array of data about
42
+	 */
43
+	const data_migrations_option_name = 'ee_data_migration';
44
+
45
+
46
+	const data_migration_script_option_prefix = 'ee_data_migration_script_';
47
+
48
+	const data_migration_script_mapping_option_prefix = 'ee_dms_map_';
49
+
50
+	/**
51
+	 * name of the wordpress option which stores the database' current version. IE, the code may be at version 4.2.0,
52
+	 * but as migrations are performed the database will progress from 3.1.35 to 4.1.0 etc.
53
+	 */
54
+	const current_database_state = 'ee_data_migration_current_db_state';
55
+
56
+	/**
57
+	 * Special status string returned when we're positive there are no more data migration
58
+	 * scripts that can be run.
59
+	 */
60
+	const status_no_more_migration_scripts = 'no_more_migration_scripts';
61
+	/**
62
+	 * string indicating the migration should continue
63
+	 */
64
+	const status_continue = 'status_continue';
65
+	/**
66
+	 * string indicating the migration has completed and should be ended
67
+	 */
68
+	const status_completed = 'status_completed';
69
+	/**
70
+	 * string indicating a fatal error occurred and the data migration should be completely aborted
71
+	 */
72
+	const status_fatal_error = 'status_fatal_error';
73
+
74
+	/**
75
+	 * the number of 'items' (usually DB rows) to migrate on each 'step' (ajax request sent
76
+	 * during migration)
77
+	 */
78
+	const step_size = 50;
79
+
80
+	/**
81
+	 * option name that stores the queue of ee plugins needing to have
82
+	 * their data initialized (or re-initialized) once we are done migrations
83
+	 */
84
+	const db_init_queue_option_name = 'ee_db_init_queue';
85
+	/**
86
+	 * Array of information concerning data migrations that have ran in the history
87
+	 * of this EE installation. Keys should be the name of the version the script upgraded to
88
+	 *
89
+	 * @var EE_Data_Migration_Script_Base[]
90
+	 */
91
+	private $_data_migrations_ran = null;
92
+	/**
93
+	 * The last ran script. It's nice to store this somewhere accessible, as its easiest
94
+	 * to know which was the last run by which is the newest wp option; but in most of the code
95
+	 * we just use the local $_data_migration_ran array, which organized the scripts differently
96
+	 *
97
+	 * @var EE_Data_Migration_Script_Base
98
+	 */
99
+	private $_last_ran_script = null;
100
+
101
+	/**
102
+	 * Similarly to _last_ran_script, but this is the last INCOMPLETE migration script.
103
+	 *
104
+	 * @var EE_Data_Migration_Script_Base
105
+	 */
106
+	private $_last_ran_incomplete_script = null;
107
+	/**
108
+	 * array where keys are classnames, and values are filepaths of all the known migration scripts
109
+	 *
110
+	 * @var array
111
+	 */
112
+	private $_data_migration_class_to_filepath_map;
113
+
114
+	/**
115
+	 * the following 4 properties are fully set on construction.
116
+	 * Note: the first two apply to whether to continue running ALL migration scripts (ie, even though we're finished
117
+	 * one, we may want to start the next one); whereas the last two indicate whether to continue running a single
118
+	 * data migration script
119
+	 *
120
+	 * @var array
121
+	 */
122
+	public $stati_that_indicate_to_continue_migrations = array();
123
+
124
+	public $stati_that_indicate_to_stop_migrations = array();
125
+
126
+	public $stati_that_indicate_to_continue_single_migration_script = array();
127
+
128
+	public $stati_that_indicate_to_stop_single_migration_script = array();
129
+
130
+	/**
131
+	 * @var \EventEspresso\core\services\database\TableManager $table_manager
132
+	 */
133
+	protected $_table_manager;
134
+
135
+	/**
136
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
137
+	 */
138
+	protected $_table_analysis;
139
+
140
+	/**
141
+	 * @var array $script_migration_versions
142
+	 */
143
+	protected $script_migration_versions;
144
+
145
+	/**
146
+	 * @var EE_Data_Migration_Manager $_instance
147
+	 * @access    private
148
+	 */
149
+	private static $_instance = null;
150
+
151
+
152
+	/**
153
+	 * @singleton method used to instantiate class object
154
+	 * @access    public
155
+	 * @return EE_Data_Migration_Manager instance
156
+	 */
157
+	public static function instance()
158
+	{
159
+		// check if class object is instantiated
160
+		if (! self::$_instance instanceof EE_Data_Migration_Manager) {
161
+			self::$_instance = new self();
162
+		}
163
+		return self::$_instance;
164
+	}
165
+
166
+	/**
167
+	 * resets the singleton to its brand-new state (but does NOT delete old references to the old singleton. Meaning,
168
+	 * all new usages of the singleton should be made with Classname::instance()) and returns it
169
+	 *
170
+	 * @return EE_Data_Migration_Manager
171
+	 */
172
+	public static function reset()
173
+	{
174
+		self::$_instance = null;
175
+		return self::instance();
176
+	}
177
+
178
+
179
+	/**
180
+	 * constructor
181
+	 */
182
+	private function __construct()
183
+	{
184
+		$this->stati_that_indicate_to_continue_migrations = array(
185
+			self::status_continue,
186
+			self::status_completed,
187
+		);
188
+		$this->stati_that_indicate_to_stop_migrations = array(
189
+			self::status_fatal_error,
190
+			self::status_no_more_migration_scripts,
191
+		);
192
+		$this->stati_that_indicate_to_continue_single_migration_script = array(
193
+			self::status_continue,
194
+		);
195
+		$this->stati_that_indicate_to_stop_single_migration_script = array(
196
+			self::status_completed,
197
+			self::status_fatal_error
198
+			// note: status_no_more_migration_scripts doesn't apply
199
+		);
200
+		// make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class
201
+		// to be defined, because right now it doesn't get autoloaded on its own
202
+		EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), true);
203
+		EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), true);
204
+		EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), true);
205
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), true);
206
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), true);
207
+		$this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true);
208
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
209
+	}
210
+
211
+
212
+	/**
213
+	 * Deciphers, from an option's name, what plugin and version it relates to (see _save_migrations_ran to see what
214
+	 * the option names are like, but generally they're like
215
+	 * 'ee_data_migration_script_Core.4.1.0' in 4.2 or 'ee_data_migration_script_4.1.0' before that).
216
+	 * The option name shouldn't ever be like 'ee_data_migration_script_Core.4.1.0.reg' because it's derived,
217
+	 * indirectly, from the data migration's classname, which should always be like EE_DMS_%s_%d_%d_%d.dms.php (eg
218
+	 * EE_DMS_Core_4_1_0.dms.php)
219
+	 *
220
+	 * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set)
221
+	 * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of
222
+	 *               that plugin (eg '4.1.0')
223
+	 */
224
+	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name)
225
+	{
226
+		$plugin_slug_and_version_string = str_replace(
227
+			EE_Data_Migration_Manager::data_migration_script_option_prefix,
228
+			"",
229
+			$option_name
230
+		);
231
+		// check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style)
232
+		$parts = explode(".", $plugin_slug_and_version_string);
233
+
234
+		if (count($parts) == 4) {
235
+			// it's 4.2-style.eg Core.4.1.0
236
+			$plugin_slug = $parts[0];// eg Core
237
+			$version_string = $parts[1] . "." . $parts[2] . "." . $parts[3]; // eg 4.1.0
238
+		} else {
239
+			// it's 4.1-style: eg 4.1.0
240
+			$plugin_slug = 'Core';
241
+			$version_string = $plugin_slug_and_version_string;// eg 4.1.0
242
+		}
243
+		return array($plugin_slug, $version_string);
244
+	}
245
+
246
+	/**
247
+	 * Gets the DMS class from the wordpress option, otherwise throws an EE_Error if it's not
248
+	 * for a known DMS class.
249
+	 *
250
+	 * @param string $dms_option_name
251
+	 * @param string $dms_option_value (serialized)
252
+	 * @return EE_Data_Migration_Script_Base
253
+	 * @throws EE_Error
254
+	 */
255
+	private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value)
256
+	{
257
+		$data_migration_data = maybe_unserialize($dms_option_value);
258
+		if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) {
259
+			$class = new $data_migration_data['class'];
260
+			if ($class instanceof EE_Data_Migration_Script_Base) {
261
+				$class->instantiate_from_array_of_properties($data_migration_data);
262
+				return $class;
263
+			} else {
264
+				// huh, so its an object but not a data migration script?? that shouldn't happen
265
+				// just leave it as an array (which will probably just get ignored)
266
+				throw new EE_Error(
267
+					sprintf(
268
+						__(
269
+							"Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists",
270
+							'event_espresso'
271
+						),
272
+						$data_migration_data['class']
273
+					)
274
+				);
275
+			}
276
+		} else {
277
+			// so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
278
+			throw new EE_Error(
279
+				sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)
280
+			);
281
+		}
282
+	}
283
+
284
+	/**
285
+	 * Gets the array describing what data migrations have run. Also has a side-effect of recording which was the last
286
+	 * ran, and which was the last ran which hasn't finished yet
287
+	 *
288
+	 * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy
289
+	 *               arrays in there - which should probably be ignored)
290
+	 */
291
+	public function get_data_migrations_ran()
292
+	{
293
+		if (! $this->_data_migrations_ran) {
294
+			// setup autoloaders for each of the scripts in there
295
+			$this->get_all_data_migration_scripts_available();
296
+			$data_migrations_options = $this->get_all_migration_script_options(
297
+			);// get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
298
+
299
+			$data_migrations_ran = array();
300
+			// convert into data migration script classes where possible
301
+			foreach ($data_migrations_options as $data_migration_option) {
302
+				list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name(
303
+					$data_migration_option['option_name']
304
+				);
305
+
306
+				try {
307
+					$class = $this->_get_dms_class_from_wp_option(
308
+						$data_migration_option['option_name'],
309
+						$data_migration_option['option_value']
310
+					);
311
+					$data_migrations_ran[ $plugin_slug ][ $version_string ] = $class;
312
+					// ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
313
+					$this->_last_ran_script = $class;
314
+					if (! $class->is_completed()) {
315
+						// sometimes we also like to know which was the last incomplete script (or if there are any at all)
316
+						$this->_last_ran_incomplete_script = $class;
317
+					}
318
+				} catch (EE_Error $e) {
319
+					// ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
320
+					$data_migrations_ran[ $plugin_slug ][ $version_string ] = maybe_unserialize(
321
+						$data_migration_option['option_value']
322
+					);
323
+				}
324
+			}
325
+			// so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
326
+			$this->_data_migrations_ran = $data_migrations_ran;
327
+			if (! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
328
+				$this->_data_migrations_ran = array();
329
+			}
330
+		}
331
+		return $this->_data_migrations_ran;
332
+	}
333
+
334
+
335
+	/**
336
+	 *
337
+	 * @param string $script_name eg 'DMS_Core_4_1_0'
338
+	 * @param string $old_table   eg 'wp_events_detail'
339
+	 * @param string $old_pk      eg 'wp_esp_posts'
340
+	 * @param        $new_table
341
+	 * @return mixed string or int
342
+	 */
343
+	public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table)
344
+	{
345
+		$script = EE_Registry::instance()->load_dms($script_name);
346
+		$mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table);
347
+		return $mapping;
348
+	}
349
+
350
+	/**
351
+	 * Gets all the options containing migration scripts that have been run. Ordering is important: it's assumed that
352
+	 * the last option returned in this array is the most-recently ran DMS option
353
+	 *
354
+	 * @return array
355
+	 */
356
+	public function get_all_migration_script_options()
357
+	{
358
+		global $wpdb;
359
+		return $wpdb->get_results(
360
+			"SELECT * FROM {$wpdb->options} WHERE option_name like '" . EE_Data_Migration_Manager::data_migration_script_option_prefix . "%' ORDER BY option_id ASC",
361
+			ARRAY_A
362
+		);
363
+	}
364
+
365
+	/**
366
+	 * Gets the array of folders which contain data migration scripts. Also adds them to be auto-loaded
367
+	 *
368
+	 * @return array where each value is the full folder path of a folder containing data migration scripts, WITH
369
+	 *               slashes at the end of the folder name.
370
+	 */
371
+	public function get_data_migration_script_folders()
372
+	{
373
+		return apply_filters(
374
+			'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
375
+			array('Core' => EE_CORE . 'data_migration_scripts')
376
+		);
377
+	}
378
+
379
+	/**
380
+	 * Gets the version the migration script upgrades to
381
+	 *
382
+	 * @param string $migration_script_name eg 'EE_DMS_Core_4_1_0'
383
+	 * @return array {
384
+	 * @type string  $slug                  like 'Core','Calendar',etc
385
+	 * @type string  $version               like 4.3.0
386
+	 *                                      }
387
+	 * @throws EE_Error
388
+	 */
389
+	public function script_migrates_to_version($migration_script_name, $eeAddonClass = '')
390
+	{
391
+		if (isset($this->script_migration_versions[ $migration_script_name ])) {
392
+			return $this->script_migration_versions[ $migration_script_name ];
393
+		}
394
+		$dms_info = $this->parse_dms_classname($migration_script_name);
395
+		$this->script_migration_versions[ $migration_script_name ] = array(
396
+			'slug'    => $eeAddonClass !== '' ? $eeAddonClass : $dms_info['slug'],
397
+			'version' => $dms_info['major_version'] . "." . $dms_info['minor_version'] . "." . $dms_info['micro_version'],
398
+		);
399
+		return $this->script_migration_versions[ $migration_script_name ];
400
+	}
401
+
402
+	/**
403
+	 * Gets the juicy details out of a dms filename like 'EE_DMS_Core_4_1_0'
404
+	 *
405
+	 * @param string $classname
406
+	 * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints)
407
+	 * @throws EE_Error
408
+	 */
409
+	public function parse_dms_classname($classname)
410
+	{
411
+		$matches = array();
412
+		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
413
+		if (! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
414
+			throw new EE_Error(
415
+				sprintf(
416
+					__(
417
+						"%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ",
418
+						"event_espresso"
419
+					),
420
+					$classname
421
+				)
422
+			);
423
+		}
424
+		return array(
425
+			'slug'          => $matches[1],
426
+			'major_version' => intval($matches[2]),
427
+			'minor_version' => intval($matches[3]),
428
+			'micro_version' => intval($matches[4]),
429
+		);
430
+	}
431
+
432
+	/**
433
+	 * Ensures that the option indicating the current DB version is set. This should only be
434
+	 * a concern when activating EE for the first time, THEORETICALLY.
435
+	 * If we detect that we're activating EE4 over top of EE3.1, then we set the current db state to 3.1.x, otherwise
436
+	 * to 4.1.x.
437
+	 *
438
+	 * @return string of current db state
439
+	 */
440
+	public function ensure_current_database_state_is_set()
441
+	{
442
+		$espresso_db_core_updates = get_option('espresso_db_update', array());
443
+		$db_state = get_option(EE_Data_Migration_Manager::current_database_state);
444
+		if (! $db_state) {
445
+			// mark the DB as being in the state as the last version in there.
446
+			// this is done to trigger maintenance mode and do data migration scripts
447
+			// if the admin installed this version of EE over 3.1.x or 4.0.x
448
+			// otherwise, the normal maintenance mode code is fine
449
+			$previous_versions_installed = array_keys($espresso_db_core_updates);
450
+			$previous_version_installed = end($previous_versions_installed);
451
+			if (version_compare('4.1.0', $previous_version_installed)) {
452
+				// last installed version was less than 4.1
453
+				// so we want the data migrations to happen. SO, we're going to say the DB is at that state
454
+				$db_state = array('Core' => $previous_version_installed);
455
+			} else {
456
+				$db_state = array('Core' => EVENT_ESPRESSO_VERSION);
457
+			}
458
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
459
+		}
460
+		// in 4.1, $db_state would have only been a simple string like '4.1.0',
461
+		// but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
462
+		// db, and possibly other keys for other addons like 'Calendar','Permissions',etc
463
+		if (! is_array($db_state)) {
464
+			$db_state = array('Core' => $db_state);
465
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
466
+		}
467
+		return $db_state;
468
+	}
469
+
470
+	/**
471
+	 * Checks if there are any data migration scripts that ought to be run. If found,
472
+	 * returns the instantiated classes. If none are found (ie, they've all already been run
473
+	 * or they don't apply), returns an empty array
474
+	 *
475
+	 * @return EE_Data_Migration_Script_Base[]
476
+	 */
477
+	public function check_for_applicable_data_migration_scripts()
478
+	{
479
+		// get the option describing what options have already run
480
+		$scripts_ran = $this->get_data_migrations_ran();
481
+		// $scripts_ran = array('4.1.0.core'=>array('monkey'=>null));
482
+		$script_class_and_filepaths_available = $this->get_all_data_migration_scripts_available();
483
+
484
+
485
+		$current_database_state = $this->ensure_current_database_state_is_set();
486
+		// determine which have already been run
487
+		$script_classes_that_should_run_per_iteration = array();
488
+		$iteration = 0;
489
+		$next_database_state_to_consider = $current_database_state;
490
+		$theoretical_database_state = null;
491
+		do {
492
+			// the next state after the currently-considered one will start off looking the same as the current, but we may make additions...
493
+			$theoretical_database_state = $next_database_state_to_consider;
494
+			// the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?)
495
+			foreach ($script_class_and_filepaths_available as $classname => $filepath) {
496
+				$migrates_to_version = $this->script_migrates_to_version($classname);
497
+				$script_converts_plugin_slug = $migrates_to_version['slug'];
498
+				$script_converts_to_version = $migrates_to_version['version'];
499
+				// check if this version script is DONE or not; or if it's never been ran
500
+				if (! $scripts_ran ||
501
+					! isset($scripts_ran[ $script_converts_plugin_slug ]) ||
502
+					! isset($scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ])) {
503
+					// we haven't ran this conversion script before
504
+					// now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
505
+					$script = new $classname($this->_get_table_manager(), $this->_get_table_analysis());
506
+					/* @var $script EE_Data_Migration_Script_Base */
507
+					$can_migrate = $script->can_migrate_from_version($theoretical_database_state);
508
+					if ($can_migrate) {
509
+						$script_classes_that_should_run_per_iteration[ $iteration ][ $script->priority() ][] = $script;
510
+						$migrates_to_version = $script->migrates_to_version();
511
+						$next_database_state_to_consider[ $migrates_to_version['slug'] ] = $migrates_to_version['version'];
512
+						unset($script_class_and_filepaths_available[ $classname ]);
513
+					}
514
+				} elseif ($scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ] instanceof EE_Data_Migration_Script_Base) {
515
+					// this script has been ran, or at least started
516
+					$script = $scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ];
517
+					if ($script->get_status() != self::status_completed) {
518
+						// this script is already underway... keep going with it
519
+						$script_classes_that_should_run_per_iteration[ $iteration ][ $script->priority() ][] = $script;
520
+						$migrates_to_version = $script->migrates_to_version();
521
+						$next_database_state_to_consider[ $migrates_to_version['slug'] ] = $migrates_to_version['version'];
522
+						unset($script_class_and_filepaths_available[ $classname ]);
523
+					} else {
524
+						// it must have a status that indicates it has finished, so we don't want to try and run it again
525
+					}
526
+				} else {
527
+					// it exists but it's not  a proper data migration script
528
+					// maybe the script got renamed? or was simply removed from EE?
529
+					// either way, its certainly not runnable!
530
+				}
531
+			}
532
+			$iteration++;
533
+		} while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
534
+		// ok we have all the scripts that should run, now let's make them into flat array
535
+		$scripts_that_should_run = array();
536
+		foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
537
+			ksort($scripts_at_priority);
538
+			foreach ($scripts_at_priority as $scripts) {
539
+				foreach ($scripts as $script) {
540
+					$scripts_that_should_run[ get_class($script) ] = $script;
541
+				}
542
+			}
543
+		}
544
+
545
+		do_action(
546
+			'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run',
547
+			$scripts_that_should_run
548
+		);
549
+		return $scripts_that_should_run;
550
+	}
551
+
552
+
553
+	/**
554
+	 * Gets the script which is currently being ran, if there is one. If $include_completed_scripts is set to TRUE
555
+	 * it will return the last ran script even if its complete.
556
+	 * This means: if you want to find the currently-executing script, leave it as FALSE.
557
+	 * If you really just want to find the script which ran most recently, regardless of status, leave it as TRUE.
558
+	 *
559
+	 * @param bool $include_completed_scripts
560
+	 * @return EE_Data_Migration_Script_Base
561
+	 */
562
+	public function get_last_ran_script($include_completed_scripts = false)
563
+	{
564
+		// make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
565
+		if (! $this->_data_migrations_ran) {
566
+			$this->get_data_migrations_ran();
567
+		}
568
+		if ($include_completed_scripts) {
569
+			return $this->_last_ran_script;
570
+		} else {
571
+			return $this->_last_ran_incomplete_script;
572
+		}
573
+	}
574
+
575
+
576
+	/**
577
+	 * Runs the data migration scripts (well, each request to this method calls one of the
578
+	 * data migration scripts' migration_step() functions).
579
+	 *
580
+	 * @param int   $step_size
581
+	 * @throws EE_Error
582
+	 * @return array {
583
+	 *                                  // where the first item is one EE_Data_Migration_Script_Base's stati,
584
+	 *                                  //and the second item is a string describing what was done
585
+	 * @type int    $records_to_migrate from the current migration script
586
+	 * @type int    $records_migrated
587
+	 * @type string $status             one of EE_Data_Migration_Manager::status_*
588
+	 * @type string $script             verbose name of the current DMS
589
+	 * @type string $message            string describing what was done during this step
590
+	 *                                  }
591
+	 */
592
+	public function migration_step($step_size = 0)
593
+	{
594
+
595
+		// bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535
596
+		if (class_exists('EE_CPT_Strategy')) {
597
+			remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5);
598
+		}
599
+
600
+		try {
601
+			$currently_executing_script = $this->get_last_ran_script();
602
+			if (! $currently_executing_script) {
603
+				// Find the next script that needs to execute
604
+				$scripts = $this->check_for_applicable_data_migration_scripts();
605
+				if (! $scripts) {
606
+					// huh, no more scripts to run... apparently we're done!
607
+					// but dont forget to make sure initial data is there
608
+					// we should be good to allow them to exit maintenance mode now
609
+					EE_Maintenance_Mode::instance()->set_maintenance_level(
610
+						intval(EE_Maintenance_Mode::level_0_not_in_maintenance)
611
+					);
612
+					// saving migrations ran should actually be unnecessary, but leaving in place just in case
613
+					// remember this migration was finished (even if we timeout initing db for core and plugins)
614
+					$this->_save_migrations_ran();
615
+					// make sure DB was updated AFTER we've recorded the migration was done
616
+					$this->initialize_db_for_enqueued_ee_plugins();
617
+					return array(
618
+						'records_to_migrate' => 1,
619
+						'records_migrated'   => 1,
620
+						'status'             => self::status_no_more_migration_scripts,
621
+						'script'             => __("Data Migration Completed Successfully", "event_espresso"),
622
+						'message'            => __("All done!", "event_espresso"),
623
+					);
624
+				}
625
+				$currently_executing_script = array_shift($scripts);
626
+				// and add to the array/wp option showing the scripts ran
627
+
628
+				$migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
629
+				$plugin_slug = $migrates_to['slug'];
630
+				$version = $migrates_to['version'];
631
+				$this->_data_migrations_ran[ $plugin_slug ][ $version ] = $currently_executing_script;
632
+			}
633
+			$current_script_name = get_class($currently_executing_script);
634
+		} catch (Exception $e) {
635
+			// an exception occurred while trying to get migration scripts
636
+
637
+			$message = sprintf(
638
+				__("Error Message: %sStack Trace:%s", "event_espresso"),
639
+				$e->getMessage() . '<br>',
640
+				$e->getTraceAsString()
641
+			);
642
+			// record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
643
+			// but that's ok-- it's just an FYI to support that we couldn't even run any data migrations
644
+			$this->add_error_to_migrations_ran(
645
+				sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)
646
+			);
647
+			return array(
648
+				'records_to_migrate' => 1,
649
+				'records_migrated'   => 0,
650
+				'status'             => self::status_fatal_error,
651
+				'script'             => __("Error loading data migration scripts", "event_espresso"),
652
+				'message'            => $message,
653
+			);
654
+		}
655
+		// ok so we definitely have a data migration script
656
+		try {
657
+			// how big of a bite do we want to take? Allow users to easily override via their wp-config
658
+			if (absint($step_size) < 1) {
659
+				$step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE)
660
+					? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
661
+			}
662
+			// do what we came to do!
663
+			$currently_executing_script->migration_step($step_size);
664
+			// can we wrap it up and verify default data?
665
+			$init_dbs = false;
666
+			switch ($currently_executing_script->get_status()) {
667
+				case EE_Data_Migration_Manager::status_continue:
668
+					$response_array = array(
669
+						'records_to_migrate' => $currently_executing_script->count_records_to_migrate(),
670
+						'records_migrated'   => $currently_executing_script->count_records_migrated(),
671
+						'status'             => EE_Data_Migration_Manager::status_continue,
672
+						'message'            => $currently_executing_script->get_feedback_message(),
673
+						'script'             => $currently_executing_script->pretty_name(),
674
+					);
675
+					break;
676
+				case EE_Data_Migration_Manager::status_completed:
677
+					// ok so THAT script has completed
678
+					$this->update_current_database_state_to($this->script_migrates_to_version($current_script_name));
679
+					$response_array = array(
680
+						'records_to_migrate' => $currently_executing_script->count_records_to_migrate(),
681
+						'records_migrated'   => $currently_executing_script->count_records_migrated(),
682
+						'status'             => EE_Data_Migration_Manager::status_completed,
683
+						'message'            => $currently_executing_script->get_feedback_message(),
684
+						'script'             => sprintf(
685
+							__("%s Completed", 'event_espresso'),
686
+							$currently_executing_script->pretty_name()
687
+						),
688
+					);
689
+					// check if there are any more after this one.
690
+					$scripts_remaining = $this->check_for_applicable_data_migration_scripts();
691
+					if (! $scripts_remaining) {
692
+						// we should be good to allow them to exit maintenance mode now
693
+						EE_Maintenance_Mode::instance()->set_maintenance_level(
694
+							intval(EE_Maintenance_Mode::level_0_not_in_maintenance)
695
+						);
696
+						// huh, no more scripts to run... apparently we're done!
697
+						// but dont forget to make sure initial data is there
698
+						$init_dbs = true;
699
+						$response_array['status'] = self::status_no_more_migration_scripts;
700
+					}
701
+					break;
702
+				default:
703
+					$response_array = array(
704
+						'records_to_migrate' => $currently_executing_script->count_records_to_migrate(),
705
+						'records_migrated'   => $currently_executing_script->count_records_migrated(),
706
+						'status'             => $currently_executing_script->get_status(),
707
+						'message'            => sprintf(
708
+							__("Minor errors occurred during %s: %s", "event_espresso"),
709
+							$currently_executing_script->pretty_name(),
710
+							implode(", ", $currently_executing_script->get_errors())
711
+						),
712
+						'script'             => $currently_executing_script->pretty_name(),
713
+					);
714
+					break;
715
+			}
716
+		} catch (Exception $e) {
717
+			// ok so some exception was thrown which killed the data migration script
718
+			// double-check we have a real script
719
+			if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) {
720
+				$script_name = $currently_executing_script->pretty_name();
721
+				$currently_executing_script->set_broken();
722
+				$currently_executing_script->add_error($e->getMessage());
723
+			} else {
724
+				$script_name = __("Error getting Migration Script", "event_espresso");
725
+			}
726
+			$response_array = array(
727
+				'records_to_migrate' => 1,
728
+				'records_migrated'   => 0,
729
+				'status'             => self::status_fatal_error,
730
+				'message'            => sprintf(
731
+					__("A fatal error occurred during the migration: %s", "event_espresso"),
732
+					$e->getMessage()
733
+				),
734
+				'script'             => $script_name,
735
+			);
736
+		}
737
+		$successful_save = $this->_save_migrations_ran();
738
+		if ($successful_save !== true) {
739
+			// ok so the current wp option didn't save. that's tricky, because we'd like to update it
740
+			// and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION!
741
+			// however, if we throw an exception, and return that, then the next request
742
+			// won't have as much info in it, and it may be able to save
743
+			throw new EE_Error(
744
+				sprintf(
745
+					__(
746
+						"The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.",
747
+						"event_espresso"
748
+					),
749
+					$successful_save
750
+				)
751
+			);
752
+		}
753
+		// if we're all done, initialize EE plugins' default data etc.
754
+		if ($init_dbs) {
755
+			$this->initialize_db_for_enqueued_ee_plugins();
756
+		}
757
+		return $response_array;
758
+	}
759
+
760
+
761
+	/**
762
+	 * Echo out JSON response to migration script AJAX requests. Takes precautions
763
+	 * to buffer output so that we don't throw junk into our json.
764
+	 *
765
+	 * @return array with keys:
766
+	 * 'records_to_migrate' which counts ALL the records for the current migration, and should remain constant. (ie,
767
+	 * it's NOT the count of hwo many remain)
768
+	 * 'records_migrated' which also counts ALL the records which have been migrated (ie, percent_complete =
769
+	 * records_migrated/records_to_migrate)
770
+	 * 'status'=>a string, one of EE_Data_migration_Manager::status_*
771
+	 * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into
772
+	 * errors, notifications, and successes
773
+	 * 'script'=>a pretty name of the script currently running
774
+	 */
775
+	public function response_to_migration_ajax_request()
776
+	{
777
+		ob_start();
778
+		try {
779
+			$response = $this->migration_step();
780
+		} catch (Exception $e) {
781
+			$response = array(
782
+				'records_to_migrate' => 0,
783
+				'records_migrated'   => 0,
784
+				'status'             => EE_Data_Migration_Manager::status_fatal_error,
785
+				'message'            => sprintf(
786
+					__("Unknown fatal error occurred: %s", "event_espresso"),
787
+					$e->getMessage()
788
+				),
789
+				'script'             => 'Unknown',
790
+			);
791
+			$this->add_error_to_migrations_ran($e->getMessage() . "; Stack trace:" . $e->getTraceAsString());
792
+		}
793
+		$warnings_etc = @ob_get_contents();
794
+		ob_end_clean();
795
+		$response['message'] .= $warnings_etc;
796
+		return $response;
797
+	}
798
+
799
+	/**
800
+	 * Updates the wordpress option that keeps track of which which EE version the database
801
+	 * is at (ie, the code may be at 4.1.0, but the database is still at 3.1.35)
802
+	 *
803
+	 * @param array $slug_and_version {
804
+	 * @type string $slug             like 'Core' or 'Calendar',
805
+	 * @type string $version          like '4.1.0'
806
+	 *                                }
807
+	 * @return void
808
+	 */
809
+	public function update_current_database_state_to($slug_and_version = null)
810
+	{
811
+		if (! $slug_and_version) {
812
+			// no version was provided, assume it should be at the current code version
813
+			$slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
814
+		}
815
+		$current_database_state = get_option(self::current_database_state);
816
+		$current_database_state[ $slug_and_version['slug'] ] = $slug_and_version['version'];
817
+		update_option(self::current_database_state, $current_database_state);
818
+	}
819
+
820
+	/**
821
+	 * Determines if the database is currently at a state matching what's indicated in $slug and $version.
822
+	 *
823
+	 * @param array $slug_and_version {
824
+	 * @type string $slug             like 'Core' or 'Calendar',
825
+	 * @type string $version          like '4.1.0'
826
+	 *                                }
827
+	 * @return boolean
828
+	 */
829
+	public function database_needs_updating_to($slug_and_version)
830
+	{
831
+
832
+		$slug = $slug_and_version['slug'];
833
+		$version = $slug_and_version['version'];
834
+		$current_database_state = get_option(self::current_database_state);
835
+		if (! isset($current_database_state[ $slug ])) {
836
+			return true;
837
+		} else {
838
+			// just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
839
+			$version_parts_current_db_state = array_slice(explode('.', $current_database_state[ $slug ]), 0, 3);
840
+			$version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
841
+			$needs_updating = false;
842
+			foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
843
+				if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ]) {
844
+					$needs_updating = true;
845
+					break;
846
+				}
847
+			}
848
+			return $needs_updating;
849
+		}
850
+	}
851
+
852
+
853
+	/**
854
+	 * Gets all the data migration scripts available in the core folder and folders
855
+	 * in addons. Has the side effect of adding them for autoloading
856
+	 *
857
+	 * @return array keys are expected classnames, values are their filepaths
858
+	 * @throws InvalidInterfaceException
859
+	 * @throws InvalidDataTypeException
860
+	 * @throws EE_Error
861
+	 * @throws InvalidArgumentException
862
+	 */
863
+	public function get_all_data_migration_scripts_available()
864
+	{
865
+		if (! $this->_data_migration_class_to_filepath_map) {
866
+			$this->_data_migration_class_to_filepath_map = array();
867
+			foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
868
+				// strip any placeholders added to classname to make it a unique array key
869
+				$eeAddonClass = trim($eeAddonClass, '*');
870
+				$eeAddonClass = $eeAddonClass === 'Core' || class_exists($eeAddonClass)
871
+					? $eeAddonClass
872
+					: '';
873
+				$folder_path = EEH_File::end_with_directory_separator($folder_path);
874
+				$files = glob($folder_path . '*.dms.php');
875
+				if (empty($files)) {
876
+					continue;
877
+				}
878
+				foreach ($files as $file) {
879
+					$pos_of_last_slash = strrpos($file, DS);
880
+					$classname = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1));
881
+					$migrates_to = $this->script_migrates_to_version($classname, $eeAddonClass);
882
+					$slug = $migrates_to['slug'];
883
+					// check that the slug as contained in the DMS is associated with
884
+					// the slug of an addon or core
885
+					if ($slug !== 'Core' && EE_Registry::instance()->get_addon_by_name($slug) === null) {
886
+						EE_Error::doing_it_wrong(
887
+							__FUNCTION__,
888
+							sprintf(
889
+								esc_html__(
890
+									'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ',
891
+									'event_espresso'
892
+								),
893
+								$classname,
894
+								$slug,
895
+								implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name()))
896
+							),
897
+							'4.3.0.alpha.019'
898
+						);
899
+					}
900
+					$this->_data_migration_class_to_filepath_map[ $classname ] = $file;
901
+				}
902
+			}
903
+			EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
904
+		}
905
+		return $this->_data_migration_class_to_filepath_map;
906
+	}
907
+
908
+
909
+	/**
910
+	 * Once we have an addon that works with EE4.1, we will actually want to fetch the PUE slugs
911
+	 * from each addon, and check if they need updating,
912
+	 *
913
+	 * @return boolean
914
+	 */
915
+	public function addons_need_updating()
916
+	{
917
+		return false;
918
+	}
919
+
920
+	/**
921
+	 * Adds this error string to the data_migrations_ran array, but we dont necessarily know
922
+	 * where to put it, so we just throw it in there... better than nothing...
923
+	 *
924
+	 * @param string $error_message
925
+	 * @throws EE_Error
926
+	 */
927
+	public function add_error_to_migrations_ran($error_message)
928
+	{
929
+		// get last-ran migration script
930
+		global $wpdb;
931
+		$last_migration_script_option = $wpdb->get_row(
932
+			"SELECT * FROM $wpdb->options WHERE option_name like '" . EE_Data_Migration_Manager::data_migration_script_option_prefix . "%' ORDER BY option_id DESC LIMIT 1",
933
+			ARRAY_A
934
+		);
935
+
936
+		$last_ran_migration_script_properties = isset($last_migration_script_option['option_value'])
937
+			? maybe_unserialize($last_migration_script_option['option_value']) : null;
938
+		// now, tread lightly because we're here because a FATAL non-catchable error
939
+		// was thrown last time when we were trying to run a data migration script
940
+		// so the fatal error could have happened while getting the migration script
941
+		// or doing running it...
942
+		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(
943
+			EE_Data_Migration_Manager::data_migration_script_option_prefix,
944
+			"",
945
+			$last_migration_script_option['option_name']
946
+		) : null;
947
+
948
+		// check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet
949
+		// because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done)
950
+		if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) {
951
+			// ok then just add this error to its list of errors
952
+			$last_ran_migration_script_properties['_errors'][] = $error_message;
953
+			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
954
+		} else {
955
+			// so we don't even know which script was last running
956
+			// use the data migration error stub, which is designed specifically for this type of thing
957
+			$general_migration_error = new EE_DMS_Unknown_1_0_0();
958
+			$general_migration_error->add_error($error_message);
959
+			$general_migration_error->set_broken();
960
+			$last_ran_migration_script_properties = $general_migration_error->properties_as_array();
961
+			$versions_migrated_to = 'Unknown.1.0.0';
962
+			// now just to make sure appears as last (in case the were previously a fatal error like this)
963
+			// delete the old one
964
+			delete_option(self::data_migration_script_option_prefix . $versions_migrated_to);
965
+		}
966
+		update_option(
967
+			self::data_migration_script_option_prefix . $versions_migrated_to,
968
+			$last_ran_migration_script_properties
969
+		);
970
+	}
971
+
972
+	/**
973
+	 * saves what data migrations have ran to the database
974
+	 *
975
+	 * @return mixed TRUE if successfully saved migrations ran, string if an error occurred
976
+	 */
977
+	protected function _save_migrations_ran()
978
+	{
979
+		if ($this->_data_migrations_ran == null) {
980
+			$this->get_data_migrations_ran();
981
+		}
982
+		// now, we don't want to save actual classes to the DB because that's messy
983
+		$successful_updates = true;
984
+		foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
985
+			foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
986
+				$plugin_slug_for_use_in_option_name = $plugin_slug . ".";
987
+				$option_name = self::data_migration_script_option_prefix . $plugin_slug_for_use_in_option_name . $version_string;
988
+				$old_option_value = get_option($option_name);
989
+				if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
990
+					$script_array_for_saving = $array_or_migration_obj->properties_as_array();
991
+					if ($old_option_value != $script_array_for_saving) {
992
+						$successful_updates = update_option($option_name, $script_array_for_saving);
993
+					}
994
+				} else {// we don't know what this array-thing is. So just save it as-is
995
+					if ($old_option_value != $array_or_migration_obj) {
996
+						$successful_updates = update_option($option_name, $array_or_migration_obj);
997
+					}
998
+				}
999
+				if (! $successful_updates) {
1000
+					global $wpdb;
1001
+					return $wpdb->last_error;
1002
+				}
1003
+			}
1004
+		}
1005
+		return true;
1006
+		// $updated = update_option(self::data_migrations_option_name, $array_of_migrations);
1007
+		// if ($updated !== true) {
1008
+		//     global $wpdb;
1009
+		//     return $wpdb->last_error;
1010
+		// } else {
1011
+		//     return true;
1012
+		// }
1013
+		// wp_mail(
1014
+		//     "[email protected]",
1015
+		//     time() . " price debug info",
1016
+		//     "updated: $updated, last error: $last_error, byte length of option: " . strlen(
1017
+		//         serialize($array_of_migrations)
1018
+		//     )
1019
+		// );
1020
+	}
1021
+
1022
+	/**
1023
+	 * Takes an array of data migration script properties and re-creates the class from
1024
+	 * them. The argument $properties_array is assumed to have been made by
1025
+	 * EE_Data_Migration_Script_Base::properties_as_array()
1026
+	 *
1027
+	 * @param array $properties_array
1028
+	 * @return EE_Data_Migration_Script_Base
1029
+	 * @throws EE_Error
1030
+	 */
1031
+	public function _instantiate_script_from_properties_array($properties_array)
1032
+	{
1033
+		if (! isset($properties_array['class'])) {
1034
+			throw new EE_Error(
1035
+				sprintf(
1036
+					__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),
1037
+					implode(",", $properties_array)
1038
+				)
1039
+			);
1040
+		}
1041
+		$class_name = $properties_array['class'];
1042
+		if (! class_exists($class_name)) {
1043
+			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
1044
+		}
1045
+		$class = new $class_name;
1046
+		if (! $class instanceof EE_Data_Migration_Script_Base) {
1047
+			throw new EE_Error(
1048
+				sprintf(
1049
+					__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),
1050
+					$class_name,
1051
+					get_class($class)
1052
+				)
1053
+			);
1054
+		}
1055
+		$class->instantiate_from_array_of_properties($properties_array);
1056
+		return $class;
1057
+	}
1058
+
1059
+	/**
1060
+	 * Gets the classname for the most up-to-date DMS (ie, the one that will finally
1061
+	 * leave the DB in a state usable by the current plugin code).
1062
+	 *
1063
+	 * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core'
1064
+	 * @return string
1065
+	 */
1066
+	public function get_most_up_to_date_dms($plugin_slug = 'Core')
1067
+	{
1068
+		$class_to_filepath_map = $this->get_all_data_migration_scripts_available();
1069
+		$most_up_to_date_dms_classname = null;
1070
+		foreach ($class_to_filepath_map as $classname => $filepath) {
1071
+			if ($most_up_to_date_dms_classname === null) {
1072
+				$migrates_to = $this->script_migrates_to_version($classname);
1073
+				$this_plugin_slug = $migrates_to['slug'];
1074
+				if ($this_plugin_slug == $plugin_slug) {
1075
+					// if it's for core, it wins
1076
+					$most_up_to_date_dms_classname = $classname;
1077
+				}
1078
+				// if it wasn't for core, we must keep searching for one that is!
1079
+				continue;
1080
+			} else {
1081
+				$champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname);
1082
+				$contender_migrates_to = $this->script_migrates_to_version($classname);
1083
+				if ($contender_migrates_to['slug'] == $plugin_slug
1084
+					&& version_compare(
1085
+						$champion_migrates_to['version'],
1086
+						$contender_migrates_to['version'],
1087
+						'<'
1088
+					)) {
1089
+					// so the contenders version is higher and its for Core
1090
+					$most_up_to_date_dms_classname = $classname;
1091
+				}
1092
+			}
1093
+		}
1094
+		return $most_up_to_date_dms_classname;
1095
+	}
1096
+
1097
+	/**
1098
+	 * Gets the migration script specified but ONLY if it has already ran.
1099
+	 *
1100
+	 * Eg, if you wanted to see if 'EE_DMS_Core_4_1_0' has ran, you would run the following code:
1101
+	 * <code> $core_4_1_0_dms_ran = EE_Data_Migration_Manager::instance()->get_migration_ran( '4.1.0', 'Core' ) !==
1102
+	 * NULL;</code> This is especially useful in addons' data migration scripts, this way they can tell if a core (or
1103
+	 * other addon) DMS has ran, in case the current DMS depends on it.
1104
+	 *
1105
+	 * @param string $version     the version the DMS searched for migrates to. Usually just the content before the 3rd
1106
+	 *                            period. Eg '4.1.0'
1107
+	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
1108
+	 * @return EE_Data_Migration_Script_Base
1109
+	 */
1110
+	public function get_migration_ran($version, $plugin_slug = 'Core')
1111
+	{
1112
+		$migrations_ran = $this->get_data_migrations_ran();
1113
+		if (isset($migrations_ran[ $plugin_slug ]) && isset($migrations_ran[ $plugin_slug ][ $version ])) {
1114
+			return $migrations_ran[ $plugin_slug ][ $version ];
1115
+		} else {
1116
+			return null;
1117
+		}
1118
+	}
1119
+
1120
+	/**
1121
+	 * Resets the borked data migration scripts so they're no longer borked
1122
+	 * so we can again attempt to migrate
1123
+	 *
1124
+	 * @return bool
1125
+	 * @throws EE_Error
1126
+	 */
1127
+	public function reattempt()
1128
+	{
1129
+		// find if the last-ran script was borked
1130
+		// set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
1131
+		// add an 'error' saying that we attempted to reset
1132
+		// does it have a stage that was borked too? if so make it no longer borked
1133
+		// add an 'error' saying we attempted to reset
1134
+		$last_ran_script = $this->get_last_ran_script();
1135
+		if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) {
1136
+			// if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
1137
+			$last_ran_script->set_completed();
1138
+		} elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) {
1139
+			$last_ran_script->reattempt();
1140
+		} else {
1141
+			throw new EE_Error(
1142
+				sprintf(
1143
+					__(
1144
+						'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s',
1145
+						'event_espresso'
1146
+					),
1147
+					print_r($last_ran_script, true)
1148
+				)
1149
+			);
1150
+		}
1151
+		return $this->_save_migrations_ran();
1152
+	}
1153
+
1154
+	/**
1155
+	 * Gets whether or not this particular migration has run or not
1156
+	 *
1157
+	 * @param string $version     the version the DMS searched for migrates to. Usually just the content before the 3rd
1158
+	 *                            period. Eg '4.1.0'
1159
+	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
1160
+	 * @return boolean
1161
+	 */
1162
+	public function migration_has_ran($version, $plugin_slug = 'Core')
1163
+	{
1164
+		return $this->get_migration_ran($version, $plugin_slug) !== null;
1165
+	}
1166
+
1167
+	/**
1168
+	 * Enqueues this ee plugin to have its data initialized
1169
+	 *
1170
+	 * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value
1171
+	 */
1172
+	public function enqueue_db_initialization_for($plugin_slug)
1173
+	{
1174
+		$queue = $this->get_db_initialization_queue();
1175
+		if (! in_array($plugin_slug, $queue)) {
1176
+			$queue[] = $plugin_slug;
1177
+		}
1178
+		update_option(self::db_init_queue_option_name, $queue);
1179
+	}
1180
+
1181
+	/**
1182
+	 * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
1183
+	 * specified in EE_Data_Migration_Manager::get_db_init_queue(), and if 'Core' is
1184
+	 * in the queue, calls EE_System::initialize_db_if_no_migrations_required().
1185
+	 */
1186
+	public function initialize_db_for_enqueued_ee_plugins()
1187
+	{
1188
+		$queue = $this->get_db_initialization_queue();
1189
+		foreach ($queue as $plugin_slug) {
1190
+			$most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
1191
+			if (! $most_up_to_date_dms) {
1192
+				// if there is NO DMS for this plugin, obviously there's no schema to verify anyways
1193
+				$verify_db = false;
1194
+			} else {
1195
+				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
1196
+				$verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
1197
+			}
1198
+			if ($plugin_slug == 'Core') {
1199
+				EE_System::instance()->initialize_db_if_no_migrations_required(
1200
+					false,
1201
+					$verify_db
1202
+				);
1203
+			} else {
1204
+				// just loop through the addons to make sure their database is setup
1205
+				foreach (EE_Registry::instance()->addons as $addon) {
1206
+					if ($addon->name() == $plugin_slug) {
1207
+						$addon->initialize_db_if_no_migrations_required($verify_db);
1208
+						break;
1209
+					}
1210
+				}
1211
+			}
1212
+		}
1213
+		// because we just initialized the DBs for the enqueued ee plugins
1214
+		// we don't need to keep remembering which ones needed to be initialized
1215
+		delete_option(self::db_init_queue_option_name);
1216
+	}
1217
+
1218
+	/**
1219
+	 * Gets a numerically-indexed array of plugin slugs that need to have their databases
1220
+	 * (re-)initialized after migrations are complete. ie, each element should be either
1221
+	 * 'Core', or the return value of EE_Addon::name() for an addon
1222
+	 *
1223
+	 * @return array
1224
+	 */
1225
+	public function get_db_initialization_queue()
1226
+	{
1227
+		return get_option(self::db_init_queue_option_name, array());
1228
+	}
1229
+
1230
+	/**
1231
+	 * Gets the injected table analyzer, or throws an exception
1232
+	 *
1233
+	 * @return TableAnalysis
1234
+	 * @throws EE_Error
1235
+	 */
1236
+	protected function _get_table_analysis()
1237
+	{
1238
+		if ($this->_table_analysis instanceof TableAnalysis) {
1239
+			return $this->_table_analysis;
1240
+		} else {
1241
+			throw new EE_Error(
1242
+				sprintf(
1243
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1244
+					get_class($this)
1245
+				)
1246
+			);
1247
+		}
1248
+	}
1249
+
1250
+	/**
1251
+	 * Gets the injected table manager, or throws an exception
1252
+	 *
1253
+	 * @return TableManager
1254
+	 * @throws EE_Error
1255
+	 */
1256
+	protected function _get_table_manager()
1257
+	{
1258
+		if ($this->_table_manager instanceof TableManager) {
1259
+			return $this->_table_manager;
1260
+		} else {
1261
+			throw new EE_Error(
1262
+				sprintf(
1263
+					__('Table manager class on class %1$s is not set properly.', 'event_espresso'),
1264
+					get_class($this)
1265
+				)
1266
+			);
1267
+		}
1268
+	}
1269 1269
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     public static function instance()
158 158
     {
159 159
         // check if class object is instantiated
160
-        if (! self::$_instance instanceof EE_Data_Migration_Manager) {
160
+        if ( ! self::$_instance instanceof EE_Data_Migration_Manager) {
161 161
             self::$_instance = new self();
162 162
         }
163 163
         return self::$_instance;
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 
234 234
         if (count($parts) == 4) {
235 235
             // it's 4.2-style.eg Core.4.1.0
236
-            $plugin_slug = $parts[0];// eg Core
237
-            $version_string = $parts[1] . "." . $parts[2] . "." . $parts[3]; // eg 4.1.0
236
+            $plugin_slug = $parts[0]; // eg Core
237
+            $version_string = $parts[1].".".$parts[2].".".$parts[3]; // eg 4.1.0
238 238
         } else {
239 239
             // it's 4.1-style: eg 4.1.0
240 240
             $plugin_slug = 'Core';
241
-            $version_string = $plugin_slug_and_version_string;// eg 4.1.0
241
+            $version_string = $plugin_slug_and_version_string; // eg 4.1.0
242 242
         }
243 243
         return array($plugin_slug, $version_string);
244 244
     }
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
      */
291 291
     public function get_data_migrations_ran()
292 292
     {
293
-        if (! $this->_data_migrations_ran) {
293
+        if ( ! $this->_data_migrations_ran) {
294 294
             // setup autoloaders for each of the scripts in there
295 295
             $this->get_all_data_migration_scripts_available();
296 296
             $data_migrations_options = $this->get_all_migration_script_options(
297
-            );// get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
297
+            ); // get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
298 298
 
299 299
             $data_migrations_ran = array();
300 300
             // convert into data migration script classes where possible
@@ -308,23 +308,23 @@  discard block
 block discarded – undo
308 308
                         $data_migration_option['option_name'],
309 309
                         $data_migration_option['option_value']
310 310
                     );
311
-                    $data_migrations_ran[ $plugin_slug ][ $version_string ] = $class;
311
+                    $data_migrations_ran[$plugin_slug][$version_string] = $class;
312 312
                     // ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
313 313
                     $this->_last_ran_script = $class;
314
-                    if (! $class->is_completed()) {
314
+                    if ( ! $class->is_completed()) {
315 315
                         // sometimes we also like to know which was the last incomplete script (or if there are any at all)
316 316
                         $this->_last_ran_incomplete_script = $class;
317 317
                     }
318 318
                 } catch (EE_Error $e) {
319 319
                     // ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
320
-                    $data_migrations_ran[ $plugin_slug ][ $version_string ] = maybe_unserialize(
320
+                    $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize(
321 321
                         $data_migration_option['option_value']
322 322
                     );
323 323
                 }
324 324
             }
325 325
             // so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
326 326
             $this->_data_migrations_ran = $data_migrations_ran;
327
-            if (! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
327
+            if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
328 328
                 $this->_data_migrations_ran = array();
329 329
             }
330 330
         }
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     {
358 358
         global $wpdb;
359 359
         return $wpdb->get_results(
360
-            "SELECT * FROM {$wpdb->options} WHERE option_name like '" . EE_Data_Migration_Manager::data_migration_script_option_prefix . "%' ORDER BY option_id ASC",
360
+            "SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",
361 361
             ARRAY_A
362 362
         );
363 363
     }
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
     {
373 373
         return apply_filters(
374 374
             'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
375
-            array('Core' => EE_CORE . 'data_migration_scripts')
375
+            array('Core' => EE_CORE.'data_migration_scripts')
376 376
         );
377 377
     }
378 378
 
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
      */
389 389
     public function script_migrates_to_version($migration_script_name, $eeAddonClass = '')
390 390
     {
391
-        if (isset($this->script_migration_versions[ $migration_script_name ])) {
392
-            return $this->script_migration_versions[ $migration_script_name ];
391
+        if (isset($this->script_migration_versions[$migration_script_name])) {
392
+            return $this->script_migration_versions[$migration_script_name];
393 393
         }
394 394
         $dms_info = $this->parse_dms_classname($migration_script_name);
395
-        $this->script_migration_versions[ $migration_script_name ] = array(
395
+        $this->script_migration_versions[$migration_script_name] = array(
396 396
             'slug'    => $eeAddonClass !== '' ? $eeAddonClass : $dms_info['slug'],
397
-            'version' => $dms_info['major_version'] . "." . $dms_info['minor_version'] . "." . $dms_info['micro_version'],
397
+            'version' => $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'],
398 398
         );
399
-        return $this->script_migration_versions[ $migration_script_name ];
399
+        return $this->script_migration_versions[$migration_script_name];
400 400
     }
401 401
 
402 402
     /**
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     {
411 411
         $matches = array();
412 412
         preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
413
-        if (! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
413
+        if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
414 414
             throw new EE_Error(
415 415
                 sprintf(
416 416
                     __(
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
     {
442 442
         $espresso_db_core_updates = get_option('espresso_db_update', array());
443 443
         $db_state = get_option(EE_Data_Migration_Manager::current_database_state);
444
-        if (! $db_state) {
444
+        if ( ! $db_state) {
445 445
             // mark the DB as being in the state as the last version in there.
446 446
             // this is done to trigger maintenance mode and do data migration scripts
447 447
             // if the admin installed this version of EE over 3.1.x or 4.0.x
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         // in 4.1, $db_state would have only been a simple string like '4.1.0',
461 461
         // but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
462 462
         // db, and possibly other keys for other addons like 'Calendar','Permissions',etc
463
-        if (! is_array($db_state)) {
463
+        if ( ! is_array($db_state)) {
464 464
             $db_state = array('Core' => $db_state);
465 465
             update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
466 466
         }
@@ -497,29 +497,29 @@  discard block
 block discarded – undo
497 497
                 $script_converts_plugin_slug = $migrates_to_version['slug'];
498 498
                 $script_converts_to_version = $migrates_to_version['version'];
499 499
                 // check if this version script is DONE or not; or if it's never been ran
500
-                if (! $scripts_ran ||
501
-                    ! isset($scripts_ran[ $script_converts_plugin_slug ]) ||
502
-                    ! isset($scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ])) {
500
+                if ( ! $scripts_ran ||
501
+                    ! isset($scripts_ran[$script_converts_plugin_slug]) ||
502
+                    ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) {
503 503
                     // we haven't ran this conversion script before
504 504
                     // now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
505 505
                     $script = new $classname($this->_get_table_manager(), $this->_get_table_analysis());
506 506
                     /* @var $script EE_Data_Migration_Script_Base */
507 507
                     $can_migrate = $script->can_migrate_from_version($theoretical_database_state);
508 508
                     if ($can_migrate) {
509
-                        $script_classes_that_should_run_per_iteration[ $iteration ][ $script->priority() ][] = $script;
509
+                        $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
510 510
                         $migrates_to_version = $script->migrates_to_version();
511
-                        $next_database_state_to_consider[ $migrates_to_version['slug'] ] = $migrates_to_version['version'];
512
-                        unset($script_class_and_filepaths_available[ $classname ]);
511
+                        $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
512
+                        unset($script_class_and_filepaths_available[$classname]);
513 513
                     }
514
-                } elseif ($scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ] instanceof EE_Data_Migration_Script_Base) {
514
+                } elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) {
515 515
                     // this script has been ran, or at least started
516
-                    $script = $scripts_ran[ $script_converts_plugin_slug ][ $script_converts_to_version ];
516
+                    $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version];
517 517
                     if ($script->get_status() != self::status_completed) {
518 518
                         // this script is already underway... keep going with it
519
-                        $script_classes_that_should_run_per_iteration[ $iteration ][ $script->priority() ][] = $script;
519
+                        $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
520 520
                         $migrates_to_version = $script->migrates_to_version();
521
-                        $next_database_state_to_consider[ $migrates_to_version['slug'] ] = $migrates_to_version['version'];
522
-                        unset($script_class_and_filepaths_available[ $classname ]);
521
+                        $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
522
+                        unset($script_class_and_filepaths_available[$classname]);
523 523
                     } else {
524 524
                         // it must have a status that indicates it has finished, so we don't want to try and run it again
525 525
                     }
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
                 }
531 531
             }
532 532
             $iteration++;
533
-        } while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
533
+        }while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
534 534
         // ok we have all the scripts that should run, now let's make them into flat array
535 535
         $scripts_that_should_run = array();
536 536
         foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
537 537
             ksort($scripts_at_priority);
538 538
             foreach ($scripts_at_priority as $scripts) {
539 539
                 foreach ($scripts as $script) {
540
-                    $scripts_that_should_run[ get_class($script) ] = $script;
540
+                    $scripts_that_should_run[get_class($script)] = $script;
541 541
                 }
542 542
             }
543 543
         }
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
     public function get_last_ran_script($include_completed_scripts = false)
563 563
     {
564 564
         // make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
565
-        if (! $this->_data_migrations_ran) {
565
+        if ( ! $this->_data_migrations_ran) {
566 566
             $this->get_data_migrations_ran();
567 567
         }
568 568
         if ($include_completed_scripts) {
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
 
600 600
         try {
601 601
             $currently_executing_script = $this->get_last_ran_script();
602
-            if (! $currently_executing_script) {
602
+            if ( ! $currently_executing_script) {
603 603
                 // Find the next script that needs to execute
604 604
                 $scripts = $this->check_for_applicable_data_migration_scripts();
605
-                if (! $scripts) {
605
+                if ( ! $scripts) {
606 606
                     // huh, no more scripts to run... apparently we're done!
607 607
                     // but dont forget to make sure initial data is there
608 608
                     // we should be good to allow them to exit maintenance mode now
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
                 $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
629 629
                 $plugin_slug = $migrates_to['slug'];
630 630
                 $version = $migrates_to['version'];
631
-                $this->_data_migrations_ran[ $plugin_slug ][ $version ] = $currently_executing_script;
631
+                $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
632 632
             }
633 633
             $current_script_name = get_class($currently_executing_script);
634 634
         } catch (Exception $e) {
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 
637 637
             $message = sprintf(
638 638
                 __("Error Message: %sStack Trace:%s", "event_espresso"),
639
-                $e->getMessage() . '<br>',
639
+                $e->getMessage().'<br>',
640 640
                 $e->getTraceAsString()
641 641
             );
642 642
             // record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                     );
689 689
                     // check if there are any more after this one.
690 690
                     $scripts_remaining = $this->check_for_applicable_data_migration_scripts();
691
-                    if (! $scripts_remaining) {
691
+                    if ( ! $scripts_remaining) {
692 692
                         // we should be good to allow them to exit maintenance mode now
693 693
                         EE_Maintenance_Mode::instance()->set_maintenance_level(
694 694
                             intval(EE_Maintenance_Mode::level_0_not_in_maintenance)
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
                 ),
789 789
                 'script'             => 'Unknown',
790 790
             );
791
-            $this->add_error_to_migrations_ran($e->getMessage() . "; Stack trace:" . $e->getTraceAsString());
791
+            $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString());
792 792
         }
793 793
         $warnings_etc = @ob_get_contents();
794 794
         ob_end_clean();
@@ -808,12 +808,12 @@  discard block
 block discarded – undo
808 808
      */
809 809
     public function update_current_database_state_to($slug_and_version = null)
810 810
     {
811
-        if (! $slug_and_version) {
811
+        if ( ! $slug_and_version) {
812 812
             // no version was provided, assume it should be at the current code version
813 813
             $slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
814 814
         }
815 815
         $current_database_state = get_option(self::current_database_state);
816
-        $current_database_state[ $slug_and_version['slug'] ] = $slug_and_version['version'];
816
+        $current_database_state[$slug_and_version['slug']] = $slug_and_version['version'];
817 817
         update_option(self::current_database_state, $current_database_state);
818 818
     }
819 819
 
@@ -832,15 +832,15 @@  discard block
 block discarded – undo
832 832
         $slug = $slug_and_version['slug'];
833 833
         $version = $slug_and_version['version'];
834 834
         $current_database_state = get_option(self::current_database_state);
835
-        if (! isset($current_database_state[ $slug ])) {
835
+        if ( ! isset($current_database_state[$slug])) {
836 836
             return true;
837 837
         } else {
838 838
             // just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
839
-            $version_parts_current_db_state = array_slice(explode('.', $current_database_state[ $slug ]), 0, 3);
839
+            $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3);
840 840
             $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
841 841
             $needs_updating = false;
842 842
             foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
843
-                if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ]) {
843
+                if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) {
844 844
                     $needs_updating = true;
845 845
                     break;
846 846
                 }
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
      */
863 863
     public function get_all_data_migration_scripts_available()
864 864
     {
865
-        if (! $this->_data_migration_class_to_filepath_map) {
865
+        if ( ! $this->_data_migration_class_to_filepath_map) {
866 866
             $this->_data_migration_class_to_filepath_map = array();
867 867
             foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
868 868
                 // strip any placeholders added to classname to make it a unique array key
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
                     ? $eeAddonClass
872 872
                     : '';
873 873
                 $folder_path = EEH_File::end_with_directory_separator($folder_path);
874
-                $files = glob($folder_path . '*.dms.php');
874
+                $files = glob($folder_path.'*.dms.php');
875 875
                 if (empty($files)) {
876 876
                     continue;
877 877
                 }
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
                             '4.3.0.alpha.019'
898 898
                         );
899 899
                     }
900
-                    $this->_data_migration_class_to_filepath_map[ $classname ] = $file;
900
+                    $this->_data_migration_class_to_filepath_map[$classname] = $file;
901 901
                 }
902 902
             }
903 903
             EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
         // get last-ran migration script
930 930
         global $wpdb;
931 931
         $last_migration_script_option = $wpdb->get_row(
932
-            "SELECT * FROM $wpdb->options WHERE option_name like '" . EE_Data_Migration_Manager::data_migration_script_option_prefix . "%' ORDER BY option_id DESC LIMIT 1",
932
+            "SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",
933 933
             ARRAY_A
934 934
         );
935 935
 
@@ -961,10 +961,10 @@  discard block
 block discarded – undo
961 961
             $versions_migrated_to = 'Unknown.1.0.0';
962 962
             // now just to make sure appears as last (in case the were previously a fatal error like this)
963 963
             // delete the old one
964
-            delete_option(self::data_migration_script_option_prefix . $versions_migrated_to);
964
+            delete_option(self::data_migration_script_option_prefix.$versions_migrated_to);
965 965
         }
966 966
         update_option(
967
-            self::data_migration_script_option_prefix . $versions_migrated_to,
967
+            self::data_migration_script_option_prefix.$versions_migrated_to,
968 968
             $last_ran_migration_script_properties
969 969
         );
970 970
     }
@@ -983,8 +983,8 @@  discard block
 block discarded – undo
983 983
         $successful_updates = true;
984 984
         foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
985 985
             foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
986
-                $plugin_slug_for_use_in_option_name = $plugin_slug . ".";
987
-                $option_name = self::data_migration_script_option_prefix . $plugin_slug_for_use_in_option_name . $version_string;
986
+                $plugin_slug_for_use_in_option_name = $plugin_slug.".";
987
+                $option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string;
988 988
                 $old_option_value = get_option($option_name);
989 989
                 if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
990 990
                     $script_array_for_saving = $array_or_migration_obj->properties_as_array();
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
                         $successful_updates = update_option($option_name, $array_or_migration_obj);
997 997
                     }
998 998
                 }
999
-                if (! $successful_updates) {
999
+                if ( ! $successful_updates) {
1000 1000
                     global $wpdb;
1001 1001
                     return $wpdb->last_error;
1002 1002
                 }
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
      */
1031 1031
     public function _instantiate_script_from_properties_array($properties_array)
1032 1032
     {
1033
-        if (! isset($properties_array['class'])) {
1033
+        if ( ! isset($properties_array['class'])) {
1034 1034
             throw new EE_Error(
1035 1035
                 sprintf(
1036 1036
                     __("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),
@@ -1039,11 +1039,11 @@  discard block
 block discarded – undo
1039 1039
             );
1040 1040
         }
1041 1041
         $class_name = $properties_array['class'];
1042
-        if (! class_exists($class_name)) {
1042
+        if ( ! class_exists($class_name)) {
1043 1043
             throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
1044 1044
         }
1045 1045
         $class = new $class_name;
1046
-        if (! $class instanceof EE_Data_Migration_Script_Base) {
1046
+        if ( ! $class instanceof EE_Data_Migration_Script_Base) {
1047 1047
             throw new EE_Error(
1048 1048
                 sprintf(
1049 1049
                     __("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
     public function get_migration_ran($version, $plugin_slug = 'Core')
1111 1111
     {
1112 1112
         $migrations_ran = $this->get_data_migrations_ran();
1113
-        if (isset($migrations_ran[ $plugin_slug ]) && isset($migrations_ran[ $plugin_slug ][ $version ])) {
1114
-            return $migrations_ran[ $plugin_slug ][ $version ];
1113
+        if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) {
1114
+            return $migrations_ran[$plugin_slug][$version];
1115 1115
         } else {
1116 1116
             return null;
1117 1117
         }
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
     public function enqueue_db_initialization_for($plugin_slug)
1173 1173
     {
1174 1174
         $queue = $this->get_db_initialization_queue();
1175
-        if (! in_array($plugin_slug, $queue)) {
1175
+        if ( ! in_array($plugin_slug, $queue)) {
1176 1176
             $queue[] = $plugin_slug;
1177 1177
         }
1178 1178
         update_option(self::db_init_queue_option_name, $queue);
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
         $queue = $this->get_db_initialization_queue();
1189 1189
         foreach ($queue as $plugin_slug) {
1190 1190
             $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
1191
-            if (! $most_up_to_date_dms) {
1191
+            if ( ! $most_up_to_date_dms) {
1192 1192
                 // if there is NO DMS for this plugin, obviously there's no schema to verify anyways
1193 1193
                 $verify_db = false;
1194 1194
             } else {
Please login to merge, or discard this patch.
core/espresso_definitions.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 define('EE_SUPPORT_EMAIL', '[email protected]');
8 8
 // used to be DIRECTORY_SEPARATOR, but that caused issues on windows
9 9
 if (! defined('DS')) {
10
-    define('DS', '/');
10
+	define('DS', '/');
11 11
 }
12 12
 if (! defined('PS')) {
13
-    define('PS', PATH_SEPARATOR);
13
+	define('PS', PATH_SEPARATOR);
14 14
 }
15 15
 if (! defined('SP')) {
16
-    define('SP', ' ');
16
+	define('SP', ' ');
17 17
 }
18 18
 if (! defined('EENL')) {
19
-    define('EENL', "\n");
19
+	define('EENL', "\n");
20 20
 }
21 21
 // define the plugin directory and URL
22 22
 define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
71 71
 // check for DOMPDF fonts in uploads
72 72
 if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
73
-    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
73
+	define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
74 74
 }
75 75
 // ajax constants
76 76
 define(
77
-    'EE_FRONT_AJAX',
78
-    isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax'])
77
+	'EE_FRONT_AJAX',
78
+	isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax'])
79 79
 );
80 80
 define(
81
-    'EE_ADMIN_AJAX',
82
-    isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax'])
81
+	'EE_ADMIN_AJAX',
82
+	isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax'])
83 83
 );
84 84
 // just a handy constant occasionally needed for finding values representing infinity in the DB
85 85
 // you're better to use this than its straight value (currently -1) in case you ever
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 define('EE_INF_IN_DB', -1);
88 88
 define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
89 89
 if (! defined('EE_DEBUG')) {
90
-    define('EE_DEBUG', false);
90
+	define('EE_DEBUG', false);
91 91
 }
92 92
 // for older WP versions
93 93
 if (! defined('MONTH_IN_SECONDS')) {
94
-    define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
94
+	define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
95 95
 }
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -6,71 +6,71 @@  discard block
 block discarded – undo
6 6
 define('EE_MIN_PHP_VER_RECOMMENDED', '5.6.32');
7 7
 define('EE_SUPPORT_EMAIL', '[email protected]');
8 8
 // used to be DIRECTORY_SEPARATOR, but that caused issues on windows
9
-if (! defined('DS')) {
9
+if ( ! defined('DS')) {
10 10
     define('DS', '/');
11 11
 }
12
-if (! defined('PS')) {
12
+if ( ! defined('PS')) {
13 13
     define('PS', PATH_SEPARATOR);
14 14
 }
15
-if (! defined('SP')) {
15
+if ( ! defined('SP')) {
16 16
     define('SP', ' ');
17 17
 }
18
-if (! defined('EENL')) {
18
+if ( ! defined('EENL')) {
19 19
     define('EENL', "\n");
20 20
 }
21 21
 // define the plugin directory and URL
22 22
 define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
23
-define('EE_PLUGIN_DIR_PATH', dirname(EVENT_ESPRESSO_MAIN_FILE) . DS);
23
+define('EE_PLUGIN_DIR_PATH', dirname(EVENT_ESPRESSO_MAIN_FILE).DS);
24 24
 define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
25 25
 // main root folder paths
26
-define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
27
-define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
28
-define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
29
-define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
30
-define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
31
-define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
32
-define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
33
-define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
26
+define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
27
+define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
28
+define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
29
+define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
30
+define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
31
+define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
32
+define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
33
+define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
34 34
 // core system paths
35
-define('EE_ADMIN', EE_CORE . 'admin' . DS);
36
-define('EE_CPTS', EE_CORE . 'CPTs' . DS);
37
-define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
38
-define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
39
-define('EE_BUSINESS', EE_CORE . 'business' . DS);
40
-define('EE_MODELS', EE_CORE . 'db_models' . DS);
41
-define('EE_HELPERS', EE_CORE . 'helpers' . DS);
42
-define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
43
-define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
44
-define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
45
-define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
46
-define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
35
+define('EE_ADMIN', EE_CORE.'admin'.DS);
36
+define('EE_CPTS', EE_CORE.'CPTs'.DS);
37
+define('EE_CLASSES', EE_CORE.'db_classes'.DS);
38
+define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
39
+define('EE_BUSINESS', EE_CORE.'business'.DS);
40
+define('EE_MODELS', EE_CORE.'db_models'.DS);
41
+define('EE_HELPERS', EE_CORE.'helpers'.DS);
42
+define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
43
+define('EE_TEMPLATES', EE_CORE.'templates'.DS);
44
+define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
45
+define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
46
+define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
47 47
 // gateways
48
-define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
49
-define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
48
+define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
49
+define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
50 50
 // asset URL paths
51
-define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
52
-define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
53
-define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
54
-define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
55
-define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
56
-define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
51
+define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
52
+define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
53
+define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
54
+define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
55
+define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
56
+define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
57 57
 // define upload paths
58 58
 $uploads = wp_upload_dir();
59 59
 // define the uploads directory and URL
60
-define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
61
-define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
60
+define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
61
+define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
62 62
 // define the templates directory and URL
63
-define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
64
-define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
63
+define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
64
+define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
65 65
 // define the gateway directory and URL
66
-define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
67
-define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
66
+define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
67
+define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
68 68
 // languages folder/path
69
-define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
70
-define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
69
+define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
70
+define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
71 71
 // check for DOMPDF fonts in uploads
72
-if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
73
-    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
72
+if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
73
+    define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
74 74
 }
75 75
 // ajax constants
76 76
 define(
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 // want to change its default value! or find when -1 means infinity
87 87
 define('EE_INF_IN_DB', -1);
88 88
 define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
89
-if (! defined('EE_DEBUG')) {
89
+if ( ! defined('EE_DEBUG')) {
90 90
     define('EE_DEBUG', false);
91 91
 }
92 92
 // for older WP versions
93
-if (! defined('MONTH_IN_SECONDS')) {
93
+if ( ! defined('MONTH_IN_SECONDS')) {
94 94
     define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
95 95
 }
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_invoice_settings.dmsstage.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
     protected function _migration_step($num_items = 1)
53 53
     {
54 54
         // if this isn't set then something is really wrong
55
-        if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
55
+        if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
56 56
             throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
57 57
         }
58 58
         $invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
59
-        if (! $invoice_settings) {
59
+        if ( ! $invoice_settings) {
60 60
             $this->add_error(__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
61 61
         } else {
62 62
             $invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
                 );
90 90
             }
91 91
             $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
92
-            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
93
-            $overridden_receipt_body= EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
92
+            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', null, false, false, true);
93
+            $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', null, false, false, true);
94 94
             if ($overridden_invoice_body || $overridden_receipt_body) {
95 95
                 new PersistentAdminNotice(
96 96
                     'invoice_overriding_templates',
Please login to merge, or discard this patch.
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -15,95 +15,95 @@
 block discarded – undo
15 15
 class EE_DMS_4_5_0_invoice_settings extends EE_Data_Migration_Script_Stage
16 16
 {
17 17
 
18
-    /**
19
-     * Just initializes the status of the migration
20
-     */
21
-    public function __construct()
22
-    {
23
-        $this->_pretty_name = __('Update Invoice Gateway Settings', 'event_espresso');
24
-        parent::__construct();
25
-    }
18
+	/**
19
+	 * Just initializes the status of the migration
20
+	 */
21
+	public function __construct()
22
+	{
23
+		$this->_pretty_name = __('Update Invoice Gateway Settings', 'event_espresso');
24
+		parent::__construct();
25
+	}
26 26
 
27 27
 
28 28
 
29
-    /**
30
-     * _count_records_to_migrate
31
-     * Counts the records to migrate; the public version may cache it
32
-     *
33
-     * @access protected
34
-     * @return int
35
-     */
36
-    protected function _count_records_to_migrate()
37
-    {
38
-        return 1;
39
-    }
29
+	/**
30
+	 * _count_records_to_migrate
31
+	 * Counts the records to migrate; the public version may cache it
32
+	 *
33
+	 * @access protected
34
+	 * @return int
35
+	 */
36
+	protected function _count_records_to_migrate()
37
+	{
38
+		return 1;
39
+	}
40 40
 
41 41
 
42 42
 
43
-    /**
44
-     *    _migration_step
45
-     *
46
-     * @access protected
47
-     * @param int $num_items
48
-     * @throws EE_Error
49
-     * @return int number of items ACTUALLY migrated
50
-     * @throws InvalidDataTypeException
51
-     */
52
-    protected function _migration_step($num_items = 1)
53
-    {
54
-        // if this isn't set then something is really wrong
55
-        if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
56
-            throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
57
-        }
58
-        $invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
59
-        if (! $invoice_settings) {
60
-            $this->add_error(__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
61
-        } else {
62
-            $invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
63
-            $invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
64
-            $invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
65
-            $invoice_settings['template_invoice_email'] = '';
66
-            $invoice_settings['template_invoice_tax_number'] = '';
67
-            unset($invoice_settings['pdf_instructions']);
68
-            unset($invoice_settings['payable_to']);
69
-            unset($invoice_settings['payment_address']);
70
-            EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
71
-            EE_Config::instance()->update_espresso_config(false, false);
43
+	/**
44
+	 *    _migration_step
45
+	 *
46
+	 * @access protected
47
+	 * @param int $num_items
48
+	 * @throws EE_Error
49
+	 * @return int number of items ACTUALLY migrated
50
+	 * @throws InvalidDataTypeException
51
+	 */
52
+	protected function _migration_step($num_items = 1)
53
+	{
54
+		// if this isn't set then something is really wrong
55
+		if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
56
+			throw new EE_Error(__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
57
+		}
58
+		$invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
59
+		if (! $invoice_settings) {
60
+			$this->add_error(__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
61
+		} else {
62
+			$invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
63
+			$invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
64
+			$invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
65
+			$invoice_settings['template_invoice_email'] = '';
66
+			$invoice_settings['template_invoice_tax_number'] = '';
67
+			unset($invoice_settings['pdf_instructions']);
68
+			unset($invoice_settings['payable_to']);
69
+			unset($invoice_settings['payment_address']);
70
+			EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
71
+			EE_Config::instance()->update_espresso_config(false, false);
72 72
 
73
-            // @todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
74
-            // (why is it tough to change? because we want to update the receipt and invoice message template, but
75
-            // message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
76
-            // update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
77
-            // also we don't want to build a dependency on the messages code because it is likely to change soon
78
-            if (isset($invoice_settings['invoice_css'])
79
-                && ! in_array($invoice_settings['invoice_css'], ['', 'simple.css'])) {
80
-                new PersistentAdminNotice(
81
-                    'invoice_css_not_updated',
82
-                    sprintf(
83
-                        esc_html__(
84
-                            'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
85
-                            'event_espresso'
86
-                        ),
87
-                        $invoice_settings['invoice_css']
88
-                    )
89
-                );
90
-            }
91
-            $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
92
-            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
93
-            $overridden_receipt_body= EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
94
-            if ($overridden_invoice_body || $overridden_receipt_body) {
95
-                new PersistentAdminNotice(
96
-                    'invoice_overriding_templates',
97
-                    esc_html__(
98
-                        '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. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
99
-                        'event_espresso'
100
-                    ),
101
-                    true
102
-                );
103
-            }
104
-        }
105
-        // regardless of whether it worked or not, we ought to continue the migration
106
-        $this->set_completed();
107
-        return 1;
108
-    }
73
+			// @todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
74
+			// (why is it tough to change? because we want to update the receipt and invoice message template, but
75
+			// message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
76
+			// update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
77
+			// also we don't want to build a dependency on the messages code because it is likely to change soon
78
+			if (isset($invoice_settings['invoice_css'])
79
+				&& ! in_array($invoice_settings['invoice_css'], ['', 'simple.css'])) {
80
+				new PersistentAdminNotice(
81
+					'invoice_css_not_updated',
82
+					sprintf(
83
+						esc_html__(
84
+							'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
85
+							'event_espresso'
86
+						),
87
+						$invoice_settings['invoice_css']
88
+					)
89
+				);
90
+			}
91
+			$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
92
+			$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
93
+			$overridden_receipt_body= EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
94
+			if ($overridden_invoice_body || $overridden_receipt_body) {
95
+				new PersistentAdminNotice(
96
+					'invoice_overriding_templates',
97
+					esc_html__(
98
+						'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. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
99
+						'event_espresso'
100
+					),
101
+					true
102
+				);
103
+			}
104
+		}
105
+		// regardless of whether it worked or not, we ought to continue the migration
106
+		$this->set_completed();
107
+		return 1;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_prices.dmsstage.php 2 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -87,57 +87,57 @@  discard block
 block discarded – undo
87 87
  */
88 88
 class EE_DMS_4_1_0_prices extends EE_Data_Migration_Script_Stage_Table
89 89
 {
90
-    private $_new_price_table;
91
-    private $_new_ticket_table;
92
-    private $_new_ticket_price_table;
93
-    private $_new_datetime_ticket_table;
94
-    /**
95
-     * A count of all the different tickets created, used for setting the new ones' TKT_Order
96
-     * @var int
97
-     */
98
-    private $_ticket_count = 0;
99
-    const price_type_base = 1;
100
-    const price_type_member_discount = 3;
101
-    const price_type_percent_surcharge = 4;
102
-    const price_type_flat_surcharge = 5;
90
+	private $_new_price_table;
91
+	private $_new_ticket_table;
92
+	private $_new_ticket_price_table;
93
+	private $_new_datetime_ticket_table;
94
+	/**
95
+	 * A count of all the different tickets created, used for setting the new ones' TKT_Order
96
+	 * @var int
97
+	 */
98
+	private $_ticket_count = 0;
99
+	const price_type_base = 1;
100
+	const price_type_member_discount = 3;
101
+	const price_type_percent_surcharge = 4;
102
+	const price_type_flat_surcharge = 5;
103 103
 
104
-    public function __construct()
105
-    {
106
-        global $wpdb;
107
-        $this->_pretty_name = __("Prices", "event_espresso");
108
-        $this->_old_table = $wpdb->prefix."events_prices";
109
-        $this->select_expression = 'p.*, e.event_status';
110
-        $this->_extra_where_sql = ' AS p 
104
+	public function __construct()
105
+	{
106
+		global $wpdb;
107
+		$this->_pretty_name = __("Prices", "event_espresso");
108
+		$this->_old_table = $wpdb->prefix."events_prices";
109
+		$this->select_expression = 'p.*, e.event_status';
110
+		$this->_extra_where_sql = ' AS p 
111 111
             INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON p.event_id=e.id
112 112
             WHERE e.event_status!="D"';
113
-        $this->_new_price_table = $wpdb->prefix."esp_price";
114
-        $this->_new_ticket_table = $wpdb->prefix."esp_ticket";
115
-        $this->_new_ticket_price_table = $wpdb->prefix."esp_ticket_price";
116
-        $this->_new_datetime_ticket_table = $wpdb->prefix."esp_datetime_ticket";
117
-        parent::__construct();
118
-    }
119
-    protected function _migrate_old_row($old_row)
120
-    {
121
-        // create the base price
122
-        $new_price_id = $this->_insert_new_price($old_row);
123
-        // create the member discount if there is any
124
-        // commented-out because we may actually NOT be supporting this in 4.1
113
+		$this->_new_price_table = $wpdb->prefix."esp_price";
114
+		$this->_new_ticket_table = $wpdb->prefix."esp_ticket";
115
+		$this->_new_ticket_price_table = $wpdb->prefix."esp_ticket_price";
116
+		$this->_new_datetime_ticket_table = $wpdb->prefix."esp_datetime_ticket";
117
+		parent::__construct();
118
+	}
119
+	protected function _migrate_old_row($old_row)
120
+	{
121
+		// create the base price
122
+		$new_price_id = $this->_insert_new_price($old_row);
123
+		// create the member discount if there is any
124
+		// commented-out because we may actually NOT be supporting this in 4.1
125 125
 //      if($old_row['event_cost'] != $old_row['member_price']){
126 126
 //          $member_price_discount_id = $this->_insert_new_member_price($old_row);
127 127
 //      }else{
128 128
 //          $member_price_discount_id = 0;
129 129
 //      }
130
-        // create the surcharge if there is any
131
-        if (floatval($old_row['surcharge']) >= 0.01) {
132
-            $surcharge_price_id = $this->_insert_new_surcharge_price($old_row);
133
-            $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id,$surcharge_price_id));
134
-        } else {
135
-            $surcharge_price_id = 0;
136
-            $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id));
137
-        }
138
-        // associate the ticket to all datetimes for event (ie, this ONE ticket grants access to ALL datetimes, not just one of the attendee's choice.
139
-        // if the latter were the case, then we'd create a separate ticket for each datetime and ahve their association be one-to-one)
140
-        // create ticket
130
+		// create the surcharge if there is any
131
+		if (floatval($old_row['surcharge']) >= 0.01) {
132
+			$surcharge_price_id = $this->_insert_new_surcharge_price($old_row);
133
+			$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id,$surcharge_price_id));
134
+		} else {
135
+			$surcharge_price_id = 0;
136
+			$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id));
137
+		}
138
+		// associate the ticket to all datetimes for event (ie, this ONE ticket grants access to ALL datetimes, not just one of the attendee's choice.
139
+		// if the latter were the case, then we'd create a separate ticket for each datetime and ahve their association be one-to-one)
140
+		// create ticket
141 141
 //      $ticket_id = $this->_insert_new_ticket($old_row);
142 142
 //      if($ticket_id){
143 143
 //          $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_ticket_table, $ticket_id);
@@ -149,62 +149,62 @@  discard block
 block discarded – undo
149 149
 //              $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id);
150 150
 //          }
151 151
 //      }
152
-        // create a ticket for each old price -old datetime combo
153
-        $tickets_for_old_price = array();
154
-        foreach ($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id) {
155
-            $ticket_id = $this->_insert_new_ticket($old_row);
156
-            $tickets_for_old_price[] = $ticket_id;
157
-            // associate to old prices
158
-            $this->_insert_ticket_price_relation($ticket_id, $new_price_id);
159
-            $this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id);
160
-            $this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id);
161
-        }
162
-        $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_ticket_table, $tickets_for_old_price);
163
-    }
164
-    /**
165
-     * Creates a 4.1 price base type
166
-     * @global type $wpdb
167
-     * @param type $old_price
168
-     * @return int
169
-     */
170
-    private function _insert_new_price($old_price)
171
-    {
172
-        global $wpdb;
173
-        $cols_n_values = array(
174
-            'PRT_ID'=>self::price_type_base,
175
-            'PRC_amount'=>floatval($old_price['event_cost']),
176
-            'PRC_name'=>$old_price['price_type'],
177
-            'PRC_is_default'=>false,
178
-            'PRC_overrides'=>false,
179
-            'PRC_order'=>0,
180
-            'PRC_deleted'=>false,
181
-            'PRC_parent'=>null
152
+		// create a ticket for each old price -old datetime combo
153
+		$tickets_for_old_price = array();
154
+		foreach ($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id) {
155
+			$ticket_id = $this->_insert_new_ticket($old_row);
156
+			$tickets_for_old_price[] = $ticket_id;
157
+			// associate to old prices
158
+			$this->_insert_ticket_price_relation($ticket_id, $new_price_id);
159
+			$this->_insert_ticket_price_relation($ticket_id, $surcharge_price_id);
160
+			$this->_insert_datetime_ticket_relation($new_datetime_id, $ticket_id);
161
+		}
162
+		$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_ticket_table, $tickets_for_old_price);
163
+	}
164
+	/**
165
+	 * Creates a 4.1 price base type
166
+	 * @global type $wpdb
167
+	 * @param type $old_price
168
+	 * @return int
169
+	 */
170
+	private function _insert_new_price($old_price)
171
+	{
172
+		global $wpdb;
173
+		$cols_n_values = array(
174
+			'PRT_ID'=>self::price_type_base,
175
+			'PRC_amount'=>floatval($old_price['event_cost']),
176
+			'PRC_name'=>$old_price['price_type'],
177
+			'PRC_is_default'=>false,
178
+			'PRC_overrides'=>false,
179
+			'PRC_order'=>0,
180
+			'PRC_deleted'=>false,
181
+			'PRC_parent'=>null
182 182
 
183
-        );
184
-        $datatypes = array(
185
-            '%d',// PRT_ID
186
-            '%f',// PRT_amount
187
-            '%s',// PRC_name
188
-            '%d',// PRC_is_default
189
-            '%d',// PRC_overrides
190
-            '%d',// PRC_order
191
-            '%d',// PRC_deleted
192
-            '%d',// PRC_parent
193
-        );
194
-        $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes);
195
-        if (! $success) {
196
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes));
197
-            return 0;
198
-        }
199
-        $new_id = $wpdb->insert_id;
200
-        return $new_id;
201
-    }
202
-    /**
203
-     * Creates a 4.1 member price discount
204
-     * @global type $wpdb
205
-     * @param type $old_price
206
-     * @return int
207
-     */
183
+		);
184
+		$datatypes = array(
185
+			'%d',// PRT_ID
186
+			'%f',// PRT_amount
187
+			'%s',// PRC_name
188
+			'%d',// PRC_is_default
189
+			'%d',// PRC_overrides
190
+			'%d',// PRC_order
191
+			'%d',// PRC_deleted
192
+			'%d',// PRC_parent
193
+		);
194
+		$success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes);
195
+		if (! $success) {
196
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes));
197
+			return 0;
198
+		}
199
+		$new_id = $wpdb->insert_id;
200
+		return $new_id;
201
+	}
202
+	/**
203
+	 * Creates a 4.1 member price discount
204
+	 * @global type $wpdb
205
+	 * @param type $old_price
206
+	 * @return int
207
+	 */
208 208
 //  private function _insert_new_member_price($old_price){
209 209
 //      $discount_amount = floatval($old_price['event_cost']) - floatval($old_price['member_price']);
210 210
 //      global $wpdb;
@@ -237,207 +237,207 @@  discard block
 block discarded – undo
237 237
 //      $new_id = $wpdb->insert_id;
238 238
 //      return $new_id;
239 239
 //  }
240
-    /**
241
-     * Creates a 4.1 member price discount
242
-     * @global type $wpdb
243
-     * @param type $old_price
244
-     * @return int
245
-     */
246
-    private function _insert_new_surcharge_price($old_price)
247
-    {
240
+	/**
241
+	 * Creates a 4.1 member price discount
242
+	 * @global type $wpdb
243
+	 * @param type $old_price
244
+	 * @return int
245
+	 */
246
+	private function _insert_new_surcharge_price($old_price)
247
+	{
248 248
 
249
-        if ($old_price['surcharge_type'] == 'flat_rate') {
250
-            $price_type = self::price_type_flat_surcharge;
251
-        } else {
252
-            $price_type = self::price_type_percent_surcharge;
253
-        }
254
-        global $wpdb;
255
-        $cols_n_values = array(
256
-            'PRT_ID'=>$price_type,
257
-            'PRC_amount'=>floatval($old_price['surcharge']),
258
-            'PRC_name'=>  __("Surcharge", "event_espresso"),
259
-            'PRC_is_default'=>false,
260
-            'PRC_overrides'=>false,
261
-            'PRC_order'=>20,
262
-            'PRC_deleted'=>false,
263
-            'PRC_parent'=>null
249
+		if ($old_price['surcharge_type'] == 'flat_rate') {
250
+			$price_type = self::price_type_flat_surcharge;
251
+		} else {
252
+			$price_type = self::price_type_percent_surcharge;
253
+		}
254
+		global $wpdb;
255
+		$cols_n_values = array(
256
+			'PRT_ID'=>$price_type,
257
+			'PRC_amount'=>floatval($old_price['surcharge']),
258
+			'PRC_name'=>  __("Surcharge", "event_espresso"),
259
+			'PRC_is_default'=>false,
260
+			'PRC_overrides'=>false,
261
+			'PRC_order'=>20,
262
+			'PRC_deleted'=>false,
263
+			'PRC_parent'=>null
264 264
 
265
-        );
266
-        $datatypes = array(
267
-            '%d',// PRT_ID
268
-            '%f',// PRT_amount
269
-            '%s',// PRC_name
270
-            '%d',// PRC_is_default
271
-            '%d',// PRC_overrides
272
-            '%d',// PRC_order
273
-            '%d',// PRC_deleted
274
-            '%d',// PRC_parent
275
-        );
276
-        $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes);
277
-        if (! $success) {
278
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes));
279
-            return 0;
280
-        }
281
-        $new_id = $wpdb->insert_id;
282
-        return $new_id;
283
-    }
284
-    /**
285
-     * Inserts a 4.1 ticket based off the 3.1 price, and the price IDs we've already made from the 3.1 price
286
-     * @param $old_price_row array where keys are columns
287
-     * @param $new_base_price_id int
288
-     * @param $new_member_discount_id int
289
-     * @param $new_surcharge_id int
290
-     * @return int new ticket id
291
-     */
292
-    private function _insert_new_ticket($old_price_row)
293
-    {
294
-        global $wpdb;
295
-        $event_row = $this->_get_event_row($old_price_row['event_id']);
296
-        if ($old_price_row['surcharge_type'] == 'flat_rate') {
297
-            $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']);
298
-        } else {// percent surcharge
299
-            $final_ticket_price = floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge'])/100);
300
-        }
301
-        $start_date = $event_row['registration_start']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']);
302
-        $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $old_price_row, $start_date, $event_row['timezone_string']);
303
-        $end_date = $event_row['registration_end']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']);
304
-        $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $old_price_row, $end_date, $event_row['timezone_string']);
305
-        $cols_n_values = array(
306
-            'TTM_ID'=>0,
307
-            'TKT_name'=>$old_price_row['price_type'],
308
-            'TKT_description'=>'',
309
-            'TKT_start_date'=>$start_date_utc,
310
-            'TKT_end_date'=>$end_date_utc,
311
-            'TKT_min'=>0,
312
-            'TKT_max'=>-1,
313
-            'TKT_price'=>$final_ticket_price,
314
-            'TKT_sold'=> 0,// note: this will get calculated as we actually add registrations during the migration
315
-            'TKT_qty'=> -1,
316
-            'TKT_uses'=> 1,
317
-            'TKT_taxable'=>false,// so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices
318
-            'TKT_is_default'=>false,
319
-            'TKT_order'=>$this->_get_ticket_count(),
320
-            'TKT_row'=>0,// doesn't matter because UI reset this on first save anyways
321
-            'TKT_deleted'=>false,
322
-            'TKT_parent'=>0
265
+		);
266
+		$datatypes = array(
267
+			'%d',// PRT_ID
268
+			'%f',// PRT_amount
269
+			'%s',// PRC_name
270
+			'%d',// PRC_is_default
271
+			'%d',// PRC_overrides
272
+			'%d',// PRC_order
273
+			'%d',// PRC_deleted
274
+			'%d',// PRC_parent
275
+		);
276
+		$success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes);
277
+		if (! $success) {
278
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes));
279
+			return 0;
280
+		}
281
+		$new_id = $wpdb->insert_id;
282
+		return $new_id;
283
+	}
284
+	/**
285
+	 * Inserts a 4.1 ticket based off the 3.1 price, and the price IDs we've already made from the 3.1 price
286
+	 * @param $old_price_row array where keys are columns
287
+	 * @param $new_base_price_id int
288
+	 * @param $new_member_discount_id int
289
+	 * @param $new_surcharge_id int
290
+	 * @return int new ticket id
291
+	 */
292
+	private function _insert_new_ticket($old_price_row)
293
+	{
294
+		global $wpdb;
295
+		$event_row = $this->_get_event_row($old_price_row['event_id']);
296
+		if ($old_price_row['surcharge_type'] == 'flat_rate') {
297
+			$final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']);
298
+		} else {// percent surcharge
299
+			$final_ticket_price = floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge'])/100);
300
+		}
301
+		$start_date = $event_row['registration_start']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']);
302
+		$start_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $old_price_row, $start_date, $event_row['timezone_string']);
303
+		$end_date = $event_row['registration_end']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']);
304
+		$end_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $old_price_row, $end_date, $event_row['timezone_string']);
305
+		$cols_n_values = array(
306
+			'TTM_ID'=>0,
307
+			'TKT_name'=>$old_price_row['price_type'],
308
+			'TKT_description'=>'',
309
+			'TKT_start_date'=>$start_date_utc,
310
+			'TKT_end_date'=>$end_date_utc,
311
+			'TKT_min'=>0,
312
+			'TKT_max'=>-1,
313
+			'TKT_price'=>$final_ticket_price,
314
+			'TKT_sold'=> 0,// note: this will get calculated as we actually add registrations during the migration
315
+			'TKT_qty'=> -1,
316
+			'TKT_uses'=> 1,
317
+			'TKT_taxable'=>false,// so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices
318
+			'TKT_is_default'=>false,
319
+			'TKT_order'=>$this->_get_ticket_count(),
320
+			'TKT_row'=>0,// doesn't matter because UI reset this on first save anyways
321
+			'TKT_deleted'=>false,
322
+			'TKT_parent'=>0
323 323
 
324
-        );
325
-        $datatypes = array(
326
-            '%d',// TTM_ID
327
-            '%s',// TKT_name
328
-            '%s',// TKT_description
329
-            '%s',// TKT_start_date
330
-            '%s',// TKT_end_date
331
-            '%d',// TKT_min
332
-            '%d',// TKT_max
333
-            '%f',// TKT_price
334
-            '%d',// TKT_sold
335
-            '%d',// TKT_qty
336
-            '%d',// TKT_uses
337
-            '%d',// TKT_taxable
338
-            '%d',// TKT_is_default
339
-            '%d',// TKT_order
340
-            '%d',// TKT_row
341
-            '%d',// TKT_deleted
342
-            '%d',// TKT_parent
343
-        );
344
-        $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $datatypes);
345
-        if (! $success) {
346
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price_row, $this->_new_ticket_table, $cols_n_values, $datatypes));
347
-            return 0;
348
-        }
349
-        $new_id = $wpdb->insert_id;
350
-        return $new_id;
351
-    }
324
+		);
325
+		$datatypes = array(
326
+			'%d',// TTM_ID
327
+			'%s',// TKT_name
328
+			'%s',// TKT_description
329
+			'%s',// TKT_start_date
330
+			'%s',// TKT_end_date
331
+			'%d',// TKT_min
332
+			'%d',// TKT_max
333
+			'%f',// TKT_price
334
+			'%d',// TKT_sold
335
+			'%d',// TKT_qty
336
+			'%d',// TKT_uses
337
+			'%d',// TKT_taxable
338
+			'%d',// TKT_is_default
339
+			'%d',// TKT_order
340
+			'%d',// TKT_row
341
+			'%d',// TKT_deleted
342
+			'%d',// TKT_parent
343
+		);
344
+		$success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $datatypes);
345
+		if (! $success) {
346
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price_row, $this->_new_ticket_table, $cols_n_values, $datatypes));
347
+			return 0;
348
+		}
349
+		$new_id = $wpdb->insert_id;
350
+		return $new_id;
351
+	}
352 352
 
353
-    /**
354
-     * Adds a join between a ticket and a price
355
-     * @global type $wpdb
356
-     * @param type $new_ticket_id
357
-     * @param type $new_price_id
358
-     * @return int
359
-     */
360
-    private function _insert_ticket_price_relation($new_ticket_id, $new_price_id)
361
-    {
362
-        global $wpdb;
363
-        $cols_n_values = array(
364
-            'TKT_ID'=>$new_ticket_id,
365
-            'PRC_ID'=>$new_price_id,
366
-        );
367
-        $datatypes = array(
368
-            '%d',// TKT_ID
369
-            '%d',// PRC_ID
370
-        );
371
-        $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $datatypes);
372
-        if (! $success) {
373
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'price id'=>$new_price_id), $this->_new_ticket_price_table, $cols_n_values, $datatypes));
374
-            return 0;
375
-        }
376
-        $new_id = $wpdb->insert_id;
377
-        return $new_id;
378
-    }
353
+	/**
354
+	 * Adds a join between a ticket and a price
355
+	 * @global type $wpdb
356
+	 * @param type $new_ticket_id
357
+	 * @param type $new_price_id
358
+	 * @return int
359
+	 */
360
+	private function _insert_ticket_price_relation($new_ticket_id, $new_price_id)
361
+	{
362
+		global $wpdb;
363
+		$cols_n_values = array(
364
+			'TKT_ID'=>$new_ticket_id,
365
+			'PRC_ID'=>$new_price_id,
366
+		);
367
+		$datatypes = array(
368
+			'%d',// TKT_ID
369
+			'%d',// PRC_ID
370
+		);
371
+		$success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $datatypes);
372
+		if (! $success) {
373
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'price id'=>$new_price_id), $this->_new_ticket_price_table, $cols_n_values, $datatypes));
374
+			return 0;
375
+		}
376
+		$new_id = $wpdb->insert_id;
377
+		return $new_id;
378
+	}
379 379
 
380
-    /**
381
-     * Adds a join between a ticket and a datetime
382
-     * @global type $wpdb
383
-     * @param type $new_ticket_id
384
-     * @param type $new_price_id
385
-     * @return int
386
-     */
387
-    private function _insert_datetime_ticket_relation($new_datetime_id, $new_ticket_id)
388
-    {
389
-        global $wpdb;
390
-        $cols_n_values = array(
391
-            'TKT_ID'=>$new_ticket_id,
392
-            'DTT_ID'=>$new_datetime_id,
393
-        );
394
-        $datatypes = array(
395
-            '%d',// TKT_ID
396
-            '%d',// DTT_ID
397
-        );
398
-        $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $datatypes);
399
-        if (! $success) {
400
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'datetime id'=>$new_datetime_id), $this->_new_datetime_ticket_table, $cols_n_values, $datatypes));
401
-            return 0;
402
-        }
403
-        $new_id = $wpdb->insert_id;
404
-        return $new_id;
405
-    }
380
+	/**
381
+	 * Adds a join between a ticket and a datetime
382
+	 * @global type $wpdb
383
+	 * @param type $new_ticket_id
384
+	 * @param type $new_price_id
385
+	 * @return int
386
+	 */
387
+	private function _insert_datetime_ticket_relation($new_datetime_id, $new_ticket_id)
388
+	{
389
+		global $wpdb;
390
+		$cols_n_values = array(
391
+			'TKT_ID'=>$new_ticket_id,
392
+			'DTT_ID'=>$new_datetime_id,
393
+		);
394
+		$datatypes = array(
395
+			'%d',// TKT_ID
396
+			'%d',// DTT_ID
397
+		);
398
+		$success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $datatypes);
399
+		if (! $success) {
400
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'datetime id'=>$new_datetime_id), $this->_new_datetime_ticket_table, $cols_n_values, $datatypes));
401
+			return 0;
402
+		}
403
+		$new_id = $wpdb->insert_id;
404
+		return $new_id;
405
+	}
406 406
 
407
-    /**
408
-     * Simply gets the 3.1 event row data
409
-     * @global type $wpdb
410
-     * @param type $event_id
411
-     * @return array
412
-     */
413
-    private function _get_event_row($event_id)
414
-    {
415
-        global $wpdb;
416
-        $old_event_table = $wpdb->prefix."events_detail";
417
-        return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A);
418
-    }
419
-    /**
420
-     * Gets a higher ticket count than last time it was called (and is persisted between HTTP requests).
421
-     * Yes we COULD run a query joining events->datetimes->ticket_datetimes->tickets, but this should work fine too
422
-     * @return int
423
-     */
424
-    private function _get_ticket_count()
425
-    {
426
-        return $this->_ticket_count++;
427
-    }
407
+	/**
408
+	 * Simply gets the 3.1 event row data
409
+	 * @global type $wpdb
410
+	 * @param type $event_id
411
+	 * @return array
412
+	 */
413
+	private function _get_event_row($event_id)
414
+	{
415
+		global $wpdb;
416
+		$old_event_table = $wpdb->prefix."events_detail";
417
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A);
418
+	}
419
+	/**
420
+	 * Gets a higher ticket count than last time it was called (and is persisted between HTTP requests).
421
+	 * Yes we COULD run a query joining events->datetimes->ticket_datetimes->tickets, but this should work fine too
422
+	 * @return int
423
+	 */
424
+	private function _get_ticket_count()
425
+	{
426
+		return $this->_ticket_count++;
427
+	}
428 428
 
429
-    /**
430
-     * Using the 3.1 event id, gets the 4.1 datetimes for it
431
-     * @param int $old_event_id
432
-     * @return array where values are datetime ids
433
-     */
434
-    private function _get_datetime_ids_for_old_event_id($old_event_id)
435
-    {
436
-        global $wpdb;
437
-        $new_cpt_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_event_id, $wpdb->posts);
438
-        $datetime_ids = $wpdb->get_col($wpdb->prepare("SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d", $new_cpt_id));
439
-        return $datetime_ids;
440
-    }
429
+	/**
430
+	 * Using the 3.1 event id, gets the 4.1 datetimes for it
431
+	 * @param int $old_event_id
432
+	 * @return array where values are datetime ids
433
+	 */
434
+	private function _get_datetime_ids_for_old_event_id($old_event_id)
435
+	{
436
+		global $wpdb;
437
+		$new_cpt_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_event_id, $wpdb->posts);
438
+		$datetime_ids = $wpdb->get_col($wpdb->prepare("SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d", $new_cpt_id));
439
+		return $datetime_ids;
440
+	}
441 441
 }
442 442
 // @todo: tell users that in 3.1 the limit was on registration PER event,in 4.1 it's limit PER TICKET... SO, if they sell 2 different types of tickets
443 443
 //
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         $this->_old_table = $wpdb->prefix."events_prices";
109 109
         $this->select_expression = 'p.*, e.event_status';
110 110
         $this->_extra_where_sql = ' AS p 
111
-            INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON p.event_id=e.id
111
+            INNER JOIN ' . $wpdb->prefix.'events_detail AS e ON p.event_id=e.id
112 112
             WHERE e.event_status!="D"';
113 113
         $this->_new_price_table = $wpdb->prefix."esp_price";
114 114
         $this->_new_ticket_table = $wpdb->prefix."esp_ticket";
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         // create the surcharge if there is any
131 131
         if (floatval($old_row['surcharge']) >= 0.01) {
132 132
             $surcharge_price_id = $this->_insert_new_surcharge_price($old_row);
133
-            $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id,$surcharge_price_id));
133
+            $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id, $surcharge_price_id));
134 134
         } else {
135 135
             $surcharge_price_id = 0;
136 136
             $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id));
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 
183 183
         );
184 184
         $datatypes = array(
185
-            '%d',// PRT_ID
186
-            '%f',// PRT_amount
187
-            '%s',// PRC_name
188
-            '%d',// PRC_is_default
189
-            '%d',// PRC_overrides
190
-            '%d',// PRC_order
191
-            '%d',// PRC_deleted
192
-            '%d',// PRC_parent
185
+            '%d', // PRT_ID
186
+            '%f', // PRT_amount
187
+            '%s', // PRC_name
188
+            '%d', // PRC_is_default
189
+            '%d', // PRC_overrides
190
+            '%d', // PRC_order
191
+            '%d', // PRC_deleted
192
+            '%d', // PRC_parent
193 193
         );
194 194
         $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes);
195
-        if (! $success) {
195
+        if ( ! $success) {
196 196
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes));
197 197
             return 0;
198 198
         }
@@ -264,17 +264,17 @@  discard block
 block discarded – undo
264 264
 
265 265
         );
266 266
         $datatypes = array(
267
-            '%d',// PRT_ID
268
-            '%f',// PRT_amount
269
-            '%s',// PRC_name
270
-            '%d',// PRC_is_default
271
-            '%d',// PRC_overrides
272
-            '%d',// PRC_order
273
-            '%d',// PRC_deleted
274
-            '%d',// PRC_parent
267
+            '%d', // PRT_ID
268
+            '%f', // PRT_amount
269
+            '%s', // PRC_name
270
+            '%d', // PRC_is_default
271
+            '%d', // PRC_overrides
272
+            '%d', // PRC_order
273
+            '%d', // PRC_deleted
274
+            '%d', // PRC_parent
275 275
         );
276 276
         $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes);
277
-        if (! $success) {
277
+        if ( ! $success) {
278 278
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes));
279 279
             return 0;
280 280
         }
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         if ($old_price_row['surcharge_type'] == 'flat_rate') {
297 297
             $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']);
298 298
         } else {// percent surcharge
299
-            $final_ticket_price = floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge'])/100);
299
+            $final_ticket_price = floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge']) / 100);
300 300
         }
301 301
         $start_date = $event_row['registration_start']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']);
302 302
         $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $old_price_row, $start_date, $event_row['timezone_string']);
@@ -311,38 +311,38 @@  discard block
 block discarded – undo
311 311
             'TKT_min'=>0,
312 312
             'TKT_max'=>-1,
313 313
             'TKT_price'=>$final_ticket_price,
314
-            'TKT_sold'=> 0,// note: this will get calculated as we actually add registrations during the migration
314
+            'TKT_sold'=> 0, // note: this will get calculated as we actually add registrations during the migration
315 315
             'TKT_qty'=> -1,
316 316
             'TKT_uses'=> 1,
317
-            'TKT_taxable'=>false,// so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices
317
+            'TKT_taxable'=>false, // so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices
318 318
             'TKT_is_default'=>false,
319 319
             'TKT_order'=>$this->_get_ticket_count(),
320
-            'TKT_row'=>0,// doesn't matter because UI reset this on first save anyways
320
+            'TKT_row'=>0, // doesn't matter because UI reset this on first save anyways
321 321
             'TKT_deleted'=>false,
322 322
             'TKT_parent'=>0
323 323
 
324 324
         );
325 325
         $datatypes = array(
326
-            '%d',// TTM_ID
327
-            '%s',// TKT_name
328
-            '%s',// TKT_description
329
-            '%s',// TKT_start_date
330
-            '%s',// TKT_end_date
331
-            '%d',// TKT_min
332
-            '%d',// TKT_max
333
-            '%f',// TKT_price
334
-            '%d',// TKT_sold
335
-            '%d',// TKT_qty
336
-            '%d',// TKT_uses
337
-            '%d',// TKT_taxable
338
-            '%d',// TKT_is_default
339
-            '%d',// TKT_order
340
-            '%d',// TKT_row
341
-            '%d',// TKT_deleted
342
-            '%d',// TKT_parent
326
+            '%d', // TTM_ID
327
+            '%s', // TKT_name
328
+            '%s', // TKT_description
329
+            '%s', // TKT_start_date
330
+            '%s', // TKT_end_date
331
+            '%d', // TKT_min
332
+            '%d', // TKT_max
333
+            '%f', // TKT_price
334
+            '%d', // TKT_sold
335
+            '%d', // TKT_qty
336
+            '%d', // TKT_uses
337
+            '%d', // TKT_taxable
338
+            '%d', // TKT_is_default
339
+            '%d', // TKT_order
340
+            '%d', // TKT_row
341
+            '%d', // TKT_deleted
342
+            '%d', // TKT_parent
343 343
         );
344 344
         $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $datatypes);
345
-        if (! $success) {
345
+        if ( ! $success) {
346 346
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price_row, $this->_new_ticket_table, $cols_n_values, $datatypes));
347 347
             return 0;
348 348
         }
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
             'PRC_ID'=>$new_price_id,
366 366
         );
367 367
         $datatypes = array(
368
-            '%d',// TKT_ID
369
-            '%d',// PRC_ID
368
+            '%d', // TKT_ID
369
+            '%d', // PRC_ID
370 370
         );
371 371
         $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $datatypes);
372
-        if (! $success) {
373
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'price id'=>$new_price_id), $this->_new_ticket_price_table, $cols_n_values, $datatypes));
372
+        if ( ! $success) {
373
+            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id, 'price id'=>$new_price_id), $this->_new_ticket_price_table, $cols_n_values, $datatypes));
374 374
             return 0;
375 375
         }
376 376
         $new_id = $wpdb->insert_id;
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
             'DTT_ID'=>$new_datetime_id,
393 393
         );
394 394
         $datatypes = array(
395
-            '%d',// TKT_ID
396
-            '%d',// DTT_ID
395
+            '%d', // TKT_ID
396
+            '%d', // DTT_ID
397 397
         );
398 398
         $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $datatypes);
399
-        if (! $success) {
400
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'datetime id'=>$new_datetime_id), $this->_new_datetime_ticket_table, $cols_n_values, $datatypes));
399
+        if ( ! $success) {
400
+            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id, 'datetime id'=>$new_datetime_id), $this->_new_datetime_ticket_table, $cols_n_values, $datatypes));
401 401
             return 0;
402 402
         }
403 403
         $new_id = $wpdb->insert_id;
Please login to merge, or discard this patch.