Completed
Branch ENH/optimize-reset-reservation... (ea022f)
by
unknown
06:52 queued 04:53
created
core/data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_gateways.dmsstage.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
         // convert settings
25 25
         $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone);
26 26
         // just do a part of them on this request
27
-        $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items);// $this->_gateways_we_know_how_to_migrate;
27
+        $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items); // $this->_gateways_we_know_how_to_migrate;
28 28
         foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) {
29 29
             $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug);
30
-            if (isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) {
30
+            if (isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) {
31 31
                 // determine the old option's name
32 32
                 $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug);
33
-                if (! $old_gateway_settings) {
33
+                if ( ! $old_gateway_settings) {
34 34
                     // no settings existed for this gateway anyways... weird...
35 35
                     $items_actually_migrated++;
36 36
                     continue;
37 37
                 }
38 38
                 // now prepare the settings to make sure they're in the 4.1 format
39 39
                 $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug);
40
-                $new_gateway_config_obj->payment_settings[ $new_gateway_slug ] = $new_gateway_settings;
40
+                $new_gateway_config_obj->payment_settings[$new_gateway_slug] = $new_gateway_settings;
41 41
                 // and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but
42 42
                 // I think it's ok to do right away this time (we wont need gateway settings elsewhere)
43 43
                 delete_option($old_gateway_wp_option_name);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $items_actually_migrated++;
52 52
         }
53 53
         // if we can keep going, and it hasn' tbeen done yet, convert active gateways
54
-        if ($items_actually_migrated < $num_items &&  ! $this->_converted_active_gateways) {
54
+        if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) {
55 55
             $this->_convert_active_gateways();
56 56
             $this->_converted_active_gateways = true;
57 57
             $items_actually_migrated++;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $step_of_setting_active_gateways = 1;
70 70
         $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone);
71 71
     //  $button_images_to_update =
72
-        return $count_of_gateways_to_convert +  $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone;
72
+        return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone;
73 73
     }
74 74
     public function __construct()
75 75
     {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     private function _get_old_gateway_option($new_gateway_slug)
116 116
     {
117 117
         $option_name = $this->_get_old_gateway_option_name($new_gateway_slug);
118
-        $settings =  get_option($option_name, null);
118
+        $settings = get_option($option_name, null);
119 119
     //  if( ! $settings){
120 120
     //      $this->add_error(sprintf(__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug));
121 121
     //  }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     private function _get_old_gateway_option_name($new_gateway_slug)
131 131
     {
132 132
         $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone));
133
-        $old_gateway_slug = $new_gateway_slugs_to_new[ $new_gateway_slug ];
133
+        $old_gateway_slug = $new_gateway_slugs_to_new[$new_gateway_slug];
134 134
         $normal_option_prefix = 'event_espresso_';
135 135
         $normal_option_postfix = '_settings';
136 136
         switch ($new_gateway_slug) {
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
         $old_active_gateways = get_option('event_espresso_active_gateways');
171 171
         $new_active_gateways = EE_Config::instance()->gateway->active_gateways;
172 172
         foreach ($old_active_gateways as $old_gateway_slug => $filepath) {
173
-            if (! isset($this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ])) {
173
+            if ( ! isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) {
174 174
                 $this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug));
175 175
                 continue;
176 176
             }
177
-            $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[ $old_gateway_slug ];
177
+            $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[$old_gateway_slug];
178 178
         
179 179
             // in the new format we can also upload gateways to the uploads directory and
180
-            $new_active_gateways[ $new_gateway_slug ] = false;
180
+            $new_active_gateways[$new_gateway_slug] = false;
181 181
         }
182 182
         EE_Config::instance()->gateway->active_gateways = $new_active_gateways;
183 183
     }
Please login to merge, or discard this 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/data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_venues.dmsstage.php 2 patches
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -63,210 +63,210 @@
 block discarded – undo
63 63
  */
64 64
 class EE_DMS_4_1_0_venues extends EE_Data_Migration_Script_Stage
65 65
 {
66
-    private $_old_table;
67
-    private $_new_table;
68
-    private $_new_meta_table;
69
-    public function _migration_step($num_items = 50)
70
-    {
71
-        global $wpdb;
72
-        $start_at_record = $this->count_records_migrated();
73
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
74
-        $items_actually_migrated = 0;
75
-        foreach ($rows as $old_venue) {
76
-            if (! $new_id = $this->_insert_into_posts($old_venue)) {
77
-                $items_actually_migrated++;
78
-                continue;
79
-            }
80
-            $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_table, $new_id);
81
-            if (! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) {
82
-                $items_actually_migrated++;
83
-                continue;
84
-            }
85
-            $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_meta_table, $new_meta_id);
86
-            // lastly, save the 'contact' as post meta, because it doesn't exist anywhere else but someone may still want it
87
-            $venue_meta = maybe_unserialize($old_venue['meta']);
88
-            if (isset($venue_meta['contact']) && $venue_meta['contact']) {
89
-                add_post_meta($new_id, 'contact', $venue_meta['contact']);
90
-            }
91
-            // is there an image on this venue?
92
-            $guid = isset($venue_meta['image']) && $venue_meta['image'] ? $venue_meta['image'] : null;
93
-            if ($guid) {
94
-                $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this);
95
-            }
96
-            $items_actually_migrated++;
97
-            if ($guid) {
98
-                // if there was an image, we may have had to download it etc and it may have taken
99
-                // longer, then let's not bother migrating anymore on this step
100
-                break;
101
-            }
102
-        }
103
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
104
-            $this->set_completed();
105
-        }
106
-        return $items_actually_migrated;
107
-    }
108
-    public function _count_records_to_migrate()
109
-    {
110
-        global $wpdb;
111
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
112
-        return $count;
113
-    }
114
-    public function __construct()
115
-    {
116
-        $this->_pretty_name = __("Venues", "event_espresso");
117
-        global $wpdb;
118
-        $this->_old_table = $wpdb->prefix."events_venue";
119
-        $this->_new_table = $wpdb->posts;
120
-        $this->_new_meta_table = $wpdb->prefix."esp_venue_meta";
121
-        parent::__construct();
122
-    }
66
+	private $_old_table;
67
+	private $_new_table;
68
+	private $_new_meta_table;
69
+	public function _migration_step($num_items = 50)
70
+	{
71
+		global $wpdb;
72
+		$start_at_record = $this->count_records_migrated();
73
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
74
+		$items_actually_migrated = 0;
75
+		foreach ($rows as $old_venue) {
76
+			if (! $new_id = $this->_insert_into_posts($old_venue)) {
77
+				$items_actually_migrated++;
78
+				continue;
79
+			}
80
+			$this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_table, $new_id);
81
+			if (! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) {
82
+				$items_actually_migrated++;
83
+				continue;
84
+			}
85
+			$this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_meta_table, $new_meta_id);
86
+			// lastly, save the 'contact' as post meta, because it doesn't exist anywhere else but someone may still want it
87
+			$venue_meta = maybe_unserialize($old_venue['meta']);
88
+			if (isset($venue_meta['contact']) && $venue_meta['contact']) {
89
+				add_post_meta($new_id, 'contact', $venue_meta['contact']);
90
+			}
91
+			// is there an image on this venue?
92
+			$guid = isset($venue_meta['image']) && $venue_meta['image'] ? $venue_meta['image'] : null;
93
+			if ($guid) {
94
+				$this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this);
95
+			}
96
+			$items_actually_migrated++;
97
+			if ($guid) {
98
+				// if there was an image, we may have had to download it etc and it may have taken
99
+				// longer, then let's not bother migrating anymore on this step
100
+				break;
101
+			}
102
+		}
103
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
104
+			$this->set_completed();
105
+		}
106
+		return $items_actually_migrated;
107
+	}
108
+	public function _count_records_to_migrate()
109
+	{
110
+		global $wpdb;
111
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
112
+		return $count;
113
+	}
114
+	public function __construct()
115
+	{
116
+		$this->_pretty_name = __("Venues", "event_espresso");
117
+		global $wpdb;
118
+		$this->_old_table = $wpdb->prefix."events_venue";
119
+		$this->_new_table = $wpdb->posts;
120
+		$this->_new_meta_table = $wpdb->prefix."esp_venue_meta";
121
+		parent::__construct();
122
+	}
123 123
 
