From 5f0df868df30c2b4f9a730331b66577a28bc6d43 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Wojtu=C5=82a?= <matw88@gmail.com>
Date: Fri, 30 Jan 2015 15:55:17 +0100
Subject: [PATCH] [BUGFIX] t3lib_div::getAllFilesAndFoldersInPath no md5 for
 folders

Added md5 hash for folders keys in returned array
in method GeneralUtility::getAllFilesAndFoldersInPath

Change-Id: Ibfaa910c53a4ffac21be791e51aecc9212c40b49
Resloves: #37701
Releases: master
Reviewed-on: http://review.typo3.org/36435
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../core/Classes/Utility/GeneralUtility.php     |  2 +-
 .../Tests/Unit/Utility/GeneralUtilityTest.php   | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index b5336e24f97b..b6901fa5d4d7 100755
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -3015,7 +3015,7 @@ Connection: close
 	 */
 	static public function getAllFilesAndFoldersInPath(array $fileArr, $path, $extList = '', $regDirs = FALSE, $recursivityLevels = 99, $excludePattern = '') {
 		if ($regDirs) {
-			$fileArr[] = $path;
+			$fileArr[md5($path)] = $path;
 		}
 		$fileArr = array_merge($fileArr, self::getFilesInDir($path, $extList, 1, 1, $excludePattern));
 		$dirs = self::get_dirs($path);
diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
index fb8f740acb9c..c1cc94eeb80f 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
@@ -4597,4 +4597,21 @@ text with a ' . $urlMatch . '$|s'),
 		$this->assertEquals($expected, GeneralUtilityFixture::stripHttpHeaders($httpResponse));
 	}
 
+	/**
+	 * @test
+	 */
+	public function getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys() {
+		$directory = PATH_site . 'typo3temp/' . $this->getUniqueId('directory_');
+		mkdir($directory);
+		$filesAndDirectories = Utility\GeneralUtility::getAllFilesAndFoldersInPath(array(), $directory, '', TRUE);
+		$check = TRUE;
+		foreach ($filesAndDirectories as $md5 => $path) {
+			if (!preg_match('/^[a-f0-9]{32}$/', $md5)) {
+				$check = FALSE;
+			}
+		}
+		Utility\GeneralUtility::rmdir($directory);
+		$this->assertTrue($check);
+	}
+
 }
-- 
GitLab