Completed
Branch back-compat-edtr-taxes (752e0e)
by
unknown
12:08 queued 09:43
created
core/services/orm/tree_traversal/NodeGroupDao.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function getModelObjNodesInGroup($code)
51 51
     {
52
-        if (! $code) {
52
+        if ( ! $code) {
53 53
             throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso'));
54 54
         }
55
-        $deletion_data = get_option($this->getOptionPrefix() . $code, []);
55
+        $deletion_data = get_option($this->getOptionPrefix().$code, []);
56 56
         foreach ($deletion_data as $root) {
57
-            if (! $root instanceof ModelObjNode) {
57
+            if ( ! $root instanceof ModelObjNode) {
58 58
                 throw new UnexpectedEntityException($root, 'ModelObjNode');
59 59
             }
60 60
         }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     public function persistModelObjNodesGroup($model_obj_nodes, $code)
112 112
     {
113 113
         return add_option(
114
-            $this->getOptionPrefix() . $code,
114
+            $this->getOptionPrefix().$code,
115 115
             $model_obj_nodes,
116 116
             null,
117 117
             'no'
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function deleteModelObjNodesInGroup($code)
128 128
     {
129
-        return delete_option($this->getOptionPrefix() . $code);
129
+        return delete_option($this->getOptionPrefix().$code);
130 130
     }
131 131
 }
132 132
 // End of file NodeGroupDao.php
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -22,112 +22,112 @@
 block discarded – undo
22 22
  */
23 23
 class NodeGroupDao
24 24
 {
25
-    /**
26
-     * @since 4.10.12.p
27
-     * @return mixed|void
28
-     */
29
-    public function generateGroupCode()
30
-    {
31
-        return wp_generate_password(6, false);
32
-    }
25
+	/**
26
+	 * @since 4.10.12.p
27
+	 * @return mixed|void
28
+	 */
29
+	public function generateGroupCode()
30
+	{
31
+		return wp_generate_password(6, false);
32
+	}
33 33
 
34
-    /**
35
-     * Gets the string we put in front of the WP Option name used to store the jobs.
36
-     * @since 4.10.12.p
37
-     * @return string
38
-     */
39
-    private function getOptionPrefix()
40
-    {
41
-        return 'ee_deletion_';
42
-    }
34
+	/**
35
+	 * Gets the string we put in front of the WP Option name used to store the jobs.
36
+	 * @since 4.10.12.p
37
+	 * @return string
38
+	 */
39
+	private function getOptionPrefix()
40
+	{
41
+		return 'ee_deletion_';
42
+	}
43 43
 
44
-    /**
45
-     * @since 4.10.12.p
46
-     * @param $code
47
-     * @return ModelObjNode[]
48
-     * @throws UnexpectedEntityException
49
-     */
50
-    public function getModelObjNodesInGroup($code)
51
-    {
52
-        if (! $code) {
53
-            throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso'));
54
-        }
55
-        $deletion_data = get_option($this->getOptionPrefix() . $code, []);
56
-        foreach ($deletion_data as $root) {
57
-            if (! $root instanceof ModelObjNode) {
58
-                throw new UnexpectedEntityException($root, 'ModelObjNode');
59
-            }
60
-        }
61
-        return $deletion_data;
62
-    }
44
+	/**
45
+	 * @since 4.10.12.p
46
+	 * @param $code
47
+	 * @return ModelObjNode[]
48
+	 * @throws UnexpectedEntityException
49
+	 */
50
+	public function getModelObjNodesInGroup($code)
51
+	{
52
+		if (! $code) {
53
+			throw new Exception(esc_html__('We aren’t sure which job you are performing. Please press back in your browser and try again.', 'event_espresso'));
54
+		}
55
+		$deletion_data = get_option($this->getOptionPrefix() . $code, []);
56
+		foreach ($deletion_data as $root) {
57
+			if (! $root instanceof ModelObjNode) {
58
+				throw new UnexpectedEntityException($root, 'ModelObjNode');
59
+			}
60
+		}
61
+		return $deletion_data;
62
+	}
63 63
 
64
-    /**
65
-     * Gets an array indicating what database rows are contained in the job.
66
-     * Each top-level key is a model name, and its value is an array of IDs.
67
-     * @since 4.10.12.p
68
-     * @param ModelObjNode[] $model_obj_nodes
69
-     * @return array
70
-     * @throws EE_Error
71
-     * @throws InvalidDataTypeException
72
-     * @throws InvalidInterfaceException
73
-     * @throws InvalidArgumentException
74
-     * @throws ReflectionException
75
-     */
76
-    public function getModelsAndIdsContainedIn($model_obj_nodes)
77
-    {
78
-        $models_and_ids_to_delete = [];
79
-        foreach ($model_obj_nodes as $root) {
80
-            $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
81
-        }
82
-        return $models_and_ids_to_delete;
83
-    }
64
+	/**
65
+	 * Gets an array indicating what database rows are contained in the job.
66
+	 * Each top-level key is a model name, and its value is an array of IDs.
67
+	 * @since 4.10.12.p
68
+	 * @param ModelObjNode[] $model_obj_nodes
69
+	 * @return array
70
+	 * @throws EE_Error
71
+	 * @throws InvalidDataTypeException
72
+	 * @throws InvalidInterfaceException
73
+	 * @throws InvalidArgumentException
74
+	 * @throws ReflectionException
75
+	 */
76
+	public function getModelsAndIdsContainedIn($model_obj_nodes)
77
+	{
78
+		$models_and_ids_to_delete = [];
79
+		foreach ($model_obj_nodes as $root) {
80
+			$models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
81
+		}
82
+		return $models_and_ids_to_delete;
83
+	}
84 84
 
85
-    /**
86
-     * Gets an array indicating what database rows are contained in the job.
87
-     * Each top-level key is a model name, and its value is an array of IDs.
88
-     * @since 4.10.12.p
89
-     * @param string $code
90
-     * @return array
91
-     * @throws EE_Error
92
-     * @throws InvalidArgumentException
93
-     * @throws InvalidDataTypeException
94
-     * @throws InvalidInterfaceException
95
-     * @throws ReflectionException
96
-     * @throws UnexpectedEntityException
97
-     */
98
-    public function getModelsAndIdsFromGroup($code)
99
-    {
100
-        $model_obj_nodes = $this->getModelObjNodesInGroup($code);
101
-        return $this->getModelsAndIdsContainedIn($model_obj_nodes);
102
-    }
85
+	/**
86
+	 * Gets an array indicating what database rows are contained in the job.
87
+	 * Each top-level key is a model name, and its value is an array of IDs.
88
+	 * @since 4.10.12.p
89
+	 * @param string $code
90
+	 * @return array
91
+	 * @throws EE_Error
92
+	 * @throws InvalidArgumentException
93
+	 * @throws InvalidDataTypeException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws ReflectionException
96
+	 * @throws UnexpectedEntityException
97
+	 */
98
+	public function getModelsAndIdsFromGroup($code)
99
+	{
100
+		$model_obj_nodes = $this->getModelObjNodesInGroup($code);
101
+		return $this->getModelsAndIdsContainedIn($model_obj_nodes);
102
+	}
103 103
 
104
-    /**
105
-     * Persists the ModelObjNodes for future requests, using the code for reference.
106
-     * @since 4.10.12.p
107
-     * @param ModelObjNode[] $model_obj_nodes
108
-     * @param string $code
109
-     * @return bool
110
-     */
111
-    public function persistModelObjNodesGroup($model_obj_nodes, $code)
112
-    {
113
-        return add_option(
114
-            $this->getOptionPrefix() . $code,
115
-            $model_obj_nodes,
116
-            null,
117
-            'no'
118
-        );
119
-    }
104
+	/**
105
+	 * Persists the ModelObjNodes for future requests, using the code for reference.
106
+	 * @since 4.10.12.p
107
+	 * @param ModelObjNode[] $model_obj_nodes
108
+	 * @param string $code
109
+	 * @return bool
110
+	 */
111
+	public function persistModelObjNodesGroup($model_obj_nodes, $code)
112
+	{
113
+		return add_option(
114
+			$this->getOptionPrefix() . $code,
115
+			$model_obj_nodes,
116
+			null,
117
+			'no'
118
+		);
119
+	}
120 120
 
121
-    /**
122
-     * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though.
123
-     * @since 4.10.12.p
124
-     * @param $code
125
-     * @return bool
126
-     */
127
-    public function deleteModelObjNodesInGroup($code)
128
-    {
129
-        return delete_option($this->getOptionPrefix() . $code);
130
-    }
121
+	/**
122
+	 * Forgets about the group of ModelObjNodes. Doesn't delete the rows in the database they reference though.
123
+	 * @since 4.10.12.p
124
+	 * @param $code
125
+	 * @return bool
126
+	 */
127
+	public function deleteModelObjNodesInGroup($code)
128
+	{
129
+		return delete_option($this->getOptionPrefix() . $code);
130
+	}
131 131
 }
132 132
 // End of file NodeGroupDao.php
133 133
 // Location: EventEspresso\core\services\orm\tree_traversal/NodeGroupDao.php
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/ExecuteBatchDeletion.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -32,158 +32,158 @@
 block discarded – undo
32 32
  */
33 33
 class ExecuteBatchDeletion extends JobHandler
34 34
 {
35
-    /**
36
-     * @var NodeGroupDao
37
-     */
38
-    protected $model_obj_node_group_persister;
39
-    public function __construct(NodeGroupDao $model_obj_node_group_persister)
40
-    {
41
-        $this->model_obj_node_group_persister = $model_obj_node_group_persister;
42
-    }
35
+	/**
36
+	 * @var NodeGroupDao
37
+	 */
38
+	protected $model_obj_node_group_persister;
39
+	public function __construct(NodeGroupDao $model_obj_node_group_persister)
40
+	{
41
+		$this->model_obj_node_group_persister = $model_obj_node_group_persister;
42
+	}
43 43
 
44 44
 
45
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
-    /**
47
-     *
48
-     * @param JobParameters $job_parameters
49
-     * @throws BatchRequestException
50
-     * @return JobStepResponse
51
-     */
52
-    public function create_job(JobParameters $job_parameters)
53
-    {
54
-        $deletion_job_code = $job_parameters->request_datum('deletion_job_code', null);
55
-        $roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code);
56
-        if ($roots === null) {
57
-            throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso'));
58
-        }
59
-        $models_and_ids_to_delete = [];
60
-        foreach ($roots as $root) {
61
-            if (! $root instanceof ModelObjNode) {
62
-                throw new UnexpectedEntityException($root, 'ModelObjNode');
63
-            }
64
-            $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
65
-        }
66
-        $job_parameters->set_extra_data(
67
-            [
68
-                'models_and_ids_to_delete' => $models_and_ids_to_delete
69
-            ]
70
-        );
71
-        // Find the job's actual size.
72
-        $job_size = 0;
73
-        foreach ($models_and_ids_to_delete as $model_name => $ids) {
74
-            $job_size += count($ids);
75
-        }
76
-        $job_parameters->set_job_size($job_size);
77
-        return new JobStepResponse(
78
-            $job_parameters,
79
-            esc_html__('Beginning to delete items...', 'event_espresso')
80
-        );
81
-    }
45
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
+	/**
47
+	 *
48
+	 * @param JobParameters $job_parameters
49
+	 * @throws BatchRequestException
50
+	 * @return JobStepResponse
51
+	 */
52
+	public function create_job(JobParameters $job_parameters)
53
+	{
54
+		$deletion_job_code = $job_parameters->request_datum('deletion_job_code', null);
55
+		$roots = $this->model_obj_node_group_persister->getModelObjNodesInGroup($deletion_job_code);
56
+		if ($roots === null) {
57
+			throw new UnexpectedEntityException($roots, 'array', esc_html__('The job seems to be stale. Please press the back button in your browser twice.', 'event_espresso'));
58
+		}
59
+		$models_and_ids_to_delete = [];
60
+		foreach ($roots as $root) {
61
+			if (! $root instanceof ModelObjNode) {
62
+				throw new UnexpectedEntityException($root, 'ModelObjNode');
63
+			}
64
+			$models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
65
+		}
66
+		$job_parameters->set_extra_data(
67
+			[
68
+				'models_and_ids_to_delete' => $models_and_ids_to_delete
69
+			]
70
+		);
71
+		// Find the job's actual size.
72
+		$job_size = 0;
73
+		foreach ($models_and_ids_to_delete as $model_name => $ids) {
74
+			$job_size += count($ids);
75
+		}
76
+		$job_parameters->set_job_size($job_size);
77
+		return new JobStepResponse(
78
+			$job_parameters,
79
+			esc_html__('Beginning to delete items...', 'event_espresso')
80
+		);
81
+	}
82 82
 
83
-    /**
84
-     * Performs another step of the job
85
-     * @param JobParameters $job_parameters
86
-     * @param int $batch_size
87
-     * @return JobStepResponse
88
-     * @throws BatchRequestException
89
-     */
90
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
91
-    {
92
-        // We already have the items IDs. So deleting is really fast. Let's speed it up.
93
-        $batch_size *= 10;
94
-        $units_processed = 0;
95
-        $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
96
-        // Build a new list of everything leftover after this request's of deletions.
97
-        $models_and_ids_remaining = [];
98
-        foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) {
99
-            if ($units_processed < $batch_size) {
100
-                $model = EE_Registry::instance()->load_model($model_name);
101
-                $ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true);
102
-                if ($model->has_primary_key_field()) {
103
-                    $where_conditions = [
104
-                        $model->primary_key_name() => [
105
-                            'IN',
106
-                            $ids_to_delete_this_query
107
-                        ]
108
-                    ];
109
-                } else {
110
-                    $where_conditions = [
111
-                        'OR' => []
112
-                    ];
113
-                    foreach ($ids_to_delete_this_query as $index_primary_key_string) {
114
-                        $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
115
-                        $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
116
-                    }
117
-                }
118
-                // Deleting time!
119
-                // The model's deletion method reports every ROW deleted, and in the case of CPT models that will be
120
-                // two rows deleted for event CPT item. So don't rely on it for the count of items deleted.
121
-                $model->delete_permanently(
122
-                    [
123
-                        $where_conditions
124
-                    ],
125
-                    false
126
-                );
127
-                $units_processed += count($ids_to_delete_this_query);
128
-                $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
129
-                // If there's any more from this model, we'll do them next time.
130
-                if (count($remaining_ids) > 0) {
131
-                    $models_and_ids_remaining[ $model_name ] = $remaining_ids;
132
-                }
133
-            } else {
134
-                $models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ];
135
-            }
136
-        }
137
-        $job_parameters->mark_processed($units_processed);
138
-        // All done deleting for this request. Is there anything to do next time?
139
-        if (empty($models_and_ids_remaining)) {
140
-            $job_parameters->set_status(JobParameters::status_complete);
141
-            return new JobStepResponse(
142
-                $job_parameters,
143
-                esc_html__('Deletion complete.', 'event_espresso')
144
-            );
145
-        }
146
-        $job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining);
147
-        return new JobStepResponse(
148
-            $job_parameters,
149
-            sprintf(
150
-                esc_html__('Deleted %d items.', 'event_espresso'),
151
-                $units_processed
152
-            )
153
-        );
154
-    }
83
+	/**
84
+	 * Performs another step of the job
85
+	 * @param JobParameters $job_parameters
86
+	 * @param int $batch_size
87
+	 * @return JobStepResponse
88
+	 * @throws BatchRequestException
89
+	 */
90
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
91
+	{
92
+		// We already have the items IDs. So deleting is really fast. Let's speed it up.
93
+		$batch_size *= 10;
94
+		$units_processed = 0;
95
+		$models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
96
+		// Build a new list of everything leftover after this request's of deletions.
97
+		$models_and_ids_remaining = [];
98
+		foreach ($models_and_ids_to_delete as $model_name => $ids_to_delete) {
99
+			if ($units_processed < $batch_size) {
100
+				$model = EE_Registry::instance()->load_model($model_name);
101
+				$ids_to_delete_this_query = array_slice($ids_to_delete, 0, $batch_size - $units_processed, true);
102
+				if ($model->has_primary_key_field()) {
103
+					$where_conditions = [
104
+						$model->primary_key_name() => [
105
+							'IN',
106
+							$ids_to_delete_this_query
107
+						]
108
+					];
109
+				} else {
110
+					$where_conditions = [
111
+						'OR' => []
112
+					];
113
+					foreach ($ids_to_delete_this_query as $index_primary_key_string) {
114
+						$keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
115
+						$where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
116
+					}
117
+				}
118
+				// Deleting time!
119
+				// The model's deletion method reports every ROW deleted, and in the case of CPT models that will be
120
+				// two rows deleted for event CPT item. So don't rely on it for the count of items deleted.
121
+				$model->delete_permanently(
122
+					[
123
+						$where_conditions
124
+					],
125
+					false
126
+				);
127
+				$units_processed += count($ids_to_delete_this_query);
128
+				$remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
129
+				// If there's any more from this model, we'll do them next time.
130
+				if (count($remaining_ids) > 0) {
131
+					$models_and_ids_remaining[ $model_name ] = $remaining_ids;
132
+				}
133
+			} else {
134
+				$models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ];
135
+			}
136
+		}
137
+		$job_parameters->mark_processed($units_processed);
138
+		// All done deleting for this request. Is there anything to do next time?
139
+		if (empty($models_and_ids_remaining)) {
140
+			$job_parameters->set_status(JobParameters::status_complete);
141
+			return new JobStepResponse(
142
+				$job_parameters,
143
+				esc_html__('Deletion complete.', 'event_espresso')
144
+			);
145
+		}
146
+		$job_parameters->add_extra_data('models_and_ids_to_delete', $models_and_ids_remaining);
147
+		return new JobStepResponse(
148
+			$job_parameters,
149
+			sprintf(
150
+				esc_html__('Deleted %d items.', 'event_espresso'),
151
+				$units_processed
152
+			)
153
+		);
154
+	}
155 155
 