124
-    /**
125
-     * Inserts the CPT
126
-     * @param array $old_venue keys are cols, values are col values
127
-     * @return int
128
-     */
129
-    private function _insert_into_posts($old_venue)
130
-    {
131
-        global $wpdb;
132
-        $meta = maybe_unserialize($old_venue['meta']);
133
-        $slug = $this->_find_unique_slug($old_venue['name'], $old_venue['identifier']);
134
-        $insertion_array = array(
135
-                    'post_title'=>stripslashes($old_venue['name']),// VNU_name
136
-                    'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '',// VNU_desc
137
-                    'post_name'=> $slug,// VNU_identifier
138
-                    'post_date'=>current_time('mysql'),// VNU_created
139
-                    'post_date_gmt'=>  current_time('mysql', true),
140
-                    'post_excerpt'=>'',// wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters
141
-                    'post_modified'=>current_time('mysql'),// VNU_modified
142
-                    'post_modified_gmt'=>current_time('mysql', true),
143
-                    'post_author'=>$old_venue['wp_user'],// VNU_wp_user
144
-                    'post_parent'=>0,// parent
145
-                    'menu_order'=>0,// VNU_order
146
-                    'post_type'=>'espresso_venues'// post_type
147
-                );
148
-        $datatypes_array = array(
149
-                    '%s',// VNU_name
150
-                    '%s',// VNU_desc
151
-                    '%s',// VNU_identifier
152
-                    '%s',// VNU_created
153
-                    '%s',
154
-                    '%s',// VNU_short_desc
155
-                    '%s',// VNU_modified
156
-                    '%s',
157
-                    '%d',// VNU_wp_user
158
-                    '%d',// parent
159
-                    '%d',// VNU_order
160
-                    '%s',// post_type
161
-                );
162
-        $success = $wpdb->insert(
163
-            $this->_new_table,
164
-            $insertion_array,
165
-            $datatypes_array
166
-        );
167
-        if (! $success) {
168
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array));
169
-            return 0;
170
-        }
171
-        return $wpdb->insert_id;
172
-    }
124
+	/**
125
+	 * Inserts the CPT
126
+	 * @param array $old_venue keys are cols, values are col values
127
+	 * @return int
128
+	 */
129
+	private function _insert_into_posts($old_venue)
130
+	{
131
+		global $wpdb;
132
+		$meta = maybe_unserialize($old_venue['meta']);
133
+		$slug = $this->_find_unique_slug($old_venue['name'], $old_venue['identifier']);
134
+		$insertion_array = array(
135
+					'post_title'=>stripslashes($old_venue['name']),// VNU_name
136
+					'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '',// VNU_desc
137
+					'post_name'=> $slug,// VNU_identifier
138
+					'post_date'=>current_time('mysql'),// VNU_created
139
+					'post_date_gmt'=>  current_time('mysql', true),
140
+					'post_excerpt'=>'',// wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters
141
+					'post_modified'=>current_time('mysql'),// VNU_modified
142
+					'post_modified_gmt'=>current_time('mysql', true),
143
+					'post_author'=>$old_venue['wp_user'],// VNU_wp_user
144
+					'post_parent'=>0,// parent
145
+					'menu_order'=>0,// VNU_order
146
+					'post_type'=>'espresso_venues'// post_type
147
+				);
148
+		$datatypes_array = array(
149
+					'%s',// VNU_name
150
+					'%s',// VNU_desc
151
+					'%s',// VNU_identifier
152
+					'%s',// VNU_created
153
+					'%s',
154
+					'%s',// VNU_short_desc
155
+					'%s',// VNU_modified
156
+					'%s',
157
+					'%d',// VNU_wp_user
158
+					'%d',// parent
159
+					'%d',// VNU_order
160
+					'%s',// post_type
161
+				);
162
+		$success = $wpdb->insert(
163
+			$this->_new_table,
164
+			$insertion_array,
165
+			$datatypes_array
166
+		);
167
+		if (! $success) {
168
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array));
169
+			return 0;
170
+		}
171
+		return $wpdb->insert_id;
172
+	}
173 173
 
174
-    /**
175
-     * Finds a unique slug for this venue, given its name (we could have simply used
176
-     * the old unique_identifier column, but it added a long string of seemingly random characters onto the end
177
-     * and really wasn't that pretty for a slug, so we decided we'd make our own slug again)
178
-     * @param string $post_name
179
-     * @return string
180
-     */
181
-    private function _find_unique_slug($post_name, $old_identifier = '')
182
-    {
183
-        $count = 0;
184
-        $original_name = $post_name ? sanitize_title($post_name) : $old_identifier;
185
-        $event_slug = $original_name;
186
-        while ($this->_other_post_exists_with_that_slug($event_slug) && $count<50) {
187
-            $event_slug = sanitize_title($original_name."-".++$count);
188
-        }
189
-        return $event_slug;
190
-    }
174
+	/**
175
+	 * Finds a unique slug for this venue, given its name (we could have simply used
176
+	 * the old unique_identifier column, but it added a long string of seemingly random characters onto the end
177
+	 * and really wasn't that pretty for a slug, so we decided we'd make our own slug again)
178
+	 * @param string $post_name
179
+	 * @return string
180
+	 */
181
+	private function _find_unique_slug($post_name, $old_identifier = '')
182
+	{
183
+		$count = 0;
184
+		$original_name = $post_name ? sanitize_title($post_name) : $old_identifier;
185
+		$event_slug = $original_name;
186
+		while ($this->_other_post_exists_with_that_slug($event_slug) && $count<50) {
187
+			$event_slug = sanitize_title($original_name."-".++$count);
188
+		}
189
+		return $event_slug;
190
+	}
191 191
 
192
-    /**
193
-     * returns whether or not there is a post that has this same slug (post_title)
194
-     * @global type $wpdb
195
-     * @param type $slug
196
-     * @return boolean
197
-     */
198
-    private function _other_post_exists_with_that_slug($slug)
199
-    {
200
-        global $wpdb;
201
-        $query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s", $slug);
202
-        $count = $wpdb->get_var($query);
203
-        return (boolean) intval($count);
204
-    }
192
+	/**
193
+	 * returns whether or not there is a post that has this same slug (post_title)
194
+	 * @global type $wpdb
195
+	 * @param type $slug
196
+	 * @return boolean
197
+	 */
198
+	private function _other_post_exists_with_that_slug($slug)
199
+	{
200
+		global $wpdb;
201
+		$query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s", $slug);
202
+		$count = $wpdb->get_var($query);
203
+		return (boolean) intval($count);
204
+	}
205 205
 
