소스 검색

Fix path when app has wrong permission

Replace slow array function used in loop: https://github.com/kalessil/phpinspectionsea/blob/master/docs/performance.md#slow-array-function-used-in-loop

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Daniel Kesselberg 5 년 전
부모
커밋
a6bb19fa11
1개의 변경된 파일5개의 추가작업 그리고 6개의 파일을 삭제
  1. 5 6
      settings/Controller/CheckSetupController.php

+ 5 - 6
settings/Controller/CheckSetupController.php

@@ -544,18 +544,17 @@ Raw output
 	 */
 	protected function getAppDirsWithDifferentOwner(): array {
 		$currentUser = posix_getpwuid(posix_getuid());
-		$appDirsWithDifferentOwner = [];
+		$appDirsWithDifferentOwner = [[]];
 
 		foreach (OC::$APPSROOTS as $appRoot) {
 			if ($appRoot['writable'] === true) {
-				$appDirsWithDifferentOwner = array_merge(
-					$appDirsWithDifferentOwner,
-					$this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot)
-				);
+				$appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
 			}
 		}
 
+		$appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
 		sort($appDirsWithDifferentOwner);
+
 		return $appDirsWithDifferentOwner;
 	}
 
@@ -576,7 +575,7 @@ Raw output
 				$absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
 				$appDirUser = posix_getpwuid(fileowner($absAppPath));
 				if ($appDirUser !== $currentUser) {
-					$appDirsWithDifferentOwner[] = $absAppPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
+					$appDirsWithDifferentOwner[] = $absAppPath;
 				}
 			}
 		}