From a6bb19fa11fb132f91eeb692057a0bd5b7e94948 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Thu, 30 Aug 2018 20:52:43 +0200 Subject: [PATCH] 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 --- settings/Controller/CheckSetupController.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index 747e60c7cb287..9169808456fd5 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -544,18 +544,17 @@ protected function hasOpcacheLoaded(): bool { */ 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 @@ private function getAppDirsWithDifferentOwnerForAppRoot(array $currentUser, arra $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename(); $appDirUser = posix_getpwuid(fileowner($absAppPath)); if ($appDirUser !== $currentUser) { - $appDirsWithDifferentOwner[] = $absAppPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename(); + $appDirsWithDifferentOwner[] = $absAppPath; } } }