206
-    /**
207
-     * Inserts into the venue_meta table
208
-     * @param type $cpt_id
209
-     * @param type $old_venue
210
-     * @return int
211
-     */
212
-    private function _insert_into_meta_table($cpt_id, $old_venue)
213
-    {
214
-        global $wpdb;
215
-        // get a country with the same name, or insert one
216
-        try {
217
-            $country = $this->get_migration_script()->get_or_create_country(stripslashes($old_venue['country']));
218
-            $country_iso = $country['CNT_ISO'];
219
-        } catch (EE_Error $e) {
220
-            $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue)));
221
-            $country_iso = null;
222
-        }
223
-        // get a state with the same name, if possible
224
-        try {
225
-            $state = $this->get_migration_script()->get_or_create_state(stripslashes($old_venue['state']), isset($country['CNT_name']) ? $country['CNT_name'] : strip_tags($old_venue['country']));
226
-            $state_id = $state['STA_ID'];
227
-        } catch (EE_Error $e) {
228
-            $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue)));
229
-            $state_id = 0;
230
-        }
231
-        $meta = maybe_unserialize($old_venue['meta']);
232
-        // now insert into meta table
233
-        $insertion_array = array(
234
-            'VNU_ID'=>$cpt_id,// VNU_ID_fk
235
-            'VNU_address'=>stripslashes($old_venue['address']),// VNU_address
236
-            'VNU_address2'=>stripslashes($old_venue['address2']),// VNU_address2
237
-            'VNU_city'=>stripslashes($old_venue['city']),// VNU_city
238
-            'STA_ID'=>$state_id,// STA_ID
239
-            'CNT_ISO'=>$country_iso,// CNT_ISO
240
-            'VNU_zip'=>stripslashes($old_venue['zip']),// VNU_zip
241
-            'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '',// VNU_phone
242
-            'VNU_capacity'=>-1,// VNU_capacity
243
-            'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '',// VNU_url
244
-            'VNU_virtual_phone'=>'',// VNU_virtual_phone
245
-            'VNU_virtual_url'=>'',// VNU_virtual_url
246
-            'VNU_google_map_link'=>'',// VNU_google_map_link
247
-            'VNU_enable_for_gmap'=>true // VNU_enable_for_gmap
248
-        );
249
-        $datatypes = array(
250
-            '%d',// VNU_ID_fk
251
-            '%s',// VNU_address
252
-            '%s',// VNU_address2
253
-            '%s',// VNU_city
254
-            '%d',// STA_ID
255
-            '%s',// CNT_ISO
256
-            '%s',// VNU_zip
257
-            '%s',// VNU_phone
258
-            '%d',// VNU_capacity
259
-            '%s',// VNU_url
260
-            '%s',// VNU_virtual_phone
261
-            '%s',// VNU_virtual_url
262
-            '%s',// VNU_google_map_link
263
-            '%d',// VNU_enable_for_gmap
264
-        );
265
-        $success = $wpdb->insert($this->_new_meta_table, $insertion_array, $datatypes);
266
-        if (! $success) {
267
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_meta_table, $insertion_array, $datatypes));
268
-            return 0;
269
-        }
270
-        return $wpdb->insert_id;
271
-    }
206
+	/**
207
+	 * Inserts into the venue_meta table
208
+	 * @param type $cpt_id
209
+	 * @param type $old_venue
210
+	 * @return int
211
+	 */
212
+	private function _insert_into_meta_table($cpt_id, $old_venue)
213
+	{
214
+		global $wpdb;
215
+		// get a country with the same name, or insert one
216
+		try {
217
+			$country = $this->get_migration_script()->get_or_create_country(stripslashes($old_venue['country']));
218
+			$country_iso = $country['CNT_ISO'];
219
+		} catch (EE_Error $e) {
220
+			$this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue)));
221
+			$country_iso = null;
222
+		}
223
+		// get a state with the same name, if possible
224
+		try {
225
+			$state = $this->get_migration_script()->get_or_create_state(stripslashes($old_venue['state']), isset($country['CNT_name']) ? $country['CNT_name'] : strip_tags($old_venue['country']));
226
+			$state_id = $state['STA_ID'];
227
+		} catch (EE_Error $e) {
228
+			$this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue)));
229
+			$state_id = 0;
230
+		}
231
+		$meta = maybe_unserialize($old_venue['meta']);
232
+		// now insert into meta table
233
+		$insertion_array = array(
234
+			'VNU_ID'=>$cpt_id,// VNU_ID_fk
235
+			'VNU_address'=>stripslashes($old_venue['address']),// VNU_address
236
+			'VNU_address2'=>stripslashes($old_venue['address2']),// VNU_address2
237
+			'VNU_city'=>stripslashes($old_venue['city']),// VNU_city
238
+			'STA_ID'=>$state_id,// STA_ID
239
+			'CNT_ISO'=>$country_iso,// CNT_ISO
240
+			'VNU_zip'=>stripslashes($old_venue['zip']),// VNU_zip
241
+			'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '',// VNU_phone
242
+			'VNU_capacity'=>-1,// VNU_capacity
243
+			'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '',// VNU_url
244
+			'VNU_virtual_phone'=>'',// VNU_virtual_phone
245
+			'VNU_virtual_url'=>'',// VNU_virtual_url
246
+			'VNU_google_map_link'=>'',// VNU_google_map_link
247
+			'VNU_enable_for_gmap'=>true // VNU_enable_for_gmap
248
+		);
249
+		$datatypes = array(
250
+			'%d',// VNU_ID_fk
251
+			'%s',// VNU_address
252
+			'%s',// VNU_address2
253
+			'%s',// VNU_city
254
+			'%d',// STA_ID
255
+			'%s',// CNT_ISO
256
+			'%s',// VNU_zip
257
+			'%s',// VNU_phone
258
+			'%d',// VNU_capacity
259
+			'%s',// VNU_url
260
+			'%s',// VNU_virtual_phone
261
+			'%s',// VNU_virtual_url
262
+			'%s',// VNU_google_map_link
263
+			'%d',// VNU_enable_for_gmap
264
+		);
265
+		$success = $wpdb->insert($this->_new_meta_table, $insertion_array, $datatypes);
266
+		if (! $success) {
267
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_meta_table, $insertion_array, $datatypes));
268
+			return 0;
269
+		}
270
+		return $wpdb->insert_id;
271
+	}
272 272
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
         $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
74 74
         $items_actually_migrated = 0;
