diff options
Diffstat (limited to 'lib')
25 files changed, 170 insertions, 131 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php index 41b272a457c..7084eb93c89 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -22,10 +22,8 @@ class Autoloader { /** * Optional low-latency memory cache for class to path mapping. - * - * @var \OC\Memcache\Cache */ - protected $memoryCache; + protected ?ICache $memoryCache = null; /** * Autoloader constructor. @@ -127,15 +125,15 @@ class Autoloader { * @throws AutoloadNotAllowedException */ public function load(string $class): bool { + if (class_exists($class, false)) { + return false; + } + $pathsToRequire = null; if ($this->memoryCache) { $pathsToRequire = $this->memoryCache->get($class); } - if (class_exists($class, false)) { - return false; - } - if (!is_array($pathsToRequire)) { // No cache or cache miss $pathsToRequire = []; diff --git a/lib/base.php b/lib/base.php index 0bebb9ef970..45058db1600 100644 --- a/lib/base.php +++ b/lib/base.php @@ -188,8 +188,6 @@ class OC { } public static function checkConfig(): void { - $l = Server::get(\OCP\L10N\IFactory::class)->get('lib'); - // Create config if it does not already exist $configFilePath = self::$configDir . '/config.php'; if (!file_exists($configFilePath)) { @@ -201,6 +199,7 @@ class OC { if (!$configFileWritable && !OC_Helper::isReadOnlyConfigEnabled() || !$configFileWritable && \OCP\Util::needUpgrade()) { $urlGenerator = Server::get(IURLGenerator::class); + $l = Server::get(\OCP\L10N\IFactory::class)->get('lib'); if (self::$CLI) { echo $l->t('Cannot write into "config" directory!') . "\n"; @@ -711,6 +710,7 @@ class OC { self::performSameSiteCookieProtection($config); if (!defined('OC_CONSOLE')) { + $eventLogger->start('check_server', 'Run a few configuration checks'); $errors = OC_Util::checkServer($systemConfig); if (count($errors) > 0) { if (!self::$CLI) { @@ -745,6 +745,7 @@ class OC { } elseif (self::$CLI && $config->getSystemValueBool('installed', false)) { $config->deleteAppValue('core', 'cronErrors'); } + $eventLogger->end('check_server'); } // User and Groups @@ -752,6 +753,7 @@ class OC { self::$server->getSession()->set('user_id', ''); } + $eventLogger->start('setup_backends', 'Setup group and user backends'); Server::get(\OCP\IUserManager::class)->registerBackend(new \OC\User\Database()); Server::get(\OCP\IGroupManager::class)->addBackend(new \OC\Group\Database()); @@ -770,6 +772,7 @@ class OC { // Run upgrades in incognito mode OC_User::setIncognitoMode(true); } + $eventLogger->end('setup_backends'); self::registerCleanupHooks($systemConfig); self::registerShareHooks($systemConfig); diff --git a/lib/l10n/sl.js b/lib/l10n/sl.js index 8677c681bcc..b9d564d8c3b 100644 --- a/lib/l10n/sl.js +++ b/lib/l10n/sl.js @@ -75,6 +75,7 @@ OC.L10N.register( "Empty file" : "Prazna datoteka", "Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator." : "Modul z ID: %s ne obstaja. Omogočite ga med nastavitvami, ali pa stopite v stik s skrbnikom sistema.", "Dot files are not allowed" : "Skrite datoteke niso dovoljene", + "Filenames must not end with \"%1$s\"." : "Imena datotek se naj ne končajo s \"%1$s\".", "File already exists" : "Datoteka že obstaja", "Invalid path" : "Neveljavna pot", "Failed to create file from template" : "Ustvarjanje datoteke iz predloge je spodletelo", diff --git a/lib/l10n/sl.json b/lib/l10n/sl.json index 39c6044b937..1d526285b66 100644 --- a/lib/l10n/sl.json +++ b/lib/l10n/sl.json @@ -73,6 +73,7 @@ "Empty file" : "Prazna datoteka", "Module with ID: %s does not exist. Please enable it in your apps settings or contact your administrator." : "Modul z ID: %s ne obstaja. Omogočite ga med nastavitvami, ali pa stopite v stik s skrbnikom sistema.", "Dot files are not allowed" : "Skrite datoteke niso dovoljene", + "Filenames must not end with \"%1$s\"." : "Imena datotek se naj ne končajo s \"%1$s\".", "File already exists" : "Datoteka že obstaja", "Invalid path" : "Neveljavna pot", "Failed to create file from template" : "Ustvarjanje datoteke iz predloge je spodletelo", diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index d69e72a29de..e8b67311636 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -131,9 +131,7 @@ class AccountManager implements IAccountManager { $property->setScope(self::SCOPE_LOCAL); } } else { - // migrate scope values to the new format - // invalid scopes are mapped to a default value - $property->setScope(AccountProperty::mapScopeToV2($property->getScope())); + $property->setScope($property->getScope()); } } diff --git a/lib/private/Accounts/AccountProperty.php b/lib/private/Accounts/AccountProperty.php index 0c4ad568709..3a89e9bbc7a 100644 --- a/lib/private/Accounts/AccountProperty.php +++ b/lib/private/Accounts/AccountProperty.php @@ -55,16 +55,11 @@ class AccountProperty implements IAccountProperty { * @since 15.0.0 */ public function setScope(string $scope): IAccountProperty { - $newScope = $this->mapScopeToV2($scope); - if (!in_array($newScope, [ - IAccountManager::SCOPE_LOCAL, - IAccountManager::SCOPE_FEDERATED, - IAccountManager::SCOPE_PRIVATE, - IAccountManager::SCOPE_PUBLISHED - ])) { + if (!in_array($scope, IAccountManager::ALLOWED_SCOPES, )) { throw new InvalidArgumentException('Invalid scope'); } - $this->scope = $newScope; + /** @var IAccountManager::SCOPE_* $scope */ + $this->scope = $scope; return $this; } @@ -105,19 +100,6 @@ class AccountProperty implements IAccountProperty { return $this->scope; } - public static function mapScopeToV2(string $scope): string { - if (str_starts_with($scope, 'v2-')) { - return $scope; - } - - return match ($scope) { - IAccountManager::VISIBILITY_PRIVATE, '' => IAccountManager::SCOPE_LOCAL, - IAccountManager::VISIBILITY_CONTACTS_ONLY => IAccountManager::SCOPE_FEDERATED, - IAccountManager::VISIBILITY_PUBLIC => IAccountManager::SCOPE_PUBLISHED, - default => $scope, - }; - } - /** * Get the verification status of a property * diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index 2b04d291730..4e613703dec 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -83,11 +83,12 @@ class Coordinator { $appNameSpace = App::buildAppNamespace($appId); $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; try { - if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { + if (class_exists($applicationClassName) && is_a($applicationClassName, IBootstrap::class, true)) { $this->eventLogger->start("bootstrap:register_app:$appId:application", "Load `Application` instance for $appId"); try { - /** @var IBootstrap|App $application */ - $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); + /** @var IBootstrap&App $application */ + $application = $this->serverContainer->query($applicationClassName); + $apps[$appId] = $application; } catch (QueryException $e) { // Weird, but ok $this->eventLogger->end("bootstrap:register_app:$appId"); diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 24918992ea3..9af65a37ab8 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -153,13 +153,13 @@ class SimpleContainer implements ArrayAccess, ContainerInterface, IContainer { return $closure($this); }; $name = $this->sanitizeName($name); - if (isset($this[$name])) { - unset($this[$name]); + if (isset($this->container[$name])) { + unset($this->container[$name]); } if ($shared) { - $this[$name] = $wrapped; + $this->container[$name] = $wrapped; } else { - $this[$name] = $this->container->factory($wrapped); + $this->container[$name] = $this->container->factory($wrapped); } } diff --git a/lib/private/DB/Adapter.php b/lib/private/DB/Adapter.php index 8f1b8e6d75f..edd8c1bf023 100644 --- a/lib/private/DB/Adapter.php +++ b/lib/private/DB/Adapter.php @@ -28,11 +28,25 @@ class Adapter { /** * @param string $table name * - * @return int id of last insert statement + * @return int id of last insert statement, 0 in case there was no INSERT before or it failed to get the ID * @throws Exception */ - public function lastInsertId($table) { - return (int)$this->conn->realLastInsertId($table); + public function lastInsertId($table, bool $allowRetry = true): int { + $return = $this->conn->realLastInsertId($table); + if ($return === 0 && $allowRetry) { + /** + * During a reconnect we are losing the connection and when the + * realLastInsertId call is the one triggering the reconnect, it + * does not return the ID. But inside the reconnect, we were able + * to save the last insert id, so calling it a second time is going + * to be successful. + * We can not return the result on the initial call, as we are already + * way deeper in the stack performing the actual database query on + * the doctrine driver. + */ + return $this->lastInsertId($table, false); + } + return $return; } /** diff --git a/lib/private/DB/AdapterOCI8.php b/lib/private/DB/AdapterOCI8.php index 0a509090bca..f5ad9f7c934 100644 --- a/lib/private/DB/AdapterOCI8.php +++ b/lib/private/DB/AdapterOCI8.php @@ -8,7 +8,7 @@ namespace OC\DB; class AdapterOCI8 extends Adapter { - public function lastInsertId($table) { + public function lastInsertId($table, bool $allowRetry = true): int { if (is_null($table)) { throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()'); } diff --git a/lib/private/DB/AdapterPgSql.php b/lib/private/DB/AdapterPgSql.php index db48c81c2c5..b321fcf4715 100644 --- a/lib/private/DB/AdapterPgSql.php +++ b/lib/private/DB/AdapterPgSql.php @@ -9,7 +9,7 @@ namespace OC\DB; class AdapterPgSql extends Adapter { - public function lastInsertId($table) { + public function lastInsertId($table, bool $allowRetry = true): int { $result = $this->conn->executeQuery('SELECT lastval()'); $val = $result->fetchOne(); $result->free(); diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 96dd578b2ef..4ba2d2a341d 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -92,6 +92,8 @@ class Connection extends PrimaryReadReplicaConnection { protected ShardConnectionManager $shardConnectionManager; protected AutoIncrementHandler $autoIncrementHandler; protected bool $isShardingEnabled; + protected bool $disableReconnect = false; + protected int $lastInsertId = 0; public const SHARD_PRESETS = [ 'filecache' => [ @@ -510,9 +512,9 @@ class Connection extends PrimaryReadReplicaConnection { * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY * columns or sequences. * - * @param string $seqName Name of the sequence object from which the ID should be returned. + * @param ?string $name Name of the sequence object from which the ID should be returned. * - * @return int the last inserted ID. + * @return int the last inserted ID, 0 in case there was no INSERT before or it failed to get the ID * @throws Exception */ public function lastInsertId($name = null): int { @@ -526,8 +528,13 @@ class Connection extends PrimaryReadReplicaConnection { * @internal * @throws Exception */ - public function realLastInsertId($seqName = null) { - return parent::lastInsertId($seqName); + public function realLastInsertId($seqName = null): int { + if ($this->lastInsertId !== 0) { + $lastInsertId = $this->lastInsertId; + $this->lastInsertId = 0; + return $lastInsertId; + } + return (int)parent::lastInsertId($seqName); } /** @@ -896,11 +903,23 @@ class Connection extends PrimaryReadReplicaConnection { if ( !isset($this->lastConnectionCheck[$this->getConnectionName()]) || time() <= $this->lastConnectionCheck[$this->getConnectionName()] + 30 || - $this->isTransactionActive() + $this->isTransactionActive() || + $this->disableReconnect ) { return; } + if ($this->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL) { + /** + * Before reconnecting we save the lastInsertId, so that if the reconnect + * happens between the INSERT executeStatement() and the getLastInsertId call + * we are able to return the correct result after all. + */ + $this->disableReconnect = true; + $this->lastInsertId = (int)parent::lastInsertId(); + $this->disableReconnect = false; + } + try { $this->_conn->query($this->getDriver()->getDatabasePlatform()->getDummySelectSQL()); $this->lastConnectionCheck[$this->getConnectionName()] = time(); diff --git a/lib/private/Files/Storage/Temporary.php b/lib/private/Files/Storage/Temporary.php index ff7a816930d..ecf8a1315a9 100644 --- a/lib/private/Files/Storage/Temporary.php +++ b/lib/private/Files/Storage/Temporary.php @@ -7,16 +7,20 @@ */ namespace OC\Files\Storage; +use OCP\Files; +use OCP\ITempManager; +use OCP\Server; + /** * local storage backend in temporary folder for testing purpose */ class Temporary extends Local { public function __construct(array $parameters = []) { - parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]); + parent::__construct(['datadir' => Server::get(ITempManager::class)->getTemporaryFolder()]); } public function cleanUp(): void { - \OC_Helper::rmdirr($this->datadir); + Files::rmdirr($this->datadir); } public function __destruct() { diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index aeaac030413..d5810a90868 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -24,6 +24,7 @@ use Psr\Log\LoggerInterface; class Detection implements IMimeTypeDetector { private const CUSTOM_MIMETYPEMAPPING = 'mimetypemapping.json'; private const CUSTOM_MIMETYPEALIASES = 'mimetypealiases.json'; + private const CUSTOM_MIMETYPENAMES = 'mimetypenames.json'; /** @var array<list{string, string|null}> */ protected array $mimeTypes = []; @@ -32,6 +33,8 @@ class Detection implements IMimeTypeDetector { protected array $mimeTypeIcons = []; /** @var array<string,string> */ protected array $mimeTypeAlias = []; + /** @var array<string,string> */ + protected array $mimeTypesNames = []; public function __construct( private IURLGenerator $urlGenerator, @@ -149,6 +152,25 @@ class Detection implements IMimeTypeDetector { return $this->mimeTypes; } + private function loadNamings(): void { + if (!empty($this->mimeTypesNames)) { + return; + } + + $mimeTypeMapping = json_decode(file_get_contents($this->defaultConfigDir . '/mimetypenames.dist.json'), true); + $mimeTypeMapping = $this->loadCustomDefinitions(self::CUSTOM_MIMETYPENAMES, $mimeTypeMapping); + + $this->mimeTypesNames = $mimeTypeMapping; + } + + /** + * @return array<string,string> + */ + public function getAllNamings(): array { + $this->loadNamings(); + return $this->mimeTypesNames; + } + /** * detect MIME type only based on filename, content of file is not used * diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 00fdd84c1bc..a1d27c9255b 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -19,6 +19,7 @@ use OC\DB\MigrationService; use OC_App; use OC_Helper; use OCP\App\IAppManager; +use OCP\Files; use OCP\HintException; use OCP\Http\Client\IClientService; use OCP\IConfig; @@ -324,14 +325,14 @@ class Installer { $baseDir = OC_App::getInstallPath() . '/' . $appId; // Remove old app with the ID if existent - OC_Helper::rmdirr($baseDir); + Files::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); + Files::rmdirr($extractDir); return; } // Signature does not match @@ -450,7 +451,7 @@ class Installer { return false; } $appDir = OC_App::getInstallPath() . '/' . $appId; - OC_Helper::rmdirr($appDir); + Files::rmdirr($appDir); return true; } else { $this->logger->error('can\'t remove app ' . $appId . '. It is not installed.'); diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index 361fe8e9b2d..2bd6e426b79 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -148,10 +148,10 @@ class Checker { } if ($filename === $this->environmentHelper->getServerRoot() . '/core/js/mimetypelist.js') { $oldMimetypeList = new GenerateMimetypeFileBuilder(); - $newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases()); + $newFile = $oldMimetypeList->generateFile($this->mimeTypeDetector->getAllAliases(), $this->mimeTypeDetector->getAllNamings()); $oldFile = $this->fileAccessHelper->file_get_contents($filename); if ($newFile === $oldFile) { - $hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases())); + $hashes[$relativeFileName] = hash('sha512', $oldMimetypeList->generateFile($this->mimeTypeDetector->getOnlyDefaultAliases(), $this->mimeTypeDetector->getAllNamings())); continue; } } diff --git a/lib/private/Repair/MoveUpdaterStepFile.php b/lib/private/Repair/MoveUpdaterStepFile.php index c9b51b308c4..eb9f78b0a39 100644 --- a/lib/private/Repair/MoveUpdaterStepFile.php +++ b/lib/private/Repair/MoveUpdaterStepFile.php @@ -5,6 +5,7 @@ */ namespace OC\Repair; +use OCP\Files; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; @@ -40,7 +41,7 @@ class MoveUpdaterStepFile implements IRepairStep { // cleanup if (file_exists($previousStepFile)) { - if (\OC_Helper::rmdirr($previousStepFile)) { + if (Files::rmdirr($previousStepFile)) { $output->info('.step-previous-update removed'); } else { $output->info('.step-previous-update can\'t be removed - abort move of .step file'); diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index d073132516d..2a60287254b 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -54,9 +54,9 @@ class Router implements IRouter { protected LoggerInterface $logger, IRequest $request, private IConfig $config, - private IEventLogger $eventLogger, + protected IEventLogger $eventLogger, private ContainerInterface $container, - private IAppManager $appManager, + protected IAppManager $appManager, ) { $baseUrl = \OC::$WEBROOT; if (!($config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { @@ -116,9 +116,11 @@ class Router implements IRouter { $this->loaded = true; $routingFiles = $this->getRoutingFiles(); + $this->eventLogger->start('route:load:attributes', 'Loading Routes from attributes'); foreach (\OC_App::getEnabledApps() as $enabledApp) { $this->loadAttributeRoutes($enabledApp); } + $this->eventLogger->end('route:load:attributes'); } else { if (isset($this->loadedApps[$app])) { return; @@ -140,6 +142,7 @@ class Router implements IRouter { } } + $this->eventLogger->start('route:load:files', 'Loading Routes from files'); foreach ($routingFiles as $app => $file) { if (!isset($this->loadedApps[$app])) { if (!$this->appManager->isAppLoaded($app)) { @@ -160,6 +163,7 @@ class Router implements IRouter { $this->root->addCollection($collection); } } + $this->eventLogger->end('route:load:files'); if (!isset($this->loadedApps['core'])) { $this->loadedApps['core'] = true; @@ -265,6 +269,7 @@ class Router implements IRouter { $this->loadRoutes(); } + $this->eventLogger->start('route:url:match', 'Symfony url matcher call'); $matcher = new UrlMatcher($this->root, $this->context); try { $parameters = $matcher->match($url); @@ -283,6 +288,7 @@ class Router implements IRouter { throw $e; } } + $this->eventLogger->end('route:url:match'); $this->eventLogger->end('route:match'); return $parameters; diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php index 9f887b2d48a..b5bcbdaeb6f 100644 --- a/lib/private/ServerContainer.php +++ b/lib/private/ServerContainer.php @@ -128,18 +128,17 @@ class ServerContainer extends SimpleContainer { } catch (QueryException $e) { // Continue with general autoloading then } - } - - // In case the service starts with OCA\ we try to find the service in - // the apps container first. - if (($appContainer = $this->getAppContainerForService($name)) !== null) { - try { - return $appContainer->queryNoFallback($name); - } catch (QueryException $e) { - // Didn't find the service or the respective app container - // In this case the service won't be part of the core container, - // so we can throw directly - throw $e; + // In case the service starts with OCA\ we try to find the service in + // the apps container first. + if (($appContainer = $this->getAppContainerForService($name)) !== null) { + try { + return $appContainer->queryNoFallback($name); + } catch (QueryException $e) { + // Didn't find the service or the respective app container + // In this case the service won't be part of the core container, + // so we can throw directly + throw $e; + } } } elseif (str_starts_with($name, 'OC\\Settings\\') && substr_count($name, '\\') >= 3) { $segments = explode('\\', $name); diff --git a/lib/private/Support/CrashReport/Registry.php b/lib/private/Support/CrashReport/Registry.php index 93969a81265..77dd8163174 100644 --- a/lib/private/Support/CrashReport/Registry.php +++ b/lib/private/Support/CrashReport/Registry.php @@ -110,6 +110,7 @@ class Registry implements IRegistry { \OC::$server->get(LoggerInterface::class)->critical('Could not load lazy crash reporter: ' . $e->getMessage(), [ 'exception' => $e, ]); + return; } /** * Try to register the loaded reporter. Theoretically it could be of a wrong diff --git a/lib/private/TempManager.php b/lib/private/TempManager.php index b7dccad3f95..4c0ffcf43d7 100644 --- a/lib/private/TempManager.php +++ b/lib/private/TempManager.php @@ -8,6 +8,7 @@ namespace OC; use bantu\IniGetWrapper\IniGetWrapper; +use OCP\Files; use OCP\IConfig; use OCP\ITempManager; use OCP\Security\ISecureRandom; @@ -99,7 +100,7 @@ class TempManager implements ITempManager { foreach ($files as $file) { if (file_exists($file)) { try { - \OC_Helper::rmdirr($file); + Files::rmdirr($file); } catch (\UnexpectedValueException $ex) { $this->log->warning( 'Error deleting temporary file/folder: {file} - Reason: {error}', diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index fd97e47c40a..172c865364c 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -95,37 +95,10 @@ class OC_Helper { * @param string $dir path to the folder * @param bool $deleteSelf if set to false only the content of the folder will be deleted * @return bool + * @deprecated 5.0.0 use \OCP\Files::rmdirr instead */ public static function rmdirr($dir, $deleteSelf = true) { - if (is_dir($dir)) { - $files = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), - RecursiveIteratorIterator::CHILD_FIRST - ); - - foreach ($files as $fileInfo) { - /** @var SplFileInfo $fileInfo */ - if ($fileInfo->isLink()) { - unlink($fileInfo->getPathname()); - } elseif ($fileInfo->isDir()) { - rmdir($fileInfo->getRealPath()); - } else { - unlink($fileInfo->getRealPath()); - } - } - if ($deleteSelf) { - rmdir($dir); - } - } elseif (file_exists($dir)) { - if ($deleteSelf) { - unlink($dir); - } - } - if (!$deleteSelf) { - return true; - } - - return !file_exists($dir); + return \OCP\Files::rmdirr($dir, $deleteSelf); } /** diff --git a/lib/public/Accounts/IAccountManager.php b/lib/public/Accounts/IAccountManager.php index a15651eb5e6..92fc0002674 100644 --- a/lib/public/Accounts/IAccountManager.php +++ b/lib/public/Accounts/IAccountManager.php @@ -48,30 +48,6 @@ interface IAccountManager { public const SCOPE_PUBLISHED = 'v2-published'; /** - * Contact details only visible locally - * - * @since 15.0.0 - * @deprecated 21.0.1 - */ - public const VISIBILITY_PRIVATE = 'private'; - - /** - * Contact details visible on trusted federated servers. - * - * @since 15.0.0 - * @deprecated 21.0.1 - */ - public const VISIBILITY_CONTACTS_ONLY = 'contacts'; - - /** - * Contact details visible on trusted federated servers and in the public lookup server. - * - * @since 15.0.0 - * @deprecated 21.0.1 - */ - public const VISIBILITY_PUBLIC = 'public'; - - /** * The list of allowed scopes * * @since 25.0.0 @@ -81,9 +57,6 @@ interface IAccountManager { self::SCOPE_LOCAL, self::SCOPE_FEDERATED, self::SCOPE_PUBLISHED, - self::VISIBILITY_PRIVATE, - self::VISIBILITY_CONTACTS_ONLY, - self::VISIBILITY_PUBLIC, ]; /** @@ -98,6 +71,7 @@ interface IAccountManager { /** * @since 27.0.0 + * @deprecated 27.0.0 only added for backwards compatibility with provisioning_api UsersController::getCurrentUser */ public const PROPERTY_DISPLAYNAME_LEGACY = 'display-name'; diff --git a/lib/public/Files.php b/lib/public/Files.php index 62c41c4ada1..fb03a4192fc 100644 --- a/lib/public/Files.php +++ b/lib/public/Files.php @@ -18,12 +18,44 @@ namespace OCP; class Files { /** * Recursive deletion of folders + * + * @param string $dir path to the folder + * @param bool $deleteSelf if set to false only the content of the folder will be deleted * @return bool * @since 5.0.0 + * @since 32.0.0 added the $deleteSelf parameter * @deprecated 14.0.0 */ - public static function rmdirr($dir) { - return \OC_Helper::rmdirr($dir); + public static function rmdirr($dir, bool $deleteSelf = true) { + if (is_dir($dir)) { + $files = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), + \RecursiveIteratorIterator::CHILD_FIRST + ); + + foreach ($files as $fileInfo) { + /** @var \SplFileInfo $fileInfo */ + if ($fileInfo->isLink()) { + unlink($fileInfo->getPathname()); + } elseif ($fileInfo->isDir()) { + rmdir($fileInfo->getRealPath()); + } else { + unlink($fileInfo->getRealPath()); + } + } + if ($deleteSelf) { + rmdir($dir); + } + } elseif (file_exists($dir)) { + if ($deleteSelf) { + unlink($dir); + } + } + if (!$deleteSelf) { + return true; + } + + return !file_exists($dir); } /** diff --git a/lib/public/Files/IMimeTypeDetector.php b/lib/public/Files/IMimeTypeDetector.php index 1bc9c514610..1e87cf932ce 100644 --- a/lib/public/Files/IMimeTypeDetector.php +++ b/lib/public/Files/IMimeTypeDetector.php @@ -87,4 +87,12 @@ interface IMimeTypeDetector { * @since 32.0.0 */ public function getAllMappings(): array; + + /** + * Get all human readable mime names + * + * @return array<string,string> + * @since 32.0.0 + */ + public function getAllNamings(): array; } |