Completed
Branch FET/event-question-group-refac... (05f43b)
by
unknown
35:39 queued 27:05
created
registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -18,179 +18,179 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper
20 20
 {
21
-    /**
22
-     *
23
-     * @var EE_Registration
24
-     */
25
-    protected $_registration = null;
21
+	/**
22
+	 *
23
+	 * @var EE_Registration
24
+	 */
25
+	protected $_registration = null;
26 26
 
27
-    /**
28
-     *
29
-     * @param EE_Registration $reg
30
-     * @param array $options
31
-     */
32
-    public function __construct(EE_Registration $reg, $options = array())
33
-    {
34
-        $this->_registration = $reg;
35
-        if (! isset($options['layout_strategy'])) {
36
-            $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
37
-        }
38
-        if (! isset($options['html_id'])) {
39
-            $options['html_id'] = 'reg-admin-attendee-questions-frm';
40
-        }
41
-        $this->build_form_from_registration();
42
-        parent::__construct($options);
43
-    }
27
+	/**
28
+	 *
29
+	 * @param EE_Registration $reg
30
+	 * @param array $options
31
+	 */
32
+	public function __construct(EE_Registration $reg, $options = array())
33
+	{
34
+		$this->_registration = $reg;
35
+		if (! isset($options['layout_strategy'])) {
36
+			$options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
37
+		}
38
+		if (! isset($options['html_id'])) {
39
+			$options['html_id'] = 'reg-admin-attendee-questions-frm';
40
+		}
41
+		$this->build_form_from_registration();
42
+		parent::__construct($options);
43
+	}
44 44
 
45 45
 
46
-    /**
47
-     * Gets the registration object this form is about
48
-     * @return EE_Registration
49
-     */
50
-    public function get_registration()
51
-    {
52
-        return $this->_registration;
53
-    }
46
+	/**
47
+	 * Gets the registration object this form is about
48
+	 * @return EE_Registration
49
+	 */
50
+	public function get_registration()
51
+	{
52
+		return $this->_registration;
53
+	}
54 54
 
55
-    /**
56
-     * @since $VID:$
57
-     * @throws EE_Error
58
-     * @throws InvalidArgumentException
59
-     * @throws ReflectionException
60
-     * @throws InvalidDataTypeException
61
-     * @throws InvalidInterfaceException
62
-     */
63
-    public function build_form_from_registration()
64
-    {
65
-        $reg = $this->get_registration();
66
-        if (! $reg instanceof EE_Registration) {
67
-            throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
68
-        }
69
-        // we want to get all their question groups
70
-        $question_groups = EEM_Question_Group::instance()->get_all(
71
-            [
72
-                [
73
-                    'Event_Question_Group.EVT_ID' => $reg->event_ID(),
74
-                    'OR' => [
75
-                        'Question.QST_system*blank' =>  '',
76
-                        'Question.QST_system*null' => ['IS_NULL']
77
-                    ],
78
-                    'Event_Question_Group.'
79
-                    . EEM_Event_Question_Group::instance()->fieldNameForContext(
80
-                        $reg->is_primary_registrant()
81
-                    ) => true
82
-                ],
83
-                'order_by' => ['QSG_order' => 'ASC']
84
-            ]
85
-        );
86
-        // get each question groups questions
87
-        foreach ($question_groups as $question_group) {
88
-            if ($question_group instanceof EE_Question_Group) {
89
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
90
-                    $question_group,
91
-                    $reg
92
-                );
93
-            }
94
-        }
95
-    }
55
+	/**
56
+	 * @since $VID:$
57
+	 * @throws EE_Error
58
+	 * @throws InvalidArgumentException
59
+	 * @throws ReflectionException
60
+	 * @throws InvalidDataTypeException
61
+	 * @throws InvalidInterfaceException
62
+	 */
63
+	public function build_form_from_registration()
64
+	{
65
+		$reg = $this->get_registration();
66
+		if (! $reg instanceof EE_Registration) {
67
+			throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
68
+		}
69
+		// we want to get all their question groups
70
+		$question_groups = EEM_Question_Group::instance()->get_all(
71
+			[
72
+				[
73
+					'Event_Question_Group.EVT_ID' => $reg->event_ID(),
74
+					'OR' => [
75
+						'Question.QST_system*blank' =>  '',
76
+						'Question.QST_system*null' => ['IS_NULL']
77
+					],
78
+					'Event_Question_Group.'
79
+					. EEM_Event_Question_Group::instance()->fieldNameForContext(
80
+						$reg->is_primary_registrant()
81
+					) => true
82
+				],
83
+				'order_by' => ['QSG_order' => 'ASC']
84
+			]
85
+		);
86
+		// get each question groups questions
87
+		foreach ($question_groups as $question_group) {
88
+			if ($question_group instanceof EE_Question_Group) {
89
+				$this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
90
+					$question_group,
91
+					$reg
92
+				);
93
+			}
94
+		}
95
+	}
96 96
 
97 97
 
98 98
 
