Completed
Branch master (30d6dc)
by
unknown
27:35 queued 25:16
created
domain/services/admin/registrations/list_table/csv_reports/AnswersCSV.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -18,66 +18,66 @@
 block discarded – undo
18 18
 class AnswersCSV
19 19
 {
20 20
 
21
-    /**
22
-     * Add question / answer columns to the CSV row
23
-     *
24
-     * @param array $reg_row
25
-     * @param array $data
26
-     * @param array $question_labels
27
-     * @return mixed
28
-     * @throws EE_Error
29
-     */
30
-    public static function addAnswerColumns(array $reg_row, $data, $question_labels)
31
-    {
32
-        // make sure each registration has the same questions in the same order
33
-        foreach ($question_labels as $question_label) {
34
-            if (! isset($data[ $question_label ])) {
35
-                $data[ $question_label ] = null;
36
-            }
37
-        }
38
-        $answers = EEM_Answer::instance()->get_all_wpdb_results([
39
-            ['REG_ID' => $reg_row['Registration.REG_ID']],
40
-            'force_join' => ['Question'],
41
-        ]);
42
-        // now fill out the questions THEY answered
43
-        foreach ($answers as $answer_row) {
44
-            if ($answer_row['Question.QST_system']) {
45
-                // it's an answer to a system question. That was already displayed as part of the attendee
46
-                // fields, so don't write it out again thanks.
47
-                continue;
48
-            }
49
-            if ($answer_row['Question.QST_ID']) {
50
-                $question_label = EEH_Export::prepare_value_from_db_for_display(
51
-                    EEM_Question::instance(),
52
-                    'QST_admin_label',
53
-                    $answer_row['Question.QST_admin_label']
54
-                );
55
-            } else {
56
-                $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
57
-            }
58
-            if (! array_key_exists($question_label, $data)) {
59
-                // We don't need an answer for this specific question in the current dataset
60
-                // so skip adding this value to $data.
61
-                continue;
62
-            }
63
-            if (
64
-                isset($answer_row['Question.QST_type'])
65
-                && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
66
-            ) {
67
-                $data[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
68
-                    $answer_row['Answer.ANS_value']
69
-                );
70
-            } else {
71
-                // this isn't for html, so don't show html entities
72
-                $data[ $question_label ] = html_entity_decode(
73
-                    EEH_Export::prepare_value_from_db_for_display(
74
-                        EEM_Answer::instance(),
75
-                        'ANS_value',
76
-                        $answer_row['Answer.ANS_value']
77
-                    )
78
-                );
79
-            }
80
-        }
81
-        return $data;
82
-    }
21
+	/**
22
+	 * Add question / answer columns to the CSV row
23
+	 *
24
+	 * @param array $reg_row
25
+	 * @param array $data
26
+	 * @param array $question_labels
27
+	 * @return mixed
28
+	 * @throws EE_Error
29
+	 */
30
+	public static function addAnswerColumns(array $reg_row, $data, $question_labels)
31
+	{
32
+		// make sure each registration has the same questions in the same order
33
+		foreach ($question_labels as $question_label) {
34
+			if (! isset($data[ $question_label ])) {
35
+				$data[ $question_label ] = null;
36
+			}
37
+		}
38
+		$answers = EEM_Answer::instance()->get_all_wpdb_results([
39
+			['REG_ID' => $reg_row['Registration.REG_ID']],
40
+			'force_join' => ['Question'],
41
+		]);
42
+		// now fill out the questions THEY answered
43
+		foreach ($answers as $answer_row) {
44
+			if ($answer_row['Question.QST_system']) {
45
+				// it's an answer to a system question. That was already displayed as part of the attendee
46
+				// fields, so don't write it out again thanks.
47
+				continue;
48
+			}
49
+			if ($answer_row['Question.QST_ID']) {
50
+				$question_label = EEH_Export::prepare_value_from_db_for_display(
51
+					EEM_Question::instance(),
52
+					'QST_admin_label',
53
+					$answer_row['Question.QST_admin_label']
54
+				);
55
+			} else {
56
+				$question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
57
+			}
58
+			if (! array_key_exists($question_label, $data)) {
59
+				// We don't need an answer for this specific question in the current dataset
60
+				// so skip adding this value to $data.
61
+				continue;
62
+			}
63
+			if (
64
+				isset($answer_row['Question.QST_type'])
65
+				&& $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
66
+			) {
67
+				$data[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
68
+					$answer_row['Answer.ANS_value']
69
+				);
70
+			} else {
71
+				// this isn't for html, so don't show html entities
72
+				$data[ $question_label ] = html_entity_decode(
73
+					EEH_Export::prepare_value_from_db_for_display(
74
+						EEM_Answer::instance(),
75
+						'ANS_value',
76
+						$answer_row['Answer.ANS_value']
77
+					)
78
+				);
79
+			}
80
+		}
81
+		return $data;
82
+	}
83 83
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
     {
32 32
         // make sure each registration has the same questions in the same order
33 33
         foreach ($question_labels as $question_label) {
34
-            if (! isset($data[ $question_label ])) {
35
-                $data[ $question_label ] = null;
34
+            if ( ! isset($data[$question_label])) {
35
+                $data[$question_label] = null;
36 36
             }
37 37
         }
38 38
         $answers = EEM_Answer::instance()->get_all_wpdb_results([
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             } else {
56 56
                 $question_label = sprintf(esc_html__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
57 57
             }
58
-            if (! array_key_exists($question_label, $data)) {
58
+            if ( ! array_key_exists($question_label, $data)) {
59 59
                 // We don't need an answer for this specific question in the current dataset
60 60
                 // so skip adding this value to $data.
61 61
                 continue;
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
                 isset($answer_row['Question.QST_type'])
65 65
                 && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
66 66
             ) {
67
-                $data[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
67
+                $data[$question_label] = EEM_State::instance()->get_state_name_by_ID(
68 68
                     $answer_row['Answer.ANS_value']
69 69
                 );
70 70
             } else {
71 71
                 // this isn't for html, so don't show html entities
72
-                $data[ $question_label ] = html_entity_decode(
72
+                $data[$question_label] = html_entity_decode(
73 73
                     EEH_Export::prepare_value_from_db_for_display(
74 74
                         EEM_Answer::instance(),
75 75
                         'ANS_value',
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.33.rc.009');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.33.rc.009');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
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   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -14,138 +14,138 @@
 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 = esc_html__('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 = esc_html__('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
-            // Updating all the rows could be slow on massive DBs, so do the slow selection first, then a quick update
44
-            // in order to avoid locking the table for too long.
45
-            $ids_to_update = $wpdb->get_col(
46
-                $wpdb->prepare(
47
-                    'SELECT EQG_ID FROM ' . $this->_old_table . ' WHERE EQG_primary=1 AND EVT_ID=%d AND QSG_ID=%d',
48
-                    $event_question_group['EVT_ID'],
49
-                    $event_question_group['QSG_ID']
50
-                )
51
-            );
52
-            $success = false;
53
-            if ($ids_to_update) {
54
-                $success = $wpdb->query(
55
-                    'UPDATE '
56
-                    . $this->_old_table
57
-                    . ' SET EQG_additional=1 WHERE EQG_ID IN ('
58
-                    . implode(',', array_map('intval', $ids_to_update))
59
-                    . ') LIMIT ' . count($ids_to_update)
60
-                );
61
-            }
62
-            if ($success) {
63
-                // Ok it's confirmed: the question group WAS for the primary attendee group too. So
64
-                // now we just need to delete this row.
65
-                $successful_delete = $wpdb->delete(
66
-                    $this->_old_table,
67
-                    [
68
-                        'EQG_ID' => $event_question_group['EQG_ID']
69
-                    ],
70
-                    ['%d']
71
-                );
72
-                if (!$successful_delete) {
73
-                    $this->add_error(
74
-                        sprintf(
75
-                            esc_html__('Could not delete old event-question group relation row "%1$s" because "%2$s"', 'event_espresso'),
76
-                            wp_json_encode($event_question_group),
77
-                            $wpdb->last_error
78
-                        )
79
-                    );
80
-                }
81
-            } else {
82
-                // Oh, the question group actually was NOT for the primary attendee. So we just need to update this row
83
-                // Let's do the selection separately from the deletion, this way we don't lock big tables for too long.
84
-                $ids_to_update2 = $wpdb->get_col(
85
-                    $wpdb->prepare(
86
-                        'SELECT EQG_ID FROM '
87
-                        . $this->_old_table
88
-                        . ' WHERE EVT_ID=%d AND QSG_ID=%d',
89
-                        $event_question_group['EVT_ID'],
90
-                        $event_question_group['QSG_ID']
91
-                    )
92
-                );
93
-                if ($ids_to_update2) {
94
-                    $wpdb->query(
95
-                        'UPDATE '
96
-                        . $this->_old_table
97
-                        . ' SET EQG_additional=1 WHERE EQG_ID IN ('
98
-                        . implode(',', array_map('intval', $ids_to_update2))
99
-                        . ') LIMIT ' . count($ids_to_update2)
100
-                    );
101
-                }
102
-            }
103
-        }
104
-    }
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
+			// Updating all the rows could be slow on massive DBs, so do the slow selection first, then a quick update
44
+			// in order to avoid locking the table for too long.
45
+			$ids_to_update = $wpdb->get_col(
46
+				$wpdb->prepare(
47
+					'SELECT EQG_ID FROM ' . $this->_old_table . ' WHERE EQG_primary=1 AND EVT_ID=%d AND QSG_ID=%d',
48
+					$event_question_group['EVT_ID'],
49
+					$event_question_group['QSG_ID']
50
+				)
51
+			);
52
+			$success = false;
53
+			if ($ids_to_update) {
54
+				$success = $wpdb->query(
55
+					'UPDATE '
56
+					. $this->_old_table
57
+					. ' SET EQG_additional=1 WHERE EQG_ID IN ('
58
+					. implode(',', array_map('intval', $ids_to_update))
59
+					. ') LIMIT ' . count($ids_to_update)
60
+				);
61
+			}
62
+			if ($success) {
63
+				// Ok it's confirmed: the question group WAS for the primary attendee group too. So
64
+				// now we just need to delete this row.
65
+				$successful_delete = $wpdb->delete(
66
+					$this->_old_table,
67
+					[
68
+						'EQG_ID' => $event_question_group['EQG_ID']
69
+					],
70
+					['%d']
71
+				);
72
+				if (!$successful_delete) {
73
+					$this->add_error(
74
+						sprintf(
75
+							esc_html__('Could not delete old event-question group relation row "%1$s" because "%2$s"', 'event_espresso'),
76
+							wp_json_encode($event_question_group),
77
+							$wpdb->last_error
78
+						)
79
+					);
80
+				}
81
+			} else {
82
+				// Oh, the question group actually was NOT for the primary attendee. So we just need to update this row
83
+				// Let's do the selection separately from the deletion, this way we don't lock big tables for too long.
84
+				$ids_to_update2 = $wpdb->get_col(
85
+					$wpdb->prepare(
86
+						'SELECT EQG_ID FROM '
87
+						. $this->_old_table
88
+						. ' WHERE EVT_ID=%d AND QSG_ID=%d',
89
+						$event_question_group['EVT_ID'],
90
+						$event_question_group['QSG_ID']
91
+					)
92
+				);
93
+				if ($ids_to_update2) {
94
+					$wpdb->query(
95
+						'UPDATE '
96
+						. $this->_old_table
97
+						. ' SET EQG_additional=1 WHERE EQG_ID IN ('
98
+						. implode(',', array_map('intval', $ids_to_update2))
99
+						. ') LIMIT ' . count($ids_to_update2)
100
+					);
101
+				}
102
+			}
103
+		}
104
+	}
105 105
 
106
-    /**
107
-     * Gets the rows for the existing table that shouldn't exist in 4.10.
108
-     * Specifically the rows where EQG_primary=false and EQG_additional=false.
109
-     * Gotcha: because the migration is REMOVING rows as it goes, we shouldn't use the offset.
110
-     *
111
-     * @global wpdb $wpdb
112
-     * @param int   $limit
113
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
114
-     */
115
-    protected function _get_rows($limit)
116
-    {
117
-        global $wpdb;
118
-        $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
119
-            "LIMIT %d",
120
-            $limit
121
-        );
122
-        return $wpdb->get_results($query, ARRAY_A);
123
-    }
106
+	/**
107
+	 * Gets the rows for the existing table that shouldn't exist in 4.10.
108
+	 * Specifically the rows where EQG_primary=false and EQG_additional=false.
109
+	 * Gotcha: because the migration is REMOVING rows as it goes, we shouldn't use the offset.
110
+	 *
111
+	 * @global wpdb $wpdb
112
+	 * @param int   $limit
113
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
114
+	 */
115
+	protected function _get_rows($limit)
116
+	{
117
+		global $wpdb;
118
+		$query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
119
+			"LIMIT %d",
120
+			$limit
121
+		);
122
+		return $wpdb->get_results($query, ARRAY_A);
123
+	}
124 124
 
125
-    /**
126
-     * Slight departure from the normal procedure here: because this removes rows from the DB, we need to ensure
127
-     * we count the records first, then do the migration.
128
-     *
129
-     * @param int $num_items
130
-     * @return int number of items ACTUALLY migrated
131
-     */
132
-    public function _migration_step($num_items = 50)
133
-    {
134
-        // Count the items right away. This migration step will be removing those rows, so we need to count them
135
-        // right away to get an accurate count.
136
-        $this->count_records_to_migrate();
137
-        $rows = $this->_get_rows($num_items);
138
-        $items_actually_migrated = 0;
139
-        foreach ($rows as $old_row) {
140
-            $this->_migrate_old_row($old_row);
141
-            $items_actually_migrated++;
142
-        }
143
-        if (
144
-            empty($rows)
145
-            || ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate())
146
-        ) {
147
-            $this->set_completed();
148
-        }
149
-        return $items_actually_migrated;
150
-    }
125
+	/**
126
+	 * Slight departure from the normal procedure here: because this removes rows from the DB, we need to ensure
127
+	 * we count the records first, then do the migration.
128
+	 *
129
+	 * @param int $num_items
130
+	 * @return int number of items ACTUALLY migrated
131
+	 */
132
+	public function _migration_step($num_items = 50)
133
+	{
134
+		// Count the items right away. This migration step will be removing those rows, so we need to count them
135
+		// right away to get an accurate count.
136
+		$this->count_records_to_migrate();
137
+		$rows = $this->_get_rows($num_items);
138
+		$items_actually_migrated = 0;
139
+		foreach ($rows as $old_row) {
140
+			$this->_migrate_old_row($old_row);
141
+			$items_actually_migrated++;
142
+		}
143
+		if (
144
+			empty($rows)
145
+			|| ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate())
146
+		) {
147
+			$this->set_completed();
148
+		}
149
+		return $items_actually_migrated;
150
+	}
151 151
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     {
22 22
         global $wpdb;
23 23
         $this->_pretty_name = esc_html__('Event-Question Group Relations', 'event_espresso');
24
-        $this->_old_table = $wpdb->prefix . 'esp_event_question_group';
24
+        $this->_old_table = $wpdb->prefix.'esp_event_question_group';
25 25
         $this->_extra_where_sql = "WHERE EQG_primary = 0 AND EQG_additional=0";
26 26
         parent::__construct();
27 27
     }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             // in order to avoid locking the table for too long.
45 45
             $ids_to_update = $wpdb->get_col(
46 46
                 $wpdb->prepare(
47
-                    'SELECT EQG_ID FROM ' . $this->_old_table . ' WHERE EQG_primary=1 AND EVT_ID=%d AND QSG_ID=%d',
47
+                    'SELECT EQG_ID FROM '.$this->_old_table.' WHERE EQG_primary=1 AND EVT_ID=%d AND QSG_ID=%d',
48 48
                     $event_question_group['EVT_ID'],
49 49
                     $event_question_group['QSG_ID']
50 50
                 )
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     . $this->_old_table
57 57
                     . ' SET EQG_additional=1 WHERE EQG_ID IN ('
58 58
                     . implode(',', array_map('intval', $ids_to_update))
59
-                    . ') LIMIT ' . count($ids_to_update)
59
+                    . ') LIMIT '.count($ids_to_update)
60 60
                 );
61 61
             }
62 62
             if ($success) {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                     ],
70 70
                     ['%d']
71 71
                 );
72
-                if (!$successful_delete) {
72
+                if ( ! $successful_delete) {
73 73
                     $this->add_error(
74 74
                         sprintf(
75 75
                             esc_html__('Could not delete old event-question group relation row "%1$s" because "%2$s"', 'event_espresso'),
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
                         . $this->_old_table
97 97
                         . ' SET EQG_additional=1 WHERE EQG_ID IN ('
98 98
                         . implode(',', array_map('intval', $ids_to_update2))
99
-                        . ') LIMIT ' . count($ids_to_update2)
99
+                        . ') LIMIT '.count($ids_to_update2)
100 100
                     );
101 101
                 }
102 102
             }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     protected function _get_rows($limit)
116 116
     {
117 117
         global $wpdb;
118
-        $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} " . $wpdb->prepare(
118
+        $query = "SELECT * FROM {$this->_old_table} {$this->_extra_where_sql} ".$wpdb->prepare(
119 119
             "LIMIT %d",
120 120
             $limit
121 121
         );
Please login to merge, or discard this patch.