75 75
         foreach ($rows as $old_venue) {
76
-            if (! $new_id = $this->_insert_into_posts($old_venue)) {
76
+            if ( ! $new_id = $this->_insert_into_posts($old_venue)) {
77 77
                 $items_actually_migrated++;
78 78
                 continue;
79 79
             }
80 80
             $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_table, $new_id);
81
-            if (! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) {
81
+            if ( ! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) {
82 82
                 $items_actually_migrated++;
83 83
                 continue;
84 84
             }
@@ -132,39 +132,39 @@  discard block
 block discarded – undo
132 132
         $meta = maybe_unserialize($old_venue['meta']);
133 133
         $slug = $this->_find_unique_slug($old_venue['name'], $old_venue['identifier']);
134 134
         $insertion_array = array(
135
-                    'post_title'=>stripslashes($old_venue['name']),// VNU_name
136
-                    'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '',// VNU_desc
137
-                    'post_name'=> $slug,// VNU_identifier
138
-                    'post_date'=>current_time('mysql'),// VNU_created
135
+                    'post_title'=>stripslashes($old_venue['name']), // VNU_name
136
+                    'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '', // VNU_desc
137
+                    'post_name'=> $slug, // VNU_identifier
138
+                    'post_date'=>current_time('mysql'), // VNU_created
139 139
                     'post_date_gmt'=>  current_time('mysql', true),
140
-                    'post_excerpt'=>'',// wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters
141
-                    'post_modified'=>current_time('mysql'),// VNU_modified
140
+                    'post_excerpt'=>'', // wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters
141
+                    'post_modified'=>current_time('mysql'), // VNU_modified
142 142
                     'post_modified_gmt'=>current_time('mysql', true),
143
-                    'post_author'=>$old_venue['wp_user'],// VNU_wp_user
144
-                    'post_parent'=>0,// parent
145
-                    'menu_order'=>0,// VNU_order
143
+                    'post_author'=>$old_venue['wp_user'], // VNU_wp_user
144
+                    'post_parent'=>0, // parent
145
+                    'menu_order'=>0, // VNU_order
146 146
                     'post_type'=>'espresso_venues'// post_type
147 147
                 );
148 148
         $datatypes_array = array(
149
-                    '%s',// VNU_name
150
-                    '%s',// VNU_desc
151
-                    '%s',// VNU_identifier
152
-                    '%s',// VNU_created
149
+                    '%s', // VNU_name
150
+                    '%s', // VNU_desc
151
+                    '%s', // VNU_identifier
152
+                    '%s', // VNU_created
153 153
                     '%s',
154
-                    '%s',// VNU_short_desc
155
-                    '%s',// VNU_modified
154
+                    '%s', // VNU_short_desc
155
+                    '%s', // VNU_modified
156 156
                     '%s',
157
-                    '%d',// VNU_wp_user
158
-                    '%d',// parent
159
-                    '%d',// VNU_order
160
-                    '%s',// post_type
157
+                    '%d', // VNU_wp_user
158
+                    '%d', // parent
159
+                    '%d', // VNU_order
160
+                    '%s', // post_type
161 161
                 );
162 162
         $success = $wpdb->insert(
163 163
             $this->_new_table,
164 164
             $insertion_array,
165 165
             $datatypes_array
166 166
         );
167
-        if (! $success) {
167
+        if ( ! $success) {
168 168
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array));
169 169
             return 0;
170 170
         }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         $count = 0;
184 184
         $original_name = $post_name ? sanitize_title($post_name) : $old_identifier;
185 185
         $event_slug = $original_name;
186
-        while ($this->_other_post_exists_with_that_slug($event_slug) && $count<50) {
186
+        while ($this->_other_post_exists_with_that_slug($event_slug) && $count < 50) {
187 187
             $event_slug = sanitize_title($original_name."-".++$count);
188 188
         }
189 189
         return $event_slug;
@@ -231,39 +231,39 @@  discard block
 block discarded – undo
231 231
         $meta = maybe_unserialize($old_venue['meta']);
232 232
         // now insert into meta table
233 233
         $insertion_array = array(
234
-            'VNU_ID'=>$cpt_id,// VNU_ID_fk
235
-            'VNU_address'=>stripslashes($old_venue['address']),// VNU_address
236
-            'VNU_address2'=>stripslashes($old_venue['address2']),// VNU_address2
237
-            'VNU_city'=>stripslashes($old_venue['city']),// VNU_city
238
-            'STA_ID'=>$state_id,// STA_ID
239
-            'CNT_ISO'=>$country_iso,// CNT_ISO
240
-            'VNU_zip'=>stripslashes($old_venue['zip']),// VNU_zip
241
-            'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '',// VNU_phone
242
-            'VNU_capacity'=>-1,// VNU_capacity
243
-            'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '',// VNU_url
244
-            'VNU_virtual_phone'=>'',// VNU_virtual_phone
245
-            'VNU_virtual_url'=>'',// VNU_virtual_url
246
-            'VNU_google_map_link'=>'',// VNU_google_map_link
234
+            'VNU_ID'=>$cpt_id, // VNU_ID_fk
235
+            'VNU_address'=>stripslashes($old_venue['address']), // VNU_address
236
+            'VNU_address2'=>stripslashes($old_venue['address2']), // VNU_address2
237
+            'VNU_city'=>stripslashes($old_venue['city']), // VNU_city
238
+            'STA_ID'=>$state_id, // STA_ID
239
+            'CNT_ISO'=>$country_iso, // CNT_ISO
240
+            'VNU_zip'=>stripslashes($old_venue['zip']), // VNU_zip
241
+            'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '', // VNU_phone
242
+            'VNU_capacity'=>-1, // VNU_capacity
243
+            'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '', // VNU_url
244
+            'VNU_virtual_phone'=>'', // VNU_virtual_phone
245
+            'VNU_virtual_url'=>'', // VNU_virtual_url
246
+            'VNU_google_map_link'=>'', // VNU_google_map_link
247 247
             'VNU_enable_for_gmap'=>true // VNU_enable_for_gmap
248 248
         );
249 249
         $datatypes = array(
250
-            '%d',// VNU_ID_fk
251
-            '%s',// VNU_address
252
-            '%s',// VNU_address2
253
-            '%s',// VNU_city
254
-            '%d',// STA_ID
255
-            '%s',// CNT_ISO
256
-            '%s',// VNU_zip
257
-            '%s',// VNU_phone
258
-            '%d',// VNU_capacity
259
-            '%s',// VNU_url
260
-            '%s',// VNU_virtual_phone
261
-            '%s',// VNU_virtual_url
262
-            '%s',// VNU_google_map_link
263
-            '%d',// VNU_enable_for_gmap
250
+            '%d', // VNU_ID_fk
251
+            '%s', // VNU_address
252
+            '%s', // VNU_address2
253
+            '%s', // VNU_city
254
+            '%d', // STA_ID
255
+            '%s', // CNT_ISO
256
+            '%s', // VNU_zip
257
+            '%s', // VNU_phone
258
+            '%d', // VNU_capacity
259
+            '%s', // VNU_url
260
+            '%s', // VNU_virtual_phone
261
+            '%s', // VNU_virtual_url
262
+            '%s', // VNU_google_map_link
263
+            '%d', // VNU_enable_for_gmap
264 264
         );
265 265
         $success = $wpdb->insert($this->_new_meta_table, $insertion_array, $datatypes);
266
-        if (! $success) {
266
+        if ( ! $success) {
267 267
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_meta_table, $insertion_array, $datatypes));
268 268
             return 0;
269 269
         }
Please login to merge, or discard this patch.
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_shortcodes.dmsstage.php 1 patch
Indentation   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -2,58 +2,57 @@
 block discarded – undo
2 2
 
3 3
 /**
4 4
  * Goes through all the posts and pages, and converts old shortcodes to new ones
5
-
6
-*/
5
+ */
7 6
 
8 7
 class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage
9 8
 {
10
-    public function __construct()
11
-    {
12
-        global $wpdb;
13
-        $this->_pretty_name = __("Shortcodes", "event_espresso");
14
-        $this->_old_table = $wpdb->posts;
15
-        parent::__construct();
16
-    }
17
-    protected function _migrate_old_row($old_row)
18
-    {
19
-        $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
20
-        global $wpdb;
21
-        $wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
22
-    }
9
+	public function __construct()
10
+	{
11
+		global $wpdb;
12
+		$this->_pretty_name = __("Shortcodes", "event_espresso");
13
+		$this->_old_table = $wpdb->posts;
14
+		parent::__construct();
15
+	}
16
+	protected function _migrate_old_row($old_row)
17
+	{
18
+		$new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
19
+		global $wpdb;
20
+		$wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
21
+	}
23 22
 
24
-    /**
25
-     * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...]
26
-     * @param string $old_content
27
-     */
28
-    private function _change_event_list_shortcode($old_content)
29
-    {
30
-        return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content);
31
-    }
23
+	/**
24
+	 * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...]
25
+	 * @param string $old_content
26
+	 */
27
+	private function _change_event_list_shortcode($old_content)
28
+	{
29
+		return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content);
30
+	}
32 31
 
33
-    public function _migration_step($num_items = 50)
34
-    {
35
-        global $wpdb;
36
-        $start_at_record = $this->count_records_migrated();
37
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
38
-        $items_actually_migrated = 0;
39
-        foreach ($rows as $old_row) {
40
-            $this->_migrate_old_row($old_row);
41
-            $items_actually_migrated++;
42
-        }
43
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
44
-            $this->set_completed();
45
-        }
46
-        return $items_actually_migrated;
47
-    }
48
-    public function _count_records_to_migrate()
49
-    {
50
-        global $wpdb;
51
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table.$this->_sql_to_only_select_non_drafts());
52
-        return $count;
53
-    }
32
+	public function _migration_step($num_items = 50)
33
+	{
34
+		global $wpdb;
35
+		$start_at_record = $this->count_records_migrated();
36
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
37
+		$items_actually_migrated = 0;
38
+		foreach ($rows as $old_row) {
39
+			$this->_migrate_old_row($old_row);
40
+			$items_actually_migrated++;
41
+		}
42
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
43
+			$this->set_completed();
44
+		}
45
+		return $items_actually_migrated;
46
+	}
47
+	public function _count_records_to_migrate()
48
+	{
49
+		global $wpdb;
50
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table.$this->_sql_to_only_select_non_drafts());
51
+		return $count;
52
+	}
54 53
 
55
-    private function _sql_to_only_select_non_drafts()
56
-    {
57
-        return " WHERE post_type NOT IN ('revision','auto-draft') ";
58
-    }
54
+	private function _sql_to_only_select_non_drafts()
55
+	{
56
+		return " WHERE post_type NOT IN ('revision','auto-draft') ";
57
+	}
59 58
 }
Please login to merge, or discard this patch.
4_1_0_stages/EE_DMS_4_1_0_question_group_question.dmsstage.php 2 patches
Indentation   +105 added lines, -107 removed lines patch added patch discarded remove patch
@@ -12,8 +12,6 @@  discard block
 block discarded – undo
12 12
   KEY `group_id` (`group_id`),
13 13
   KEY `question_id` (`question_id`)
14 14
 ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8$$
15
-
16
-
17 15
  * 4.1 question group question model's tables and fields:
18 16
  $this->_tables = array(
19 17
             'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question','QGQ_ID')
@@ -29,113 +27,113 @@  discard block
 block discarded – undo
29 27
  */
30 28
 class EE_DMS_4_1_0_question_group_question extends EE_Data_Migration_Script_Stage
31 29
 {
32
-    private $_old_table;
33
-    private $_new_table;
34
-    public function _migration_step($num_items = 50)
35
-    {
30
+	private $_old_table;
31
+	private $_new_table;
32
+	public function _migration_step($num_items = 50)
33
+	{
36 34
         
37
-        global $wpdb;
38
-        $start_at_record = $this->count_records_migrated();
39
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
40
-        $items_actually_migrated = 0;
41
-        foreach ($rows as $question_group_question) {
42
-            $this->_insert_new_question_group_question($question_group_question);
43
-            $items_actually_migrated++;
44
-        }
45
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
46
-            $this->set_completed();
47
-        }
48
-        return $items_actually_migrated;
49
-    }
50
-    public function _count_records_to_migrate()
51
-    {
52
-        global $wpdb;
53
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
54
-        return $count;
55
-    }
56
-    public function __construct()
57
-    {
58
-        global $wpdb;
59
-        $this->_old_table = $wpdb->prefix."events_qst_group_rel";
60
-        $this->_new_table = $wpdb->prefix."esp_question_group_question";
61
-        $this->_pretty_name = __("Question Group to Question Relations", "event_espresso");
62
-        parent::__construct();
63
-    }
35
+		global $wpdb;
36
+		$start_at_record = $this->count_records_migrated();
37
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
38
+		$items_actually_migrated = 0;
39
+		foreach ($rows as $question_group_question) {
40
+			$this->_insert_new_question_group_question($question_group_question);
41
+			$items_actually_migrated++;
42
+		}
43
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
44
+			$this->set_completed();
45
+		}
46
+		return $items_actually_migrated;
47
+	}
48
+	public function _count_records_to_migrate()
49
+	{
50
+		global $wpdb;
51
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table);
52
+		return $count;
53
+	}
54
+	public function __construct()
55
+	{
56
+		global $wpdb;
57
+		$this->_old_table = $wpdb->prefix."events_qst_group_rel";
58
+		$this->_new_table = $wpdb->prefix."esp_question_group_question";
59
+		$this->_pretty_name = __("Question Group to Question Relations", "event_espresso");
60
+		parent::__construct();
61
+	}
64 62
     