99
-    /**
100
-     *
101
-     * @param EE_Question_Group $question_group
102
-     * @param EE_Registration   $registration
103
-     * @return \EE_Form_Section_Proper
104
-     * @throws \EE_Error
105
-     */
106
-    public function build_subform_from_question_group($question_group, $registration)
107
-    {
108
-        if (! $question_group instanceof EE_Question_Group ||
109
-            ! $registration instanceof EE_Registration) {
110
-            throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
111
-        }
112
-        $parts_of_subsection = array(
113
-            'title' => new EE_Form_Section_HTML(
114
-                EEH_HTML::h5(
115
-                    $question_group->name(),
116
-                    $question_group->identifier(),
117
-                    'espresso-question-group-title-h5 section-title'
118
-                )
119
-            )
120
-        );
121
-        $questions = $question_group->questions(
122
-            array(
123
-                array(
124
-                    'OR' => array(
125
-                        'QST_system*blank' => '',
126
-                        'QST_system*null' => array( 'IS_NULL' )
127
-                    )
128
-                )
129
-            )
130
-        );
131
-        foreach ($questions as $question) {
132
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
133
-        }
134
-        if (EE_Registry::instance()->CAP->current_user_can(
135
-            'ee_edit_registration',
136
-            'edit-reg-questions-mbox',
137
-            $this->_registration->ID()
138
-        )) {
139
-            $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
140
-                '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
99
+	/**
100
+	 *
101
+	 * @param EE_Question_Group $question_group
102
+	 * @param EE_Registration   $registration
103
+	 * @return \EE_Form_Section_Proper
104
+	 * @throws \EE_Error
105
+	 */
106
+	public function build_subform_from_question_group($question_group, $registration)
107
+	{
108
+		if (! $question_group instanceof EE_Question_Group ||
109
+			! $registration instanceof EE_Registration) {
110
+			throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
111
+		}
112
+		$parts_of_subsection = array(
113
+			'title' => new EE_Form_Section_HTML(
114
+				EEH_HTML::h5(
115
+					$question_group->name(),
116
+					$question_group->identifier(),
117
+					'espresso-question-group-title-h5 section-title'
118
+				)
119
+			)
120
+		);
121
+		$questions = $question_group->questions(
122
+			array(
123
+				array(
124
+					'OR' => array(
125
+						'QST_system*blank' => '',
126
+						'QST_system*null' => array( 'IS_NULL' )
127
+					)
128
+				)
129
+			)
130
+		);
131
+		foreach ($questions as $question) {
132
+			$parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
133
+		}
134
+		if (EE_Registry::instance()->CAP->current_user_can(
135
+			'ee_edit_registration',
136
+			'edit-reg-questions-mbox',
137
+			$this->_registration->ID()
138
+		)) {
139
+			$parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
140
+				'<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
141 141
 		  			<span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span>
142 142
 		  			<div class="dashicons dashicons-edit"></div>
143 143
 		  		</a></td></tr>'
144
-            );
145
-        }
146
-        return new EE_Form_Section_Proper(
147
-            array(
148
-                'subsections' => $parts_of_subsection,
149
-                'html_class' => 'question-group-questions',
150
-            )
151
-        );
152
-    }
144
+			);
145
+		}
146
+		return new EE_Form_Section_Proper(
147
+			array(
148
+				'subsections' => $parts_of_subsection,
149
+				'html_class' => 'question-group-questions',
150
+			)
151
+		);
152
+	}
153 153
 
154
-    /**
155
-     * Overrides parent so if inputs were disabled, we leave those with their defaults
156
-     * from the answers in the DB
157
-     * @param array $req_data like $_POST
158
-     * @return void
159
-     */
160
-    protected function _normalize($req_data)
161
-    {
162
-        $this->_received_submission = true;
163
-        $this->_validation_errors = array();
164
-        foreach ($this->get_validatable_subsections() as $subsection) {
165
-            if ($subsection->form_data_present_in($req_data)) {
166
-                try {
167
-                    $subsection->_normalize($req_data);
168
-                } catch (EE_Validation_Error $e) {
169
-                    $subsection->add_validation_error($e);
170
-                }
171
-            }
172
-        }
173
-    }
154
+	/**
155
+	 * Overrides parent so if inputs were disabled, we leave those with their defaults
156
+	 * from the answers in the DB
157
+	 * @param array $req_data like $_POST
158
+	 * @return void
159
+	 */
160
+	protected function _normalize($req_data)
161
+	{
162
+		$this->_received_submission = true;
163
+		$this->_validation_errors = array();
164
+		foreach ($this->get_validatable_subsections() as $subsection) {
165
+			if ($subsection->form_data_present_in($req_data)) {
166
+				try {
167
+					$subsection->_normalize($req_data);
168
+				} catch (EE_Validation_Error $e) {
169
+					$subsection->add_validation_error($e);
170
+				}
171
+			}
172
+		}
173
+	}
174 174
 
175 175
 
176 176
 
177
-    /**
178
-     * Performs validation on this form section and its subsections. For each subsection,
179
-     * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
180
-     * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
181
-     * calling parent::_validate() first.
182
-     */
183
-    protected function _validate()
184
-    {
185
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
186
-            if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
187
-                if (method_exists($this, '_validate_'.$subsection_name)) {
188
-                    call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
189
-                }
190
-                $subsection->_validate();
191
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
192
-                $subsection->_received_submission = true;
193
-            }
194
-        }
195
-    }
177
+	/**
178
+	 * Performs validation on this form section and its subsections. For each subsection,
179
+	 * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
180
+	 * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
181
+	 * calling parent::_validate() first.
182
+	 */
183
+	protected function _validate()
184
+	{
185
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
186
+			if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
187
+				if (method_exists($this, '_validate_'.$subsection_name)) {
188
+					call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
189
+				}
190
+				$subsection->_validate();
191
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
192
+				$subsection->_received_submission = true;
193
+			}
194
+		}
195
+	}
196 196
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
     public function __construct(EE_Registration $reg, $options = array())
