Passed
Push — v3 ( db5cc8...c32422 )
by Andrew
20:34 queued 30s
created
src/services/Sitemaps.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     // Constants
44 44
     // =========================================================================
45 45
 
46
-    const SEOMATIC_SITEMAPINDEX_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapIndexTemplate::TEMPLATE_TYPE;
46
+    const SEOMATIC_SITEMAPINDEX_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapIndexTemplate::TEMPLATE_TYPE;
47 47
 
48
-    const SEOMATIC_SITEMAP_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapTemplate::TEMPLATE_TYPE;
48
+    const SEOMATIC_SITEMAP_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapTemplate::TEMPLATE_TYPE;
49 49
 
50
-    const SEOMATIC_SITEMAPCUSTOM_CONTAINER = Seomatic::SEOMATIC_HANDLE . SitemapCustomTemplate::TEMPLATE_TYPE;
50
+    const SEOMATIC_SITEMAPCUSTOM_CONTAINER = Seomatic::SEOMATIC_HANDLE.SitemapCustomTemplate::TEMPLATE_TYPE;
51 51
 
52 52
     const SEARCH_ENGINE_SUBMISSION_URLS = [
53 53
     ];
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
                         $siteId = $groupSiteIds[0];
248 248
                         $sitemapIndexUrl = $this->sitemapIndexUrlForSiteId($siteId);