65
-    /**
66
-     * Attempts to insert a new question group inthe new format given an old one
67
-     * @global type $wpdb
68
-     * @param array $old_question_group_question
69
-     * @return int
70
-     */
71
-    private function _insert_new_question_group_question($old_question_group_question)
72
-    {
73
-        global $wpdb;
74
-        $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question");
75
-        $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group");
76
-        if (! $new_question_id) {
77
-            $this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id']));
78
-            return 0;
79
-        }
80
-        if (! $new_question_group_id) {
81
-            $this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id']));
82
-            return 0;
83
-        }
84
-        // if it's a system question, it needs to be in the right system group. otherwise no dice!
85
-        if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) )
86
-                ||
87
-                ! $this->_is_system_question_for_question_group($new_question_id)
88
-            ) {
89
-            $cols_n_values = array(
90
-                'QSG_ID'=>$new_question_group_id,
91
-                'QST_ID'=>$new_question_id
92
-            );
93
-            $datatypes = array(
94
-                '%d',// QSG_ID
95
-                '%d',// QST_ID
96
-            );
97
-            $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
98
-            if (! $success) {
99
-                $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes));
100
-                return 0;
101
-            }
102
-            return $wpdb->insert_id;
103
-        } else {
104
-            return false;
105
-        }
106
-    }
63
+	/**
64
+	 * Attempts to insert a new question group inthe new format given an old one
65
+	 * @global type $wpdb
66
+	 * @param array $old_question_group_question
67
+	 * @return int
68
+	 */
69
+	private function _insert_new_question_group_question($old_question_group_question)
70
+	{
71
+		global $wpdb;
72
+		$new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question");
73
+		$new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group");
74
+		if (! $new_question_id) {
75
+			$this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id']));
76
+			return 0;
77
+		}
78
+		if (! $new_question_group_id) {
79
+			$this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id']));
80
+			return 0;
81
+		}
82
+		// if it's a system question, it needs to be in the right system group. otherwise no dice!
83
+		if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) )
84
+				||
85
+				! $this->_is_system_question_for_question_group($new_question_id)
86
+			) {
87
+			$cols_n_values = array(
88
+				'QSG_ID'=>$new_question_group_id,
89
+				'QST_ID'=>$new_question_id
90
+			);
91
+			$datatypes = array(
92
+				'%d',// QSG_ID
93
+				'%d',// QST_ID
94
+			);
95
+			$success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
96
+			if (! $success) {
97
+				$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes));
98
+				return 0;
99
+			}
100
+			return $wpdb->insert_id;
101
+		} else {
102
+			return false;
103
+		}
104
+	}
107 105
     
108
-    /**
109
-     * If this question is a system question, returns the QSG_system number that
110
-     * indicates the question group its permitted in.
111
-     * @global type $wpdb
112
-     * @param type $new_question_id
113
-     * @return int
114
-     */
115
-    private function _is_system_question_for_question_group($new_question_id)
116
-    {
117
-        global $wpdb;
118
-        $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id));
119
-        if (in_array($system_id, array('fname','lname','email'))) {
120
-            return 1;
121
-        } elseif ($system_id!='' && $system_id) {
122
-            return 2;
123
-        } else {
124
-            return 0;
125
-        }
126
-    }
106
+	/**
107
+	 * If this question is a system question, returns the QSG_system number that
108
+	 * indicates the question group its permitted in.
109
+	 * @global type $wpdb
110
+	 * @param type $new_question_id
111
+	 * @return int
112
+	 */
113
+	private function _is_system_question_for_question_group($new_question_id)
114
+	{
115
+		global $wpdb;
116
+		$system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id));
117
+		if (in_array($system_id, array('fname','lname','email'))) {
118
+			return 1;
119
+		} elseif ($system_id!='' && $system_id) {
120
+			return 2;
121
+		} else {
122
+			return 0;
123
+		}
124
+	}
127 125
     
128
-    /**
129
-     * Returns the questino group's QSG_system value (1 meaning personal info, 2
130
-     * being address info, and 0 being neither)
131
-     * @global type $wpdb
132
-     * @param type $new_question_group_id
133
-     * @return boolean
134
-     */
135
-    private function _is_system_question_group($new_question_group_id)
136
-    {
137
-        global $wpdb;
138
-        $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM ".$wpdb->prefix."esp_question_group WHERE QSG_ID=%d", $new_question_group_id));
139
-        return intval($system_id);
140
-    }
126
+	/**
127
+	 * Returns the questino group's QSG_system value (1 meaning personal info, 2
128
+	 * being address info, and 0 being neither)
129
+	 * @global type $wpdb
130
+	 * @param type $new_question_group_id
131
+	 * @return boolean
132
+	 */
133
+	private function _is_system_question_group($new_question_group_id)
134
+	{
135
+		global $wpdb;
136
+		$system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM ".$wpdb->prefix."esp_question_group WHERE QSG_ID=%d", $new_question_group_id));
137
+		return intval($system_id);
138
+	}
141 139
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
         global $wpdb;
74 74
         $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question");
75 75
         $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group");
76
-        if (! $new_question_id) {
76
+        if ( ! $new_question_id) {
77 77
             $this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id']));
78 78
             return 0;
79 79
         }
80
-        if (! $new_question_group_id) {
80
+        if ( ! $new_question_group_id) {
81 81
             $this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id']));
82 82
             return 0;
83 83
         }
84 84
         // if it's a system question, it needs to be in the right system group. otherwise no dice!
85
-        if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) )
85
+        if (($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id))
86 86
                 ||
87 87
                 ! $this->_is_system_question_for_question_group($new_question_id)
88 88
             ) {
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
                 'QST_ID'=>$new_question_id
92 92
             );
93 93
             $datatypes = array(
94
-                '%d',// QSG_ID
95
-                '%d',// QST_ID
94
+                '%d', // QSG_ID
95
+                '%d', // QST_ID
96 96
             );
97 97
             $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
98
-            if (! $success) {
98
+            if ( ! $success) {
99 99
                 $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes));
100 100
                 return 0;
101 101
             }
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
     {
117 117
         global $wpdb;
118 118
         $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id));