33 33
     {
34 34
         $this->_registration = $reg;
35
-        if (! isset($options['layout_strategy'])) {
35
+        if ( ! isset($options['layout_strategy'])) {
36 36
             $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
37 37
         }
38
-        if (! isset($options['html_id'])) {
38
+        if ( ! isset($options['html_id'])) {
39 39
             $options['html_id'] = 'reg-admin-attendee-questions-frm';
40 40
         }
41 41
         $this->build_form_from_registration();
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function build_form_from_registration()
64 64
     {
65 65
         $reg = $this->get_registration();
66
-        if (! $reg instanceof EE_Registration) {
66
+        if ( ! $reg instanceof EE_Registration) {
67 67
             throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
68 68
         }
69 69
         // we want to get all their question groups
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         // get each question groups questions
87 87
         foreach ($question_groups as $question_group) {
88 88
             if ($question_group instanceof EE_Question_Group) {
89
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
89
+                $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group(
90 90
                     $question_group,
91 91
                     $reg
92 92
                 );
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function build_subform_from_question_group($question_group, $registration)
107 107
     {
108
-        if (! $question_group instanceof EE_Question_Group ||
108
+        if ( ! $question_group instanceof EE_Question_Group ||
109 109
             ! $registration instanceof EE_Registration) {
110 110
             throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
111 111
         }
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
                 array(
124 124
                     'OR' => array(
125 125
                         'QST_system*blank' => '',
126
-                        'QST_system*null' => array( 'IS_NULL' )
126
+                        'QST_system*null' => array('IS_NULL')
127 127
                     )
128 128
                 )
129 129
             )
130 130
         );
131 131
         foreach ($questions as $question) {
132
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
132
+            $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration);
133 133
         }
134 134
         if (EE_Registry::instance()->CAP->current_user_can(
135 135
             'ee_edit_registration',
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
             $this->_registration->ID()
138 138
         )) {
139 139
             $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
140
-                '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
141
-		  			<span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span>
140
+                '<tr><th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="'.esc_attr__('click to edit question', 'event_espresso').'">
141
+		  			<span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso').'</span>
142 142
 		  			<div class="dashicons dashicons-edit"></div>
143 143
 		  		</a></td></tr>'
144 144
             );
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
186 186
             if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
187 187
                 if (method_exists($this, '_validate_'.$subsection_name)) {
188
-                    call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
188
+                    call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
189 189
                 }
190 190
                 $subsection->_validate();
191 191
             } elseif ($subsection instanceof EE_Form_Section_Proper) {
Please login to merge, or discard this patch.
4_10_0_stages/EE_DMS_4_10_0_Event_Question_Group.dmsstage.php 2 patches
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -14,118 +14,118 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 
17
-    /**
18
-     * Just initializes the status of the migration
19
-     */
20
-    public function __construct()
21
-    {
22
-        global $wpdb;
23
-        $this->_pretty_name = __('Event-Question Group Relations', 'event_espresso');
24
-        $this->_old_table = $wpdb->prefix.'esp_event_question_group';
25
-        $this->_extra_where_sql = "WHERE EQG_primary = 0 AND EQG_additional=0";
26
-        parent::__construct();
27
-    }
17
+	/**
18
+	 * Just initializes the status of the migration
19
+	 */
20
+	public function __construct()
21
+	{
22
+		global $wpdb;
23
+		$this->_pretty_name = __('Event-Question Group Relations', 'event_espresso');
24
+		$this->_old_table = $wpdb->prefix.'esp_event_question_group';
25
+		$this->_extra_where_sql = "WHERE EQG_primary = 0 AND EQG_additional=0";
26
+		parent::__construct();
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * Removes the duplicate event_question_group rows that only had EQG_primary=0. Now we just have one row
32
-     * joining event-to-question-groups with two columns: EQG_primary and EQG_additional, indicating which question
33
-     * groups apply to which category of registrant.
34
-     * @param array $event_question_group an associative array where keys are column names and values are their values.
35
-     * @return null
36
-     */
37
-    protected function _migrate_old_row($event_question_group)
38
-    {
39
-        if (isset($event_question_group['EVT_ID'], $event_question_group['QSG_ID'])) {
40
-            global $wpdb;
41
-            // If the question group was also for primary attendees, we should just update that row.
42
-            // And we delete this row.
43
-            $success = $wpdb->update(
44
-                $this->_old_table,
45
-                ['EQG_additional' => true],  // data
46
-                [
47
-                    'EQG_primary' => true,
48
-                    'EVT_ID' => $event_question_group['EVT_ID'],
49
-                    'QSG_ID' => $event_question_group['QSG_ID']
50
-                ],  // where
51
-                array( '%d' ),   // data format
52
-                array( '%d', '%d', '%d' )  // where format
53
-            );
54
-            if ($success) {
55
-                // Ok it's confirmed: the question group WAS for the primary attendee group too. So
56
-                // now we just need to delete this row.
57
-                $successful_delete = $wpdb->delete(
58
-                    $this->_old_table,
59
-                    [
60
-                        'EQG_ID' => $event_question_group['EQG_ID']
61
-                    ],
62
-                    ['%d']
63
-                );
64
-                if (! $successful_delete) {
65
-                    $this->add_error(
66
-                        sprintf(
67
-                            __('Could not delete old event-question group relation row "%1$s" because "%2$s"', 'event_espresso'),
68
-                            wp_json_encode($event_question_group),
69
-                            $wpdb->last_error
70
-                        )
71
-                    );
72
-                }
73
-            } else {
74
-                // Oh, the question group actually was NOT for the primary attendee. So we just need to update this row
75
-                $wpdb->update(
76
-                    $this->_old_table,
77
-                    ['EQG_additional' => true],  // data
78
-                    [
79
-                        'EVT_ID' => $event_question_group['EVT_ID'],
80
-                        'QSG_ID' => $event_question_group['QSG_ID']
81
-                    ],  // where
82
-                    array( '%d' ),   // data format
83
-                    array( '%d', '%d', '%d' )  // where format
84
-                );
85
-            }
86
-        }
87
-    }
30
+	/**
31
+	 * Removes the duplicate event_question_group rows that only had EQG_primary=0. Now we just have one row
32
+	 * joining event-to-question-groups with two columns: EQG_primary and EQG_additional, indicating which question
33
+	 * groups apply to which category of registrant.
34
+	 * @param array $event_question_group an associative array where keys are column names and values are their values.
35
+	 * @return null
36
+	 */
37
+	protected function _migrate_old_row($event_question_group)
38
+	{
39
+		if (isset($event_question_group['EVT_ID'], $event_question_group['QSG_ID'])) {
40
+			global $wpdb;
41
+			// If the question group was also for primary attendees, we should just update that row.
42
+			// And we delete this row.
43
+			$success = $wpdb->update(
44
+				$this->_old_table,
45
+				['EQG_additional' => true],  // data
46
+				[
47
+					'EQG_primary' => true,
48
+					'EVT_ID' => $event_question_group['EVT_ID'],
49
+					'QSG_ID' => $event_question_group['QSG_ID']
50
+				],  // where
51
+				array( '%d' ),   // data format
52
+				array( '%d', '%d', '%d' )  // where format
53
+			);
54
+			if ($success) {
55
+				// Ok it's confirmed: the question group WAS for the primary attendee group too. So
56
+				// now we just need to delete this row.
57
+				$successful_delete = $wpdb->delete(
58
+					$this->_old_table,
59
+					[
60
+						'EQG_ID' => $event_question_group['EQG_ID']
61
+					],
62
+					['%d']
63
+				);
64
+				if (! $successful_delete) {
65
+					$this->add_error(
66
+						sprintf(
67
+							__('Could not delete old event-question group relation row "%1$s" because "%2$s"', 'event_espresso'),
68
+							wp_json_encode($event_question_group),
69
+							$wpdb->last_error
70
+						)
71
+					);
72
+				}
73
+			} else {
74
+				// Oh, the question group actually was NOT for the primary attendee. So we just need to update this row
75
+				$wpdb->update(
76
+					$this->_old_table,
77
+					['EQG_additional' => true],  // data
78
+					[
79
+						'EVT_ID' => $event_question_group['EVT_ID'],
80
+						'QSG_ID' => $event_question_group['QSG_ID']
81
+					],  // where
82
+					array( '%d' ),   // data format
83
+					array( '%d', '%d', '%d' )  // where format
84
+				);
85
+			}
86
+		}
87
+	}
88 88
 
89
-    /**
90
-     * Gets the rows for the existing table that shouldn't exist in 4.10.
91
-     * Specifically the rows where EQG_primary=false and EQG_additional=false.
92
-     * Gotcha: because the migration is REMOVING rows as it goes, we shouldn't use the offset.
93
-     *
94
-     * @global wpdb $wpdb
95
-     * @param int   $limit
96
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
97
-     */
98
-    protected function _get_rows($limit)
99
-    {
100
-        global $wpdb;
101
-        $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
102
-            "LIMIT %d",
103
-            $limit
104
-        );
105
-        return $wpdb->get_results($query, ARRAY_A);
106
-    }
89
+	/**
90
+	 * Gets the rows for the existing table that shouldn't exist in 4.10.
91
+	 * Specifically the rows where EQG_primary=false and EQG_additional=false.
92
+	 * Gotcha: because the migration is REMOVING rows as it goes, we shouldn't use the offset.
93
+	 *
94
+	 * @global wpdb $wpdb
95
+	 * @param int   $limit
96
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
97
+	 */
98
+	protected function _get_rows($limit)
99
+	{
100
+		global $wpdb;
101
+		$query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
102
+			"LIMIT %d",
103
+			$limit
104
+		);
105
+		return $wpdb->get_results($query, ARRAY_A);
106
+	}
107 107
 
108
-    /**
109
-     * Slight departure from the normal procedure here: because this removes rows from the DB, we need to ensure
110
-     * we count the records first, then do the migration.
111
-     *
112
-     * @param int $num_items
113
-     * @return int number of items ACTUALLY migrated
114
-     */
115
-    public function _migration_step($num_items = 50)
116
-    {
117
-        // Count the items right away. This migration step will be removing those rows, so we need to count them
118
-        // right away to get an accurate count.
119
-        $this->count_records_to_migrate();
120
-        $rows = $this->_get_rows($num_items);
121
-        $items_actually_migrated = 0;
122
-        foreach ($rows as $old_row) {
123
-            $this->_migrate_old_row($old_row);
124
-            $items_actually_migrated++;
125
-        }
126
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
127
-            $this->set_completed();
128
-        }
129
-        return $items_actually_migrated;
130
-    }
108
+	/**
109
+	 * Slight departure from the normal procedure here: because this removes rows from the DB, we need to ensure
110
+	 * we count the records first, then do the migration.
111
+	 *
112
+	 * @param int $num_items
113
+	 * @return int number of items ACTUALLY migrated
114
+	 */
115
+	public function _migration_step($num_items = 50)
116
+	{
117
+		// Count the items right away. This migration step will be removing those rows, so we need to count them
118
+		// right away to get an accurate count.
119
+		$this->count_records_to_migrate();
120
+		$rows = $this->_get_rows($num_items);
121
+		$items_actually_migrated = 0;
122
+		foreach ($rows as $old_row) {
123
+			$this->_migrate_old_row($old_row);
124
+			$items_actually_migrated++;
125
+		}
126
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
127
+			$this->set_completed();
128
+		}
129
+		return $items_actually_migrated;
130
+	}
131 131
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
             // And we delete this row.
43 43
             $success = $wpdb->update(
44 44
                 $this->_old_table,
45
-                ['EQG_additional' => true],  // data
45
+                ['EQG_additional' => true], // data
46 46
                 [
47 47
                     'EQG_primary' => true,
48 48
                     'EVT_ID' => $event_question_group['EVT_ID'],
49 49
                     'QSG_ID' => $event_question_group['QSG_ID']
50
-                ],  // where
51
-                array( '%d' ),   // data format
52
-                array( '%d', '%d', '%d' )  // where format
50
+                ], // where
51
+                array('%d'), // data format
52
+                array('%d', '%d', '%d')  // where format
53 53
             );
54 54
             if ($success) {
55 55
                 // Ok it's confirmed: the question group WAS for the primary attendee group too. So
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                     ],
62 62
                     ['%d']
63 63
                 );
64
-                if (! $successful_delete) {
64
+                if ( ! $successful_delete) {
65 65
                     $this->add_error(
66 66
                         sprintf(
67 67
                             __('Could not delete old event-question group relation row "%1$s" because "%2$s"', 'event_espresso'),
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
                 // Oh, the question group actually was NOT for the primary attendee. So we just need to update this row
75 75
                 $wpdb->update(
76 76
                     $this->_old_table,
77
-                    ['EQG_additional' => true],  // data
77
+                    ['EQG_additional' => true], // data
78 78
                     [
79 79
                         'EVT_ID' => $event_question_group['EVT_ID'],
80 80
                         'QSG_ID' => $event_question_group['QSG_ID']
81
-                    ],  // where
82
-                    array( '%d' ),   // data format
83
-                    array( '%d', '%d', '%d' )  // where format
81
+                    ], // where
82
+                    array('%d'), // data format
83
+                    array('%d', '%d', '%d')  // where format
84 84
                 );
85 85
             }
86 86
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     protected function _get_rows($limit)
99 99
     {
100 100
         global $wpdb;
101
-        $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
101
+        $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} ".$wpdb->prepare(
102 102
             "LIMIT %d",
103 103
             $limit
104 104
         );
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_10_0.dms.php 2 patches
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*');
16 16
 $class_to_filepath = [];
17 17
 foreach ($stages as $filepath) {
18
-    $matches = [];
19
-    preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-    $class_to_filepath[ $matches[1] ] = $filepath;
18
+	$matches = [];
19
+	preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+	$class_to_filepath[ $matches[1] ] = $filepath;
21 21
 }
22 22
 // give addons a chance to autoload their stages too
23 23
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath);
@@ -35,67 +35,67 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base
37 37
 {
38
-    /**
39
-     *
40
-     * @param TableManager  $table_manager
41
-     * @param TableAnalysis $table_analysis
42
-     */
43
-    public function __construct(
44
-        TableManager $table_manager = null,
45
-        TableAnalysis $table_analysis = null,
46
-        EE_DMS_Core_4_9_0 $dms_4_9
47
-    ) {
48
-        $this->previous_dms = $dms_4_9;
49
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso");
50
-        $this->_priority = 10;
51
-        $this->_migration_stages = array(
52
-            new EE_DMS_4_10_0_Event_Question_Group(),
53
-        );
54
-        parent::__construct($table_manager, $table_analysis);
55
-    }
38
+	/**
39
+	 *
40
+	 * @param TableManager  $table_manager
41
+	 * @param TableAnalysis $table_analysis
42
+	 */
43
+	public function __construct(
44
+		TableManager $table_manager = null,
45
+		TableAnalysis $table_analysis = null,
46
+		EE_DMS_Core_4_9_0 $dms_4_9
47
+	) {
48
+		$this->previous_dms = $dms_4_9;
49
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_10_0_Event_Question_Group(),
53
+		);
54
+		parent::__construct($table_manager, $table_analysis);
55
+	}
56 56
 
57 57
 
58 58
 
59
-    /**
60
-     * Whether to migrate or not.
61
-     *
62
-     * @param array $version_array
63
-     * @return bool
64
-     */
65
-    public function can_migrate_from_version($version_array)
66
-    {
67
-        $version_string = $version_array['Core'];
68
-        if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) {
69
-            //          echo "$version_string can be migrated from";
70
-            return true;
71
-        } elseif (! $version_string) {
72
-            //          echo "no version string provided: $version_string";
73
-            // no version string provided... this must be pre 4.3
74
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
75
-        }
76
-        return false;
77
-    }
59
+	/**
60
+	 * Whether to migrate or not.
61
+	 *
62
+	 * @param array $version_array
63
+	 * @return bool
64
+	 */
65
+	public function can_migrate_from_version($version_array)
66
+	{
67
+		$version_string = $version_array['Core'];
68
+		if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) {
69
+			//          echo "$version_string can be migrated from";
70
+			return true;
71
+		} elseif (! $version_string) {
72
+			//          echo "no version string provided: $version_string";
73
+			// no version string provided... this must be pre 4.3
74
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
75
+		}
76
+		return false;
77
+	}
78 78
 