249 249
                         if (!empty($sitemapIndexUrl)) {
250
-                            $submissionUrl = $url . urlencode($sitemapIndexUrl);
250
+                            $submissionUrl = $url.urlencode($sitemapIndexUrl);
251 251
                             // create new guzzle client
252 252
                             $guzzleClient = Craft::createGuzzleClient(['timeout' => 5, 'connect_timeout' => 5]);
253 253
                             // Submit the sitemap index to each search engine
254 254
                             try {
255 255
                                 $guzzleClient->post($submissionUrl);
256 256
                                 Craft::info(
257
-                                    'Sitemap index submitted to: ' . $submissionUrl,
257
+                                    'Sitemap index submitted to: '.$submissionUrl,
258 258
                                     __METHOD__
259 259
                                 );
260 260
                             } catch (\Exception $e) {
261 261
                                 Craft::error(
262
-                                    'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(),
262
+                                    'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(),
263 263
                                     __METHOD__
264 264
                                 );
265 265
                             }
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
             foreach ($searchEngineUrls as &$url) {
322 322
                 $sitemapUrl = $this->sitemapUrlForBundle($sourceBundleType, $sourceHandle, $sourceSiteId);
323 323
                 if (!empty($sitemapUrl)) {
324
-                    $submissionUrl = $url . urlencode($sitemapUrl);
324
+                    $submissionUrl = $url.urlencode($sitemapUrl);
325 325
                     // create new guzzle client
326 326
                     $guzzleClient = Craft::createGuzzleClient(['timeout' => 5, 'connect_timeout' => 5]);
327 327
                     // Submit the sitemap index to each search engine
328 328
                     try {
329 329
                         $guzzleClient->post($submissionUrl);
330 330
                         Craft::info(
331
-                            'Sitemap index submitted to: ' . $submissionUrl,
331
+                            'Sitemap index submitted to: '.$submissionUrl,
332 332
                             __METHOD__
333 333
                         );
334 334
                     } catch (\Exception $e) {
335 335
                         Craft::error(
336
-                            'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(),
336
+                            'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(),
337 337
                             __METHOD__
338 338
                         );
339 339
                     }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
                     . '-'
375 375
                     . $metaBundle->sourceSiteId
376 376
                     . '-sitemap'
377
-                    . (!empty($page) ? '-p' . $page : '')
377
+                    . (!empty($page) ? '-p'.$page : '')
378 378
                     . '.xml',
379 379
                     null,
380 380
                     null,
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
             foreach ($searchEngineUrls as &$url) {
404 404
                 $sitemapUrl = $this->sitemapCustomUrlForSiteId($siteId);
405 405
                 if (!empty($sitemapUrl)) {
406
-                    $submissionUrl = $url . urlencode($sitemapUrl);
406
+                    $submissionUrl = $url.urlencode($sitemapUrl);
407 407
                     // create new guzzle client
408 408
                     $guzzleClient = Craft::createGuzzleClient(['timeout' => 5, 'connect_timeout' => 5]);
409 409
                     // Submit the sitemap index to each search engine
410 410
                     try {
411 411
                         $guzzleClient->post($submissionUrl);
412 412
                         Craft::info(
413
-                            'Sitemap Custom submitted to: ' . $submissionUrl,
413
+                            'Sitemap Custom submitted to: '.$submissionUrl,
414 414
                             __METHOD__
415 415
                         );
416 416
                     } catch (\Exception $e) {
417 417
                         Craft::error(
418
-                            'Error submitting sitemap index to: ' . $submissionUrl . ' - ' . $e->getMessage(),
418
+                            'Error submitting sitemap index to: '.$submissionUrl.' - '.$e->getMessage(),
419 419
                             __METHOD__
420 420
                         );
421 421
                     }
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
         }
494 494
 
495 495
         foreach ($sites as $site) {
496
-            $result .= 'sitemap: ' . $this->sitemapIndexUrlForSiteId($site->id) . PHP_EOL;
496
+            $result .= 'sitemap: '.$this->sitemapIndexUrlForSiteId($site->id).PHP_EOL;
497 497
         }
498 498
 
499 499
         return rtrim($result, PHP_EOL);
@@ -525,9 +525,9 @@  discard block
 block discarded – undo
525 525
         // Since we want a stale-while-revalidate pattern, only invalidate the cache if we're asked to
526 526
         if ($invalidateCache) {
527 527
             $cache = Craft::$app->getCache();
528
-            TagDependency::invalidate($cache, SitemapTemplate::SITEMAP_CACHE_TAG . $handle . $siteId);
528
+            TagDependency::invalidate($cache, SitemapTemplate::SITEMAP_CACHE_TAG.$handle.$siteId);
529 529
             Craft::info(
530
-                'Sitemap cache cleared: ' . $handle,
530
+                'Sitemap cache cleared: '.$handle,
531 531
                 __METHOD__
532 532
             );
533 533
         }
Please login to merge, or discard this patch.
src/console/controllers/SitemapController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function actionGenerate()
70 70
     {
71
-        echo 'Generating sitemap' . PHP_EOL;
71
+        echo 'Generating sitemap'.PHP_EOL;
72 72
         if ($this->siteId !== null) {
73 73
             $siteIds[] = $this->siteId;
74 74
         } else {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                     $sitemap = SitemapTemplate::create();
116 116
                     if ($site) {
117 117
                         for ($pageNum = 1; $pageNum <= $pageCount; $pageNum++) {
118
-                            echo sprintf('Generating page %d of %d' . PHP_EOL, $pageNum, $pageCount);
118
+                            echo sprintf('Generating page %d of %d'.PHP_EOL, $pageNum, $pageCount);
119 119
                             $sitemap->render([
120 120
                                 'groupId' => $site->groupId,
121 121
                                 'siteId' => $metaBundle->sourceSiteId,
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                         // Generate the sitemap so it is in the cache
128 128
                     }
129 129
 
130
-                    echo '---' . PHP_EOL;
130
+                    echo '---'.PHP_EOL;
131 131
                 }
132 132
             }
133 133
         }
Please login to merge, or discard this patch.
src/helpers/Sitemap.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         if ($multiSite) {
121 121
             $urlsetLine .= ' xmlns:xhtml="http://www.w3.org/1999/xhtml"';
122 122
         }
123
-        if ((bool)$metaBundle->metaSitemapVars->newsSitemap) {
123
+        if ((bool) $metaBundle->metaSitemapVars->newsSitemap) {
124 124
             $urlsetLine .= ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"';
125 125
         }
126 126
         $urlsetLine .= '>';
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
                         $paginator->getTotalPages(),
189 189
                         $paginator->getTotalResults());
190 190
                 }
191
-                echo $message . PHP_EOL;
191
+                echo $message.PHP_EOL;
192 192
             }
193 193
             /** @var Element $element */
194 194
             foreach ($elements as $element) {
195 195
                 // Output some info if this is a console app
196 196
                 if (Craft::$app instanceof ConsoleApplication) {
197
-                    echo "Processing element {$currentElement}/{$totalElements} - {$element->title}" . PHP_EOL;
197
+                    echo "Processing element {$currentElement}/{$totalElements} - {$element->title}".PHP_EOL;
198 198
                 }
199 199
 
200 200
                 $metaBundle->metaSitemapVars->setAttributes($stashedSitemapAttrs, false);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                         }
243 243
                         $canonicalUrl = UrlHelper::absoluteUrlWithProtocol($canonicalUrl);
244 244
                         if ($url !== $canonicalUrl) {
245
-                            Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - " . $metaBundle->metaGlobalVars->canonicalUrl . " - " . $element->uri);
245
+                            Craft::info("Excluding URL: {$url} from the sitemap because it does not match the Canonical URL: {$canonicalUrl} - ".$metaBundle->metaGlobalVars->canonicalUrl." - ".$element->uri);
246 246
                             continue;
247 247
                         }
248 248
                     }
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
                                             if ($primarySiteId === $altSourceSiteId && Seomatic::$settings->addXDefaultHrefLang) {
304 304
                                                 $lines[] = '<xhtml:link rel="alternate"'
305 305
                                                     . ' hreflang="x-default"'
306
-                                                    . ' href="' . Html::encode($altUrl) . '"'
306
+                                                    . ' href="'.Html::encode($altUrl).'"'
307 307
                                                     . ' />';
308 308
                                             }
309 309
                                             $lines[] = '<xhtml:link rel="alternate"'
310
-                                                . ' hreflang="' . $altSiteSettings['language'] . '"'
311
-                                                . ' href="' . Html::encode($altUrl) . '"'
310
+                                                . ' hreflang="'.$altSiteSettings['language'].'"'
311
+                                                . ' href="'.Html::encode($altUrl).'"'
312 312
                                                 . ' />';
313 313
                                         }
314 314
                                     }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
                         }