156
-    /**
157
-     * Performs any clean-up logic when we know the job is completed
158
-     * @param JobParameters $job_parameters
159
-     * @return JobStepResponse
160
-     */
161
-    public function cleanup_job(JobParameters $job_parameters)
162
-    {
163
-        $this->model_obj_node_group_persister->deleteModelObjNodesInGroup(
164
-            $job_parameters->request_datum('deletion_job_code')
165
-        );
166
-        // For backwards compatibility with how we used to delete events, make sure we still trigger the old action.
167
-        $models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
168
-        foreach ($models_and_ids_to_delete['Event'] as $event_id) {
169
-            // Create a log entry so we know who and when this event was permanently deleted.
170
-            (EE_Change_Log::new_instance(
171
-                [
172
-                    'OBJ_ID' => $event_id,
173
-                    'OBJ_type' => 'Event',
174
-                    'LOG_message' => sprintf(
175
-                        esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'),
176
-                        $event_id
177
-                    )
178
-                ]
179
-            ))->save();
180
-            do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id);
181
-        }
182
-        return new JobStepResponse(
183
-            $job_parameters,
184
-            esc_html__('All done', 'event_espresso')
185
-        );
186
-    }
156
+	/**
157
+	 * Performs any clean-up logic when we know the job is completed
158
+	 * @param JobParameters $job_parameters
159
+	 * @return JobStepResponse
160
+	 */
161
+	public function cleanup_job(JobParameters $job_parameters)
162
+	{
163
+		$this->model_obj_node_group_persister->deleteModelObjNodesInGroup(
164
+			$job_parameters->request_datum('deletion_job_code')
165
+		);
166
+		// For backwards compatibility with how we used to delete events, make sure we still trigger the old action.
167
+		$models_and_ids_to_delete = $job_parameters->extra_datum('models_and_ids_to_delete', []);
168
+		foreach ($models_and_ids_to_delete['Event'] as $event_id) {
169
+			// Create a log entry so we know who and when this event was permanently deleted.
170
+			(EE_Change_Log::new_instance(
171
+				[
172
+					'OBJ_ID' => $event_id,
173
+					'OBJ_type' => 'Event',
174
+					'LOG_message' => sprintf(
175
+						esc_html__('Event %1$d permanently deleted using ExecuteBatchDeletion.', 'event_espresso'),
176
+						$event_id
177
+					)
178
+				]
179
+			))->save();
180
+			do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $event_id);
181
+		}
182
+		return new JobStepResponse(
183
+			$job_parameters,
184
+			esc_html__('All done', 'event_espresso')
185
+		);
186
+	}
187 187
 }
188 188
 // End of file EventDeletion.php
189 189
 // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         }
59 59
         $models_and_ids_to_delete = [];