79 79
 
80 80
 
81
-    /**
82
-     * @return bool
83
-     */
84
-    public function schema_changes_before_migration()
85
-    {
86
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
87
-        $now_in_mysql = current_time('mysql', true);
88
-        $table_name = 'esp_answer';
89
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
81
+	/**
82
+	 * @return bool
83
+	 */
84
+	public function schema_changes_before_migration()
85
+	{
86
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
87
+		$now_in_mysql = current_time('mysql', true);
88
+		$table_name = 'esp_answer';
89
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
90 90
 					REG_ID int(10) unsigned NOT NULL,
91 91
 					QST_ID int(10) unsigned NOT NULL,
92 92
 					ANS_value text NOT NULL,
93 93
 					PRIMARY KEY  (ANS_ID),
94 94
 					KEY REG_ID (REG_ID),
95 95
 					KEY QST_ID (QST_ID)";
96
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
97
-        $table_name = 'esp_attendee_meta';
98
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
96
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
97
+		$table_name = 'esp_attendee_meta';
98
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
99 99
 				ATT_ID bigint(20) unsigned NOT NULL,
100 100
 				ATT_fname varchar(45) NOT NULL,
101 101
 				ATT_lname varchar(45) NOT NULL,
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 				KEY ATT_email (ATT_email(191)),
113 113
 				KEY ATT_lname (ATT_lname),
114 114
 				KEY ATT_fname (ATT_fname)";
115
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
116
-        $table_name = 'esp_checkin';
117
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
115
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
116
+		$table_name = 'esp_checkin';
117
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
118 118
 				REG_ID int(10) unsigned NOT NULL,
119 119
 				DTT_ID int(10) unsigned NOT NULL,
120 120
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 				PRIMARY KEY  (CHK_ID),
123 123
 				KEY REG_ID (REG_ID),
124 124
 				KEY DTT_ID (DTT_ID)";
125
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
126
-        $table_name = 'esp_country';
127
-        $sql = "CNT_ISO varchar(2) NOT NULL,
125
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
126
+		$table_name = 'esp_country';
127
+		$sql = "CNT_ISO varchar(2) NOT NULL,
128 128
 				CNT_ISO3 varchar(3) NOT NULL,
129 129
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
130 130
 				CNT_name varchar(45) NOT NULL,
@@ -140,29 +140,29 @@  discard block
 block discarded – undo
140 140
 				CNT_is_EU tinyint(1) DEFAULT '0',
141 141
 				CNT_active tinyint(1) DEFAULT '0',
142 142
 				PRIMARY KEY  (CNT_ISO)";
143
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
144
-        $table_name = 'esp_currency';
145
-        $sql = "CUR_code varchar(6) NOT NULL,
143
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
144
+		$table_name = 'esp_currency';
145
+		$sql = "CUR_code varchar(6) NOT NULL,
146 146
 				CUR_single varchar(45) DEFAULT 'dollar',
147 147
 				CUR_plural varchar(45) DEFAULT 'dollars',
148 148
 				CUR_sign varchar(45) DEFAULT '$',
149 149
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
150 150
 				CUR_active tinyint(1) DEFAULT '0',
151 151
 				PRIMARY KEY  (CUR_code)";
152
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
153
-        // note: although this table is no longer in use,
154
-        // it hasn't been removed because then queries to the model will have errors.
155
-        // but you should expect this table and its corresponding model to be removed in
156
-        // the next few months
157
-        $table_name = 'esp_currency_payment_method';
158
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
152
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
153
+		// note: although this table is no longer in use,
154
+		// it hasn't been removed because then queries to the model will have errors.
155
+		// but you should expect this table and its corresponding model to be removed in
156
+		// the next few months
157
+		$table_name = 'esp_currency_payment_method';
158
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
159 159
 				CUR_code varchar(6) NOT NULL,
160 160
 				PMD_ID int(11) NOT NULL,
161 161
 				PRIMARY KEY  (CPM_ID),
162 162
 				KEY PMD_ID (PMD_ID)";
163
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
164
-        $table_name = 'esp_datetime';
165
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
163
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
164
+		$table_name = 'esp_datetime';
165
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
166 166
 				EVT_ID bigint(20) unsigned NOT NULL,
167 167
 				DTT_name varchar(255) NOT NULL DEFAULT '',
168 168
 				DTT_description text NOT NULL,
@@ -179,25 +179,25 @@  discard block
 block discarded – undo
179 179
 				KEY DTT_EVT_start (DTT_EVT_start),
180 180
 				KEY EVT_ID (EVT_ID),
181 181
 				KEY DTT_is_primary (DTT_is_primary)";
182
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
183
-        $table_name = "esp_datetime_ticket";
184
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
182
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
183
+		$table_name = "esp_datetime_ticket";
184
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
185 185
 				DTT_ID int(10) unsigned NOT NULL,
186 186
 				TKT_ID int(10) unsigned NOT NULL,
187 187
 				PRIMARY KEY  (DTK_ID),
188 188
 				KEY DTT_ID (DTT_ID),
189 189
 				KEY TKT_ID (TKT_ID)";
190
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
191
-        $table_name = 'esp_event_message_template';
192
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
190
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
191
+		$table_name = 'esp_event_message_template';
192
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
193 193
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
194 194
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
195 195
 				PRIMARY KEY  (EMT_ID),
196 196
 				KEY EVT_ID (EVT_ID),
197 197
 				KEY GRP_ID (GRP_ID)";
198
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
199
-        $table_name = 'esp_event_meta';
200
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
198
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
199
+		$table_name = 'esp_event_meta';
200
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
201 201
 				EVT_ID bigint(20) unsigned NOT NULL,
202 202
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
203 203
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
 				EVT_donations tinyint(1) NULL,
213 213
 				PRIMARY KEY  (EVTM_ID),
214 214
 				KEY EVT_ID (EVT_ID)";
215
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
216
-        $table_name = 'esp_event_question_group';
217
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
215
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
216
+		$table_name = 'esp_event_question_group';
217
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
218 218
 				EVT_ID bigint(20) unsigned NOT NULL,
219 219
 				QSG_ID int(10) unsigned NOT NULL,
220 220
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
@@ -222,25 +222,25 @@  discard block
 block discarded – undo
222 222
 				PRIMARY KEY  (EQG_ID),
223 223
 				KEY EVT_ID (EVT_ID),
224 224
 				KEY QSG_ID (QSG_ID)";
225
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
226
-        $table_name = 'esp_event_venue';
227
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
225
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
226
+		$table_name = 'esp_event_venue';
227
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
228 228
 				EVT_ID bigint(20) unsigned NOT NULL,
229 229
 				VNU_ID bigint(20) unsigned NOT NULL,
230 230
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
231 231
 				PRIMARY KEY  (EVV_ID)";
232
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
233
-        $table_name = 'esp_extra_meta';
234
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
232
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
233
+		$table_name = 'esp_extra_meta';
234
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
235 235
 				OBJ_ID int(11) DEFAULT NULL,
236 236
 				EXM_type varchar(45) DEFAULT NULL,
237 237
 				EXM_key varchar(45) DEFAULT NULL,
238 238
 				EXM_value text,
239 239
 				PRIMARY KEY  (EXM_ID),
240 240
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
241
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
242
-        $table_name = 'esp_extra_join';
243
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
241
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
242
+		$table_name = 'esp_extra_join';
243
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
244 244
 				EXJ_first_model_id varchar(6) NOT NULL,
245 245
 				EXJ_first_model_name varchar(20) NOT NULL,
246 246
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 				PRIMARY KEY  (EXJ_ID),
249 249
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
250 250
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
251
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
252
-        $table_name = 'esp_line_item';
253
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
251
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
252
+		$table_name = 'esp_line_item';
253
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
254 254
 				LIN_code varchar(245) NOT NULL DEFAULT '',
255 255
 				TXN_ID int(11) DEFAULT NULL,
256 256
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
272 272
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
273 273
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
274
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
275
-        $table_name = 'esp_log';
276
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
274
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
275
+		$table_name = 'esp_log';
276
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
277 277
 				LOG_time datetime DEFAULT NULL,
278 278
 				OBJ_ID varchar(45) DEFAULT NULL,
279 279
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 				KEY LOG_time (LOG_time),
285 285
 				KEY OBJ (OBJ_type,OBJ_ID),
286 286
 				KEY LOG_type (LOG_type)";
287
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
288
-        $table_name = 'esp_message';
289
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
287
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
288
+		$table_name = 'esp_message';
289
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
290 290
 				GRP_ID int(10) unsigned NULL,
291 291
 				MSG_token varchar(255) NULL,
292 292
 				TXN_ID int(10) unsigned NULL,
@@ -318,18 +318,18 @@  discard block
 block discarded – undo
318 318
 				KEY STS_ID (STS_ID),
319 319
 				KEY MSG_created (MSG_created),
320 320
 				KEY MSG_modified (MSG_modified)";
321
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
322
-        $table_name = 'esp_message_template';
323
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
321
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
322
+		$table_name = 'esp_message_template';
323
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
324 324
 				GRP_ID int(10) unsigned NOT NULL,
325 325
 				MTP_context varchar(50) NOT NULL,
326 326
 				MTP_template_field varchar(30) NOT NULL,
327 327
 				MTP_content text NOT NULL,
328 328
 				PRIMARY KEY  (MTP_ID),
329 329
 				KEY GRP_ID (GRP_ID)";
330
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
331
-        $table_name = 'esp_message_template_group';
332
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
331
+		$table_name = 'esp_message_template_group';
332
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
333 333
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
334 334
 				MTP_name varchar(245) NOT NULL DEFAULT '',
335 335
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
342 342
 				PRIMARY KEY  (GRP_ID),
343 343
 				KEY MTP_user_id (MTP_user_id)";
344
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
345
-        $table_name = 'esp_payment';
346
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
344
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
345
+		$table_name = 'esp_payment';
346
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
347 347
 				TXN_ID int(10) unsigned DEFAULT NULL,
348 348
 				STS_ID varchar(3) DEFAULT NULL,
349 349
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 				PRIMARY KEY  (PAY_ID),
361 361
 				KEY PAY_timestamp (PAY_timestamp),
362 362
 				KEY TXN_ID (TXN_ID)";
363
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
364
-        $table_name = 'esp_payment_method';
365
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
363
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
364
+		$table_name = 'esp_payment_method';
365
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
366 366
 				PMD_type varchar(124) DEFAULT NULL,
367 367
 				PMD_name varchar(255) DEFAULT NULL,
368 368
 				PMD_desc text,
@@ -378,24 +378,24 @@  discard block
 block discarded – undo
378 378
 				PRIMARY KEY  (PMD_ID),
379 379
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
380 380
 				KEY PMD_type (PMD_type)";
381
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
382
-        $table_name = "esp_ticket_price";
383
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
381
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
382
+		$table_name = "esp_ticket_price";
383
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
384 384
 				TKT_ID int(10) unsigned NOT NULL,
385 385
 				PRC_ID int(10) unsigned NOT NULL,
386 386
 				PRIMARY KEY  (TKP_ID),
387 387
 				KEY TKT_ID (TKT_ID),
388 388
 				KEY PRC_ID (PRC_ID)";
389
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
390
-        $table_name = "esp_ticket_template";
391
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
389
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
390
+		$table_name = "esp_ticket_template";
391
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
392 392
 				TTM_name varchar(45) NOT NULL,
393 393
 				TTM_description text,
394 394
 				TTM_file varchar(45),
395 395
 				PRIMARY KEY  (TTM_ID)";
396
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
397
-        $table_name = 'esp_question';
398
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
396
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
397
+		$table_name = 'esp_question';
398
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
399 399
 				QST_display_text text NOT NULL,
400 400
 				QST_admin_label varchar(255) NOT NULL,
401 401
 				QST_system varchar(25) DEFAULT NULL,
@@ -409,18 +409,18 @@  discard block
 block discarded – undo
409 409
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
410 410
 				PRIMARY KEY  (QST_ID),
411 411
 				KEY QST_order (QST_order)';
412
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
413
-        $table_name = 'esp_question_group_question';
414
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
412
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
413
+		$table_name = 'esp_question_group_question';
414
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
415 415
 				QSG_ID int(10) unsigned NOT NULL,
416 416
 				QST_ID int(10) unsigned NOT NULL,
417 417
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
418 418
 				PRIMARY KEY  (QGQ_ID),
419 419
 				KEY QST_ID (QST_ID),
420 420
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
421
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
422
-        $table_name = 'esp_question_option';
423
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
421
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
422
+		$table_name = 'esp_question_option';
423
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
424 424
 				QSO_value varchar(255) NOT NULL,
425 425
 				QSO_desc text NOT NULL,
426 426
 				QST_ID int(10) unsigned NOT NULL,
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 				PRIMARY KEY  (QSO_ID),
431 431
 				KEY QST_ID (QST_ID),
432 432
 				KEY QSO_order (QSO_order)";
433
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
434
-        $table_name = 'esp_registration';
435
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
433
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
434
+		$table_name = 'esp_registration';
435
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
436 436
 				EVT_ID bigint(20) unsigned NOT NULL,
437 437
 				ATT_ID bigint(20) unsigned NOT NULL,
438 438
 				TXN_ID int(10) unsigned NOT NULL,
@@ -456,18 +456,18 @@  discard block
 block discarded – undo
456 456
 				KEY TKT_ID (TKT_ID),
457 457
 				KEY EVT_ID (EVT_ID),
458 458
 				KEY STS_ID (STS_ID)";
459
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
460
-        $table_name = 'esp_registration_payment';
461
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
459
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
460
+		$table_name = 'esp_registration_payment';
461
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
462 462
 					  REG_ID int(10) unsigned NOT NULL,
463 463
 					  PAY_ID int(10) unsigned NULL,
464 464
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
465 465
 					  PRIMARY KEY  (RPY_ID),
466 466
 					  KEY REG_ID (REG_ID),
467 467
 					  KEY PAY_ID (PAY_ID)";
468
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
469
-        $table_name = 'esp_state';
470
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
468
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
469
+		$table_name = 'esp_state';
470
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
471 471
 				CNT_ISO varchar(2) NOT NULL,
472 472
 				STA_abbrev varchar(24) NOT NULL,
473 473
 				STA_name varchar(100) NOT NULL,
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
 				PRIMARY KEY  (STA_ID),
476 476
 				KEY STA_abbrev (STA_abbrev),
477 477
 				KEY CNT_ISO (CNT_ISO)";
478
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
479
-        $table_name = 'esp_status';
480
-        $sql = "STS_ID varchar(3) NOT NULL,
478
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
479
+		$table_name = 'esp_status';
480
+		$sql = "STS_ID varchar(3) NOT NULL,
481 481
 				STS_code varchar(45) NOT NULL,
482 482
 				STS_type varchar(45) NOT NULL,
483 483
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
486 486
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
487 487
 				KEY STS_type (STS_type)";
488
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
489
-        $table_name = 'esp_transaction';
490
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
488
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
489
+		$table_name = 'esp_transaction';
490
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
491 491
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
492 492
 				TXN_total decimal(12,3) DEFAULT '0.00',
493 493
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 				PRIMARY KEY  (TXN_ID),
500 500
 				KEY TXN_timestamp (TXN_timestamp),
501 501
 				KEY STS_ID (STS_ID)";
502
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
503
-        $table_name = 'esp_venue_meta';
504
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
502
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
503
+		$table_name = 'esp_venue_meta';
504
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
505 505
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
506 506
 			VNU_address varchar(255) DEFAULT NULL,
507 507
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
 			KEY VNU_ID (VNU_ID),
521 521
 			KEY STA_ID (STA_ID),
522 522
 			KEY CNT_ISO (CNT_ISO)";
523
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
524
-        // modified tables
525
-        $table_name = "esp_price";
526
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
523
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
524
+		// modified tables
525
+		$table_name = "esp_price";
526
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
527 527
 				PRT_ID tinyint(3) unsigned NOT NULL,
528 528
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
529 529
 				PRC_name varchar(245) NOT NULL,
@@ -536,9 +536,9 @@  discard block
 block discarded – undo
536 536
 				PRC_parent int(10) unsigned DEFAULT 0,
537 537
 				PRIMARY KEY  (PRC_ID),
538 538
 				KEY PRT_ID (PRT_ID)";
539
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
540
-        $table_name = "esp_price_type";
541
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
539
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
540
+		$table_name = "esp_price_type";
541
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
542 542
 				PRT_name varchar(45) NOT NULL,
543 543
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
544 544
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -547,9 +547,9 @@  discard block
 block discarded – undo
547 547
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
548 548
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
549 549
 				PRIMARY KEY  (PRT_ID)";
550
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
551
-        $table_name = "esp_ticket";
552
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
550
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
551
+		$table_name = "esp_ticket";
552
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
553 553
 				TTM_ID int(10) unsigned NOT NULL,
554 554
 				TKT_name varchar(245) NOT NULL DEFAULT '',
555 555
 				TKT_description text NOT NULL,
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
573 573
 				PRIMARY KEY  (TKT_ID),
574 574
 				KEY TKT_start_date (TKT_start_date)";
575
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
576
-        $table_name = 'esp_question_group';
577
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
575
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
576
+		$table_name = 'esp_question_group';
577
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
578 578
 				QSG_name varchar(255) NOT NULL,
579 579
 				QSG_identifier varchar(100) NOT NULL,
580 580
 				QSG_desc text NULL,
@@ -587,38 +587,38 @@  discard block
 block discarded – undo
587 587
 				PRIMARY KEY  (QSG_ID),
588 588
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
589 589
 				KEY QSG_order (QSG_order)';
590
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
591
-        $this->insert_default_data();
592
-        return true;
593
-    }
590
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
591
+		$this->insert_default_data();
592
+		return true;
593
+	}
594 594
 