318 318
                     }
319 319
                     // Handle news sitemaps https://developers.google.com/search/docs/crawling-indexing/sitemaps/news-sitemap
320
-                    if ((bool)$metaBundle->metaSitemapVars->newsSitemap) {
320
+                    if ((bool) $metaBundle->metaSitemapVars->newsSitemap) {
321 321
                         $now = new DateTime();
322 322
                         $interval = $now->diff($dateUpdated);
323 323
                         if ($interval->days <= 2) {
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
                             }
328 328
                             $lines[] = '<news:news>';
329 329
                             $lines[] = '<news:publication>';
330
-                            $lines[] = '<news:name>' . $metaBundle->metaSitemapVars->newsPublicationName . '</news:name>';
331
-                            $lines[] = '<news:language>' . $language . '</news:language>';
330
+                            $lines[] = '<news:name>'.$metaBundle->metaSitemapVars->newsPublicationName.'</news:name>';
331
+                            $lines[] = '<news:language>'.$language.'</news:language>';
332 332
                             $lines[] = '</news:publication>';
333
-                            $lines[] = '<news:publication_date>' . $dateUpdated->format(DateTime::W3C) . '</news:publication_date>';
334
-                            $lines[] = '<news:title>' . $element->title . '</news:title>';
333
+                            $lines[] = '<news:publication_date>'.$dateUpdated->format(DateTime::W3C).'</news:publication_date>';
334
+                            $lines[] = '<news:title>'.$element->title.'</news:title>';
335 335
                             $lines[] = '</news:news>';
336 336
                         }
337 337
                     }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
      */
548 548
     protected static function assetSitemapItem(Asset $asset, MetaBundle $metaBundle, array &$lines)
549 549
     {
550
-        if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) {
550
+        if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) {
551 551
             switch ($asset->kind) {
552 552
                 case 'image':
553 553
                     $transform = Craft::$app->getAssetTransforms()->getTransformByHandle($metaBundle->metaSitemapVars->sitemapAssetTransform ?? '');
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
                         $fieldName = $row['field'] ?? '';
561 561
                         $propName = $row['property'] ?? '';
562 562
                         if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) {
563
-                            $lines[] = '<image:' . $propName . '>';
563
+                            $lines[] = '<image:'.$propName.'>';
564 564
                             $lines[] = Html::encode($asset[$fieldName]);
565
-                            $lines[] = '</image:' . $propName . '>';
565
+                            $lines[] = '</image:'.$propName.'>';
566 566
                         }
567 567
                     }
568 568
                     $lines[] = '</image:image>';
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
                         $fieldName = $row['field'] ?? '';
579 579
                         $propName = $row['property'] ?? '';
580 580
                         if (!empty($fieldName) && !empty($asset[$fieldName]) && !empty($propName)) {
581
-                            $lines[] = '<video:' . $propName . '>';
581
+                            $lines[] = '<video:'.$propName.'>';
582 582
                             $lines[] = Html::encode($asset[$fieldName]);
583
-                            $lines[] = '</video:' . $propName . '>';
583
+                            $lines[] = '</video:'.$propName.'>';
584 584
                         }
585 585
                     }
586 586
                     $lines[] = '</video:video>';
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
      */
597 597
     protected static function assetFilesSitemapLink(Asset $asset, MetaBundle $metaBundle, array &$lines)