60 60
         foreach ($roots as $root) {
61
-            if (! $root instanceof ModelObjNode) {
61
+            if ( ! $root instanceof ModelObjNode) {
62 62
                 throw new UnexpectedEntityException($root, 'ModelObjNode');
63 63
             }
64 64
             $models_and_ids_to_delete = array_replace_recursive($models_and_ids_to_delete, $root->getIds());
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
                     ];
113 113
                     foreach ($ids_to_delete_this_query as $index_primary_key_string) {
114 114
                         $keys_n_values = $model->parse_index_primary_key_string($index_primary_key_string);
115
-                        $where_conditions['OR'][ 'AND*' . $index_primary_key_string ] = $keys_n_values;
115
+                        $where_conditions['OR']['AND*'.$index_primary_key_string] = $keys_n_values;
116 116
                     }
117 117
                 }
118 118
                 // Deleting time!
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
                 $remaining_ids = array_diff_key($ids_to_delete, $ids_to_delete_this_query);
129 129
                 // If there's any more from this model, we'll do them next time.
130 130
                 if (count($remaining_ids) > 0) {
131
-                    $models_and_ids_remaining[ $model_name ] = $remaining_ids;
131
+                    $models_and_ids_remaining[$model_name] = $remaining_ids;
132 132
                 }
133 133
             } else {
134
-                $models_and_ids_remaining[ $model_name ] = $models_and_ids_to_delete[ $model_name ];
134
+                $models_and_ids_remaining[$model_name] = $models_and_ids_to_delete[$model_name];
135 135
             }
136 136
         }
137 137
         $job_parameters->mark_processed($units_processed);
Please login to merge, or discard this patch.
core/domain/services/admin/events/data/PreviewDeletion.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
         $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
90 90
         $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
91 91
         $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