119
-        if (in_array($system_id, array('fname','lname','email'))) {
119
+        if (in_array($system_id, array('fname', 'lname', 'email'))) {
120 120
             return 1;
121
-        } elseif ($system_id!='' && $system_id) {
121
+        } elseif ($system_id != '' && $system_id) {
122 122
             return 2;
123 123
         } else {
124 124
             return 0;
Please login to merge, or discard this patch.
4_8_0_stages/EE_DMS_4_8_0_event_subtotals.dmsstage.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -11,77 +11,77 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_8_0_event_subtotals extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    public function __construct()
15
-    {
16
-        global $wpdb;
17
-        $this->_old_table = $wpdb->prefix . 'esp_line_item';
18
-        $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"';
19
-        $this->_pretty_name = __('Event Sub-total line items', 'event_espresso');
20
-        parent::__construct();
21
-    }
22
-    protected function _migrate_old_row($line_item_row)
23
-    {
24
-        global $wpdb;
25
-        // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID
26
-        $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
27
-        $new_line_item_data = array(
28
-                    'LIN_code' => 'event-' . $event_id,
29
-                    'TXN_ID' => $line_item_row['TXN_ID'],
30
-                    'LIN_name' => __('Event', 'event_espresso'),
31
-                    'LIN_desc' => $line_item_row['LIN_desc'],
32
-                    'LIN_unit_price' => $line_item_row['LIN_unit_price'],
33
-                    'LIN_percent' => $line_item_row['LIN_percent'],
34
-                    'LIN_is_taxable' => $line_item_row['LIN_is_taxable'],
35
-                    'LIN_order' => $line_item_row['LIN_order'],
36
-                    'LIN_total' => $line_item_row['LIN_total'],
37
-                    'LIN_quantity' => $line_item_row['LIN_quantity'],
38
-                    'LIN_parent' => $line_item_row['LIN_ID'],
39
-                    'LIN_type' => 'sub-total',
40
-                    'OBJ_type' => 'Event',
41
-                    'OBJ_ID' => $event_id,
42
-                );
43
-        $new_line_item_datatypes = array(
44
-                    '%s',// LIN_code
45
-                    '%d',// TXN_ID
46
-                    '%s',// LIN_name
47
-                    '%s',// LIN_desc
48
-                    '%f',// LIN_unit_price
49
-                    '%f',// LIN_percent
50
-                    '%d',// LIN_is_taxable
51
-                    '%d',// LIN_order
52
-                    '%f',// LIN_total
53
-                    '%d',// LIN_quantity
54
-                    '%d',// LIN_parent
55
-                    '%s',// LIN_type
56
-                    '%s',// OBJ_type
57
-                    '%d',// OBJ_ID
58
-                );
59
-        // insert the new event subtotal line item, pointing to this line item
60
-        $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes);
61
-        if (! $success) {
62
-            $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes));
63
-        }
64
-        $new_line_item_id = $wpdb->insert_id;
65
-        $this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id);
66
-        $query = $wpdb->prepare(
67
-            "UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100",
68
-            $new_line_item_id,
69
-            $line_item_row['LIN_ID'],
70
-            $new_line_item_id
71
-        );
72
-        $success = $wpdb->query($query);
73
-        if ($success === false) {
74
-            $this->add_error(
75
-                sprintf(
76
-                    __('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'),
77
-                    $new_line_item_id,
78
-                    $line_item_row['LIN_ID'],
79
-                    $wpdb->last_error,
80
-                    $query,
81
-                    $success
82
-                )
83
-            );
84
-        }
85
-        return 1;
86
-    }
14
+	public function __construct()
15
+	{
16
+		global $wpdb;
17
+		$this->_old_table = $wpdb->prefix . 'esp_line_item';
18
+		$this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"';
19
+		$this->_pretty_name = __('Event Sub-total line items', 'event_espresso');
20
+		parent::__construct();
21
+	}
22
+	protected function _migrate_old_row($line_item_row)
23
+	{
24
+		global $wpdb;
25
+		// what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID
26
+		$event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
27
+		$new_line_item_data = array(
28
+					'LIN_code' => 'event-' . $event_id,
29
+					'TXN_ID' => $line_item_row['TXN_ID'],
30
+					'LIN_name' => __('Event', 'event_espresso'),
31
+					'LIN_desc' => $line_item_row['LIN_desc'],
32
+					'LIN_unit_price' => $line_item_row['LIN_unit_price'],
33
+					'LIN_percent' => $line_item_row['LIN_percent'],
34
+					'LIN_is_taxable' => $line_item_row['LIN_is_taxable'],
35
+					'LIN_order' => $line_item_row['LIN_order'],
36
+					'LIN_total' => $line_item_row['LIN_total'],
37
+					'LIN_quantity' => $line_item_row['LIN_quantity'],
38
+					'LIN_parent' => $line_item_row['LIN_ID'],
39
+					'LIN_type' => 'sub-total',
40
+					'OBJ_type' => 'Event',
41
+					'OBJ_ID' => $event_id,
42
+				);
43
+		$new_line_item_datatypes = array(
44
+					'%s',// LIN_code
45
+					'%d',// TXN_ID
46
+					'%s',// LIN_name
47
+					'%s',// LIN_desc
48
+					'%f',// LIN_unit_price
49
+					'%f',// LIN_percent
50
+					'%d',// LIN_is_taxable
51
+					'%d',// LIN_order
52
+					'%f',// LIN_total
53
+					'%d',// LIN_quantity
54
+					'%d',// LIN_parent
55
+					'%s',// LIN_type
56
+					'%s',// OBJ_type
57
+					'%d',// OBJ_ID
58
+				);
59
+		// insert the new event subtotal line item, pointing to this line item
60
+		$success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes);
61
+		if (! $success) {
62
+			$this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes));
63
+		}
64
+		$new_line_item_id = $wpdb->insert_id;
65
+		$this->get_migration_script()->set_mapping($this->_old_table, $line_item_row['LIN_ID'], $this->_old_table, $new_line_item_id);
66
+		$query = $wpdb->prepare(
67
+			"UPDATE {$this->_old_table} SET LIN_parent=%d WHERE LIN_parent = %d AND LIN_ID != %d LIMIT 100",
68
+			$new_line_item_id,
69
+			$line_item_row['LIN_ID'],
70
+			$new_line_item_id
71
+		);
72
+		$success = $wpdb->query($query);
73
+		if ($success === false) {
74
+			$this->add_error(
75
+				sprintf(
76
+					__('Error updating rows to new event subtotal %1$s from %2$s. Error was: %3$s, while using query %4$s which had a result of %5$s', 'event_espresso'),
77
+					$new_line_item_id,
78
+					$line_item_row['LIN_ID'],
79
+					$wpdb->last_error,
80
+					$query,
81
+					$success
82
+				)
83
+			);
84
+		}
85
+		return 1;
86
+	}
87 87
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     public function __construct()
15 15
     {
16 16
         global $wpdb;
17
-        $this->_old_table = $wpdb->prefix . 'esp_line_item';
17
+        $this->_old_table = $wpdb->prefix.'esp_line_item';
18 18
         $this->_extra_where_sql = ' WHERE LIN_type="sub-total" AND LIN_code="pre-tax-subtotal"';
19 19
         $this->_pretty_name = __('Event Sub-total line items', 'event_espresso');
20 20
         parent::__construct();
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
     {
24 24
         global $wpdb;
25 25
         // what event is this line item for? this can be found by looking at its transaction's registration's EVT_ID
26
-        $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM ' . $wpdb->prefix . 'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
26
+        $event_id = $wpdb->get_var($wpdb->prepare('SELECT EVT_ID FROM '.$wpdb->prefix.'esp_registration WHERE TXN_ID=%d LIMIT 1', $line_item_row['TXN_ID']));
27 27
         $new_line_item_data = array(
28
-                    'LIN_code' => 'event-' . $event_id,
28
+                    'LIN_code' => 'event-'.$event_id,
29 29
                     'TXN_ID' => $line_item_row['TXN_ID'],
30 30
                     'LIN_name' => __('Event', 'event_espresso'),
31 31
                     'LIN_desc' => $line_item_row['LIN_desc'],
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
                     'OBJ_ID' => $event_id,
42 42
                 );
43 43
         $new_line_item_datatypes = array(
44
-                    '%s',// LIN_code
45
-                    '%d',// TXN_ID
46
-                    '%s',// LIN_name
47
-                    '%s',// LIN_desc
48
-                    '%f',// LIN_unit_price
49
-                    '%f',// LIN_percent
50
-                    '%d',// LIN_is_taxable
51
-                    '%d',// LIN_order
52
-                    '%f',// LIN_total
53
-                    '%d',// LIN_quantity
54
-                    '%d',// LIN_parent
55
-                    '%s',// LIN_type
56
-                    '%s',// OBJ_type
57
-                    '%d',// OBJ_ID
44
+                    '%s', // LIN_code
45
+                    '%d', // TXN_ID
46
+                    '%s', // LIN_name
47
+                    '%s', // LIN_desc
48
+                    '%f', // LIN_unit_price
49
+                    '%f', // LIN_percent
50
+                    '%d', // LIN_is_taxable
51
+                    '%d', // LIN_order
52
+                    '%f', // LIN_total
53
+                    '%d', // LIN_quantity
54
+                    '%d', // LIN_parent
55
+                    '%s', // LIN_type
56
+                    '%s', // OBJ_type
57
+                    '%d', // OBJ_ID
58 58
                 );
59 59
         // insert the new event subtotal line item, pointing to this line item
60 60
         $success = $wpdb->insert($this->_old_table, $new_line_item_data, $new_line_item_datatypes);
61
-        if (! $success) {
61
+        if ( ! $success) {
62 62
             $this->add_error($this->_create_error_message_for_db_insertion($this->_old_table, $line_item_row, $this->_old_table, $new_line_item_data, $new_line_item_datatypes));
63 63
         }
64 64
         $new_line_item_id = $wpdb->insert_id;
Please login to merge, or discard this patch.
data_migration_scripts/4_8_0_stages/EE_DMS_4_8_0_pretax_totals.dmsstage.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -13,53 +13,53 @@
 block discarded – undo
13 13
 class EE_DMS_4_8_0_pretax_totals extends EE_Data_Migration_Script_Stage
14 14
 {
15 15
 
16
-    protected $_line_item_table_name;
16
+	protected $_line_item_table_name;
17 17
 
18 18
 
19
-    /**
20
-     * Just initializes the status of the migration
21
-     */
22
-    public function __construct()
23
-    {
24
-        global $wpdb;
25
-        $this->_line_item_table_name = $wpdb->prefix."esp_line_item";
26
-        $this->_pretty_name = __('Pre-tax total line items', 'event_espresso');
27
-        parent::__construct();
28
-    }
19
+	/**
20
+	 * Just initializes the status of the migration
21
+	 */
22
+	public function __construct()
23
+	{
24
+		global $wpdb;
25
+		$this->_line_item_table_name = $wpdb->prefix."esp_line_item";
26
+		$this->_pretty_name = __('Pre-tax total line items', 'event_espresso');
27
+		parent::__construct();
28
+	}
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * Counts the records to migrate; the public version may cache it
34
-     * @return int
35
-     */
36
-    protected function _count_records_to_migrate()
37
-    {
38
-        return 1;
39
-    }
32
+	/**
33
+	 * Counts the records to migrate; the public version may cache it
34
+	 * @return int
35
+	 */
36
+	protected function _count_records_to_migrate()
37
+	{
38
+		return 1;
39
+	}
40 40
 
41 41
 
42 42
 
43
-    /**
44
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
45
-     * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
46
-     * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
47
-     * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50,
48
-     * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
49
-     * @param int $num_items_to_migrate
50
-     * @return int number of items ACTUALLY migrated
51
-     */
52
-    protected function _migration_step($num_items_to_migrate = 50)
53
-    {
54
-        global $wpdb;
55
-        $rows_updated = $wpdb->update(
56
-            $this->_line_item_table_name,
57
-            array( 'LIN_code' => 'pre-tax-subtotal' ),
58
-            array( 'LIN_code' => 'tickets' ),
59
-            array( '%s' ),
60
-            array( '%s' )
61
-        );
62
-        $this->set_completed();
63
-        return 1;
64
-    }
43
+	/**
44
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
45
+	 * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
46
+	 * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
47
+	 * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50,
48
+	 * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
49
+	 * @param int $num_items_to_migrate
50
+	 * @return int number of items ACTUALLY migrated
51
+	 */
52
+	protected function _migration_step($num_items_to_migrate = 50)
53
+	{
54
+		global $wpdb;
55
+		$rows_updated = $wpdb->update(
56
+			$this->_line_item_table_name,
57
+			array( 'LIN_code' => 'pre-tax-subtotal' ),
58
+			array( 'LIN_code' => 'tickets' ),
59
+			array( '%s' ),
60
+			array( '%s' )
61
+		);
62
+		$this->set_completed();
63
+		return 1;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@
 block discarded – undo
54 54
         global $wpdb;
55 55
         $rows_updated = $wpdb->update(
56 56
             $this->_line_item_table_name,
57
-            array( 'LIN_code' => 'pre-tax-subtotal' ),
58
-            array( 'LIN_code' => 'tickets' ),
59
-            array( '%s' ),
60
-            array( '%s' )
57
+            array('LIN_code' => 'pre-tax-subtotal'),
58
+            array('LIN_code' => 'tickets'),
59
+            array('%s'),
60
+            array('%s')
61 61
         );
62 62
         $this->set_completed();
63 63
         return 1;
Please login to merge, or discard this patch.
4_2_0_stages/EE_DMS_4_2_0_datetime_fields.dmsstage.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -8,49 +8,49 @@
 block discarded – undo
8 8
 
9 9
 class EE_DMS_4_2_0_datetime_fields extends EE_Data_Migration_Script_Stage_Table
10 10
 {
11
-    public function __construct()
12
-    {
13
-        global $wpdb;
14
-        $this->_pretty_name = __("Datetime Fields", "event_espresso");
15
-        $this->_old_table = $wpdb->prefix . "esp_datetime";
16
-        parent::__construct();
17
-    }
11
+	public function __construct()
12
+	{
13
+		global $wpdb;
14
+		$this->_pretty_name = __("Datetime Fields", "event_espresso");
15
+		$this->_old_table = $wpdb->prefix . "esp_datetime";
16
+		parent::__construct();
17
+	}
18 18
 
19
-    protected function _migrate_old_row($old_row)
20
-    {
21
-        // foreach question_group_question entry with this QST_ID, we want to set its
22
-        // QSG_order equal to this question's QST_order
23
-        global $wpdb;
19
+	protected function _migrate_old_row($old_row)
20
+	{
21
+		// foreach question_group_question entry with this QST_ID, we want to set its
22
+		// QSG_order equal to this question's QST_order
23
+		global $wpdb;
24 24
 
25
-        $updated = $wpdb->update(
26
-            $this->_old_table,
27
-            array(
28
-                'DTT_name' => '',
29
-                'DTT_description' => '',
30
-            ),
31
-            array(
32
-                'DTT_ID' => $old_row['DTT_ID'],
33
-            ),
34
-            array(
35
-                '%s',// DTT_name,
36
-                '%s',// DTT_description
37
-            ),
38
-            array(
39
-                '%d',// DTT_ID
40
-            )
41
-        );
42
-        if (false === $updated) {
43
-            $this->add_error(
44
-                sprintf(
45
-                    __(
46
-                        "Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d",
47
-                        'event_espresso'
48
-                    ),
49
-                    $this->_old_table,
50
-                    $old_row['QST_ID']
51
-                )
52
-            );
53
-        }
54
-        // nothing to map really
55
-    }
25
+		$updated = $wpdb->update(
26
+			$this->_old_table,
27
+			array(
28
+				'DTT_name' => '',
29
+				'DTT_description' => '',
30
+			),
31
+			array(
32
+				'DTT_ID' => $old_row['DTT_ID'],
33
+			),
34
+			array(
35
+				'%s',// DTT_name,
36
+				'%s',// DTT_description
37
+			),
38
+			array(
39
+				'%d',// DTT_ID
40
+			)
41
+		);
42
+		if (false === $updated) {
43
+			$this->add_error(
44
+				sprintf(
45
+					__(
46
+						"Error in updating table %s setting DTT_name = '' and DTT_description = '' where DTT_ID = %d",
47
+						'event_espresso'
48
+					),
49
+					$this->_old_table,
50
+					$old_row['QST_ID']
51
+				)
52
+			);
53
+		}
54
+		// nothing to map really
55
+	}
56 56
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     {
13 13
         global $wpdb;
14 14
         $this->_pretty_name = __("Datetime Fields", "event_espresso");
15
-        $this->_old_table = $wpdb->prefix . "esp_datetime";
15
+        $this->_old_table = $wpdb->prefix."esp_datetime";
16 16
         parent::__construct();
17 17
     }
18 18
 
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
                 'DTT_ID' => $old_row['DTT_ID'],
33 33
             ),
34 34
             array(
35
-                '%s',// DTT_name,
36
-                '%s',// DTT_description
35
+                '%s', // DTT_name,
36
+                '%s', // DTT_description
37 37
             ),
38 38
             array(
39
-                '%d',// DTT_ID
39
+                '%d', // DTT_ID
40 40
             )
41 41
         );
42 42
         if (false === $updated) {
Please login to merge, or discard this patch.
4_2_0_stages/EE_DMS_4_2_0_question_group_questions.dmsstage.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 
7 7
 class EE_DMS_4_2_0_question_group_questions extends EE_Data_Migration_Script_Stage_Table
8 8
 {
9
-    private $_qgq_table;
10
-    public function __construct()
11
-    {
12
-        global $wpdb;
13
-        $this->_pretty_name = __("Question Group Questions", "event_espresso");
14
-        $this->_old_table = $wpdb->prefix."esp_question";
15
-        $this->_qgq_table = $wpdb->prefix."esp_question_group_question";
16
-        parent::__construct();
17
-    }
18
-    protected function _migrate_old_row($old_row)
19
-    {
20
-        // foreach question_group_question entry with this QST_ID, we want to set its
21
-        // QSG_order equal to this question's QST_order
22
-        global $wpdb;
23
-        $updated = $wpdb->update(
24
-            $this->_qgq_table,
25
-            array('QGQ_order'=>$old_row['QST_order']),
26
-            array('QST_ID'=>$old_row['QST_ID']),
27
-            array('%d',// QGQ_order
28
-                    ),
29
-            array('%d',// QST_ID
30
-                    )
31
-        );
32
-        if (false === $updated) {
33
-            $this->add_error(
34
-                sprintf(
35
-                    __(
36
-                        "Error in updating table %s setting QGQ_order = %d where QST_ID = %d",
37
-                        'event_espresso'
38
-                    ),
39
-                    $this->_qgq_table,
40
-                    $old_row['QST_order'],
41
-                    $old_row['QST_ID']
42
-                )
43
-            );
44
-        }
45
-        // nothing to map really
46
-    }
9
+	private $_qgq_table;
10
+	public function __construct()
11
+	{
12
+		global $wpdb;
13
+		$this->_pretty_name = __("Question Group Questions", "event_espresso");
14
+		$this->_old_table = $wpdb->prefix."esp_question";
15
+		$this->_qgq_table = $wpdb->prefix."esp_question_group_question";
16
+		parent::__construct();
17
+	}
18
+	protected function _migrate_old_row($old_row)
19
+	{
20
+		// foreach question_group_question entry with this QST_ID, we want to set its
21
+		// QSG_order equal to this question's QST_order
22
+		global $wpdb;
23
+		$updated = $wpdb->update(
24
+			$this->_qgq_table,
25
+			array('QGQ_order'=>$old_row['QST_order']),
26
+			array('QST_ID'=>$old_row['QST_ID']),
27
+			array('%d',// QGQ_order
28
+					),
29
+			array('%d',// QST_ID
30
+					)
31
+		);
32
+		if (false === $updated) {
33
+			$this->add_error(
34
+				sprintf(
35
+					__(
36
+						"Error in updating table %s setting QGQ_order = %d where QST_ID = %d",
37
+						'event_espresso'
38
+					),
39
+					$this->_qgq_table,
40
+					$old_row['QST_order'],
41
+					$old_row['QST_ID']
42
+				)
43
+			);
44
+		}
45
+		// nothing to map really
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
             $this->_qgq_table,
25 25
             array('QGQ_order'=>$old_row['QST_order']),
26 26
             array('QST_ID'=>$old_row['QST_ID']),
27
-            array('%d',// QGQ_order
27
+            array('%d', // QGQ_order
28 28
                     ),
29
-            array('%d',// QST_ID
29
+            array('%d', // QST_ID
30 30
                     )
31 31
         );
32 32
         if (false === $updated) {
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Script_Stage.core.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -37,103 +37,103 @@
 block discarded – undo
37 37
  */
38 38
 abstract class EE_Data_Migration_Script_Stage extends EE_Data_Migration_Class_Base
39 39
 {
40
-    /**
41
-     * The migration script this is a stage of
42
-     *
43
-     * @var EE_Data_Migration_Script_Base
44
-     */
45
-    protected $_migration_script;
40
+	/**
41
+	 * The migration script this is a stage of
42
+	 *
43
+	 * @var EE_Data_Migration_Script_Base
44
+	 */
45
+	protected $_migration_script;
46 46
 
47
-    /**
48
-     * This should eb called to essentially 'finalize' construction of the stage.
49
-     * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is
50
-     * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to
51
-     *
52
-     * @param EE_Data_Migration_Script_Base $migration_script
53
-     */
54
-    public function _construct_finalize($migration_script)
55
-    {
56
-        $this->_migration_script = $migration_script;
57
-    }
47
+	/**
48
+	 * This should eb called to essentially 'finalize' construction of the stage.
49
+	 * This isn't done on the main constructor in order to avoid repetitive code. Instead, this is
50
+	 * called by EE_Data_Migration_Script_Base's __construct() method so children don't have to
51
+	 *
52
+	 * @param EE_Data_Migration_Script_Base $migration_script
53
+	 */
54
+	public function _construct_finalize($migration_script)
55
+	{
56
+		$this->_migration_script = $migration_script;
57
+	}
58 58
 
59
-    /**
60
-     * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here,
61
-     * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children
62
-     * needs to catch exceptions and decide what's a fatal error and what isn't.
63
-     *
64
-     * @param int $num_items_to_migrate
65
-     * @return int
66
-     */
67
-    public function migration_step($num_items_to_migrate = 50)
68
-    {
69
-        // before we run the migration step, we want ot take note of warnings that get outputted
70
-        ob_start();
71
-        $items_migrated = $this->_migration_step($num_items_to_migrate);
72
-        $output = ob_get_contents();
73
-        ob_end_clean();
74
-        if ($output) {
75
-            $this->add_error($output);
76
-        }
77
-        $this->_records_migrated += $items_migrated;
78
-        return $items_migrated;
79
-    }
59
+	/**
60
+	 * Migrates X old records to the new format. If a fatal error is encountered it is NOT caught here,
61
+	 * but is propagated upwards for catching. So basically, the _migration_step() function implemented by children
62
+	 * needs to catch exceptions and decide what's a fatal error and what isn't.
63
+	 *
64
+	 * @param int $num_items_to_migrate
65
+	 * @return int
66
+	 */
67
+	public function migration_step($num_items_to_migrate = 50)
68
+	{
69
+		// before we run the migration step, we want ot take note of warnings that get outputted
70
+		ob_start();
71
+		$items_migrated = $this->_migration_step($num_items_to_migrate);
72
+		$output = ob_get_contents();
73
+		ob_end_clean();
74
+		if ($output) {
75
+			$this->add_error($output);
76
+		}
77
+		$this->_records_migrated += $items_migrated;
78
+		return $items_migrated;
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
84
-     * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
85
-     * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
86
-     * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
87
-     * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
88
-     * very least we MUST report/return 50 items migrated)
89
-     *
90
-     * @param int $num_items_to_migrate
91
-     * @return int number of items ACTUALLY migrated
92
-     */
93
-    abstract protected function _migration_step($num_items_to_migrate = 50);
82
+	/**
83
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property
84
+	 * accordingly. Note: it should not alter the count of items migrated. That is done in the public function that
85
+	 * calls this. IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the
86
+	 * last migration step, otherwise it should always return $num_items_to_migrate. (Eg, if we're migrating attendees
87
+	 * rows from the database, and $num_items_to_migrate is set to 50, then we SHOULD actually migrate 50 rows,but at
88
+	 * very least we MUST report/return 50 items migrated)
89
+	 *
90
+	 * @param int $num_items_to_migrate
91
+	 * @return int number of items ACTUALLY migrated
92
+	 */
93
+	abstract protected function _migration_step($num_items_to_migrate = 50);
94 94
 
95
-    /**
96
-     * Counts the records that have been migrated so far
97
-     *
98
-     * @return int
99
-     */
100
-    public function count_records_migrated()
101
-    {
102
-        return $this->_records_migrated;
103
-    }
95
+	/**
96
+	 * Counts the records that have been migrated so far
97
+	 *
98
+	 * @return int
99
+	 */
100
+	public function count_records_migrated()
101
+	{
102
+		return $this->_records_migrated;
103
+	}
104 104
 
105
-    /**
106
-     * returns an array of strings describing errors
107
-     *
108
-     * @return array
109
-     */
110
-    public function get_errors()
111
-    {
112
-        return $this->_errors;
113
-    }
105
+	/**
106
+	 * returns an array of strings describing errors
107
+	 *
108
+	 * @return array
109
+	 */
110
+	public function get_errors()
111
+	{
112
+		return $this->_errors;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Sets all of the properties of this script stage to match what's in the array, which is assumed
118
-     * to have been made from the properties_as_array() function.
119
-     *
120
-     * @param array $array_of_properties like what's produced from properties_as_array() method
121
-     */
122
-    public function instantiate_from_array_of_properties($array_of_properties)
123
-    {
124
-        unset($array_of_properties['class']);
125
-        foreach ($array_of_properties as $property_name => $property_value) {
126
-            $this->{$property_name} = $property_value;
127
-        }
128
-    }
116
+	/**
117
+	 * Sets all of the properties of this script stage to match what's in the array, which is assumed
118
+	 * to have been made from the properties_as_array() function.
119
+	 *
120
+	 * @param array $array_of_properties like what's produced from properties_as_array() method
121
+	 */
122
+	public function instantiate_from_array_of_properties($array_of_properties)
123
+	{
124
+		unset($array_of_properties['class']);
125
+		foreach ($array_of_properties as $property_name => $property_value) {
126
+			$this->{$property_name} = $property_value;
127
+		}
128
+	}
129 129
 
130
-    /**
131
-     * Gets the script this is a stage of
132
-     *
133
-     * @return EE_Data_Migration_Script_Base
134
-     */
135
-    protected function get_migration_script()
136
-    {
137
-        return $this->_migration_script;
138
-    }
130
+	/**
131
+	 * Gets the script this is a stage of
132
+	 *
133
+	 * @return EE_Data_Migration_Script_Base
134
+	 */
135
+	protected function get_migration_script()
136
+	{
137
+		return $this->_migration_script;
138
+	}
139 139
 }
Please login to merge, or discard this patch.