598 598
     {
599
-        if ((bool)$asset->enabledForSite && $asset->getUrl() !== null) {
599
+        if ((bool) $asset->enabledForSite && $asset->getUrl() !== null) {
600 600
             if (in_array($asset->kind, SitemapTemplate::FILE_TYPES, false)) {
601 601
                 $dateUpdated = $asset->dateUpdated ?? $asset->dateCreated ?? new DateTime();
602 602
                 $lines[] = '<url>';
Please login to merge, or discard this patch.
src/models/SitemapTemplate.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
         }
150 150
 
151 151
         $cache = Craft::$app->getCache();
152
-        $pageCacheSuffix = 's' . (int)$metaBundle->metaSitemapVars->sitemapPageSize . 'p' . $page;
152
+        $pageCacheSuffix = 's'.(int) $metaBundle->metaSitemapVars->sitemapPageSize.'p'.$page;
153 153
 
154
-        $uniqueKey = $groupId . $type . $handle . $siteId . $pageCacheSuffix;
155
-        $cacheKey = self::CACHE_KEY . $uniqueKey;
154
+        $uniqueKey = $groupId.$type.$handle.$siteId.$pageCacheSuffix;
155
+        $cacheKey = self::CACHE_KEY.$uniqueKey;
156 156
         $result = $cache->get($cacheKey);
157 157
 
158 158
         // If the sitemap isn't cached, start a job to create it
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                 $dependency = new TagDependency([
172 172
                     'tags' => [
173 173
                         self::GLOBAL_SITEMAP_CACHE_TAG,
174
-                        self::SITEMAP_CACHE_TAG . $handle . $siteId . $pageCacheSuffix,
174
+                        self::SITEMAP_CACHE_TAG.$handle.$siteId.$pageCacheSuffix,
175 175
                     ],
176 176
                 ]);
177 177
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
                 // Output some info if this is a console app
185 185
                 if (Craft::$app instanceof ConsoleApplication) {
186
-                    echo 'Sitemap cache result: ' . print_r($result, true) . ' for cache key: ' . $cacheKey . PHP_EOL;
186
+                    echo 'Sitemap cache result: '.print_r($result, true).' for cache key: '.$cacheKey.PHP_EOL;
187 187
                 }
188 188
 
189 189
                 // If the FastCGI Cache Bust plugin is installed, clear its caches too
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
                 // Return an empty XML document
212 212
                 $lines[] = '<?xml version="1.0" encoding="UTF-8"?>';
213 213
                 $lines[] = '<?xml-stylesheet type="text/xsl" href="sitemap-empty.xsl"?>';
214
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'This sitemap has not been generated yet.') . ' -->';
215
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'If you are seeing this in local dev or an') . ' -->';
216
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'environment with `devMode` on, caches only') . ' -->';
217
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'last for 30 seconds in local dev, so it is') . ' -->';
218
-                $lines[] = '<!-- ' . Craft::t('seomatic', 'normal for the sitemap to not be cached.') . ' -->';
214
+                $lines[] = '<!-- '.Craft::t('seomatic', 'This sitemap has not been generated yet.').' -->';
215
+                $lines[] = '<!-- '.Craft::t('seomatic', 'If you are seeing this in local dev or an').' -->';
216
+                $lines[] = '<!-- '.Craft::t('seomatic', 'environment with `devMode` on, caches only').' -->';
217
+                $lines[] = '<!-- '.Craft::t('seomatic', 'last for 30 seconds in local dev, so it is').' -->';
218
+                $lines[] = '<!-- '.Craft::t('seomatic', 'normal for the sitemap to not be cached.').' -->';
219 219
                 $lines[] = '<urlset>';
220 220
                 $lines[] = '</urlset>';
221 221
             }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             return $lines;
225 225
         } else {
226 226
             if (Craft::$app instanceof ConsoleApplication) {
227
-                echo 'Found in cache' . PHP_EOL;
227
+                echo 'Found in cache'.PHP_EOL;
228 228
             }
229 229
         }
230 230
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
     public function invalidateCache(string $handle, int $siteId)
241 241
     {
242 242
         $cache = Craft::$app->getCache();
243
-        TagDependency::invalidate($cache, self::SITEMAP_CACHE_TAG . $handle . $siteId);
243
+        TagDependency::invalidate($cache, self::SITEMAP_CACHE_TAG.$handle.$siteId);
244 244
         Craft::info(
245
-            'Sitemap cache cleared: ' . $handle,
245
+            'Sitemap cache cleared: '.$handle,
246 246
             __METHOD__
247 247
         );
248 248
     }
Please login to merge, or discard this patch.