595
-    /**
596
-     * Inserts default data on new installs
597
-     * @since $VID:$
598
-     * @throws EE_Error
599
-     * @throws InvalidArgumentException
600
-     * @throws ReflectionException
601
-     * @throws InvalidDataTypeException
602
-     * @throws InvalidInterfaceException
603
-     */
604
-    public function insert_default_data()
605
-    {
606
-        $this->previous_dms->insert_default_data();
607
-    }
595
+	/**
596
+	 * Inserts default data on new installs
597
+	 * @since $VID:$
598
+	 * @throws EE_Error
599
+	 * @throws InvalidArgumentException
600
+	 * @throws ReflectionException
601
+	 * @throws InvalidDataTypeException
602
+	 * @throws InvalidInterfaceException
603
+	 */
604
+	public function insert_default_data()
605
+	{
606
+		$this->previous_dms->insert_default_data();
607
+	}
608 608
 
609 609
 
610 610
 
611
-    /**
612
-     * @return boolean
613
-     */
614
-    public function schema_changes_after_migration()
615
-    {
616
-        return true;
617
-    }
611
+	/**
612
+	 * @return boolean
613
+	 */
614
+	public function schema_changes_after_migration()
615
+	{
616
+		return true;
617
+	}
618 618
 
619 619
 
