diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Collaboration/Resources/Manager.php | 2 | ||||
-rw-r--r-- | lib/private/Files/View.php | 2 | ||||
-rw-r--r-- | lib/private/Installer.php | 133 | ||||
-rw-r--r-- | lib/private/Memcache/Memcached.php | 1 | ||||
-rw-r--r-- | lib/private/Notification/Manager.php | 4 |
5 files changed, 66 insertions, 76 deletions
diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index a0fba16998f..8fc3d0dd5ea 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -131,7 +131,7 @@ class Manager implements IManager { */ public function searchCollections(IUser $user, string $filter, int $limit = 50, int $start = 0): array { $query = $this->connection->getQueryBuilder(); - $userId = $user instanceof IUser ? $user->getUID() : ''; + $userId = $user->getUID(); $query->select('c.*', 'a.access') ->from(self::TABLE_COLLECTIONS, 'c') diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index f2d91065b9a..72de70a8248 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1407,7 +1407,7 @@ class View { } $info = new FileInfo($path, $storage, $internalPath, $data, $mount, $owner); - if ($data and isset($data['fileid'])) { + if (isset($data['fileid'])) { if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') { //add the sizes of other mount points to the folder $extOnly = ($includeMountPoints === 'ext'); diff --git a/lib/private/Installer.php b/lib/private/Installer.php index b63619b821c..95143656295 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -308,91 +308,80 @@ class Installer { $extractDir = $this->tempManager->getTemporaryFolder(); $archive = new TAR($tempFile); - if ($archive) { - if (!$archive->extract($extractDir)) { - $errorMessage = 'Could not extract app ' . $appId; + if (!$archive->extract($extractDir)) { + $errorMessage = 'Could not extract app ' . $appId; - $archiveError = $archive->getError(); - if ($archiveError instanceof \PEAR_Error) { - $errorMessage .= ': ' . $archiveError->getMessage(); - } - - throw new \Exception($errorMessage); - } - $allFiles = scandir($extractDir); - $folders = array_diff($allFiles, ['.', '..']); - $folders = array_values($folders); - - if (count($folders) > 1) { - throw new \Exception( - sprintf( - 'Extracted app %s has more than 1 folder', - $appId - ) - ); + $archiveError = $archive->getError(); + if ($archiveError instanceof \PEAR_Error) { + $errorMessage .= ': ' . $archiveError->getMessage(); } - // Check if appinfo/info.xml has the same app ID as well - if ((PHP_VERSION_ID < 80000)) { - $loadEntities = libxml_disable_entity_loader(false); - $xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml'); - libxml_disable_entity_loader($loadEntities); - } else { - $xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml'); - } - if ((string)$xml->id !== $appId) { - throw new \Exception( - sprintf( - 'App for id %s has a wrong app ID in info.xml: %s', - $appId, - (string)$xml->id - ) - ); - } + throw new \Exception($errorMessage); + } + $allFiles = scandir($extractDir); + $folders = array_diff($allFiles, ['.', '..']); + $folders = array_values($folders); - // Check if the version is lower than before - $currentVersion = OC_App::getAppVersion($appId); - $newVersion = (string)$xml->version; - if (version_compare($currentVersion, $newVersion) === 1) { - throw new \Exception( - sprintf( - 'App for id %s has version %s and tried to update to lower version %s', - $appId, - $currentVersion, - $newVersion - ) - ); - } + if (count($folders) > 1) { + throw new \Exception( + sprintf( + 'Extracted app %s has more than 1 folder', + $appId + ) + ); + } - $baseDir = OC_App::getInstallPath() . '/' . $appId; - // Remove old app with the ID if existent - OC_Helper::rmdirr($baseDir); - // Move to app folder - if (@mkdir($baseDir)) { - $extractDir .= '/' . $folders[0]; - OC_Helper::copyr($extractDir, $baseDir); - } - OC_Helper::copyr($extractDir, $baseDir); - OC_Helper::rmdirr($extractDir); - return; + // Check if appinfo/info.xml has the same app ID as well + if ((PHP_VERSION_ID < 80000)) { + $loadEntities = libxml_disable_entity_loader(false); + $xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml'); + libxml_disable_entity_loader($loadEntities); } else { + $xml = simplexml_load_file($extractDir . '/' . $folders[0] . '/appinfo/info.xml'); + } + if ((string)$xml->id !== $appId) { throw new \Exception( sprintf( - 'Could not extract app with ID %s to %s', + 'App for id %s has a wrong app ID in info.xml: %s', $appId, - $extractDir + (string)$xml->id ) ); } - } else { - // Signature does not match - throw new \Exception( - sprintf( - 'App with id %s has invalid signature', - $appId - ) - ); + + // Check if the version is lower than before + $currentVersion = OC_App::getAppVersion($appId); + $newVersion = (string)$xml->version; + if (version_compare($currentVersion, $newVersion) === 1) { + throw new \Exception( + sprintf( + 'App for id %s has version %s and tried to update to lower version %s', + $appId, + $currentVersion, + $newVersion + ) + ); + } + + $baseDir = OC_App::getInstallPath() . '/' . $appId; + // Remove old app with the ID if existent + OC_Helper::rmdirr($baseDir); + // Move to app folder + if (@mkdir($baseDir)) { + $extractDir .= '/' . $folders[0]; + OC_Helper::copyr($extractDir, $baseDir); + } + OC_Helper::copyr($extractDir, $baseDir); + OC_Helper::rmdirr($extractDir); + return; } + // Signature does not match + throw new \Exception( + sprintf( + 'App with id %s has invalid signature', + $appId + ) + ); } } diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php index b3414a7d290..87b71223280 100644 --- a/lib/private/Memcache/Memcached.php +++ b/lib/private/Memcache/Memcached.php @@ -66,6 +66,7 @@ class Memcached extends Cache implements IMemcache { //\Memcached::OPT_BINARY_PROTOCOL => true, ]; // by default enable igbinary serializer if available + /** @psalm-suppress RedundantCondition */ if (\Memcached::HAVE_IGBINARY) { $defaultOptions[\Memcached::OPT_SERIALIZER] = \Memcached::SERIALIZER_IGBINARY; diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index d8bbc02e105..c707884355b 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -381,12 +381,12 @@ class Manager implements IManager { throw new \InvalidArgumentException('The given notification has been processed'); } - if (!($notification instanceof INotification) || !$notification->isValidParsed()) { + if (!$notification->isValidParsed()) { throw new \InvalidArgumentException('The given notification has not been handled'); } } - if (!($notification instanceof INotification) || !$notification->isValidParsed()) { + if (!$notification->isValidParsed()) { throw new \InvalidArgumentException('The given notification has not been handled'); } |