[BUGFIX] Set proper default value for unavailable redirect report 05/61705/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Sat, 14 Sep 2019 07:03:26 +0000 (09:03 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 17 Sep 2019 05:05:39 +0000 (07:05 +0200)
In case the redirect integrity check has never been executed before, the
code now uses an empty array as fallback value to fix issues with wrong
variable types.

Additionaly, a repeated typo has been fixed.

Resolves: #89172
Releases: master
Change-Id: Ib3f2815ad355dc9d8161c845f3b0dba9efc07ce9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61705
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Michael Schams <typo3@2018.schams.net>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/redirects/Classes/Report/Status/RedirectStatus.php
typo3/sysext/redirects/Resources/Private/Templates/Report/RedirectStatus.html
typo3/sysext/redirects/Tests/Functional/Service/IntegrityServiceTest.php

index 22df9f2..7199c86 100644 (file)
@@ -35,7 +35,7 @@ class RedirectStatus implements StatusProviderInterface
     public function getStatus(): array
     {
         return [
-            'Conflictes' => $this->getConflictingRedirects(),
+            'Conflicts' => $this->getConflictingRedirects(),
         ];
     }
 
@@ -45,8 +45,8 @@ class RedirectStatus implements StatusProviderInterface
         $severity = Status::OK;
 
         $registry = GeneralUtility::makeInstance(Registry::class);
-        $reportedConflictes = $registry->get('tx_redirects', 'conflicting_redirects');
-        $count = count($reportedConflictes);
+        $reportedConflicts = $registry->get('tx_redirects', 'conflicting_redirects', []);
+        $count = count($reportedConflicts);
 
         $view = GeneralUtility::makeInstance(StandaloneView::class);
         $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:redirects/Resources/Private/Templates/Report/RedirectStatus.html'));
@@ -58,7 +58,7 @@ class RedirectStatus implements StatusProviderInterface
 
         $view->assignMultiple([
             'count' => $count,
-            'reportedConflictes' => $reportedConflictes,
+            'reportedConflicts' => $reportedConflicts,
         ]);
 
         return GeneralUtility::makeInstance(
index 111ea10..910c8eb 100644 (file)
@@ -6,7 +6,7 @@
 <f:if condition="{count} > 0">
     <p><f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_reports.xlf:status.conflictingRedirects.message" /></p>
     <ul>
-        <f:for each="{reportedConflictes}" as="conflict">
+        <f:for each="{reportedConflicts}" as="conflict">
             <li>
                 <span title="{conflict.uri}">{conflict.uri -> f:format.crop(maxCharacters: '100')}</span><br>
                 <f:translate key="LLL:EXT:redirects/Resources/Private/Language/locallang_db.xlf:sys_redirect.source_host" />: {conflict.redirect.source_host}<br>
index 8d2abaf..23eccfa 100644 (file)
@@ -61,7 +61,7 @@ class IntegrityServiceTest extends FunctionalTestCase
         $this->importCSVDataSet(__DIR__ . '/Fixtures/SimplePages.csv');
         $this->importCSVDataSet(__DIR__ . '/Fixtures/sys_redirect.csv');
 
-        $expectedConflictes = [
+        $expectedConflicts = [
             [
                 'uri' => 'https://example.com/',
                 'redirect' => [
@@ -85,7 +85,7 @@ class IntegrityServiceTest extends FunctionalTestCase
             ],
         ];
 
-        $this->assertExpectedPathsFromGenerator($expectedConflictes, $this->subject->findConflictingRedirects('simple-page'));
+        $this->assertExpectedPathsFromGenerator($expectedConflicts, $this->subject->findConflictingRedirects('simple-page'));
     }
 
     /**
@@ -96,7 +96,7 @@ class IntegrityServiceTest extends FunctionalTestCase
         $this->importCSVDataSet(__DIR__ . '/Fixtures/LocalizedPages.csv');
         $this->importCSVDataSet(__DIR__ . '/Fixtures/sys_redirect.csv');
 
-        $expectedConflictes = [
+        $expectedConflicts = [
             [
                 'uri' => 'https://another.example.com/about-us/we-are-here',
                 'redirect' => [
@@ -113,7 +113,7 @@ class IntegrityServiceTest extends FunctionalTestCase
             ],
         ];
 
-        $this->assertExpectedPathsFromGenerator($expectedConflictes, $this->subject->findConflictingRedirects('localized-page'));
+        $this->assertExpectedPathsFromGenerator($expectedConflicts, $this->subject->findConflictingRedirects('localized-page'));
     }
 
     /**
@@ -125,7 +125,7 @@ class IntegrityServiceTest extends FunctionalTestCase
         $this->importCSVDataSet(__DIR__ . '/Fixtures/LocalizedPages.csv');
         $this->importCSVDataSet(__DIR__ . '/Fixtures/sys_redirect.csv');
 
-        $expectedConflictes = [
+        $expectedConflicts = [
             [
                 'uri' => 'https://example.com/',
                 'redirect' => [
@@ -163,17 +163,17 @@ class IntegrityServiceTest extends FunctionalTestCase
             ],
         ];
 
-        $this->assertExpectedPathsFromGenerator($expectedConflictes, $this->subject->findConflictingRedirects());
+        $this->assertExpectedPathsFromGenerator($expectedConflicts, $this->subject->findConflictingRedirects());
     }
 
-    private function assertExpectedPathsFromGenerator(array $expectedConflictes, \Generator $generator): void
+    private function assertExpectedPathsFromGenerator(array $expectedConflicts, \Generator $generator): void
     {
         $matches = 0;
         foreach ($generator as $reportedConflict) {
-            $this->assertContains($reportedConflict, $expectedConflictes);
+            $this->assertContains($reportedConflict, $expectedConflicts);
             $matches++;
         }
-        $this->assertSame(count($expectedConflictes), $matches);
+        $this->assertSame(count($expectedConflicts), $matches);
     }
 
     private function prophesizeSiteFinder(): ObjectProphecy