92
-        if (empty($event_ids) || !is_array($event_ids)) {
92
+        if (empty($event_ids) || ! is_array($event_ids)) {
93 93
             throw new EE_Error(
94 94
                 esc_html__('No Events were found to delete.', 'event_espresso')
95 95
             );
96 96
         }
97 97
         $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
98
-        if (!is_array($datetime_ids)) {
98
+        if ( ! is_array($datetime_ids)) {
99 99
             throw new UnexpectedEntityException($datetime_ids, 'array');
100 100
         }
101 101
         $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
102
-        if (!is_array($registration_ids)) {
102
+        if ( ! is_array($registration_ids)) {
103 103
             throw new UnexpectedEntityException($registration_ids, 'array');
104 104
         }
105 105
         $num_registrations_to_show = 10;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         ];
136 136
         return [
137 137
             'admin_page_content' => EEH_Template::display_template(
138
-                EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
138
+                EVENTS_TEMPLATE_PATH.'event_preview_deletion.template.php',
139 139
                 [
140 140
                     'form_url' => EE_Admin_Page::add_query_args_and_nonce(
141 141
                         $confirm_deletion_args,
Please login to merge, or discard this patch.
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -31,127 +31,127 @@
 block discarded – undo
31 31
  */
32 32
 class PreviewDeletion
33 33
 {
34
-    /**
35
-     * @var NodeGroupDao
36
-     */
37
-    protected $dao;
34
+	/**
35
+	 * @var NodeGroupDao
36
+	 */
37
+	protected $dao;
38 38
 
39
-    /**
40
-     * @var EEM_Event
41
-     */
42
-    protected $event_model;
39
+	/**
40
+	 * @var EEM_Event
41
+	 */
42
+	protected $event_model;
43 43
 
44
-    /**
45
-     * @var EEM_Datetime
46
-     */
47
-    protected $datetime_model;
44
+	/**
45
+	 * @var EEM_Datetime
46
+	 */
47
+	protected $datetime_model;
48 48
 
49
-    /**
50
-     * @var EEM_Registration
51
-     */
52
-    protected $registration_model;
49
+	/**
50
+	 * @var EEM_Registration
51
+	 */
52
+	protected $registration_model;
53 53
 
54
-    /**
55
-     * PreviewDeletion constructor.
56
-     * @param NodeGroupDao $dao
57
-     * @param EEM_Event $event_model
58
-     * @param EEM_Datetime $datetime_model
59
-     * @param EEM_Registration $registration_model
60
-     */
61
-    public function __construct(
62
-        NodeGroupDao $dao,
63
-        EEM_Event $event_model,
64
-        EEM_Datetime $datetime_model,
65
-        EEM_Registration $registration_model
66
-    ) {
67
-        $this->dao = $dao;
68
-        $this->event_model = $event_model;
69
-        $this->datetime_model = $datetime_model;
70
-        $this->registration_model = $registration_model;
71
-    }
54
+	/**
55
+	 * PreviewDeletion constructor.
56
+	 * @param NodeGroupDao $dao
57
+	 * @param EEM_Event $event_model
58
+	 * @param EEM_Datetime $datetime_model
59
+	 * @param EEM_Registration $registration_model
60
+	 */
61
+	public function __construct(
62
+		NodeGroupDao $dao,
63
+		EEM_Event $event_model,
64
+		EEM_Datetime $datetime_model,
65
+		EEM_Registration $registration_model
66
+	) {
67
+		$this->dao = $dao;
68
+		$this->event_model = $event_model;
69
+		$this->datetime_model = $datetime_model;
70
+		$this->registration_model = $registration_model;
71
+	}
72 72
 
73
-    /**
74
-     * Renders the preview deletion page.
75
-     * @since 4.10.12.p
76
-     * @param $request_data
77
-     * @param $admin_base_url
78
-     * @return array
79
-     * @throws UnexpectedEntityException
80
-     * @throws DomainException
81
-     * @throws EE_Error
82
-     * @throws InvalidDataTypeException
83
-     * @throws InvalidInterfaceException
84
-     * @throws InvalidArgumentException
85
-     * @throws ReflectionException
86
-     */
87
-    public function handle($request_data, $admin_base_url)
88
-    {
89
-        $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
90
-        $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
91
-        $event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
92
-        if (empty($event_ids) || !is_array($event_ids)) {
93
-            throw new EE_Error(
94
-                esc_html__('No Events were found to delete.', 'event_espresso')
95
-            );
96
-        }
97
-        $datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
98
-        if (!is_array($datetime_ids)) {
99
-            throw new UnexpectedEntityException($datetime_ids, 'array');
100
-        }
101
-        $registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
102
-        if (!is_array($registration_ids)) {
103
-            throw new UnexpectedEntityException($registration_ids, 'array');
104
-        }
105
-        $num_registrations_to_show = 10;
106
-        $reg_count = count($registration_ids);
107
-        if ($reg_count > $num_registrations_to_show) {
108
-            $registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
109
-        }
110
-        $form = new ConfirmEventDeletionForm($event_ids);
111
-        $events = $this->event_model->get_all_deleted_and_undeleted(
112
-            [
113
-                [
114
-                    'EVT_ID' => ['IN', $event_ids]
115
-                ]
116
-            ]
117
-        );
118
-        $datetimes = $this->datetime_model->get_all_deleted_and_undeleted(
119
-            [
120
-                [
121
-                    'DTT_ID' => ['IN', $datetime_ids]
122
-                ]
123
-            ]
124
-        );
125
-        $registrations = $this->registration_model->get_all_deleted_and_undeleted(
126
-            [
127
-                [
128
-                    'REG_ID' => ['IN', $registration_ids]
129
-                ]
130
-            ]
131
-        );
132
-        $confirm_deletion_args = [
133
-            'action' => 'confirm_deletion',
134
-            'deletion_job_code' => $deletion_job_code
135
-        ];
136
-        return [
137
-            'admin_page_content' => EEH_Template::display_template(
138
-                EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
139
-                [
140
-                    'form_url' => EE_Admin_Page::add_query_args_and_nonce(
141
-                        $confirm_deletion_args,
142
-                        $admin_base_url
143
-                    ),
144
-                    'form' => $form,
145
-                    'events' => $events,
146
-                    'datetimes' => $datetimes,
147
-                    'registrations' => $registrations,
148
-                    'reg_count' => $reg_count,
149
-                    'num_registrations_to_show' => $num_registrations_to_show
150
-                ],
151
-                true
152
-            )
153
-        ];
154
-    }
73
+	/**
74
+	 * Renders the preview deletion page.
75
+	 * @since 4.10.12.p
76
+	 * @param $request_data
77
+	 * @param $admin_base_url
78
+	 * @return array
79
+	 * @throws UnexpectedEntityException
80
+	 * @throws DomainException
81
+	 * @throws EE_Error
82
+	 * @throws InvalidDataTypeException
83
+	 * @throws InvalidInterfaceException
84
+	 * @throws InvalidArgumentException
85
+	 * @throws ReflectionException
86
+	 */
87
+	public function handle($request_data, $admin_base_url)
88
+	{
89
+		$deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : '';
90
+		$models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code);
91
+		$event_ids = isset($models_and_ids_to_delete['Event']) ? $models_and_ids_to_delete['Event'] : array();
92
+		if (empty($event_ids) || !is_array($event_ids)) {
93
+			throw new EE_Error(
94
+				esc_html__('No Events were found to delete.', 'event_espresso')
95
+			);
96
+		}
97
+		$datetime_ids = isset($models_and_ids_to_delete['Datetime']) ? $models_and_ids_to_delete['Datetime'] : array();
98
+		if (!is_array($datetime_ids)) {
99
+			throw new UnexpectedEntityException($datetime_ids, 'array');
100
+		}
101
+		$registration_ids = isset($models_and_ids_to_delete['Registration']) ? $models_and_ids_to_delete['Registration'] : array();
102
+		if (!is_array($registration_ids)) {
103
+			throw new UnexpectedEntityException($registration_ids, 'array');
104
+		}
105
+		$num_registrations_to_show = 10;
106
+		$reg_count = count($registration_ids);
107
+		if ($reg_count > $num_registrations_to_show) {
108
+			$registration_ids = array_slice($registration_ids, 0, $num_registrations_to_show);
109
+		}
110
+		$form = new ConfirmEventDeletionForm($event_ids);
111
+		$events = $this->event_model->get_all_deleted_and_undeleted(
112
+			[
113
+				[
114
+					'EVT_ID' => ['IN', $event_ids]
115
+				]
116
+			]
117
+		);
118
+		$datetimes = $this->datetime_model->get_all_deleted_and_undeleted(
119
+			[
120
+				[
121
+					'DTT_ID' => ['IN', $datetime_ids]
122
+				]
123
+			]
124
+		);
125
+		$registrations = $this->registration_model->get_all_deleted_and_undeleted(
126
+			[
127
+				[
128
+					'REG_ID' => ['IN', $registration_ids]
129
+				]
130
+			]
131
+		);
132
+		$confirm_deletion_args = [
133
+			'action' => 'confirm_deletion',
134
+			'deletion_job_code' => $deletion_job_code
135
+		];
136
+		return [
137
+			'admin_page_content' => EEH_Template::display_template(
138
+				EVENTS_TEMPLATE_PATH . 'event_preview_deletion.template.php',
139
+				[
140
+					'form_url' => EE_Admin_Page::add_query_args_and_nonce(
141
+						$confirm_deletion_args,
142
+						$admin_base_url
143
+					),
144
+					'form' => $form,
145
+					'events' => $events,
146
+					'datetimes' => $datetimes,
147
+					'registrations' => $registrations,
148
+					'reg_count' => $reg_count,
149
+					'num_registrations_to_show' => $num_registrations_to_show
150
+				],
151
+				true
152
+			)
153
+		];
154
+	}
155 155
 }
156 156
 // End of file PreviewDeletion.php
157 157
 // Location: EventEspresso\core\domain\services\admin\events\data/PreviewDeletion.php
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/PreviewEventDeletion.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@
 block discarded – undo
199 199
             if ($units_processed >= $batch_size) {
200 200
                 break;
201 201
             }
202
-            if (!$root_node instanceof ModelObjNode) {
202
+            if ( ! $root_node instanceof ModelObjNode) {
203 203
                 throw new InvalidClassException('ModelObjNode');
204 204
             }
205 205
             if ($root_node->isComplete()) {
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -34,149 +34,149 @@  discard block
 block discarded – undo
34 34
 class PreviewEventDeletion extends JobHandler
35 35
 {
36 36
 
37
-    /**
38
-     * @var NodeGroupDao
39
-     */
40
-    protected $model_obj_node_group_persister;
37
+	/**
38
+	 * @var NodeGroupDao
39
+	 */
40
+	protected $model_obj_node_group_persister;
41 41
 
42
-    public function __construct(NodeGroupDao $model_obj_node_group_persister)
43
-    {
44
-        $this->model_obj_node_group_persister = $model_obj_node_group_persister;
45
-    }
42
+	public function __construct(NodeGroupDao $model_obj_node_group_persister)
43
+	{
44
+		$this->model_obj_node_group_persister = $model_obj_node_group_persister;
45
+	}
46 46
 
47
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
47
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
48 48
 
49
-    /**
50
-     *
51
-     * @param JobParameters $job_parameters
52
-     * @return JobStepResponse
53
-     * @throws EE_Error
54
-     * @throws InvalidDataTypeException
55
-     * @throws InvalidInterfaceException
56
-     * @throws InvalidArgumentException
57
-     * @throws ReflectionException
58
-     */
59
-    public function create_job(JobParameters $job_parameters)
60
-    {
61
-        // Set the "root" model objects we will want to delete (record their ID and model)
62
-        $event_ids = $job_parameters->request_datum('EVT_IDs', array());
63
-        // Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
64
-        // prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
65
-        // we have no UI to access them independent of events, so they may as well get deleted too.)
66
-        $roots = [];
67
-        foreach ($event_ids as $event_id) {
68
-            $roots[] = new ModelObjNode(
69
-                $event_id,
70
-                EEM_Event::instance()
71
-            );
72
-            // Also, we want to delete their related, non-global, tickets, prices and message templates
73
-            $related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
74
-                [
75
-                    [
76
-                        'TKT_is_default' => false,
77
-                        'Datetime.EVT_ID' => $event_id
78
-                    ]
79
-                ]
80
-            );
81
-            foreach ($related_non_global_tickets as $ticket) {
82
-                $roots[] = new ModelObjNode(
83
-                    $ticket->ID(),
84
-                    $ticket->get_model(),
85
-                    ['Registration']
86
-                );
87
-            }
88
-            $related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
89
-                [
90
-                    [
91
-                        'PRC_is_default' => false,
92
-                        'Ticket.Datetime.EVT_ID' => $event_id
93
-                    ]
94
-                ]
95
-            );
96
-            foreach ($related_non_global_prices as $price) {
97
-                $roots[] = new ModelObjNode(
98
-                    $price->ID(),
99
-                    $price->get_model()
100
-                );
101
-            }
102
-        }
103
-        $transactions_ids = $this->getTransactionsToDelete($event_ids);
104
-        foreach ($transactions_ids as $transaction_id) {
105
-            $roots[] = new ModelObjNode(
106
-                $transaction_id,
107
-                EEM_Transaction::instance(),
108
-                ['Registration']
109
-            );
110
-        }
111
-        $job_parameters->add_extra_data('roots', $roots);
112
-        // Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
113
-        // an accurate count.)
114
-        $estimated_work_per_model_obj = 10;
115
-        $count_regs = EEM_Registration::instance()->count(
116
-            [
117
-                [
118
-                    'EVT_ID' => ['IN', $event_ids]
119
-                ]
120
-            ]
121
-        );
122
-        $job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj);
123
-        return new JobStepResponse(
124
-            $job_parameters,
125
-            esc_html__('Generating preview of data to be deleted...', 'event_espresso')
126
-        );
127
-    }
49
+	/**
50
+	 *
51
+	 * @param JobParameters $job_parameters
52
+	 * @return JobStepResponse
53
+	 * @throws EE_Error
54
+	 * @throws InvalidDataTypeException
55
+	 * @throws InvalidInterfaceException
56
+	 * @throws InvalidArgumentException
57
+	 * @throws ReflectionException
58
+	 */
59
+	public function create_job(JobParameters $job_parameters)
60
+	{
61
+		// Set the "root" model objects we will want to delete (record their ID and model)
62
+		$event_ids = $job_parameters->request_datum('EVT_IDs', array());
63
+		// Find all the root nodes to delete (this isn't just events, because there's other data, like related tickets,
64
+		// prices, message templates, etc, whose model definition doesn't make them dependent on events. But,
65
+		// we have no UI to access them independent of events, so they may as well get deleted too.)
66
+		$roots = [];
67
+		foreach ($event_ids as $event_id) {
68
+			$roots[] = new ModelObjNode(
69
+				$event_id,
70
+				EEM_Event::instance()
71
+			);
72
+			// Also, we want to delete their related, non-global, tickets, prices and message templates
73
+			$related_non_global_tickets = EEM_Ticket::instance()->get_all_deleted_and_undeleted(
74
+				[
75
+					[
76
+						'TKT_is_default' => false,
77
+						'Datetime.EVT_ID' => $event_id
78
+					]
79
+				]
80
+			);
81
+			foreach ($related_non_global_tickets as $ticket) {
82
+				$roots[] = new ModelObjNode(
83
+					$ticket->ID(),
84
+					$ticket->get_model(),
85
+					['Registration']
86
+				);
87
+			}
88
+			$related_non_global_prices = EEM_Price::instance()->get_all_deleted_and_undeleted(
89
+				[
90
+					[
91
+						'PRC_is_default' => false,
92
+						'Ticket.Datetime.EVT_ID' => $event_id
93
+					]
94
+				]
95
+			);
96
+			foreach ($related_non_global_prices as $price) {
97
+				$roots[] = new ModelObjNode(
98
+					$price->ID(),
99
+					$price->get_model()
100
+				);
101
+			}
102
+		}
103
+		$transactions_ids = $this->getTransactionsToDelete($event_ids);
104
+		foreach ($transactions_ids as $transaction_id) {
105
+			$roots[] = new ModelObjNode(
106
+				$transaction_id,
107
+				EEM_Transaction::instance(),
108
+				['Registration']
109
+			);
110
+		}
111
+		$job_parameters->add_extra_data('roots', $roots);
112
+		// Set an estimate of how long this will take (we're discovering as we go, so it seems impossible to give
113
+		// an accurate count.)
114
+		$estimated_work_per_model_obj = 10;
115
+		$count_regs = EEM_Registration::instance()->count(
116
+			[
117
+				[
118
+					'EVT_ID' => ['IN', $event_ids]
119
+				]
120
+			]
121
+		);
122
+		$job_parameters->set_job_size((count($roots) + $count_regs) * $estimated_work_per_model_obj);
123
+		return new JobStepResponse(
124
+			$job_parameters,
125
+			esc_html__('Generating preview of data to be deleted...', 'event_espresso')
126
+		);
127
+	}
128 128
 
129
-    /**
130
-     * @since 4.10.12.p
131
-     * @param EE_Base_Class[] $model_objs
132
-     * @param array $dont_traverse_models
133
-     * @return array
134
-     * @throws EE_Error
135
-     * @throws InvalidArgumentException
136
-     * @throws InvalidDataTypeException
137
-     * @throws InvalidInterfaceException
138
-     * @throws ReflectionException
139
-     */
140
-    protected function createModelObjNodes($model_objs, array $dont_traverse_models = [])
141
-    {
142
-        $nodes = [];
143
-        foreach ($model_objs as $model_obj) {
144
-            $nodes[] = new ModelObjNode(
145
-                $model_obj->ID(),
146
-                $model_obj->get_model(),
147
-                $dont_traverse_models
148
-            );
149
-        }
150
-        return $nodes;
151
-    }
129
+	/**
130
+	 * @since 4.10.12.p
131
+	 * @param EE_Base_Class[] $model_objs
132
+	 * @param array $dont_traverse_models
133
+	 * @return array
134
+	 * @throws EE_Error
135
+	 * @throws InvalidArgumentException
136
+	 * @throws InvalidDataTypeException
137
+	 * @throws InvalidInterfaceException
138
+	 * @throws ReflectionException
139
+	 */
140
+	protected function createModelObjNodes($model_objs, array $dont_traverse_models = [])
141
+	{
142
+		$nodes = [];
143
+		foreach ($model_objs as $model_obj) {
144
+			$nodes[] = new ModelObjNode(
145
+				$model_obj->ID(),
146
+				$model_obj->get_model(),
147
+				$dont_traverse_models
148
+			);
149
+		}
150
+		return $nodes;
151
+	}
152 152
 
153
-    /**
154
-     * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too.
155
-     * (Ones that are related to other events can stay around until those other events are deleted too.)
156
-     * @since 4.10.12.p
157
-     * @param $event_ids
158
-     * @return array of transaction IDs
159
-     */
160
-    protected function getTransactionsToDelete($event_ids)
161
-    {
162
-        if (empty($event_ids)) {
163
-            return [];
164
-        }
165
-        global $wpdb;
166
-        $event_ids = array_map(
167
-            'intval',
168
-            $event_ids
169
-        );
170
-        $imploded_sanitized_event_ids = implode(',', $event_ids);
171
-        // Select transactions with registrations for the events $event_ids which also don't have registrations
172
-        // for any events NOT in $event_ids.
173
-        // Notice the outer query searched for transactions whose registrations ARE in $event_ids,
174
-        // whereas the inner query checks if the outer query's transaction has any registrations that are
175
-        // NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.)
176
-        return array_map(
177
-            'intval',
178
-            $wpdb->get_col(
179
-                "SELECT 
153
+	/**
154
+	 * Gets all the transactions related to these events that aren't related to other events. They'll be deleted too.
155
+	 * (Ones that are related to other events can stay around until those other events are deleted too.)
156
+	 * @since 4.10.12.p
157
+	 * @param $event_ids
158
+	 * @return array of transaction IDs
159
+	 */
160
+	protected function getTransactionsToDelete($event_ids)
161
+	{
162
+		if (empty($event_ids)) {
163
+			return [];
164
+		}
165
+		global $wpdb;
166
+		$event_ids = array_map(
167
+			'intval',
168
+			$event_ids
169
+		);
170
+		$imploded_sanitized_event_ids = implode(',', $event_ids);
171
+		// Select transactions with registrations for the events $event_ids which also don't have registrations
172
+		// for any events NOT in $event_ids.
173
+		// Notice the outer query searched for transactions whose registrations ARE in $event_ids,
174
+		// whereas the inner query checks if the outer query's transaction has any registrations that are
175
+		// NOT IN $event_ids (ie, don't have registrations for events we're not just about to delete.)
176
+		return array_map(
177
+			'intval',
178
+			$wpdb->get_col(
179
+				"SELECT 
180 180
                       DISTINCT t.TXN_ID
181 181
                     FROM 
182 182
                       {$wpdb->prefix}esp_transaction t INNER JOIN 
@@ -194,83 +194,83 @@  discard block
 block discarded – undo
194 194
                            tsub.TXN_ID=t.TXN_ID AND
195 195
                            rsub.EVT_ID NOT IN ({$imploded_sanitized_event_ids})
196 196
                        )"
197
-            )
198
-        );
199
-    }
197
+			)
198
+		);
199
+	}
200 200
 
201
-    /**
202
-     * Performs another step of the job
203
-     * @param JobParameters $job_parameters
204
-     * @param int $batch_size
205
-     * @return JobStepResponse
206
-     */
207
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
208
-    {
209
-        // Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
210
-        // about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
211
-        // 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
212
-        $batch_size *= 3;
213
-        $units_processed = 0;
214
-        foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
215
-            if ($units_processed >= $batch_size) {
216
-                break;
217
-            }
218
-            if (!$root_node instanceof ModelObjNode) {
219
-                throw new InvalidClassException('ModelObjNode');
220
-            }
221
-            if ($root_node->isComplete()) {
222
-                continue;
223
-            }
224
-            $units_processed += $root_node->visit($batch_size - $units_processed);
225
-        }
226
-        $job_parameters->mark_processed($units_processed);
227
-        // If the most-recently processed root node is complete, we must be all done because we're doing them
228
-        // sequentially.
229
-        if (isset($root_node) && $root_node instanceof ModelObjNode && $root_node->isComplete()) {
230
-            $job_parameters->set_status(JobParameters::status_complete);
231
-            // Show a full progress bar.
232
-            $job_parameters->set_units_processed($job_parameters->job_size());
233
-            $deletion_job_code = $job_parameters->request_datum('deletion_job_code');
234
-            $this->model_obj_node_group_persister->persistModelObjNodesGroup(
235
-                $job_parameters->extra_datum('roots'),
236
-                $deletion_job_code
237
-            );
238
-            return new JobStepResponse(
239
-                $job_parameters,
240
-                esc_html__('Finished identifying items for deletion.', 'event_espresso'),
241
-                [
242
-                    'deletion_job_code' => $deletion_job_code
243
-                ]
244
-            );
245
-        } else {
246
-            // Because the job size was a guess, it may have likely been proven wrong. We don't want to show more work
247
-            // done than we originally said there would be. So adjust the estimate.
248
-            if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
249
-                $job_parameters->set_job_size($job_parameters->job_size() * 2);
250
-            }
251
-            return new JobStepResponse(
252
-                $job_parameters,
253
-                sprintf(
254
-                    esc_html__('Identified %d items for deletion.', 'event_espresso'),
255
-                    $units_processed
256
-                )
257
-            );
258
-        }
259
-    }
201
+	/**
202
+	 * Performs another step of the job
203
+	 * @param JobParameters $job_parameters
204
+	 * @param int $batch_size
205
+	 * @return JobStepResponse
206
+	 */
207
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
208
+	{
209
+		// Serializing and unserializing is what really makes this drag on (eg on localhost, the ajax requests took
210
+		// about 4 seconds when the batch size was 250, but 3 seconds when the batch size was 50. So like
211
+		// 50% of the request is just serializing and unserializing.) So, make the batches much bigger.
212
+		$batch_size *= 3;
213
+		$units_processed = 0;
214
+		foreach ($job_parameters->extra_datum('roots', array()) as $root_node) {
215
+			if ($units_processed >= $batch_size) {
216
+				break;
217
+			}
218
+			if (!$root_node instanceof ModelObjNode) {
219
+				throw new InvalidClassException('ModelObjNode');
220
+			}
221
+			if ($root_node->isComplete()) {
222
+				continue;
223
+			}
224
+			$units_processed += $root_node->visit($batch_size - $units_processed);
225
+		}
226
+		$job_parameters->mark_processed($units_processed);
227
+		// If the most-recently processed root node is complete, we must be all done because we're doing them
228
+		// sequentially.
229
+		if (isset($root_node) && $root_node instanceof ModelObjNode && $root_node->isComplete()) {
230
+			$job_parameters->set_status(JobParameters::status_complete);
231
+			// Show a full progress bar.
232
+			$job_parameters->set_units_processed($job_parameters->job_size());
233
+			$deletion_job_code = $job_parameters->request_datum('deletion_job_code');
234
+			$this->model_obj_node_group_persister->persistModelObjNodesGroup(
235
+				$job_parameters->extra_datum('roots'),
236
+				$deletion_job_code
237
+			);
238
+			return new JobStepResponse(
239
+				$job_parameters,
240
+				esc_html__('Finished identifying items for deletion.', 'event_espresso'),
241
+				[
242
+					'deletion_job_code' => $deletion_job_code
243
+				]
244
+			);
245
+		} else {
246
+			// Because the job size was a guess, it may have likely been proven wrong. We don't want to show more work
247
+			// done than we originally said there would be. So adjust the estimate.
248
+			if (($job_parameters->units_processed() / $job_parameters->job_size()) > .8) {
249
+				$job_parameters->set_job_size($job_parameters->job_size() * 2);
250
+			}
251
+			return new JobStepResponse(
252
+				$job_parameters,
253
+				sprintf(
254
+					esc_html__('Identified %d items for deletion.', 'event_espresso'),
255
+					$units_processed
256
+				)
257
+			);
258
+		}
259
+	}
260 260
 
261
-    /**
262
-     * Performs any clean-up logic when we know the job is completed
263
-     * @param JobParameters $job_parameters
264
-     * @return JobStepResponse
265
-     */
266
-    public function cleanup_job(JobParameters $job_parameters)
267
-    {
268
-        // Nothing much to do. We can't delete the option with the built tree because we may need it in a moment for the deletion
269
-        return new JobStepResponse(
270
-            $job_parameters,
271
-            esc_html__('All done', 'event_espresso')
272
-        );
273
-    }
261
+	/**
262
+	 * Performs any clean-up logic when we know the job is completed
263
+	 * @param JobParameters $job_parameters
264
+	 * @return JobStepResponse
265
+	 */
266
+	public function cleanup_job(JobParameters $job_parameters)
267
+	{
268
+		// Nothing much to do. We can't delete the option with the built tree because we may need it in a moment for the deletion
269
+		return new JobStepResponse(
270
+			$job_parameters,
271
+			esc_html__('All done', 'event_espresso')
272
+		);
273
+	}
274 274
 }
275 275
 // End of file EventDeletion.php
276 276
 // Location: EventEspressoBatchRequest\JobHandlers/EventDeletion.php
Please login to merge, or discard this patch.
core/services/orm/tree_traversal/RelationNode.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
             // Add entity nodes for each of the model objects we fetched.
94 94
             foreach ($related_model_objs as $related_model_obj) {
95 95
                 $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models);
96
-                $this->nodes[ $related_model_obj->ID() ] = $entity_node;
97
-                $new_item_nodes[ $related_model_obj->ID() ] = $entity_node;
96
+                $this->nodes[$related_model_obj->ID()] = $entity_node;
97
+                $new_item_nodes[$related_model_obj->ID()] = $entity_node;
98 98
             }
