[BUGFIX] Display documentation changelog files with same issue number 46/57446/2
authorAnja <aleichsenring@ab-softlab.de>
Thu, 28 Jun 2018 16:45:33 +0000 (18:45 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 2 Jul 2018 12:39:27 +0000 (14:39 +0200)
By using a hash instead of the issue number as array key, no file gets
lost any longer due to collision. Same issue numbers for documentation
files are quite common, e.g. when a new feature deprecates replaced code.

Change-Id: I3aef23b3bbc0d63486b1f75c38a54648991633b5
Resolves: #85420
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/57446
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/install/Classes/UpgradeAnalysis/DocumentationFile.php
typo3/sysext/install/Tests/Unit/UpgradeAnalysis/DocumentationFileTest.php

index 091fe21..9f8a16f 100644 (file)
@@ -110,9 +110,8 @@ class DocumentationFile
         $entry['content'] = file_get_contents($file);
         $entry['parsedContent'] = $this->parseContent($entry['content']);
         $entry['file_hash'] = md5($entry['content']);
-        $issueNumber = $this->extractIssueNumber($headline);
 
-        return [$issueNumber => $entry];
+        return [md5($file) => $entry];
     }
 
     /**
@@ -200,17 +199,6 @@ class DocumentationFile
     }
 
     /**
-     * Get issue number from headline
-     *
-     * @param string $headline
-     * @return int
-     */
-    protected function extractIssueNumber(string $headline): int
-    {
-        return (int)substr($headline, strpos($headline, '#') + 1, 5);
-    }
-
-    /**
      * True for real directories and a valid version
      *
      * @param string $versionDirectory
index ef94d11..f87d8ae 100644 (file)
@@ -88,6 +88,7 @@ class DocumentationFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
                 ],
                 'master' => [
                     'Breaking-13579-Issue.rst' => implode("\n", $content_13579),
+                    'Important-13579-Issue.rst' => implode("\n", $content_13579),
                     'Index.rst' => '',
                 ],
             ],
@@ -151,6 +152,15 @@ class DocumentationFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
     /**
      * @test
      */
+    public function findDocumentsRespectsFilesWithSameIssueNumber()
+    {
+        $result = $this->documentationFileService->findDocumentationFiles(vfsStream::url('root/Changelog'));
+        $this->assertCount(2, $result['master']);
+    }
+
+    /**
+     * @test
+     */
     public function extractingTagsProvidesTagsAsDesired()
     {
         $expected = [
@@ -158,7 +168,8 @@ class DocumentationFileTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
             'cat:Important',
         ];
         $result = $this->documentationFileService->findDocumentationFiles(vfsStream::url('root/Changelog'));
-        self::assertEquals($expected, $result['2.0'][98574]['tags']);
+        $key = md5('vfs://root/Changelog/2.0/Important-98574-Issue.rst');
+        self::assertEquals($expected, $result['2.0'][$key]['tags']);
     }
 
     /**