620 620
 
621
-    public function migration_page_hooks()
622
-    {
623
-    }
621
+	public function migration_page_hooks()
622
+	{
623
+	}
624 624
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 // unfortunately, this needs to be done upon INCLUSION of this file,
13 13
 // instead of construction, because it only gets constructed on first page load
14 14
 // (all other times it gets resurrected from a wordpress option)
15
-$stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*');
15
+$stages = glob(EE_CORE.'data_migration_scripts/4_10_0_stages/*');
16 16
 $class_to_filepath = [];
17 17
 foreach ($stages as $filepath) {
18 18
     $matches = [];
19 19
     preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-    $class_to_filepath[ $matches[1] ] = $filepath;
20
+    $class_to_filepath[$matches[1]] = $filepath;
21 21
 }
22 22
 // give addons a chance to autoload their stages too
23 23
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath);
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
         if (version_compare($version_string, '4.10.0.rc.000', '<') && version_compare($version_string, '4.9.0', '>=')) {
69 69
             //          echo "$version_string can be migrated from";
70 70
             return true;
71
-        } elseif (! $version_string) {
71
+        } elseif ( ! $version_string) {
72 72
             //          echo "no version string provided: $version_string";
73 73
             // no version string provided... this must be pre 4.3
74
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
75 75
         }
76 76
         return false;
77 77
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function schema_changes_before_migration()
85 85
     {
86
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
86
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
87 87
         $now_in_mysql = current_time('mysql', true);
88 88
         $table_name = 'esp_answer';
89 89
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
Please login to merge, or discard this patch.