diff --git a/apps/admin_audit/composer/autoload.php b/apps/admin_audit/composer/autoload.php deleted file mode 100644 index 7480b576ba0e7..0000000000000 --- a/apps/admin_audit/composer/autoload.php +++ /dev/null @@ -1,22 +0,0 @@ -getStats()); exit($exitCode); } catch (Exception $ex) { exceptionHandler($ex); diff --git a/lib/OC.php b/lib/OC.php index b2b4f65fee004..3bfbf11a5ba2a 100644 --- a/lib/OC.php +++ b/lib/OC.php @@ -40,6 +40,9 @@ require_once __DIR__ . '/public/Constants.php'; +// There is no autoloading for functions so we need to hardcode it +require_once __DIR__ . '/public/Log/functions.php'; + /** * Class that is a namespace for all global OC variables * @internal @@ -89,6 +92,7 @@ class OC { * @psalm-suppress ImpureStaticProperty */ public static \Composer\Autoload\ClassLoader $composerAutoloader; + public static \OC\Autoloader $autoloader; /** * @psalm-suppress ImpureStaticProperty @@ -670,14 +674,38 @@ public static function boot(): void { // calculate the root directories OC::$SERVERROOT = str_replace('\\', '/', substr(__DIR__, 0, -4)); + // No autoloader yet, manually load Config class + require_once __DIR__ . '/private/Config.php'; + + // load configs + if (defined('PHPUNIT_CONFIG_DIR')) { + self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; + } elseif (defined('PHPUNIT_RUN') && PHPUNIT_RUN && is_dir(OC::$SERVERROOT . '/tests/config/')) { + self::$configDir = OC::$SERVERROOT . '/tests/config/'; + } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { + self::$configDir = rtrim($dir, '/') . '/'; + } else { + self::$configDir = OC::$SERVERROOT . '/config/'; + } + self::$config = new \OC\Config(self::$configDir); + + $cacheDirectory = self::$config->getValue('cachedirectory', OC::$SERVERROOT . '/cache'); + // register autoloader self::$loaderStart = microtime(true); self::$CLI = (php_sapi_name() == 'cli'); - // Add default composer PSR-4 autoloader, ensure apcu to be disabled - self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; - self::$composerAutoloader->setApcuPrefix(null); + require_once __DIR__ . '/private/PhpDumpCache.php'; + require_once __DIR__ . '/private/Autoloader.php'; + $phpDumpCache = new \OC\PhpDumpCache($cacheDirectory); + self::$autoloader = new \OC\Autoloader($phpDumpCache); + self::$autoloader->addPsr4('OC', OC::$SERVERROOT . '/lib/private'); + self::$autoloader->addPsr4('OCP', OC::$SERVERROOT . '/lib/public'); + self::$autoloader->addPsr4('NCU', OC::$SERVERROOT . '/lib/unstable'); + self::$autoloader->addPsr4('OC\\Core', OC::$SERVERROOT . '/core'); + self::$autoloader->addPsr4('', OC::$SERVERROOT . '/lib/private/legacy'); + self::$autoloader->register(); // setup 3rdparty autoloader $vendorAutoLoad = OC::$SERVERROOT . '/3rdparty/autoload.php'; @@ -688,18 +716,6 @@ public static function boot(): void { self::$loaderEnd = microtime(true); - // load configs - if (defined('PHPUNIT_CONFIG_DIR')) { - self::$configDir = OC::$SERVERROOT . '/' . PHPUNIT_CONFIG_DIR . '/'; - } elseif (defined('PHPUNIT_RUN') && PHPUNIT_RUN && is_dir(OC::$SERVERROOT . '/tests/config/')) { - self::$configDir = OC::$SERVERROOT . '/tests/config/'; - } elseif ($dir = getenv('NEXTCLOUD_CONFIG_DIR')) { - self::$configDir = rtrim($dir, '/') . '/'; - } else { - self::$configDir = OC::$SERVERROOT . '/config/'; - } - self::$config = new \OC\Config(self::$configDir); - // Enable lazy loading if activated \OC\AppFramework\Utility\SimpleContainer::$useLazyObjects = (bool)self::$config->getValue('enable_lazy_objects', true); diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 4b802f72c34a5..db1d9cbdbd61d 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -83,9 +83,12 @@ class AppManager implements IAppManager { /** @var array */ private array $loadedApps = []; + /** @var array */ + private array $registeredApps = []; /** @var string[] */ private $namespaceCache = []; + private $appinfoCache = []; private ?AppConfig $appConfig = null; private ?IURLGenerator $urlGenerator = null; @@ -105,6 +108,8 @@ public function __construct( private ServerVersion $serverVersion, private ConfigManager $configManager, private DependencyAnalyzer $dependencyAnalyzer, + private \OC\PhpDumpCache $phpDumpCache, + private IEventLogger $eventLogger, ) { } @@ -267,21 +272,13 @@ public function loadApps(array $types = []): bool { // Load the enabled apps here $apps = $this->getEnabledApps(); - - // Add each apps' folder as allowed class path - foreach ($apps as $app) { + $appsToRegister = array_filter( + $apps, // If the app is already loaded then autoloading it makes no sense - if (!$this->isAppLoaded($app) && ($types === [] || $this->isType($app, $types))) { - try { - $path = $this->getAppPath($app); - \OC_App::registerAutoloading($app, $path); - } catch (AppPathNotFoundException $e) { - $this->logger->info('Error during app loading: ' . $e->getMessage(), [ - 'exception' => $e, - 'app' => $app, - ]); - } - } + fn (string $app) => (!isset($this->registeredApps[$app]) && ($types === [] || $this->isType($app, $types))), + ); + if (count($appsToRegister) > 0) { + $this->registerAppsAutoloading($appsToRegister); } // prevent app loading from printing output @@ -483,11 +480,12 @@ public function loadApp(string $app): void { ]); return; } - $eventLogger = Server::get(IEventLogger::class); - $eventLogger->start("bootstrap:load_app:$app", "Load app: $app"); + $this->eventLogger->start("bootstrap:load_app:$app", "Load app: $app"); // in case someone calls loadApp() directly - \OC_App::registerAutoloading($app, $appPath); + if (!isset($this->registeredApps[$app])) { + $this->registerAppsAutoloading([$app]); + } if (is_file($appPath . '/appinfo/app.php')) { $this->logger->error('/appinfo/app.php is not supported anymore, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [ @@ -498,7 +496,7 @@ public function loadApp(string $app): void { $coordinator = Server::get(Coordinator::class); $coordinator->bootApp($app); - $eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it"); + $this->eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it"); $info = $this->getAppInfo($app); if (!empty($info['activity'])) { $activityManager = Server::get(IActivityManager::class); @@ -573,9 +571,96 @@ public function loadApp(string $app): void { } } } - $eventLogger->end("bootstrap:load_app:$app:info"); + $this->eventLogger->end("bootstrap:load_app:$app:info"); + + $this->eventLogger->end("bootstrap:load_app:$app"); + } + + /** + * @internal + */ + public function registerAppsAutoloading(array $apps): void { + $this->eventLogger->start('bootstrap:register_apps_autoloading', ''); + $loadedApps = array_unique(array_merge($apps, array_keys($this->registeredApps))); + sort($loadedApps); + $cacheKey = [self::class, ...$loadedApps]; + $this->eventLogger->start('bootstrap:register_apps_autoloading:load_cache', ''); + $cachedInfo = $this->phpDumpCache->loadCache($cacheKey); + if ($cachedInfo !== null) { + // echo "loading cache, key is ".json_encode($cacheKey).' '.md5(serialize($cacheKey))."\n"; + $this->eventLogger->end('bootstrap:register_apps_autoloading:load_cache'); + [$this->namespaceCache, $this->appInfos, $autoloaderProperties] = $cachedInfo; + \OC::$autoloader->loadFromArray($autoloaderProperties); + + $this->eventLogger->start('bootstrap:register_apps_autoloading:apply_cache', ''); + foreach ($apps as $app) { + if (isset($this->registeredApps[$app])) { + continue; + } + $this->registeredApps[$app] = true; + + $appNamespace = $this->getAppNamespace($app); + \OC::$server->registerNamespace($app, $appNamespace); + $path = $this->getAppPath($app); + if (file_exists($path . '/composer/autoload.php')) { + // FIXME needed? + require_once $path . '/composer/autoload.php'; + } + } + $this->eventLogger->end('bootstrap:register_apps_autoloading:apply_cache'); + $this->eventLogger->end('bootstrap:register_apps_autoloading'); + return; + } + $reload = false; + foreach ($apps as $app) { + if (!isset($this->registeredApps[$app])) { + try { + $path = $this->getAppPath($app); + $this->registerAutoloading($app, $path); + $reload = true; + } catch (AppPathNotFoundException $e) { + $this->logger->info('Error during app loading: ' . $e->getMessage(), [ + 'exception' => $e, + 'app' => $app, + ]); + } + } + } + if ($reload) { + \OC::$autoloader->rebuild(); + } + $this->phpDumpCache->saveCache($cacheKey, [$this->namespaceCache, $this->appInfos, \OC::$autoloader->serializeToArray()]); + $this->eventLogger->end('bootstrap:register_apps_autoloading'); + } - $eventLogger->end("bootstrap:load_app:$app"); + /** + * @internal + */ + public function registerAutoloading(string $app, string $path, bool $force = false): void { + if (!$force && isset($this->registeredApps[$app])) { + return; + } + + $this->registeredApps[$app] = true; + + // Register on PSR-4 composer autoloader + $appNamespace = $this->getAppNamespace($app); + \OC::$server->registerNamespace($app, $appNamespace); + + if (file_exists($path . '/composer/autoload.php')) { + require_once $path . '/composer/autoload.php'; + } elseif (is_dir($path . '/lib')) { + // autoloader crashes on non-existing dir + \OC::$autoloader->addPsr4($appNamespace, $path . '/lib'); + } + + // Register Test namespace only when testing + if ((defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) && is_dir($path . '/tests/')) { + \OC::$autoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/'); + } + if ($force) { + \OC::$autoloader->triggerReload(); + } } /** @@ -1107,7 +1192,7 @@ public function upgradeApp(string $appId): bool { $ignoreMax = in_array($appId, $ignoreMaxApps, true); $this->checkAppDependencies($appId, $ignoreMax); - \OC_App::registerAutoloading($appId, $appPath, true); + $this->registerAutoloading($appId, $appPath, true); $this->executeRepairSteps($appId, $appInfo['repair-steps']['pre-migration']); $ms = new MigrationService($appId, Server::get(\OC\DB\Connection::class)); diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index 9912e2c901337..e0bd85355edaa 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -9,10 +9,8 @@ namespace OC\AppFramework\Bootstrap; +use OC\App\AppManager; use OC\Support\CrashReport\Registry; -use OC_App; -use OCP\App\AppPathNotFoundException; -use OCP\App\IAppManager; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\QueryException; @@ -40,7 +38,7 @@ public function __construct( private IManager $dashboardManager, private IEventDispatcher $eventDispatcher, private IEventLogger $eventLogger, - private IAppManager $appManager, + private AppManager $appManager, private LoggerInterface $logger, ) { } @@ -66,21 +64,16 @@ private function registerApps(array $appIds): void { if ($this->registrationContext === null) { $this->registrationContext = new RegistrationContext($this->logger); } + $this->eventLogger->start('bootstrap:register_app:autoloader', 'Setup autoloader for apps'); + if ($appIds === []) { + $this->appManager->registerAppsAutoloading($this->appManager->getAlwaysEnabledApps()); + } else { + $this->appManager->registerAppsAutoloading($appIds); + } + $this->eventLogger->end('bootstrap:register_app:autoloader'); $apps = []; foreach ($appIds as $appId) { $this->eventLogger->start("bootstrap:register_app:$appId", "Register $appId"); - $this->eventLogger->start("bootstrap:register_app:$appId:autoloader", "Setup autoloader for $appId"); - /* - * First, we have to enable the app's autoloader - */ - try { - $path = $this->appManager->getAppPath($appId); - OC_App::registerAutoloading($appId, $path); - } catch (AppPathNotFoundException) { - // Ignore - continue; - } - $this->eventLogger->end("bootstrap:register_app:$appId:autoloader"); /* * Next we check if there is an application class, and it implements diff --git a/lib/private/Autoloader.php b/lib/private/Autoloader.php new file mode 100644 index 0000000000000..5bbb3632ffd69 --- /dev/null +++ b/lib/private/Autoloader.php @@ -0,0 +1,312 @@ + namespace => path */ + private array $psr4Paths = []; + + /** @var string[] */ + private array $excludeDirs = []; + + /** @var array class => [file, time] */ + private array $classes = []; + private bool $cacheLoaded = false; + private bool $refreshed = false; + + /** @var array class => counter */ + private array $missingClasses = []; + + private bool $needSave = false; + + private int $loadsFromCache = 0; + private int $diskScans = 0; + + public function __construct( + private PhpDumpCache $dumpCache, + ) { + if (!extension_loaded('tokenizer')) { + throw new \LogicException('PHP extension Tokenizer is not loaded.'); + } + } + + public function __destruct() { + if ($this->needSave) { + $this->saveCache(); + } + } + + /** + * Register autoloader. + */ + public function register(bool $prepend = false): static { + spl_autoload_register([$this, 'tryLoad'], prepend: $prepend); + return $this; + } + + /** + * Handles autoloading of classes, interfaces or traits. + */ + public function tryLoad(string $type): void { + try { + $this->loadCache(); + + $missing = $this->missingClasses[$type] ?? 0; + if ($missing >= self::RetryLimit) { + return; + } + + [$file, $mtime] = $this->classes[$type] ?? null; + + if ($file) { + (static function ($file) { + require $file; + })($file); + } + } catch (\Throwable $t) { + throw $t; + } + } + + /** + * Add path for given namespace + * + * @param string $namespace The namespace to register, with no \ at either end. + * @param string $path The path to register, with a beginning / and no ending /. + */ + public function addPsr4(string $namespace, string $path): static { + $this->psr4Paths[$namespace] = $path; + return $this; + } + + public function triggerReload(): void { + $this->refreshed = false; + $this->cacheLoaded = false; + } + + public function reportParseErrors(bool $on = true): static { + $this->reportParseErrors = $on; + return $this; + } + + /** + * Excludes path or paths from list. + */ + public function excludeDirectory(string ...$paths): static { + $this->excludeDirs = array_merge($this->excludeDirs, $paths); + return $this; + } + + /** + * @return array class => filename + */ + public function getIndexedClasses(): array { + $this->loadCache(); + $res = []; + foreach ($this->classes as $class => [$file]) { + $res[$class] = $file; + } + + return $res; + } + + /** + * Rebuilds class list cache. + */ + public function rebuild(): void { + $this->cacheLoaded = true; + $this->classes = $this->missingClasses = []; + $this->refreshClasses(); + $this->saveCache(); + } + + /** + * Refreshes class list cache. + */ + public function refresh(): void { + $this->loadCache(); + if (!$this->refreshed) { + $this->refreshClasses(); + $this->saveCache(); + } + } + + /** + * Refreshes $this->classes. + */ + private function refreshClasses(): void { + $this->refreshed = true; // prevents calling refreshClasses() in tryLoad() + $files = []; + $classes = []; + foreach ($this->classes as $class => [$file, $mtime]) { + $files[$file] = $mtime; + $classes[$file][] = $class; + } + + $this->classes = []; + + foreach ($this->psr4Paths as $namespace => $path) { + $iterator = $this->createFileIterator($path); + // Length of path + separator + $pathLen = strlen($path) + 1; + if ($namespace === '') { + $prefix = ''; + } else { + $prefix = $namespace . '\\'; + } + foreach ($iterator as $file) { + $class = $prefix . str_replace('/', '\\', substr($file, $pathLen, -4)); + if (isset($this->classes[$class])) { + throw new \RuntimeException(sprintf( + 'Ambiguous class %s resolution; defined in %s and in %s.', + $class, + $this->classes[$class][0], + $file, + )); + } + + //FIXME needed? + $mtime = filemtime($file); + + $this->classes[$class] = [$file, $mtime]; + unset($this->missingClasses[$class]); + } + } + + $this->diskScans++; + } + + /** + * Creates an iterator scanning directory for PHP files and subdirectories. + * @throws \RuntimeException if path is not found + */ + private function createFileIterator(string $dir): \Generator { + if (!is_dir($dir)) { + throw new \RuntimeException(sprintf("Directory '%s' not found.", $dir)); + } + + $dir = realpath($dir) ?: $dir; // realpath does not work in phar + $disallow = []; + foreach (array_merge($this->ignoreDirs, $this->excludeDirs) as $item) { + if ($item = realpath($item)) { + $disallow[$item] = true; + } + } + + yield from $this->traverseDir($dir, $disallow); + } + + private function traverseDir(string $dir, array $disallow): \Generator { + try { + $files = new \FilesystemIterator($dir, \FilesystemIterator::FOLLOW_SYMLINKS | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::UNIX_PATHS); + } catch (\RuntimeException) { + return; + } + + foreach ($files as $file) { + $realPath = realpath($file); + $file = $realPath ?: $file; + if ($realPath && isset($disallow[$realPath])) { + continue; + } elseif (is_dir($file) && !self::matches(basename($file), $this->ignoreDirs)) { + yield from $this->traverseDir($file, $disallow); + } elseif (is_file($file) && self::matches(basename($file), $this->acceptFiles)) { + yield $file; + } + } + } + + private static function matches(string $file, array $masks): bool { + foreach ($masks as $mask) { + if (fnmatch($mask, $file)) { + return true; + } + } + return false; + } + + /********************* caching *******************/ + + /** + * Loads class list from cache. + */ + private function loadCache(): void { + if ($this->cacheLoaded) { + return; + } + + $this->cacheLoaded = true; + + $data = $this->dumpCache->loadCache($this->generateCacheKey()); + if (is_array($data)) { + [$this->classes, $this->missingClasses] = $data; + $this->loadsFromCache++; + return; + } + + $this->classes = $this->missingClasses = []; + $this->refreshClasses(); + $this->saveCache(); + } + + /** + * Writes class list to cache. + * @param resource $lock + */ + private function saveCache(): void { + $this->dumpCache->saveCache($this->generateCacheKey(), [$this->classes, $this->missingClasses]); + } + + protected function generateCacheKey(): array { + return [$this->psr4Paths,$this->ignoreDirs, $this->acceptFiles, $this->excludeDirs]; + } + + public function getStats(): array { + return [ + 'Loads from cache' => $this->loadsFromCache, + 'Disk scans' => $this->diskScans, + ]; + } + + public function serializeToArray(): array { + return [ + 'psr4Paths' => $this->psr4Paths, + 'excludeDirs' => $this->excludeDirs, + 'classes' => $this->classes, + 'missingClasses' => $this->missingClasses, + ]; + } + + public function loadFromArray(array $properties): void { + $this->psr4Paths = $properties['psr4Paths']; + $this->excludeDirs = $properties['excludeDirs']; + $this->classes = $properties['classes']; + $this->missingClasses = $properties['missingClasses']; + + /* Avoid any refresh */ + $this->cacheLoaded = true; + $this->refreshed = true; + } +} diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 7f903693d1cf7..5cce7871b954e 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -11,6 +11,7 @@ use ArgumentCountError; use OC\MemoryInfo; use OC\NeedsUpdateException; +use OC\PhpDumpCache; use OC\SystemConfig; use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; @@ -43,6 +44,7 @@ public function __construct( private MemoryInfo $memoryInfo, private IAppManager $appManager, private Defaults $defaults, + private PhpDumpCache $dumpCache, ) { $this->application = new SymfonyApplication($defaults->getName(), $serverVersion->getVersionString()); } @@ -83,11 +85,11 @@ public function loadCommands( } try { - require_once __DIR__ . '/../../../core/register_command.php'; if ($this->config->getSystemValueBool('installed', false)) { if (Util::needUpgrade()) { throw new NeedsUpdateException(); } elseif ($this->config->getSystemValueBool('maintenance')) { + require_once __DIR__ . '/../../../core/register_command.php'; if ($this->appManager->isEnabledForAnyone('app_api')) { // AppAPI must stay usable during maintenance mode; // loading commands from register_command.php is intentionally skipped. @@ -106,6 +108,16 @@ public function loadCommands( } $this->writeMaintenanceModeInfo($input, $output); } else { + $cachedCommandList = $this->dumpCache->loadCache([self::class]); + if (is_array($cachedCommandList)) { + $firstArg = $input->getArgument('command'); + if ($firstArg !== null && isset($cachedCommandList[$firstArg])) { + $this->appManager->loadApps(); + $this->application->add(Server::get($cachedCommandList[$firstArg])); + return; + } + } + require_once __DIR__ . '/../../../core/register_command.php'; $this->appManager->loadApps(); foreach ($this->appManager->getEnabledApps() as $app) { try { @@ -126,7 +138,6 @@ public function loadCommands( } } // load from register_command.php - \OC_App::registerAutoloading($app, $appPath); $file = $appPath . '/appinfo/register_command.php'; if (file_exists($file)) { try { @@ -151,6 +162,9 @@ public function loadCommands( } } + /* To cover branches from above if that skipped register_command */ + require_once __DIR__ . '/../../../core/register_command.php'; + if ($input->getFirstArgument() !== 'check') { $errors = \OC_Util::checkServer(Server::get(SystemConfig::class)); if (!empty($errors)) { @@ -162,6 +176,19 @@ public function loadCommands( throw new \Exception('Environment not properly prepared.'); } } + $commands = $this->application->all(); + $cache = []; + foreach ($commands as $command) { + $name = $command->getName(); + if ($name !== null) { + $cache[$name] = $command::class; + } + + foreach ($command->getAliases() as $alias) { + $cache[$alias] = $command::class; + } + } + $this->dumpCache->saveCache([self::class], $cache); } /** diff --git a/lib/private/Installer.php b/lib/private/Installer.php index b1e444f6b984a..1852a103be7a3 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -534,7 +534,7 @@ public function installShippedApps(bool $softErrors = false, ?IOutput $output = } private function installAppLastSteps(string $appPath, array $info, ?IOutput $output = null, string $enabled = 'no'): string { - \OC_App::registerAutoloading($info['id'], $appPath); + $this->appManager->registerAutoloading($info['id'], $appPath, true); $previousVersion = $this->config->getAppValue($info['id'], 'installed_version', ''); $ms = new MigrationService($info['id'], Server::get(Connection::class)); diff --git a/lib/private/PhpDumpCache.php b/lib/private/PhpDumpCache.php new file mode 100644 index 0000000000000..dfa1215559935 --- /dev/null +++ b/lib/private/PhpDumpCache.php @@ -0,0 +1,112 @@ +setTempDirectory($tempDirectory); + } + + /** + * Sets path to temporary directory. + */ + public function setTempDirectory(string $dir): static { + if (!is_dir($dir) && !@mkdir($dir, recursive: true) && !is_dir($dir)) { // @ - dir may already exist + throw new \RuntimeException("Unable to create directory '$dir'"); + } + $this->tempDirectory = $dir; + return $this; + } + + /** + * Loads class list from cache. + */ + public function loadCache(array $cacheKey): ?array { + $file = $this->generateCacheFileName($cacheKey); + + // Solving atomicity to work everywhere + // 1) We want to do as little as possible IO calls on production and also directory and file can be not writable (#19) + // so on Linux we include the file directly without shared lock, therefore, the file must be created atomically by renaming. + // 2) On Windows file cannot be renamed-to while is open (ie by include() #11), so we have to acquire a lock. + $lock = defined('PHP_WINDOWS_VERSION_BUILD') + ? $this->acquireLock("$file.lock", LOCK_SH) + : null; + + try { + $data = @include $file; // @ file may not exist + if (is_array($data)) { + return $data; + } + + return null; + } finally { + if ($lock) { + flock($lock, LOCK_UN); // release shared lock + } + } + } + + /** + * Writes class list to cache. + * @param ?resource $lock + */ + public function saveCache(array $cacheKey, array $data, $lock = null): void { + // we have to acquire a lock to be able safely rename file + // on Linux: that another thread does not rename the same named file earlier + // on Windows: that the file is not read by another thread + $file = $this->generateCacheFileName($cacheKey); + $lock = $lock ?: $this->acquireLock("$file.lock", LOCK_EX); + $code = "tempDirectory) { + throw new \LogicException('Set path to temporary directory using setTempDirectory().'); + } + + return $this->tempDirectory . '/' . md5(serialize($cacheKey)) . '.php'; + } +} diff --git a/lib/private/Server.php b/lib/private/Server.php index 7edd96f041440..0a1b8741703a2 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -322,6 +322,9 @@ public function __construct( $this->registerService(ContainerInterface::class, function (ContainerInterface $c) { return $c; }); + $this->registerService(\OC\PhpDumpCache::class, function (ContainerInterface $c) { + return new \OC\PhpDumpCache($c->get(SystemConfig::class)->getValue('cachedirectory', \OC::$SERVERROOT . '/cache')); + }); $this->registerDeprecatedAlias(IServerContainer::class, ContainerInterface::class); $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class); diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 39c067e57304f..a6728d3977c3b 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -7,6 +7,7 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ + use OC\App\AppManager; use OC\AppFramework\Bootstrap\Coordinator; use OC\Installer; @@ -110,27 +111,7 @@ public static function loadApp(string $app): void { * @internal */ public static function registerAutoloading(string $app, string $path, bool $force = false): void { - $key = $app . '-' . $path; - if (!$force && isset(self::$alreadyRegistered[$key])) { - return; - } - - self::$alreadyRegistered[$key] = true; - - // Register on PSR-4 composer autoloader - $appNamespace = Server::get(IAppManager::class)->getAppNamespace($app); - \OC::$server->registerNamespace($app, $appNamespace); - - if (file_exists($path . '/composer/autoload.php')) { - require_once $path . '/composer/autoload.php'; - } else { - \OC::$composerAutoloader->addPsr4($appNamespace . '\\', $path . '/lib/', true); - } - - // Register Test namespace only when testing - if (defined('PHPUNIT_RUN') || defined('CLI_TEST_RUN')) { - \OC::$composerAutoloader->addPsr4($appNamespace . '\\Tests\\', $path . '/tests/', true); - } + Server::get(AppManager::class)->registerAutoloading($app, $path, $force); } /** diff --git a/tests/Core/Command/Config/System/CastHelperTest.php b/tests/Core/Command/Config/System/CastHelperTest.php index c47c77ee9f827..d65382ba82b5d 100644 --- a/tests/Core/Command/Config/System/CastHelperTest.php +++ b/tests/Core/Command/Config/System/CastHelperTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Core\Command\Config\System; +namespace Tests\Core\Command\Config\System; use OC\Core\Command\Config\System\CastHelper; use Test\TestCase; diff --git a/tests/Core/Command/Group/AddTest.php b/tests/Core/Command/Group/AddTest.php index fc1406c77a6ba..52186411c5254 100644 --- a/tests/Core/Command/Group/AddTest.php +++ b/tests/Core/Command/Group/AddTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\Group; +namespace Tests\Core\Command\Group; use OC\Core\Command\Group\Add; use OCP\IGroup; diff --git a/tests/Core/Command/Group/AddUserTest.php b/tests/Core/Command/Group/AddUserTest.php index 8d31f7cdbc454..920e2994e3113 100644 --- a/tests/Core/Command/Group/AddUserTest.php +++ b/tests/Core/Command/Group/AddUserTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\Group; +namespace Tests\Core\Command\Group; use OC\Core\Command\Group\AddUser; use OCP\IGroup; diff --git a/tests/Core/Command/Group/DeleteTest.php b/tests/Core/Command/Group/DeleteTest.php index 92315c4daf475..1778ec817b3ed 100644 --- a/tests/Core/Command/Group/DeleteTest.php +++ b/tests/Core/Command/Group/DeleteTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\Group; +namespace Tests\Core\Command\Group; use OC\Core\Command\Group\Delete; use OCP\IGroup; diff --git a/tests/Core/Command/Group/InfoTest.php b/tests/Core/Command/Group/InfoTest.php index 8d9cb1c329181..70df2bd2b4160 100644 --- a/tests/Core/Command/Group/InfoTest.php +++ b/tests/Core/Command/Group/InfoTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\Group; +namespace Tests\Core\Command\Group; use OC\Core\Command\Group\Info; use OCP\IGroup; diff --git a/tests/Core/Command/Group/ListCommandTest.php b/tests/Core/Command/Group/ListCommandTest.php index 2885a6e44b051..99db782ad32c8 100644 --- a/tests/Core/Command/Group/ListCommandTest.php +++ b/tests/Core/Command/Group/ListCommandTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\Group; +namespace Tests\Core\Command\Group; use OC\Core\Command\Group\ListCommand; use OCP\IGroup; diff --git a/tests/Core/Command/Group/RemoveUserTest.php b/tests/Core/Command/Group/RemoveUserTest.php index 0c50152fe1a74..90ba3b3937a16 100644 --- a/tests/Core/Command/Group/RemoveUserTest.php +++ b/tests/Core/Command/Group/RemoveUserTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\Group; +namespace Tests\Core\Command\Group; use OC\Core\Command\Group\RemoveUser; use OCP\IGroup; diff --git a/tests/Core/Command/Preview/CleanupTest.php b/tests/Core/Command/Preview/CleanupTest.php index 6625e792695ca..f00b206ad4c9d 100644 --- a/tests/Core/Command/Preview/CleanupTest.php +++ b/tests/Core/Command/Preview/CleanupTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Core\Command\Preview; +namespace Tests\Core\Command\Preview; use OC\Core\Command\Preview\Cleanup; use OC\Preview\PreviewService; diff --git a/tests/Core/Command/SystemTag/AddTest.php b/tests/Core/Command/SystemTag/AddTest.php index f36bf6c9f14ba..0e4d21eca8bf9 100644 --- a/tests/Core/Command/SystemTag/AddTest.php +++ b/tests/Core/Command/SystemTag/AddTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\SystemTag; +namespace Tests\Core\Command\SystemTag; use OC\Core\Command\SystemTag\Add; use OCP\SystemTag\ISystemTag; diff --git a/tests/Core/Command/SystemTag/DeleteTest.php b/tests/Core/Command/SystemTag/DeleteTest.php index ee53c8b6d3bf7..5ab3a20ab1988 100644 --- a/tests/Core/Command/SystemTag/DeleteTest.php +++ b/tests/Core/Command/SystemTag/DeleteTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\SystemTag; +namespace Tests\Core\Command\SystemTag; use OC\Core\Command\SystemTag\Delete; use OCP\SystemTag\ISystemTagManager; diff --git a/tests/Core/Command/SystemTag/EditTest.php b/tests/Core/Command/SystemTag/EditTest.php index 6e87ff5f3e43b..d554c0c155938 100644 --- a/tests/Core/Command/SystemTag/EditTest.php +++ b/tests/Core/Command/SystemTag/EditTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\SystemTag; +namespace Tests\Core\Command\SystemTag; use OC\Core\Command\SystemTag\Edit; use OCP\SystemTag\ISystemTag; diff --git a/tests/Core/Command/SystemTag/ListCommandTest.php b/tests/Core/Command/SystemTag/ListCommandTest.php index 93f8ca458ad07..623e49133e6c6 100644 --- a/tests/Core/Command/SystemTag/ListCommandTest.php +++ b/tests/Core/Command/SystemTag/ListCommandTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\SystemTag; +namespace Tests\Core\Command\SystemTag; use OC\Core\Command\SystemTag\ListCommand; use OCP\SystemTag\ISystemTag; diff --git a/tests/Core/Command/TwoFactorAuth/CleanupTest.php b/tests/Core/Command/TwoFactorAuth/CleanupTest.php index 33d9a86f2c664..72436e90d391b 100644 --- a/tests/Core/Command/TwoFactorAuth/CleanupTest.php +++ b/tests/Core/Command/TwoFactorAuth/CleanupTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Core\Command\TwoFactorAuth; +namespace Tests\Core\Command\TwoFactorAuth; use OC\Core\Command\TwoFactorAuth\Cleanup; use OCP\Authentication\TwoFactorAuth\IRegistry; diff --git a/tests/Core/Command/TwoFactorAuth/DisableTest.php b/tests/Core/Command/TwoFactorAuth/DisableTest.php index ab5c3dd365bd9..4663d3785f7c6 100644 --- a/tests/Core/Command/TwoFactorAuth/DisableTest.php +++ b/tests/Core/Command/TwoFactorAuth/DisableTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\TwoFactorAuth; +namespace Tests\Core\Command\TwoFactorAuth; use OC\Authentication\TwoFactorAuth\ProviderManager; use OC\Core\Command\TwoFactorAuth\Disable; diff --git a/tests/Core/Command/TwoFactorAuth/EnableTest.php b/tests/Core/Command/TwoFactorAuth/EnableTest.php index 320782c039fc6..90859ffe1323b 100644 --- a/tests/Core/Command/TwoFactorAuth/EnableTest.php +++ b/tests/Core/Command/TwoFactorAuth/EnableTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Command\TwoFactorAuth; +namespace Tests\Core\Command\TwoFactorAuth; use OC\Authentication\TwoFactorAuth\ProviderManager; use OC\Core\Command\TwoFactorAuth\Enable; diff --git a/tests/Core/Command/TwoFactorAuth/StateTest.php b/tests/Core/Command/TwoFactorAuth/StateTest.php index da18a405478fa..cb1dff02ec0cc 100644 --- a/tests/Core/Command/TwoFactorAuth/StateTest.php +++ b/tests/Core/Command/TwoFactorAuth/StateTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Core\Command\TwoFactorAuth; +namespace Tests\Core\Command\TwoFactorAuth; use OC\Core\Command\TwoFactorAuth\State; use OCP\Authentication\TwoFactorAuth\IRegistry; diff --git a/tests/Core/Command/User/AddTest.php b/tests/Core/Command/User/AddTest.php index 43b7aaea55601..7f76b8931e0cc 100644 --- a/tests/Core/Command/User/AddTest.php +++ b/tests/Core/Command/User/AddTest.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace Core\Command\User; +namespace Tests\Core\Command\User; use OC\Core\Command\User\Add; use OCA\Settings\Mailer\NewUserMailHelper; diff --git a/tests/Core/Command/User/ProfileTest.php b/tests/Core/Command/User/ProfileTest.php index 5ebbd9182a3a2..d967fc0b1281e 100644 --- a/tests/Core/Command/User/ProfileTest.php +++ b/tests/Core/Command/User/ProfileTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Core\Command\User; +namespace Tests\Core\Command\User; use OC\Core\Command\User\Profile; use OCP\Accounts\IAccount; diff --git a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php index d20dde5fe29a8..6a2a27b7cee13 100644 --- a/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginV2ControllerTest.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Controller; +namespace Tests\Core\Controller; use OC\Core\Controller\ClientFlowLoginV2Controller; use OC\Core\Data\LoginFlowV2Credentials; diff --git a/tests/Core/Controller/ContactsMenuControllerTest.php b/tests/Core/Controller/ContactsMenuControllerTest.php index c06086bce24c4..0f8bc3814f977 100644 --- a/tests/Core/Controller/ContactsMenuControllerTest.php +++ b/tests/Core/Controller/ContactsMenuControllerTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Controller; +namespace Tests\Core\Controller; use OC\Contacts\ContactsMenu\Manager; use OC\Core\Controller\ContactsMenuController; diff --git a/tests/Core/Controller/GuestAvatarControllerTest.php b/tests/Core/Controller/GuestAvatarControllerTest.php index 0626f0198fdaf..6c83ffbe40981 100644 --- a/tests/Core/Controller/GuestAvatarControllerTest.php +++ b/tests/Core/Controller/GuestAvatarControllerTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Core\Controller; +namespace Tests\Core\Controller; use OC\Core\Controller\GuestAvatarController; use OCP\AppFramework\Http\FileDisplayResponse; diff --git a/tests/Core/Controller/OCSControllerTest.php b/tests/Core/Controller/OCSControllerTest.php index fac18e344920c..cd87fa458df21 100644 --- a/tests/Core/Controller/OCSControllerTest.php +++ b/tests/Core/Controller/OCSControllerTest.php @@ -6,9 +6,10 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace OC\Core\Controller; +namespace Tests\Core\Controller; use OC\CapabilitiesManager; +use OC\Core\Controller\OCSController; use OC\Security\IdentityProof\Key; use OC\Security\IdentityProof\Manager; use OCP\AppFramework\Http\DataResponse; diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php index 2d47f7d651954..a7492be300f22 100644 --- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php +++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Test\Core\Controller; +namespace Tests\Core\Controller; use OC\Authentication\TwoFactorAuth\Manager; use OC\Authentication\TwoFactorAuth\ProviderSet; diff --git a/tests/Core/Controller/UserControllerTest.php b/tests/Core/Controller/UserControllerTest.php index 4f0380f6b96d8..90aca5c7ab78d 100644 --- a/tests/Core/Controller/UserControllerTest.php +++ b/tests/Core/Controller/UserControllerTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\Core\Controller; +namespace Tests\Core\Controller; use OC\Core\Controller\UserController; use OCP\AppFramework\Http\JSONResponse; diff --git a/tests/Core/Middleware/TwoFactorMiddlewareTest.php b/tests/Core/Middleware/TwoFactorMiddlewareTest.php index 46b4afaff0a44..6fb53ea174447 100644 --- a/tests/Core/Middleware/TwoFactorMiddlewareTest.php +++ b/tests/Core/Middleware/TwoFactorMiddlewareTest.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Test\Core\Middleware; +namespace Tests\Core\Middleware; use OC\AppFramework\Http\Attributes\TwoFactorSetUpDoneRequired; use OC\AppFramework\Http\Request; diff --git a/tests/autoload.php b/tests/autoload.php index 05fc38529242f..c25319e45f381 100644 --- a/tests/autoload.php +++ b/tests/autoload.php @@ -13,4 +13,5 @@ * This is a file that applications can require to be able to autoload the class Test\TestCase from Nextcloud tests */ -\OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true); +\OC::$autoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/'); +\OC::$autoloader->triggerReload(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1fb54344d4978..8db9c6fca81cc 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -21,7 +21,7 @@ require_once __DIR__ . '/../lib/base.php'; require_once __DIR__ . '/autoload.php'; -\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/', true); +\OC::$autoloader->addPsr4('Tests\\Core', OC::$SERVERROOT . '/tests/Core'); $dontLoadApps = getenv('TEST_DONT_LOAD_APPS'); if (!$dontLoadApps) { diff --git a/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php index f1d38c10801c1..0b8da3bfd1eeb 100644 --- a/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/EnforcementStateTest.php @@ -12,7 +12,7 @@ * Time: 13:01 */ -namespace Tests\Authentication\TwoFactorAuth; +namespace Test\Authentication\TwoFactorAuth; use OC\Authentication\TwoFactorAuth\EnforcementState; use Test\TestCase; diff --git a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php index cfbb701414c93..5b24a4a25b1b9 100644 --- a/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/MandatoryTwoFactorTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Authentication\TwoFactorAuth; +namespace Test\Authentication\TwoFactorAuth; use OC\Authentication\TwoFactorAuth\EnforcementState; use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor; diff --git a/tests/lib/Config/LexiconTest.php b/tests/lib/Config/LexiconTest.php index c3ead6240b5f4..83ec9ca207482 100644 --- a/tests/lib/Config/LexiconTest.php +++ b/tests/lib/Config/LexiconTest.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Tests\lib\Config; +namespace Test\Config; use OC\AppConfig; use OC\AppFramework\Bootstrap\Coordinator; diff --git a/tests/lib/Config/TestConfigLexicon_I.php b/tests/lib/Config/TestConfigLexicon_I.php index a7fb9e6d568ff..390157418250d 100644 --- a/tests/lib/Config/TestConfigLexicon_I.php +++ b/tests/lib/Config/TestConfigLexicon_I.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Tests\lib\Config; +namespace Test\Config; use OCP\Config\IUserConfig; use OCP\Config\Lexicon\Entry; diff --git a/tests/lib/Config/TestLexicon_E.php b/tests/lib/Config/TestLexicon_E.php index b3992e72d8e73..62deb8c742e3a 100644 --- a/tests/lib/Config/TestLexicon_E.php +++ b/tests/lib/Config/TestLexicon_E.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Tests\lib\Config; +namespace Test\Config; use OCP\Config\IUserConfig; use OCP\Config\Lexicon\Entry; diff --git a/tests/lib/Config/TestLexicon_N.php b/tests/lib/Config/TestLexicon_N.php index aee68db5032a7..1ce4eac3550e9 100644 --- a/tests/lib/Config/TestLexicon_N.php +++ b/tests/lib/Config/TestLexicon_N.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Tests\lib\Config; +namespace Test\Config; use OCP\Config\IUserConfig; use OCP\Config\Lexicon\Entry; diff --git a/tests/lib/Config/TestLexicon_UserIndexed.php b/tests/lib/Config/TestLexicon_UserIndexed.php index e876b834585f8..7b4ea3c0e2999 100644 --- a/tests/lib/Config/TestLexicon_UserIndexed.php +++ b/tests/lib/Config/TestLexicon_UserIndexed.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Tests\lib\Config; +namespace Test\Config; use OCP\Config\IUserConfig; use OCP\Config\Lexicon\Entry; diff --git a/tests/lib/Config/TestLexicon_UserIndexedRemove.php b/tests/lib/Config/TestLexicon_UserIndexedRemove.php index 5cb326d364625..b4a163ed164b9 100644 --- a/tests/lib/Config/TestLexicon_UserIndexedRemove.php +++ b/tests/lib/Config/TestLexicon_UserIndexedRemove.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Tests\lib\Config; +namespace Test\Config; use OCP\Config\Lexicon\Entry; use OCP\Config\Lexicon\ILexicon; diff --git a/tests/lib/Config/TestLexicon_W.php b/tests/lib/Config/TestLexicon_W.php index f945bd4bba510..c420cc85ad488 100644 --- a/tests/lib/Config/TestLexicon_W.php +++ b/tests/lib/Config/TestLexicon_W.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Tests\lib\Config; +namespace Test\Config; use OCP\Config\IUserConfig; use OCP\Config\Lexicon\Entry; diff --git a/tests/lib/Config/UserConfigMigrationFallbackTest.php b/tests/lib/Config/UserConfigMigrationFallbackTest.php index 3d7232c429a32..22a091015061e 100644 --- a/tests/lib/Config/UserConfigMigrationFallbackTest.php +++ b/tests/lib/Config/UserConfigMigrationFallbackTest.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Test\lib\Config; +namespace Test\Config; use Doctrine\DBAL\Exception\InvalidFieldNameException; use OC\Config\ConfigManager; diff --git a/tests/lib/Config/UserConfigTest.php b/tests/lib/Config/UserConfigTest.php index 7d0feb84f14c0..aecd513b7d4ce 100644 --- a/tests/lib/Config/UserConfigTest.php +++ b/tests/lib/Config/UserConfigTest.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -namespace Test\lib\Config; +namespace Test\Config; use OC\Config\ConfigManager; use OC\Config\PresetManager; diff --git a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php index 8b939928d8609..0a0754bea1000 100644 --- a/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php +++ b/tests/lib/Contacts/ContactsMenu/ActionFactoryTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Contacts\ContactsMenu; +namespace Test\Contacts\ContactsMenu; use OC\Contacts\ContactsMenu\ActionFactory; use OCP\Contacts\ContactsMenu\IAction; diff --git a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php index 08afc6e930786..dfa03a003a82b 100644 --- a/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php +++ b/tests/lib/Contacts/ContactsMenu/ActionProviderStoreTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Contacts\ContactsMenu; +namespace Test\Contacts\ContactsMenu; use OC\App\AppManager; use OC\Contacts\ContactsMenu\ActionProviderStore; diff --git a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php index b2a9ecb362fb6..f0d11a44a11f9 100644 --- a/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php +++ b/tests/lib/Contacts/ContactsMenu/Actions/LinkActionTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Contacts\ContactsMenu\Actions; +namespace Test\Contacts\ContactsMenu\Actions; use OC\Contacts\ContactsMenu\Actions\LinkAction; use Test\TestCase; diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php index f8faa2b17f966..645167c28d293 100644 --- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php +++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Contacts\ContactsMenu; +namespace Test\Contacts\ContactsMenu; use OC\Contacts\ContactsMenu\ContactsStore; use OC\KnownUser\KnownUserService; diff --git a/tests/lib/Contacts/ContactsMenu/EntryTest.php b/tests/lib/Contacts/ContactsMenu/EntryTest.php index c0f07f7bf3b00..8f38469d38416 100644 --- a/tests/lib/Contacts/ContactsMenu/EntryTest.php +++ b/tests/lib/Contacts/ContactsMenu/EntryTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Contacts\ContactsMenu; +namespace Test\Contacts\ContactsMenu; use OC\Contacts\ContactsMenu\Actions\LinkAction; use OC\Contacts\ContactsMenu\Entry; diff --git a/tests/lib/Contacts/ContactsMenu/ManagerTest.php b/tests/lib/Contacts/ContactsMenu/ManagerTest.php index dfa37dd926ec5..0d66cea061860 100644 --- a/tests/lib/Contacts/ContactsMenu/ManagerTest.php +++ b/tests/lib/Contacts/ContactsMenu/ManagerTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Contacts\ContactsMenu; +namespace Test\Contacts\ContactsMenu; use OC\Contacts\ContactsMenu\ActionProviderStore; use OC\Contacts\ContactsMenu\ContactsStore; diff --git a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php index 36ce0b96540f3..59cd08e7fa706 100644 --- a/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php +++ b/tests/lib/Contacts/ContactsMenu/Providers/EMailproviderTest.php @@ -5,7 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Contacts\ContactsMenu\Providers; +namespace Test\Contacts\ContactsMenu\Providers; use OC\Contacts\ContactsMenu\Providers\EMailProvider; use OCP\Contacts\ContactsMenu\IActionFactory; diff --git a/tests/lib/Http/WellKnown/GenericResponseTest.php b/tests/lib/Http/WellKnown/GenericResponseTest.php index f35f43221b8ce..2e74569a43469 100644 --- a/tests/lib/Http/WellKnown/GenericResponseTest.php +++ b/tests/lib/Http/WellKnown/GenericResponseTest.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace Tests\Http\WellKnown; +namespace Test\Http\WellKnown; use OCP\AppFramework\Http\JSONResponse; use OCP\Http\WellKnown\GenericResponse;