Passed
Push — hotfix/fix-counts ( 4b43d1...cc9e05 )
by Paul
03:52
created
plugin/Modules/Upgrader.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@
 block discarded – undo
43 43
         if ($version !== glsr()->version) {
44 44
             $this->setReviewCounts();
45 45
             $this->updateVersionFrom($version);
46
-        } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) {
46
+        }
47
+        elseif (!glsr(OptionManager::class)->get('last_review_count', false)) {
47 48
             $this->setReviewCounts();
48 49
         }
49 50
     }
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 1 patch
Braces   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @return int|false
21 21
 	 */
22 22
     public function deleteAllSessions($sessionCookiePrefix)
23
-	{
23
+    {
24 24
 		return $this->db->query("
25 25
 			DELETE
26 26
 			FROM {$this->db->options}
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @return int|false
34 34
 	 */
35 35
     public function deleteExpiredSessions($expiredSessions)
36
-	{
36
+    {
37 37
 		return $this->db->query("
38 38
 			DELETE
39 39
 			FROM {$this->db->options}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @return array
48 48
 	 */
49 49
     public function getExpiredSessions($sessionCookiePrefix, $limit)
50
-	{
50
+    {
51 51
 		return (array) $this->db->get_results("
52 52
 			SELECT option_name AS name, option_value AS expiration
53 53
 			FROM {$this->db->options}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @return int
63 63
 	 */
64 64
     public function getPostIdFromReviewId($metaReviewId)
65
-	{
65
+    {
66 66
 		$postId = $this->db->get_var("
67 67
 			SELECT p.ID
68 68
 			FROM {$this->db->posts} AS p
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @return array
81 81
 	 */
82 82
     public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
83
-	{
83
+    {
84 84
 		return (array) $this->db->get_results("
85 85
 			SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
86 86
 			FROM {$this->db->posts} AS p
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return array
105 105
 	 */
106 106
     public function getReviewCountsFor($metaKey)
107
-	{
107
+    {
108 108
 		return (array) $this->db->get_results("
109 109
 			SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
110 110
 			FROM {$this->db->posts} AS p
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return array
122 122
 	 */
123 123
     public function getReviewIdsByType($reviewType)
124
-	{
124
+    {
125 125
 		$results = $this->db->get_col("
126 126
 			SELECT DISTINCT m1.meta_value AS review_id
127 127
 			FROM {$this->db->posts} AS p
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return array
142 142
 	 */
143 143
     public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
144
-	{
144
+    {
145 145
         sort($postIds);
146 146
         $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
147 147
         $postIds = implode(',', $postIds);
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @return array
167 167
 	 */
168 168
     public function getReviewsMeta($key, $status = 'publish')
169
-	{
169
+    {
170 170
 		$values = $this->db->get_col("
171 171
 			SELECT DISTINCT m.meta_value
172 172
 			FROM {$this->db->postmeta} m
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
     protected function getAndForCounts(array $args, $and = '')
190
-	{
190
+    {
191 191
         $postIds = implode(',', array_filter(glsr_get($args, 'post_ids')));
192 192
         $termIds = implode(',', array_filter(glsr_get($args, 'term_ids')));
193 193
         if (!empty($args['type'])) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 * @return string
208 208
 	 */
209 209
     protected function getInnerJoinForCounts(array $args, $innerJoin = '')
210
-	{
210
+    {
211 211
         if (!empty(glsr_get($args, 'post_ids'))) {
212 212
             $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
213 213
 		}
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Braces   +27 added lines, -26 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @todo verify the additional type checks are needed
22 22
 	 */
23 23
     public function buildCounts(array $args = [])
24
-	{
24
+    {
25 25
 		$counts = [];
26 26
         $query = $this->queryReviews($args);
27 27
         while ($query) {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return array
52 52
 	 */
53 53
     public function buildPostCounts($postId)
54
-	{
54
+    {
55 55
         return $this->buildCounts(['post_ids' => [$postId]]);
56 56
 	}
57 57
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @return array
61 61
 	 */
62 62
     public function buildTermCounts($termTaxonomyId)
63
-	{
63
+    {
64 64
         return $this->buildCounts(['term_ids' => [$termTaxonomyId]]);
65 65
 	}
66 66
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @return void
85 85
 	 */
86 86
     public function decrease(Review $review)
87
-	{
87
+    {
88 88
         $this->decreaseCounts($review);
89 89
         $this->decreasePostCounts($review);
90 90
         $this->decreaseTermCounts($review);
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return void
95 95
 	 */
96 96
     public function decreaseCounts(Review $review)
97
-	{
97
+    {
98 98
         $this->setCounts($this->decreaseRating(
99 99
 			$this->getCounts(),
100 100
 			$review->review_type,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @return void
107 107
 	 */
108 108
     public function decreasePostCounts(Review $review)
109
-	{
109
+    {
110 110
         if (empty($counts = $this->getPostCounts($review->assigned_to))) {
111 111
             return;
112 112
         }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @return void
119 119
 	 */
120 120
     public function decreaseTermCounts(Review $review)
121
-	{
121
+    {
122 122
         foreach ($review->term_ids as $termId) {
123 123
             if (empty($counts = $this->getTermCounts($termId))) {
124 124
                 continue;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @return array
133 133
 	 */
134 134
     public function flatten(array $reviewCounts, array $args = [])
135
-	{
135
+    {
136 136
 		$counts = [];
137 137
         array_walk_recursive($reviewCounts, function ($num, $index) use (&$counts) {
138 138
             $counts[$index] = $num + intval(glsr_get($counts, $index, 0));
@@ -154,12 +154,13 @@  discard block
 block discarded – undo
154 154
 	 * @return array
155 155
 	 */
156 156
     public function get(array $args = [])
157
-	{
157
+    {
158 158
         $args = $this->normalizeArgs($args);
159 159
 		$counts = [];
160 160
         if ($this->isMixedCount($args)) {
161 161
             $counts = [$this->buildCounts($args)]; // force query the database
162
-        } else {
162
+        }
163
+        else {
163 164
             foreach ($args['post_ids'] as $postId) {
164 165
                 $counts[] = $this->getPostCounts($postId);
165 166
 		}
@@ -193,7 +194,7 @@  discard block
 block discarded – undo
193 194
 	 * @return array
194 195
 	 */
195 196
     public function getPostCounts($postId)
196
-	{
197
+    {
197 198
         return array_filter((array) get_post_meta($postId, static::META_COUNT, true));
198 199
 	}
199 200
 
@@ -202,7 +203,7 @@  discard block
 block discarded – undo
202 203
 	 * @return array
203 204
 	 */
204 205
     public function getTermCounts($termId)
205
-	{
206
+    {
206 207
         return array_filter((array) get_term_meta($termId, static::META_COUNT, true));
207 208
 	}
208 209
 
@@ -210,7 +211,7 @@  discard block
 block discarded – undo
210 211
 	 * @return void
211 212
 	 */
212 213
     public function increase(Review $review)
213
-	{
214
+    {
214 215
         $this->increaseCounts($review);
215 216
         $this->increasePostCounts($review);
216 217
         $this->increaseTermCounts($review);
@@ -220,7 +221,7 @@  discard block
 block discarded – undo
220 221
 	 * @return void
221 222
 	 */
222 223
     public function increaseCounts(Review $review)
223
-	{
224
+    {
224 225
         if (empty($counts = $this->getCounts())) {
225 226
 			$counts = $this->buildCounts();
226 227
 		}
@@ -231,7 +232,7 @@  discard block
 block discarded – undo
231 232
 	 * @return void
232 233
 	 */
233 234
     public function increasePostCounts(Review $review)
234
-	{
235
+    {
235 236
         if (!(get_post($review->assigned_to) instanceof WP_Post)) {
236 237
             return;
237 238
         }
@@ -246,7 +247,7 @@  discard block
 block discarded – undo
246 247
 	 * @return void
247 248
 	 */
248 249
     public function increaseTermCounts(Review $review)
249
-	{
250
+    {
250 251
         $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
251 252
         foreach ($terms as $term) {
252 253
             $counts = $this->getTermCounts($term['term_id']);
@@ -261,7 +262,7 @@  discard block
 block discarded – undo
261 262
 	 * @return void
262 263
 	 */
263 264
     public function setCounts(array $reviewCounts)
264
-	{
265
+    {
265 266
         glsr(OptionManager::class)->set('counts', $reviewCounts);
266 267
 	}
267 268
 
@@ -270,7 +271,7 @@  discard block
 block discarded – undo
270 271
 	 * @return void
271 272
 	 */
272 273
     public function setPostCounts($postId, array $reviewCounts)
273
-	{
274
+    {
274 275
         $ratingCounts = $this->flatten($reviewCounts);
275 276
         update_post_meta($postId, static::META_COUNT, $reviewCounts);
276 277
         update_post_meta($postId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
@@ -282,7 +283,7 @@  discard block
 block discarded – undo
282 283
 	 * @return void
283 284
 	 */
284 285
     public function setTermCounts($termId, array $reviewCounts)
285
-	{
286
+    {
286 287
         $term = get_term($termId, Application::TAXONOMY);
287 288
         if (!isset($term->term_id)) {
288 289
             return;
@@ -299,7 +300,7 @@  discard block
 block discarded – undo
299 300
 	 * @return array
300 301
 	 */
301 302
     protected function decreaseRating(array $reviewCounts, $type, $rating)
302
-	{
303
+    {
303 304
         if (isset($reviewCounts[$type][$rating])) {
304 305
             $reviewCounts[$type][$rating] = max(0, $reviewCounts[$type][$rating] - 1);
305 306
 		}
@@ -312,7 +313,7 @@  discard block
 block discarded – undo
312 313
 	 * @return array
313 314
 	 */
314 315
     protected function increaseRating(array $reviewCounts, $type, $rating)
315
-	{
316
+    {
316 317
         if (!array_key_exists($type, glsr()->reviewTypes)) {
317 318
 			return $reviewCounts;
318 319
 		}
@@ -328,7 +329,7 @@  discard block
 block discarded – undo
328 329
 	 * @return bool
329 330
 	 */
330 331
     protected function isMixedCount(array $args)
331
-	{
332
+    {
332 333
         return !empty($args['post_ids']) && !empty($args['term_ids']);
333 334
 	}
334 335
 
@@ -336,7 +337,7 @@  discard block
 block discarded – undo
336 337
 	 * @return array
337 338
 	 */
338 339
     protected function normalize(array $reviewCounts)
339
-	{
340
+    {
340 341
         if (empty($reviewCounts)) {
341 342
 			$reviewCounts = [[]];
342 343
 		}
@@ -356,7 +357,7 @@  discard block
 block discarded – undo
356 357
 	 * @return array
357 358
 	 */
358 359
     protected function normalizeArgs(array $args)
359
-	{
360
+    {
360 361
         $args = wp_parse_args(array_filter($args), [
361 362
 			'post_ids' => [],
362 363
 			'term_ids' => [],
@@ -372,7 +373,7 @@  discard block
 block discarded – undo
372 373
 	 * @return string
373 374
 	 */
374 375
     protected function normalizeType($type)
375
-	{
376
+    {
376 377
         return empty($type) || !is_string($type)
377 378
 			? 'local'
378 379
 			: $type;
@@ -383,7 +384,7 @@  discard block
 block discarded – undo
383 384
 	 * @return object
384 385
 	 */
385 386
     protected function queryReviews(array $args = [], $lastPostId = 0)
386
-	{
387
+    {
387 388
         $reviews = glsr(SqlQueries::class)->getReviewCounts($args, $lastPostId, static::LIMIT);
388 389
         $hasMore = is_array($reviews)
389 390
             ? count($reviews) == static::LIMIT
Please login to merge, or discard this patch.
plugin/Blocks/BlockGenerator.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,8 @@
 block discarded – undo
27 27
         }
28 28
         if ('post_id' == $attributes['assigned_to']) {
29 29
             $attributes['assigned_to'] = $attributes['post_id'];
30
-        } elseif ('parent_id' == $attributes['assigned_to']) {
30
+        }
31
+        elseif ('parent_id' == $attributes['assigned_to']) {
31 32
             $attributes['assigned_to'] = wp_get_post_parent_id($attributes['post_id']);
32 33
         }
33 34
         return $attributes;
Please login to merge, or discard this patch.
plugin/Helper.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -221,7 +221,8 @@
 block discarded – undo
221 221
                 if ($flattenValue) {
222 222
                     $value = '['.implode(', ', $value).']';
223 223
                 }
224
-            } elseif (is_array($value)) {
224
+            }
225
+            elseif (is_array($value)) {
225 226
                 $result = array_merge($result, $this->flattenArray($value, $flattenValue, $newKey));
226 227
                 continue;
227 228
             }
Please login to merge, or discard this patch.
plugin/Container.php 1 patch
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,9 +68,11 @@  discard block
 block discarded – undo
68 68
     {
69 69
         if (!property_exists($this, $property) || in_array($property, static::PROTECTED_PROPERTIES)) {
70 70
             $this->storage[$property] = $value;
71
-        } elseif (!isset($this->$property)) {
71
+        }
72
+        elseif (!isset($this->$property)) {
72 73
             $this->$property = $value;
73
-        } else {
74
+        }
75
+        else {
74 76
             throw new Exception(sprintf('The "%s" property cannot be changed once set.', $property));
75 77
         }
76 78
     }
@@ -165,7 +167,8 @@  discard block
 block discarded – undo
165 167
     {
166 168
         try {
167 169
             return $this->make($parameter->getClass()->name);
168
-        } catch (Exception $error) {
170
+        }
171
+        catch (Exception $error) {
169 172
             if ($parameter->isOptional()) {
170 173
                 return $parameter->getDefaultValue();
171 174
             }
Please login to merge, or discard this patch.
plugin/Handlers/TogglePinned.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@
 block discarded – undo
18 18
         if (is_null($command->pinned)) {
19 19
             $meta = get_post_meta($command->id, 'pinned', true);
20 20
             $command->pinned = !wp_validate_boolean($meta);
21
-        } else {
21
+        }
22
+        else {
22 23
             $notice = $command->pinned
23 24
                 ? __('Review pinned.', 'site-reviews')
24 25
                 : __('Review unpinned.', 'site-reviews');
Please login to merge, or discard this patch.
plugin/Shortcodes/Shortcode.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -148,7 +148,8 @@
 block discarded – undo
148 148
     {
149 149
         if ('parent_id' == $postId) {
150 150
             $postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
151
-        } elseif ('post_id' == $postId) {
151
+        }
152
+        elseif ('post_id' == $postId) {
152 153
             $postId = intval(get_the_ID());
153 154
         }
154 155
         return $postId;
Please login to merge, or discard this patch.
plugin/Shortcodes/TinymcePopupGenerator.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -318,7 +318,8 @@
 block discarded – undo
318 318
         $alert = esc_html__('Some of the shortcode options are required.', 'site-reviews');
319 319
         if (isset($args['required']['alert'])) {
320 320
             $alert = $args['required']['alert'];
321
-        } elseif (!empty($args['label'])) {
321
+        }
322
+        elseif (!empty($args['label'])) {
322 323
             $alert = sprintf(
323 324
                 esc_html_x('The "%s" option is required.', 'the option label', 'site-reviews'),
324 325
                 str_replace(':', '', $args['label'])
Please login to merge, or discard this patch.