99 99
             $num_identified += count($new_item_nodes);
100 100
             if ($num_identified < $model_objects_to_identify) {
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     protected function allChildrenComplete()
121 121
     {
122 122
         foreach ($this->nodes as $model_obj_node) {
123
-            if (! $model_obj_node->isComplete()) {
123
+            if ( ! $model_obj_node->isComplete()) {
124 124
                 return false;
125 125
             }
126 126
         }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget)
138 138
     {
139 139
         $work_done = 0;
140
-        if (! $model_obj_nodes) {
140
+        if ( ! $model_obj_nodes) {
141 141
             return 0;
142 142
         }
143 143
         foreach ($model_obj_nodes as $model_obj_node) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
      */
200 200
     protected function whereQueryParams()
201 201
     {
202
-        $where_params =  [
202
+        $where_params = [
203 203
             $this->related_model->get_foreign_key_to(
204 204
                 $this->main_model->get_this_model_name()
205 205
             )->get_name() => $this->id
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             $relation_settings = null;
213 213
         }
214 214
         if ($relation_settings instanceof EE_Has_Many_Any_Relation) {
215
-            $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name();
215
+            $where_params[$this->related_model->get_field_containing_related_model_name()->get_name()] = $this->main_model->get_this_model_name();
216 216
         }
217 217
         return $where_params;
218 218
     }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             'objs' => []
229 229
         ];
230 230
         foreach ($this->nodes as $id => $model_obj_node) {
231
-            $tree['objs'][ $id ] = $model_obj_node->toArray();
231
+            $tree['objs'][$id] = $model_obj_node->toArray();
232 232
         }
233 233
         return $tree;
234 234
     }
Please login to merge, or discard this patch.
Indentation   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -28,289 +28,289 @@
 block discarded – undo
28 28
 class RelationNode extends BaseNode
29 29
 {
30 30
 
31
-    /**
32
-     * @var string|int
33
-     */
34
-    protected $id;
31
+	/**
32
+	 * @var string|int
33
+	 */
34
+	protected $id;
35 35
 
36
-    /**
37
-     * @var EEM_Base
38
-     */
39
-    protected $main_model;
36
+	/**
37
+	 * @var EEM_Base
38
+	 */
39
+	protected $main_model;
40 40
 
41
-    /**
42
-     * @var int
43
-     */
44
-    protected $count;
41
+	/**
42
+	 * @var int
43
+	 */
44
+	protected $count;
45 45
 
46
-    /**
47
-     * @var EEM_Base
48
-     */
49
-    protected $related_model;
46
+	/**
47
+	 * @var EEM_Base
48
+	 */
49
+	protected $related_model;
50 50
 
51
-    /**
52
-     * @var ModelObjNode[]
53
-     */
54
-    protected $nodes;
51
+	/**
52
+	 * @var ModelObjNode[]
53
+	 */
54
+	protected $nodes;
55 55
 
56
-    /**
57
-     * RelationNode constructor.
58
-     * @param $main_model_obj_id
59
-     * @param EEM_Base $main_model
60
-     * @param EEM_Base $related_model
61
-     * @param array $dont_traverse_models array of model names we DON'T want to traverse
62
-     */
63
-    public function __construct(
64
-        $main_model_obj_id,
65
-        EEM_Base $main_model,
66
-        EEM_Base $related_model,
67
-        array $dont_traverse_models = []
68
-    ) {
69
-        $this->id = $main_model_obj_id;
70
-        $this->main_model = $main_model;
71
-        $this->related_model = $related_model;
72
-        $this->nodes = [];
73
-        $this->dont_traverse_models = $dont_traverse_models;
74
-    }
56
+	/**
57
+	 * RelationNode constructor.
58
+	 * @param $main_model_obj_id
59
+	 * @param EEM_Base $main_model
60
+	 * @param EEM_Base $related_model
61
+	 * @param array $dont_traverse_models array of model names we DON'T want to traverse
62
+	 */
63
+	public function __construct(
64
+		$main_model_obj_id,
65
+		EEM_Base $main_model,
66
+		EEM_Base $related_model,
67
+		array $dont_traverse_models = []
68
+	) {
69
+		$this->id = $main_model_obj_id;
70
+		$this->main_model = $main_model;
71
+		$this->related_model = $related_model;
72
+		$this->nodes = [];
73
+		$this->dont_traverse_models = $dont_traverse_models;
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * Here is where most of the work happens. We've counted how many related model objects exist, here we identify
79
-     * them (ie, learn their IDs). But its recursive, so we'll also find their related dependent model objects etc.
80
-     * @since 4.10.12.p
81
-     * @param int $model_objects_to_identify
82
-     * @return int
83
-     * @throws EE_Error
84
-     * @throws InvalidArgumentException
85
-     * @throws InvalidDataTypeException
86
-     * @throws InvalidInterfaceException
87
-     * @throws ReflectionException
88
-     */
89
-    protected function work($model_objects_to_identify)
90
-    {
91
-        $num_identified = $this->visitAlreadyDiscoveredNodes($this->nodes, $model_objects_to_identify);
92
-        if ($num_identified < $model_objects_to_identify) {
93
-            $related_model_objs = $this->related_model->get_all(
94
-                [
95
-                    $this->whereQueryParams(),
96
-                    'limit' => [
97
-                        count($this->nodes),
98
-                        $model_objects_to_identify - $num_identified
99
-                    ]
100
-                ]
101
-            );
102
-            $new_item_nodes = [];
77
+	/**
78
+	 * Here is where most of the work happens. We've counted how many related model objects exist, here we identify
79
+	 * them (ie, learn their IDs). But its recursive, so we'll also find their related dependent model objects etc.
80
+	 * @since 4.10.12.p
81
+	 * @param int $model_objects_to_identify
82
+	 * @return int
83
+	 * @throws EE_Error
84
+	 * @throws InvalidArgumentException
85
+	 * @throws InvalidDataTypeException
86
+	 * @throws InvalidInterfaceException
87
+	 * @throws ReflectionException
88
+	 */
89
+	protected function work($model_objects_to_identify)
90
+	{
91
+		$num_identified = $this->visitAlreadyDiscoveredNodes($this->nodes, $model_objects_to_identify);
92
+		if ($num_identified < $model_objects_to_identify) {
93
+			$related_model_objs = $this->related_model->get_all(
94
+				[
95
+					$this->whereQueryParams(),
96
+					'limit' => [
97
+						count($this->nodes),
98
+						$model_objects_to_identify - $num_identified
99
+					]
100
+				]
101
+			);
102
+			$new_item_nodes = [];
103 103
 
104
-            // Add entity nodes for each of the model objects we fetched.
105
-            foreach ($related_model_objs as $related_model_obj) {
106
-                $entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models);
107
-                $this->nodes[ $related_model_obj->ID() ] = $entity_node;
108
-                $new_item_nodes[ $related_model_obj->ID() ] = $entity_node;
109
-            }
110
-            $num_identified += count($new_item_nodes);
111
-            if ($num_identified < $model_objects_to_identify) {
112
-                // And lastly do the work.
113
-                $num_identified += $this->visitAlreadyDiscoveredNodes(
114
-                    $new_item_nodes,
115
-                    $model_objects_to_identify - $num_identified
116
-                );
117
-            }
118
-        }
104
+			// Add entity nodes for each of the model objects we fetched.
105
+			foreach ($related_model_objs as $related_model_obj) {
106
+				$entity_node = new ModelObjNode($related_model_obj->ID(), $related_model_obj->get_model(), $this->dont_traverse_models);
107
+				$this->nodes[ $related_model_obj->ID() ] = $entity_node;
108
+				$new_item_nodes[ $related_model_obj->ID() ] = $entity_node;
109
+			}
110
+			$num_identified += count($new_item_nodes);
111
+			if ($num_identified < $model_objects_to_identify) {
112
+				// And lastly do the work.
113
+				$num_identified += $this->visitAlreadyDiscoveredNodes(
114
+					$new_item_nodes,
115
+					$model_objects_to_identify - $num_identified
116
+				);
117
+			}
118
+		}
119 119
 
120
-        if (count($this->nodes) >= $this->count && $this->allChildrenComplete()) {
121
-            $this->complete = true;
122
-        }
123
-        return $num_identified;
124
-    }
120
+		if (count($this->nodes) >= $this->count && $this->allChildrenComplete()) {
121
+			$this->complete = true;
122
+		}
123
+		return $num_identified;
124
+	}
125 125
 
126
-    /**
127
-     * Checks if all the identified child nodes are complete or not.
128
-     * @since 4.10.12.p
129
-     * @return bool
130
-     */
131
-    protected function allChildrenComplete()
132
-    {
133
-        foreach ($this->nodes as $model_obj_node) {
134
-            if (! $model_obj_node->isComplete()) {
135
-                return false;
136
-            }
137
-        }
138
-        return true;
139
-    }
126
+	/**
127
+	 * Checks if all the identified child nodes are complete or not.
128
+	 * @since 4.10.12.p
129
+	 * @return bool
130
+	 */
131
+	protected function allChildrenComplete()
132
+	{
133
+		foreach ($this->nodes as $model_obj_node) {
134
+			if (! $model_obj_node->isComplete()) {
135
+				return false;
136
+			}
137
+		}
138
+		return true;
139
+	}
140 140
 
141
-    /**
142
-     * Visits the provided nodes and keeps track of how much work was done, making sure to not go over budget.
143
-     * @since 4.10.12.p
144
-     * @param ModelObjNode[] $model_obj_nodes
145
-     * @param $work_budget
146
-     * @return int
147
-     */
148
-    protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget)
149
-    {
150
-        $work_done = 0;
151
-        if (! $model_obj_nodes) {
152
-            return 0;
153
-        }
154
-        foreach ($model_obj_nodes as $model_obj_node) {
155
-            if ($work_done >= $work_budget) {
156
-                break;
157
-            }
158
-            $work_done += $model_obj_node->visit($work_budget - $work_done);
159
-        }
160
-        return $work_done;
161
-    }
141
+	/**
142
+	 * Visits the provided nodes and keeps track of how much work was done, making sure to not go over budget.
143
+	 * @since 4.10.12.p
144
+	 * @param ModelObjNode[] $model_obj_nodes
145
+	 * @param $work_budget
146
+	 * @return int
147
+	 */
148
+	protected function visitAlreadyDiscoveredNodes($model_obj_nodes, $work_budget)
149
+	{
150
+		$work_done = 0;
151
+		if (! $model_obj_nodes) {
152
+			return 0;
153
+		}
154
+		foreach ($model_obj_nodes as $model_obj_node) {
155
+			if ($work_done >= $work_budget) {
156
+				break;
157
+			}
158
+			$work_done += $model_obj_node->visit($work_budget - $work_done);
159
+		}
160
+		return $work_done;
161
+	}
162 162
 
163
-    /**
164
-     * Whether this item has already been initialized
165
-     */
166
-    protected function isDiscovered()
167
-    {
168
-        return $this->count !== null;
169
-    }
163
+	/**
164
+	 * Whether this item has already been initialized
165
+	 */
166
+	protected function isDiscovered()
167
+	{
168
+		return $this->count !== null;
169
+	}
170 170
 
171
-    /**
172
-     * @since 4.10.12.p
173
-     * @return boolean
174
-     */
175
-    public function isComplete()
176
-    {
177
-        if ($this->complete === null) {
178
-            if (count($this->nodes) === $this->count) {
179
-                $this->complete = true;
180
-            } else {
181
-                $this->complete = false;
182
-            }
183
-        }
184
-        return $this->complete;
185
-    }
171
+	/**
172
+	 * @since 4.10.12.p
173
+	 * @return boolean
174
+	 */
175
+	public function isComplete()
176
+	{
177
+		if ($this->complete === null) {
178
+			if (count($this->nodes) === $this->count) {
179
+				$this->complete = true;
180
+			} else {
181
+				$this->complete = false;
182
+			}
183
+		}
184
+		return $this->complete;
185
+	}
186 186
 
187
-    /**
188
-     * Discovers how many related model objects exist.
189
-     * @since 4.10.12.p
190
-     * @return mixed|void
191
-     * @throws EE_Error
192
-     * @throws InvalidArgumentException
193
-     * @throws InvalidDataTypeException
194
-     * @throws InvalidInterfaceException
195
-     * @throws ReflectionException
196
-     */
197
-    protected function discover()
198
-    {
199
-        $this->count = $this->related_model->count([$this->whereQueryParams()]);
200
-    }
187
+	/**
188
+	 * Discovers how many related model objects exist.
189
+	 * @since 4.10.12.p
190
+	 * @return mixed|void
191
+	 * @throws EE_Error
192
+	 * @throws InvalidArgumentException
193
+	 * @throws InvalidDataTypeException
194
+	 * @throws InvalidInterfaceException
195
+	 * @throws ReflectionException
196
+	 */
197
+	protected function discover()
198
+	{
199
+		$this->count = $this->related_model->count([$this->whereQueryParams()]);
200
+	}
201 201
 
202
-    /**
203
-     * @since 4.10.12.p
204
-     * @return array
205
-     * @throws EE_Error
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidInterfaceException
208
-     * @throws InvalidArgumentException
209
-     * @throws ReflectionException
210
-     */
211
-    protected function whereQueryParams()
212
-    {
213
-        $where_params =  [
214
-            $this->related_model->get_foreign_key_to(
215
-                $this->main_model->get_this_model_name()
216
-            )->get_name() => $this->id
217
-        ];
218
-        try {
219
-            $relation_settings = $this->main_model->related_settings_for($this->related_model->get_this_model_name());
220
-        } catch (EE_Error $e) {
221
-            // This will happen for has-and-belongs-to-many relations, when this node's related model is that join table
222
-            // which hasn't been explicitly declared in the main model object's model's relations.
223
-            $relation_settings = null;
224
-        }
225
-        if ($relation_settings instanceof EE_Has_Many_Any_Relation) {
226
-            $where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name();
227
-        }
228
-        return $where_params;
229
-    }
230
-    /**
231
-     * @since 4.10.12.p
232
-     * @return array
233
-     */
234
-    public function toArray()
235
-    {
236
-        $tree = [
237
-            'count' => $this->count,
238
-            'complete' => $this->isComplete(),
239
-            'objs' => []
240
-        ];
241
-        foreach ($this->nodes as $id => $model_obj_node) {
242
-            $tree['objs'][ $id ] = $model_obj_node->toArray();
243
-        }
244
-        return $tree;
245
-    }
202
+	/**
203
+	 * @since 4.10.12.p
204
+	 * @return array
205
+	 * @throws EE_Error
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidInterfaceException
208
+	 * @throws InvalidArgumentException
209
+	 * @throws ReflectionException
210
+	 */
211
+	protected function whereQueryParams()
212
+	{
213
+		$where_params =  [
214
+			$this->related_model->get_foreign_key_to(
215
+				$this->main_model->get_this_model_name()
216
+			)->get_name() => $this->id
217
+		];
218
+		try {
219
+			$relation_settings = $this->main_model->related_settings_for($this->related_model->get_this_model_name());
220
+		} catch (EE_Error $e) {
221
+			// This will happen for has-and-belongs-to-many relations, when this node's related model is that join table
222
+			// which hasn't been explicitly declared in the main model object's model's relations.
223
+			$relation_settings = null;
224
+		}
225
+		if ($relation_settings instanceof EE_Has_Many_Any_Relation) {
226
+			$where_params[ $this->related_model->get_field_containing_related_model_name()->get_name() ] = $this->main_model->get_this_model_name();
227
+		}
228
+		return $where_params;
229
+	}
230
+	/**
231
+	 * @since 4.10.12.p
232
+	 * @return array
233
+	 */
234
+	public function toArray()
235
+	{
236
+		$tree = [
237
+			'count' => $this->count,
238
+			'complete' => $this->isComplete(),
239
+			'objs' => []
240
+		];
241
+		foreach ($this->nodes as $id => $model_obj_node) {
242
+			$tree['objs'][ $id ] = $model_obj_node->toArray();
243
+		}
244
+		return $tree;
245
+	}
246 246
 
247
-    /**
248
-     * Gets the IDs of all the model objects to delete; indexed first by model object name.
249
-     * @since 4.10.12.p
250
-     * @return array
251
-     */
252
-    public function getIds()
253
-    {
254
-        if (empty($this->nodes)) {
255
-            return [];
256
-        }
257
-        $ids = [
258
-            $this->related_model->get_this_model_name() => array_combine(
259
-                array_keys($this->nodes),
260
-                array_keys($this->nodes)
261
-            )
262
-        ];
263
-        foreach ($this->nodes as $model_obj_node) {
264
-            $ids = array_replace_recursive($ids, $model_obj_node->getIds());
265
-        }
266
-        return $ids;
267
-    }
247
+	/**
248
+	 * Gets the IDs of all the model objects to delete; indexed first by model object name.
249
+	 * @since 4.10.12.p
250
+	 * @return array
251
+	 */
252
+	public function getIds()
253
+	{
254
+		if (empty($this->nodes)) {
255
+			return [];
256
+		}
257
+		$ids = [
258
+			$this->related_model->get_this_model_name() => array_combine(
259
+				array_keys($this->nodes),
260
+				array_keys($this->nodes)
261
+			)
262
+		];
263
+		foreach ($this->nodes as $model_obj_node) {
264
+			$ids = array_replace_recursive($ids, $model_obj_node->getIds());
265
+		}
266
+		return $ids;
267
+	}
268 268
 
269
-    /**
270
-     * Returns the number of sub-nodes found (ie, related model objects across this relation.)
271
-     * @since 4.10.12.p
272
-     * @return int
273
-     */
274
-    public function countSubNodes()
275
-    {
276
-        return count($this->nodes);
277
-    }
269
+	/**
270
+	 * Returns the number of sub-nodes found (ie, related model objects across this relation.)
271
+	 * @since 4.10.12.p
272
+	 * @return int
273
+	 */
274
+	public function countSubNodes()
275
+	{
276
+		return count($this->nodes);
277
+	}
278 278
 
279
-    /**
280
-     * Don't serialize the models. Just record their names on some dynamic properties.
281
-     * @since 4.10.12.p
282
-     */
283
-    public function __sleep()
284
-    {
285
-        $this->m = $this->main_model->get_this_model_name();
286
-        $this->rm = $this->related_model->get_this_model_name();
287
-        return array_merge(
288
-            [
289
-                'm',
290
-                'rm',
291
-                'id',
292
-                'count',
293
-                'nodes',
294
-            ],
295
-            parent::__sleep()
296
-        );
297
-    }
279
+	/**
280
+	 * Don't serialize the models. Just record their names on some dynamic properties.
281
+	 * @since 4.10.12.p
282
+	 */
283
+	public function __sleep()
284
+	{
285
+		$this->m = $this->main_model->get_this_model_name();
286
+		$this->rm = $this->related_model->get_this_model_name();
287
+		return array_merge(
288
+			[
289
+				'm',
290
+				'rm',
291
+				'id',
292
+				'count',
293
+				'nodes',
294
+			],
295
+			parent::__sleep()
296
+		);
297
+	}
298 298
 
299
-    /**
300
-     * Use the dynamic properties to instantiate the models we use.
301
-     * @since 4.10.12.p
302
-     * @throws EE_Error
303
-     * @throws InvalidArgumentException
304
-     * @throws InvalidDataTypeException
305
-     * @throws InvalidInterfaceException
306
-     * @throws ReflectionException
307
-     */
308
-    public function __wakeup()
309
-    {
310
-        $this->main_model = EE_Registry::instance()->load_model($this->m);
311
-        $this->related_model = EE_Registry::instance()->load_model($this->rm);
312
-        parent::__wakeup();
313
-    }
299
+	/**
300
+	 * Use the dynamic properties to instantiate the models we use.
301
+	 * @since 4.10.12.p
302
+	 * @throws EE_Error
303
+	 * @throws InvalidArgumentException
304
+	 * @throws InvalidDataTypeException
305
+	 * @throws InvalidInterfaceException
306
+	 * @throws ReflectionException
307
+	 */
308
+	public function __wakeup()
309
+	{
310
+		$this->main_model = EE_Registry::instance()->load_model($this->m);
311
+		$this->related_model = EE_Registry::instance()->load_model($this->rm);
312
+		parent::__wakeup();
313
+	}
314 314
 }
315 315
 // End of file RelationNode.php
316 316
 // Location: EventEspresso\core\services\orm\tree_traversal/RelationNode.php
Please login to merge, or discard this patch.
admin_pages/events/form_sections/ConfirmEventDeletionForm.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -22,55 +22,55 @@
 block discarded – undo
22 22
  */
23 23
 class ConfirmEventDeletionForm extends \EE_Form_Section_Proper
24 24
 {
25
-    /**
26
-     * @var EE_Event[]
27
-     */
28
-    protected $events;
29
-    public function __construct($event_ids, $options_array = array())
30
-    {
31
-        if (! isset($options_array['subsections'])) {
32
-            $options_array['subsections'] = [];
33
-        }
34
-        if (! isset($options_array['subsections']['events'])) {
35
-            $events_subsection = new \EE_Form_Section_Proper();
36
-            $options_array['subsections']['events'] = $events_subsection;
37
-        }
38
-        $events = EEM_Event::instance()->get_all_deleted_and_undeleted(
39
-            [
40
-                [
41
-                    'EVT_ID' => ['IN',$event_ids]
42
-                ]
43
-            ]
44
-        );
45
-        if (! is_array($events)) {
46
-            throw new UnexpectedEntityException($event_ids, 'array');
47
-        }
48
-        $this->events = $events;
49
-        $events_inputs = [
50
-        ];
51
-        foreach ($events as $event) {
52
-            $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
53
-                [
54
-                    'yes' => $event->name(),
55
-                ],
56
-                [
57
-                    'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'),
58
-                    'required' => true
59
-                ]
60
-            );
61
-        }
62
-        $events_subsection->add_subsections($events_inputs);
63
-        $options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input(
64
-            [
65
-                'yes' => esc_html__('I have backed up my database.', 'event_espresso')
66
-            ],
67
-            [
68
-                'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'),
69
-                'required' => true
70
-            ]
71
-        );
72
-        parent::__construct($options_array);
73
-    }
25
+	/**
26
+	 * @var EE_Event[]
27
+	 */
28
+	protected $events;
29
+	public function __construct($event_ids, $options_array = array())
30
+	{
31
+		if (! isset($options_array['subsections'])) {
32
+			$options_array['subsections'] = [];
33
+		}
34
+		if (! isset($options_array['subsections']['events'])) {
35
+			$events_subsection = new \EE_Form_Section_Proper();
36
+			$options_array['subsections']['events'] = $events_subsection;
37
+		}
38
+		$events = EEM_Event::instance()->get_all_deleted_and_undeleted(
39
+			[
40
+				[
41
+					'EVT_ID' => ['IN',$event_ids]
42
+				]
43
+			]
44
+		);
45
+		if (! is_array($events)) {
46
+			throw new UnexpectedEntityException($event_ids, 'array');
47
+		}
48
+		$this->events = $events;
49
+		$events_inputs = [
50
+		];
51
+		foreach ($events as $event) {
52
+			$events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
53
+				[
54
+					'yes' => $event->name(),
55
+				],
56
+				[
57
+					'html_label_text' => esc_html__('Please confirm you wish to delete:', 'event_espresso'),
58
+					'required' => true
59
+				]
60
+			);
61
+		}
62
+		$events_subsection->add_subsections($events_inputs);
63
+		$options_array['subsections']['backup'] = new EE_Checkbox_Multi_Input(
64
+			[
65
+				'yes' => esc_html__('I have backed up my database.', 'event_espresso')
66
+			],
67
+			[
68
+				'html_label_text' => esc_html__('Deleting this data cannot be undone. Please confirm you have a usable database backup.', 'event_espresso'),
69
+				'required' => true
70
+			]
71
+		);
72
+		parent::__construct($options_array);
73
+	}
74 74
 }
75 75
 // End of file ConfirmEventDeletionForm.php
76 76
 // Location: EventEspresso\admin_pages\events\form_sections/ConfirmEventDeletionForm.php
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,28 +28,28 @@
 block discarded – undo
28 28
     protected $events;
29 29
     public function __construct($event_ids, $options_array = array())
30 30
     {
31
-        if (! isset($options_array['subsections'])) {
31
+        if ( ! isset($options_array['subsections'])) {
32 32
             $options_array['subsections'] = [];
33 33
         }
34
-        if (! isset($options_array['subsections']['events'])) {
34
+        if ( ! isset($options_array['subsections']['events'])) {
35 35
             $events_subsection = new \EE_Form_Section_Proper();
36 36
             $options_array['subsections']['events'] = $events_subsection;
37 37
         }
38 38
         $events = EEM_Event::instance()->get_all_deleted_and_undeleted(
39 39
             [
40 40
                 [
41
-                    'EVT_ID' => ['IN',$event_ids]
41
+                    'EVT_ID' => ['IN', $event_ids]
42 42
                 ]
43 43
             ]
44 44
         );
45
-        if (! is_array($events)) {
45
+        if ( ! is_array($events)) {
46 46
             throw new UnexpectedEntityException($event_ids, 'array');
47 47
         }
48 48
         $this->events = $events;
49 49
         $events_inputs = [
50 50
         ];
51 51
         foreach ($events as $event) {
52
-            $events_inputs[ $event->ID() ] = new EE_Checkbox_Multi_Input(
52
+            $events_inputs[$event->ID()] = new EE_Checkbox_Multi_Input(
53 53
                 [
54 54
                     'yes' => $event->name(),
55 55
                 ],
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Email_Confirm_Input.input.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,29 +10,29 @@
 block discarded – undo
10 10
 class EE_Email_Confirm_Input extends EE_Form_Input_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @param array $input_settings
15
-     */
16
-    public function __construct($input_settings = array())
17
-    {
18
-        $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email'));
19
-        $this->_set_normalization_strategy(new EE_Text_Normalization());
20
-        $this->_add_validation_strategy(
21
-            new EE_Email_Validation_Strategy(
22
-                isset($input_settings['validation_error_message'])
23
-                    ? $input_settings['validation_error_message']
24
-                    : null
25
-            )
26
-        );
27
-        $this->_add_validation_strategy(
28
-            new EE_Equal_To_Validation_Strategy(
29
-                isset($input_settings['validation_error_message'])
30
-                    ? $input_settings['validation_error_message']
31
-                    : null,
32
-                '#' . str_replace('email_confirm', 'email', $input_settings['html_id'])
33
-            )
34
-        );
35
-        parent::__construct($input_settings);
36
-        $this->set_html_class($this->html_class() . ' email');
37
-    }
13
+	/**
14
+	 * @param array $input_settings
15
+	 */
16
+	public function __construct($input_settings = array())
17
+	{
18
+		$this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email'));
19
+		$this->_set_normalization_strategy(new EE_Text_Normalization());
20
+		$this->_add_validation_strategy(
21
+			new EE_Email_Validation_Strategy(
22
+				isset($input_settings['validation_error_message'])
23
+					? $input_settings['validation_error_message']
24
+					: null
25
+			)
26
+		);
27
+		$this->_add_validation_strategy(
28
+			new EE_Equal_To_Validation_Strategy(
29
+				isset($input_settings['validation_error_message'])
30
+					? $input_settings['validation_error_message']
31
+					: null,
32
+				'#' . str_replace('email_confirm', 'email', $input_settings['html_id'])
33
+			)
34
+		);
35
+		parent::__construct($input_settings);
36
+		$this->set_html_class($this->html_class() . ' email');
37
+	}
38 38
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@
 block discarded – undo
29 29
                 isset($input_settings['validation_error_message'])
30 30
                     ? $input_settings['validation_error_message']
31 31
                     : null,
32
-                '#' . str_replace('email_confirm', 'email', $input_settings['html_id'])
32
+                '#'.str_replace('email_confirm', 'email', $input_settings['html_id'])
33 33
             )
34 34
         );
35 35
         parent::__construct($input_settings);
36
-        $this->set_html_class($this->html_class() . ' email');
36
+        $this->set_html_class($this->html_class().' email');
37 37
     }
38 38
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Equal_To_Validation_Strategy.strategy.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
      */
24 24
     public function __construct($validation_error_message = '', $compare_to)
25 25
     {
26
-        if (! $validation_error_message) {
26
+        if ( ! $validation_error_message) {
27 27
             $validation_error_message = apply_filters(
28 28
                 'FHEE__EE_Equal_To_Validation_Strategy____construct__validation_error_message',
29 29
                 esc_html__('Fields do not match.', 'event_espresso')
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -16,49 +16,49 @@
 block discarded – undo
16 16
 class EE_Equal_To_Validation_Strategy extends EE_Text_Validation_Strategy
17 17
 {
18 18
 
19
-    protected $_compare_to = null;
19
+	protected $_compare_to = null;
20 20
 
21 21
 
22
-    /**
23
-     * @param string               $validation_error_message
24
-     */
25
-    public function __construct($validation_error_message = '', $compare_to)
26
-    {
27
-        if (! $validation_error_message) {
28
-            $validation_error_message = apply_filters(
29
-                'FHEE__EE_Equal_To_Validation_Strategy____construct__validation_error_message',
30
-                esc_html__('Fields do not match.', 'event_espresso')
31
-            );
32
-        }
33
-        parent::__construct($validation_error_message);
34
-        $this->_compare_to = $compare_to;
35
-    }
22
+	/**
23
+	 * @param string               $validation_error_message
24
+	 */
25
+	public function __construct($validation_error_message = '', $compare_to)
26
+	{
27
+		if (! $validation_error_message) {
28
+			$validation_error_message = apply_filters(
29
+				'FHEE__EE_Equal_To_Validation_Strategy____construct__validation_error_message',
30
+				esc_html__('Fields do not match.', 'event_espresso')
31
+			);
32
+		}
33
+		parent::__construct($validation_error_message);
34
+		$this->_compare_to = $compare_to;
35
+	}
36 36
 
37 37
 
38 38
 
39
-    /**
40
-     * just checks the field isn't blank
41
-     *
42
-     * @param $normalized_value
43
-     * @return bool
44
-     * @throws InvalidArgumentException
45
-     * @throws InvalidInterfaceException
46
-     * @throws InvalidDataTypeException
47
-     * @throws EE_Validation_Error
48
-     */
49
-    public function validate($normalized_value)
50
-    {
51
-        // No need to be validated
52
-        return true;
53
-    }
39
+	/**
40
+	 * just checks the field isn't blank
41
+	 *
42
+	 * @param $normalized_value
43
+	 * @return bool
44
+	 * @throws InvalidArgumentException
45
+	 * @throws InvalidInterfaceException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws EE_Validation_Error
48
+	 */
49
+	public function validate($normalized_value)
50
+	{
51
+		// No need to be validated
52
+		return true;
53
+	}
54 54
 
55 55
 
56 56
 
57
-    /**
58
-     * @return array
59
-     */
60
-    public function get_jquery_validation_rule_array()
61
-    {
62
-        return array('equalTo' => $this->_compare_to, 'messages' => array('equalTo' => $this->get_validation_error_message()));
63
-    }
57
+	/**
58
+	 * @return array
59
+	 */
60
+	public function get_jquery_validation_rule_array()
61
+	{
62
+		return array('equalTo' => $this->_compare_to, 'messages' => array('equalTo' => $this->get_validation_error_message()));
63
+	}
64 64
 }
Please login to merge, or discard this patch.
venues/templates/venue_virtual_location_metabox_content.template.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
                         <?php esc_html_e('URL of Event:', 'event_espresso'); ?>
8 8
                     </label>
9 9
                     <?php //phpcs:disable Generic.Files.LineLength.TooLong
10
-                    // no new lines within <textarea> here because they'll output whitespace ?>
10
+					// no new lines within <textarea> here because they'll output whitespace ?>
11 11
                     <textarea id="url-event" cols="30" rows="4" tabindex="112" name="vnu_virtual_url"><?php $_venue->f('VNU_virtual_url'); ?></textarea>
12 12
                     <?php //phpcs:enable ?>
13 13
                 </p>
Please login to merge, or discard this patch.