aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php3
-rw-r--r--lib/composer/composer/autoload_static.php3
-rw-r--r--lib/l10n/ja.js2
-rw-r--r--lib/l10n/ja.json2
-rw-r--r--lib/l10n/pt_BR.js6
-rw-r--r--lib/l10n/pt_BR.json6
-rw-r--r--lib/private/AppFramework/Routing/RouteConfig.php279
-rw-r--r--lib/private/AppFramework/Routing/RouteParser.php4
-rw-r--r--lib/private/Files/Cache/Cache.php2
-rw-r--r--lib/private/Installer.php45
-rw-r--r--lib/private/Preview/Generator.php2
-rw-r--r--lib/private/Route/Router.php2
-rw-r--r--lib/private/legacy/OC_App.php22
-rw-r--r--lib/private/legacy/OC_Helper.php65
-rw-r--r--lib/public/AppFramework/ApiController.php5
-rw-r--r--lib/public/AppFramework/App.php38
-rw-r--r--lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php3
-rw-r--r--lib/public/AppFramework/Http/Response.php7
-rw-r--r--lib/public/Color.php2
-rw-r--r--lib/public/Defaults.php2
-rw-r--r--lib/public/Diagnostics/IQueryLogger.php2
-rw-r--r--lib/public/EventDispatcher/GenericEvent.php4
-rw-r--r--lib/public/Files.php16
-rw-r--r--lib/public/Files_FullTextSearch/Model/AFilesDocument.php2
-rw-r--r--lib/public/L10N/ILanguageIterator.php10
-rw-r--r--lib/public/Mail/IMailer.php2
-rw-r--r--lib/public/Profiler/IProfile.php2
-rw-r--r--lib/public/Security/ICrypto.php4
-rw-r--r--lib/public/Security/IHasher.php4
-rw-r--r--lib/public/Security/ISecureRandom.php2
-rw-r--r--lib/public/Util.php66
31 files changed, 157 insertions, 457 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 856afbe5677..c0c086e4038 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -1034,7 +1034,6 @@ return array(
'OC\\AppFramework\\OCS\\V1Response' => $baseDir . '/lib/private/AppFramework/OCS/V1Response.php',
'OC\\AppFramework\\OCS\\V2Response' => $baseDir . '/lib/private/AppFramework/OCS/V2Response.php',
'OC\\AppFramework\\Routing\\RouteActionHandler' => $baseDir . '/lib/private/AppFramework/Routing/RouteActionHandler.php',
- 'OC\\AppFramework\\Routing\\RouteConfig' => $baseDir . '/lib/private/AppFramework/Routing/RouteConfig.php',
'OC\\AppFramework\\Routing\\RouteParser' => $baseDir . '/lib/private/AppFramework/Routing/RouteParser.php',
'OC\\AppFramework\\ScopedPsrLogger' => $baseDir . '/lib/private/AppFramework/ScopedPsrLogger.php',
'OC\\AppFramework\\Services\\AppConfig' => $baseDir . '/lib/private/AppFramework/Services/AppConfig.php',
@@ -1266,6 +1265,8 @@ return array(
'OC\\Core\\Command\\Info\\File' => $baseDir . '/core/Command/Info/File.php',
'OC\\Core\\Command\\Info\\FileUtils' => $baseDir . '/core/Command/Info/FileUtils.php',
'OC\\Core\\Command\\Info\\Space' => $baseDir . '/core/Command/Info/Space.php',
+ 'OC\\Core\\Command\\Info\\Storage' => $baseDir . '/core/Command/Info/Storage.php',
+ 'OC\\Core\\Command\\Info\\Storages' => $baseDir . '/core/Command/Info/Storages.php',
'OC\\Core\\Command\\Integrity\\CheckApp' => $baseDir . '/core/Command/Integrity/CheckApp.php',
'OC\\Core\\Command\\Integrity\\CheckCore' => $baseDir . '/core/Command/Integrity/CheckCore.php',
'OC\\Core\\Command\\Integrity\\SignApp' => $baseDir . '/core/Command/Integrity/SignApp.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index fed9723421e..f2f817877d2 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -1075,7 +1075,6 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\AppFramework\\OCS\\V1Response' => __DIR__ . '/../../..' . '/lib/private/AppFramework/OCS/V1Response.php',
'OC\\AppFramework\\OCS\\V2Response' => __DIR__ . '/../../..' . '/lib/private/AppFramework/OCS/V2Response.php',
'OC\\AppFramework\\Routing\\RouteActionHandler' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Routing/RouteActionHandler.php',
- 'OC\\AppFramework\\Routing\\RouteConfig' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Routing/RouteConfig.php',
'OC\\AppFramework\\Routing\\RouteParser' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Routing/RouteParser.php',
'OC\\AppFramework\\ScopedPsrLogger' => __DIR__ . '/../../..' . '/lib/private/AppFramework/ScopedPsrLogger.php',
'OC\\AppFramework\\Services\\AppConfig' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Services/AppConfig.php',
@@ -1307,6 +1306,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OC\\Core\\Command\\Info\\File' => __DIR__ . '/../../..' . '/core/Command/Info/File.php',
'OC\\Core\\Command\\Info\\FileUtils' => __DIR__ . '/../../..' . '/core/Command/Info/FileUtils.php',
'OC\\Core\\Command\\Info\\Space' => __DIR__ . '/../../..' . '/core/Command/Info/Space.php',
+ 'OC\\Core\\Command\\Info\\Storage' => __DIR__ . '/../../..' . '/core/Command/Info/Storage.php',
+ 'OC\\Core\\Command\\Info\\Storages' => __DIR__ . '/../../..' . '/core/Command/Info/Storages.php',
'OC\\Core\\Command\\Integrity\\CheckApp' => __DIR__ . '/../../..' . '/core/Command/Integrity/CheckApp.php',
'OC\\Core\\Command\\Integrity\\CheckCore' => __DIR__ . '/../../..' . '/core/Command/Integrity/CheckCore.php',
'OC\\Core\\Command\\Integrity\\SignApp' => __DIR__ . '/../../..' . '/core/Command/Integrity/SignApp.php',
diff --git a/lib/l10n/ja.js b/lib/l10n/ja.js
index 820aec1a2ba..06aad919ff3 100644
--- a/lib/l10n/ja.js
+++ b/lib/l10n/ja.js
@@ -93,6 +93,8 @@ OC.L10N.register(
"Destination does not exist" : "宛先が存在しません",
"Destination is not creatable" : "宛先は作成できません",
"Dot files are not allowed" : "隠しファイルは許可されていません",
+ "%1$s (renamed)" : "%1$s (リネーム済み)",
+ "renamed file" : "リネーム済みファイル",
"\"%1$s\" is a forbidden file or folder name." : "\"%1$s\"は禁止されているファイル名またはフォルダー名です。",
"\"%1$s\" is a forbidden prefix for file or folder names." : "\"%1$s\"は、ファイル名やフォルダー名には使用できない接頭辞です。",
"\"%1$s\" is not allowed inside a file or folder name." : "\"%1$s\"はファイル名やフォルダー名の中に入れることはできません。",
diff --git a/lib/l10n/ja.json b/lib/l10n/ja.json
index 04f6e2ee13d..f0328f6d484 100644
--- a/lib/l10n/ja.json
+++ b/lib/l10n/ja.json
@@ -91,6 +91,8 @@
"Destination does not exist" : "宛先が存在しません",
"Destination is not creatable" : "宛先は作成できません",
"Dot files are not allowed" : "隠しファイルは許可されていません",
+ "%1$s (renamed)" : "%1$s (リネーム済み)",
+ "renamed file" : "リネーム済みファイル",
"\"%1$s\" is a forbidden file or folder name." : "\"%1$s\"は禁止されているファイル名またはフォルダー名です。",
"\"%1$s\" is a forbidden prefix for file or folder names." : "\"%1$s\"は、ファイル名やフォルダー名には使用できない接頭辞です。",
"\"%1$s\" is not allowed inside a file or folder name." : "\"%1$s\"はファイル名やフォルダー名の中に入れることはできません。",
diff --git a/lib/l10n/pt_BR.js b/lib/l10n/pt_BR.js
index bf7f7728be6..4b6c3ae36b7 100644
--- a/lib/l10n/pt_BR.js
+++ b/lib/l10n/pt_BR.js
@@ -306,7 +306,7 @@ OC.L10N.register(
"This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Isso provavelmente é causado por um cache/acelerador, como Zend OPcache ou eAccelerator.",
"PHP modules have been installed, but they are still listed as missing?" : "Módulos do PHP foram instalados, mas eles ainda estão listados como faltantes?",
"Please ask your server administrator to restart the web server." : "Por favor peça ao administrador do servidor para reiniciar o servidor web.",
- "The required %s config variable is not configured in the config.php file." : "A variável %s de configuração necessária não está configurada no arquivo config.php.",
+ "The required %s config variable is not configured in the config.php file." : "A variável de configuração %s obrigatória não está configurada no arquivo config.php.",
"Please ask your server administrator to check the Nextcloud configuration." : "Peça ao administrador do servidor para verificar a configuração do Nextcloud.",
"Your data directory is readable by other people." : "Seu diretório de dados pode ser lido por outras pessoas.",
"Please change the permissions to 0770 so that the directory cannot be listed by other people." : "Altere as permissões para 0770 para que o diretório não possa ser listado por outras pessoas.",
@@ -400,12 +400,12 @@ OC.L10N.register(
"Tool calls" : "Chamadas de ferramentas",
"Tools call instructions from the model in JSON format" : "Instruções de chamada de ferramentas do modelo no formato JSON",
"Formalize text" : "Formalizar texto",
- "Takes a text and makes it sound more formal" : "Pega um texto e faz com que ele soe mais formal",
+ "Takes a text and makes it sound more formal" : "Pega um texto e o faz parecer mais formal",
"Write a text that you want the assistant to formalize" : "Escreva um texto que você deseja que o assistente formalize",
"Formalized text" : "Texto formalizado",
"The formalized text" : "O texto formalizado",
"Generate a headline" : "Gere um título",
- "Generates a possible headline for a text." : "Gera um título possível para um texto.",
+ "Generates a possible headline for a text." : "Gera um possível título para um texto.",
"Original text" : "Texto original",
"The original text to generate a headline for" : "O texto original para gerar um título para",
"The generated headline" : "O título gerado",
diff --git a/lib/l10n/pt_BR.json b/lib/l10n/pt_BR.json
index ad7df10df2b..47f04ec37db 100644
--- a/lib/l10n/pt_BR.json
+++ b/lib/l10n/pt_BR.json
@@ -304,7 +304,7 @@
"This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator." : "Isso provavelmente é causado por um cache/acelerador, como Zend OPcache ou eAccelerator.",
"PHP modules have been installed, but they are still listed as missing?" : "Módulos do PHP foram instalados, mas eles ainda estão listados como faltantes?",
"Please ask your server administrator to restart the web server." : "Por favor peça ao administrador do servidor para reiniciar o servidor web.",
- "The required %s config variable is not configured in the config.php file." : "A variável %s de configuração necessária não está configurada no arquivo config.php.",
+ "The required %s config variable is not configured in the config.php file." : "A variável de configuração %s obrigatória não está configurada no arquivo config.php.",
"Please ask your server administrator to check the Nextcloud configuration." : "Peça ao administrador do servidor para verificar a configuração do Nextcloud.",
"Your data directory is readable by other people." : "Seu diretório de dados pode ser lido por outras pessoas.",
"Please change the permissions to 0770 so that the directory cannot be listed by other people." : "Altere as permissões para 0770 para que o diretório não possa ser listado por outras pessoas.",
@@ -398,12 +398,12 @@
"Tool calls" : "Chamadas de ferramentas",
"Tools call instructions from the model in JSON format" : "Instruções de chamada de ferramentas do modelo no formato JSON",
"Formalize text" : "Formalizar texto",
- "Takes a text and makes it sound more formal" : "Pega um texto e faz com que ele soe mais formal",
+ "Takes a text and makes it sound more formal" : "Pega um texto e o faz parecer mais formal",
"Write a text that you want the assistant to formalize" : "Escreva um texto que você deseja que o assistente formalize",
"Formalized text" : "Texto formalizado",
"The formalized text" : "O texto formalizado",
"Generate a headline" : "Gere um título",
- "Generates a possible headline for a text." : "Gera um título possível para um texto.",
+ "Generates a possible headline for a text." : "Gera um possível título para um texto.",
"Original text" : "Texto original",
"The original text to generate a headline for" : "O texto original para gerar um título para",
"The generated headline" : "O título gerado",
diff --git a/lib/private/AppFramework/Routing/RouteConfig.php b/lib/private/AppFramework/Routing/RouteConfig.php
deleted file mode 100644
index 2b7f21a8ba5..00000000000
--- a/lib/private/AppFramework/Routing/RouteConfig.php
+++ /dev/null
@@ -1,279 +0,0 @@
-<?php
-
-declare(strict_types=1);
-/**
- * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
- * SPDX-License-Identifier: AGPL-3.0-only
- */
-namespace OC\AppFramework\Routing;
-
-use OC\AppFramework\DependencyInjection\DIContainer;
-use OC\Route\Router;
-
-/**
- * Class RouteConfig
- * @package OC\AppFramework\routing
- */
-class RouteConfig {
- /** @var DIContainer */
- private $container;
-
- /** @var Router */
- private $router;
-
- /** @var array */
- private $routes;
-
- /** @var string */
- private $appName;
-
- /** @var string[] */
- private $controllerNameCache = [];
-
- protected $rootUrlApps = [
- 'cloud_federation_api',
- 'core',
- 'files_sharing',
- 'files',
- 'profile',
- 'settings',
- 'spreed',
- ];
-
- /**
- * @param \OC\AppFramework\DependencyInjection\DIContainer $container
- * @param \OC\Route\Router $router
- * @param array $routes
- * @internal param $appName
- */
- public function __construct(DIContainer $container, Router $router, $routes) {
- $this->routes = $routes;
- $this->container = $container;
- $this->router = $router;
- $this->appName = $container['AppName'];
- }
-
- /**
- * The routes and resource will be registered to the \OCP\Route\IRouter
- */
- public function register() {
- // parse simple
- $this->processIndexRoutes($this->routes);
-
- // parse resources
- $this->processIndexResources($this->routes);
-
- /*
- * OCS routes go into a different collection
- */
- $oldCollection = $this->router->getCurrentCollection();
- $this->router->useCollection($oldCollection . '.ocs');
-
- // parse ocs simple routes
- $this->processOCS($this->routes);
-
- // parse ocs simple routes
- $this->processOCSResources($this->routes);
-
- $this->router->useCollection($oldCollection);
- }
-
- private function processOCS(array $routes): void {
- $ocsRoutes = $routes['ocs'] ?? [];
- foreach ($ocsRoutes as $ocsRoute) {
- $this->processRoute($ocsRoute, 'ocs.');
- }
- }
-
- /**
- * Creates one route base on the give configuration
- * @param array $routes
- * @throws \UnexpectedValueException
- */
- private function processIndexRoutes(array $routes): void {
- $simpleRoutes = $routes['routes'] ?? [];
- foreach ($simpleRoutes as $simpleRoute) {
- $this->processRoute($simpleRoute);
- }
- }
-
- protected function processRoute(array $route, string $routeNamePrefix = ''): void {
- $name = $route['name'];
- $postfix = $route['postfix'] ?? '';
- $root = $this->buildRootPrefix($route, $routeNamePrefix);
-
- $url = $root . '/' . ltrim($route['url'], '/');
- $verb = strtoupper($route['verb'] ?? 'GET');
-
- $split = explode('#', $name, 2);
- if (count($split) !== 2) {
- throw new \UnexpectedValueException('Invalid route name: use the format foo#bar to reference FooController::bar');
- }
- [$controller, $action] = $split;
-
- $controllerName = $this->buildControllerName($controller);
- $actionName = $this->buildActionName($action);
-
- /*
- * The route name has to be lowercase, for symfony to match it correctly.
- * This is required because smyfony allows mixed casing for controller names in the routes.
- * To avoid breaking all the existing route names, registering and matching will only use the lowercase names.
- * This is also safe on the PHP side because class and method names collide regardless of the casing.
- */
- $routeName = strtolower($routeNamePrefix . $this->appName . '.' . $controller . '.' . $action . $postfix);
-
- $router = $this->router->create($routeName, $url)
- ->method($verb);
-
- // optionally register requirements for route. This is used to
- // tell the route parser how url parameters should be matched
- if (array_key_exists('requirements', $route)) {
- $router->requirements($route['requirements']);
- }
-
- // optionally register defaults for route. This is used to
- // tell the route parser how url parameters should be default valued
- $defaults = [];
- if (array_key_exists('defaults', $route)) {
- $defaults = $route['defaults'];
- }
-
- $defaults['caller'] = [$this->appName, $controllerName, $actionName];
- $router->defaults($defaults);
- }
-
- /**
- * For a given name and url restful OCS routes are created:
- * - index
- * - show
- * - create
- * - update
- * - destroy
- *
- * @param array $routes
- */
- private function processOCSResources(array $routes): void {
- $this->processResources($routes['ocs-resources'] ?? [], 'ocs.');
- }
-
- /**
- * For a given name and url restful routes are created:
- * - index
- * - show
- * - create
- * - update
- * - destroy
- *
- * @param array $routes
- */
- private function processIndexResources(array $routes): void {
- $this->processResources($routes['resources'] ?? []);
- }
-
- /**
- * For a given name and url restful routes are created:
- * - index
- * - show
- * - create
- * - update
- * - destroy
- *
- * @param array $resources
- * @param string $routeNamePrefix
- */
- protected function processResources(array $resources, string $routeNamePrefix = ''): void {
- // declaration of all restful actions
- $actions = [
- ['name' => 'index', 'verb' => 'GET', 'on-collection' => true],
- ['name' => 'show', 'verb' => 'GET'],
- ['name' => 'create', 'verb' => 'POST', 'on-collection' => true],
- ['name' => 'update', 'verb' => 'PUT'],
- ['name' => 'destroy', 'verb' => 'DELETE'],
- ];
-
- foreach ($resources as $resource => $config) {
- $root = $this->buildRootPrefix($config, $routeNamePrefix);
-
- // the url parameter used as id to the resource
- foreach ($actions as $action) {
- $url = $root . '/' . ltrim($config['url'], '/');
- $method = $action['name'];
-
- $verb = strtoupper($action['verb'] ?? 'GET');
- $collectionAction = $action['on-collection'] ?? false;
- if (!$collectionAction) {
- $url .= '/{id}';
- }
- if (isset($action['url-postfix'])) {
- $url .= '/' . $action['url-postfix'];
- }
-
- $controller = $resource;
-
- $controllerName = $this->buildControllerName($controller);
- $actionName = $this->buildActionName($method);
-
- $routeName = $routeNamePrefix . $this->appName . '.' . strtolower($resource) . '.' . $method;
-
- $route = $this->router->create($routeName, $url)
- ->method($verb);
-
- $route->defaults(['caller' => [$this->appName, $controllerName, $actionName]]);
- }
- }
- }
-
- private function buildRootPrefix(array $route, string $routeNamePrefix): string {
- $defaultRoot = $this->appName === 'core' ? '' : '/apps/' . $this->appName;
- $root = $route['root'] ?? $defaultRoot;
-
- if ($routeNamePrefix !== '') {
- // In OCS all apps are whitelisted
- return $root;
- }
-
- if (!\in_array($this->appName, $this->rootUrlApps, true)) {
- // Only allow root URLS for some apps
- return $defaultRoot;
- }
-
- return $root;
- }
-
- /**
- * Based on a given route name the controller name is generated
- * @param string $controller
- * @return string
- */
- private function buildControllerName(string $controller): string {
- if (!isset($this->controllerNameCache[$controller])) {
- $this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller';
- }
- return $this->controllerNameCache[$controller];
- }
-
- /**
- * Based on the action part of the route name the controller method name is generated
- * @param string $action
- * @return string
- */
- private function buildActionName(string $action): string {
- return $this->underScoreToCamelCase($action);
- }
-
- /**
- * Underscored strings are converted to camel case strings
- * @param string $str
- * @return string
- */
- private function underScoreToCamelCase(string $str): string {
- $pattern = '/_[a-z]?/';
- return preg_replace_callback(
- $pattern,
- function ($matches) {
- return strtoupper(ltrim($matches[0], '_'));
- },
- $str);
- }
-}
diff --git a/lib/private/AppFramework/Routing/RouteParser.php b/lib/private/AppFramework/Routing/RouteParser.php
index 894a74c727b..55e58234673 100644
--- a/lib/private/AppFramework/Routing/RouteParser.php
+++ b/lib/private/AppFramework/Routing/RouteParser.php
@@ -76,7 +76,7 @@ class RouteParser {
$url = $root . '/' . ltrim($route['url'], '/');
$verb = strtoupper($route['verb'] ?? 'GET');
- $split = explode('#', $name, 2);
+ $split = explode('#', $name, 3);
if (count($split) !== 2) {
throw new \UnexpectedValueException('Invalid route name: use the format foo#bar to reference FooController::bar');
}
@@ -87,7 +87,7 @@ class RouteParser {
/*
* The route name has to be lowercase, for symfony to match it correctly.
- * This is required because smyfony allows mixed casing for controller names in the routes.
+ * This is required because symfony allows mixed casing for controller names in the routes.
* To avoid breaking all the existing route names, registering and matching will only use the lowercase names.
* This is also safe on the PHP side because class and method names collide regardless of the casing.
*/
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 2c190720c23..cb160115851 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -663,7 +663,7 @@ class Cache implements ICache {
$sourceData = $sourceCache->get($sourcePath);
if (!$sourceData) {
- throw new \Exception('Invalid source storage path: ' . $sourcePath);
+ throw new \Exception('Source path not found in cache: ' . $sourcePath);
}
$shardDefinition = $this->connection->getShardDefinition('filecache');
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index a1d27c9255b..f32b0e5919a 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -16,8 +16,8 @@ use OC\AppFramework\Bootstrap\Coordinator;
use OC\Archive\TAR;
use OC\DB\Connection;
use OC\DB\MigrationService;
+use OC\Files\FilenameValidator;
use OC_App;
-use OC_Helper;
use OCP\App\IAppManager;
use OCP\Files;
use OCP\HintException;
@@ -25,6 +25,7 @@ use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\ITempManager;
use OCP\Migration\IOutput;
+use OCP\Server;
use phpseclib\File\X509;
use Psr\Log\LoggerInterface;
@@ -242,6 +243,10 @@ class Installer {
// Download the release
$tempFile = $this->tempManager->getTemporaryFile('.tar.gz');
+ if ($tempFile === false) {
+ throw new \RuntimeException('Could not create temporary file for downloading app archive.');
+ }
+
$timeout = $this->isCLI ? 0 : 120;
$client = $this->clientService->newClient();
$client->get($app['releases'][0]['download'], ['sink' => $tempFile, 'timeout' => $timeout]);
@@ -253,8 +258,11 @@ class Installer {
if ($verified === true) {
// Seems to match, let's proceed
$extractDir = $this->tempManager->getTemporaryFolder();
- $archive = new TAR($tempFile);
+ if ($extractDir === false) {
+ throw new \RuntimeException('Could not create temporary directory for unpacking app.');
+ }
+ $archive = new TAR($tempFile);
if (!$archive->extract($extractDir)) {
$errorMessage = 'Could not extract app ' . $appId;
@@ -329,9 +337,9 @@ class Installer {
// Move to app folder
if (@mkdir($baseDir)) {
$extractDir .= '/' . $folders[0];
- OC_Helper::copyr($extractDir, $baseDir);
}
- OC_Helper::copyr($extractDir, $baseDir);
+ // otherwise we just copy the outer directory
+ $this->copyRecursive($extractDir, $baseDir);
Files::rmdirr($extractDir);
return;
}
@@ -588,4 +596,33 @@ class Installer {
include $script;
}
}
+
+ /**
+ * Recursive copying of local folders.
+ *
+ * @param string $src source folder
+ * @param string $dest target folder
+ */
+ private function copyRecursive(string $src, string $dest): void {
+ if (!file_exists($src)) {
+ return;
+ }
+
+ if (is_dir($src)) {
+ if (!is_dir($dest)) {
+ mkdir($dest);
+ }
+ $files = scandir($src);
+ foreach ($files as $file) {
+ if ($file != '.' && $file != '..') {
+ $this->copyRecursive("$src/$file", "$dest/$file");
+ }
+ }
+ } else {
+ $validator = Server::get(FilenameValidator::class);
+ if (!$validator->isForbidden($src)) {
+ copy($src, $dest);
+ }
+ }
+ }
}
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 00fc3b43d61..4a7341896ef 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -165,7 +165,7 @@ class Generator {
$maxPreviewImage = $this->helper->getImage($maxPreview);
}
- $this->logger->warning('Cached preview not found for file {path}, generating a new preview.', ['path' => $file->getPath()]);
+ $this->logger->debug('Cached preview not found for file {path}, generating a new preview.', ['path' => $file->getPath()]);
$preview = $this->generatePreview($previewFolder, $maxPreviewImage, $width, $height, $crop, $maxWidth, $maxHeight, $previewVersion, $cacheResult);
// New file, augment our array
$previewFiles[] = $preview;
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php
index 2a60287254b..376852a1b6e 100644
--- a/lib/private/Route/Router.php
+++ b/lib/private/Route/Router.php
@@ -169,7 +169,7 @@ class Router implements IRouter {
$this->loadedApps['core'] = true;
$this->useCollection('root');
$this->setupRoutes($this->getAttributeRoutes('core'), 'core');
- require __DIR__ . '/../../../core/routes.php';
+ $this->requireRouteFile(__DIR__ . '/../../../core/routes.php', 'core');
// Also add the OCS collection
$collection = $this->getCollection('root.ocs');
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index ecceafa65b3..abac0d2635e 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -768,28 +768,6 @@ class OC_App {
}
}
- /**
- * @param string $appId
- * @return \OC\Files\View|false
- */
- public static function getStorage(string $appId) {
- if (\OC::$server->getAppManager()->isEnabledForUser($appId)) { //sanity check
- if (\OC::$server->getUserSession()->isLoggedIn()) {
- $view = new \OC\Files\View('/' . OC_User::getUser());
- if (!$view->file_exists($appId)) {
- $view->mkdir($appId);
- }
- return new \OC\Files\View('/' . OC_User::getUser() . '/' . $appId);
- } else {
- \OCP\Server::get(LoggerInterface::class)->error('Can\'t get app storage, app ' . $appId . ', user not logged in', ['app' => 'core']);
- return false;
- }
- } else {
- \OCP\Server::get(LoggerInterface::class)->error('Can\'t get app storage, app ' . $appId . ' not enabled', ['app' => 'core']);
- return false;
- }
- }
-
protected static function findBestL10NOption(array $options, string $lang): string {
// only a single option
if (isset($options['@value'])) {
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index 172c865364c..6caab38b784 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -66,6 +66,7 @@ class OC_Helper {
* @param string $src source folder
* @param string $dest target folder
* @return void
+ * @deprecated 32.0.0 - use \OCP\Files\Folder::copy
*/
public static function copyr($src, $dest) {
if (!file_exists($src)) {
@@ -131,7 +132,7 @@ class OC_Helper {
$exts = [''];
$check_fn = 'is_executable';
// Default check will be done with $path directories :
- $dirs = explode(PATH_SEPARATOR, $path);
+ $dirs = explode(PATH_SEPARATOR, (string)$path);
// WARNING : We have to check if open_basedir is enabled :
$obd = OC::$server->get(IniGetWrapper::class)->getString('open_basedir');
if ($obd != 'none') {
@@ -246,49 +247,30 @@ class OC_Helper {
/**
* Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
+ * Based on https://www.php.net/manual/en/function.array-change-key-case.php#107715
*
* @param array $input The array to work on
* @param int $case Either MB_CASE_UPPER or MB_CASE_LOWER (default)
* @param string $encoding The encoding parameter is the character encoding. Defaults to UTF-8
* @return array
- *
- * Returns an array with all keys from input lowercased or uppercased. Numbered indices are left as is.
- * based on https://www.php.net/manual/en/function.array-change-key-case.php#107715
- *
+ * @deprecated 4.5.0 use \OCP\Util::mb_array_change_key_case instead
*/
public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
- $case = ($case != MB_CASE_UPPER) ? MB_CASE_LOWER : MB_CASE_UPPER;
- $ret = [];
- foreach ($input as $k => $v) {
- $ret[mb_convert_case($k, $case, $encoding)] = $v;
- }
- return $ret;
+ return \OCP\Util::mb_array_change_key_case($input, $case, $encoding);
}
/**
- * performs a search in a nested array
+ * Performs a search in a nested array.
+ * Taken from https://www.php.net/manual/en/function.array-search.php#97645
+ *
* @param array $haystack the array to be searched
* @param string $needle the search string
* @param mixed $index optional, only search this key name
* @return mixed the key of the matching field, otherwise false
- *
- * performs a search in a nested array
- *
- * taken from https://www.php.net/manual/en/function.array-search.php#97645
+ * @deprecated 4.5.0 - use \OCP\Util::recursiveArraySearch
*/
public static function recursiveArraySearch($haystack, $needle, $index = null) {
- $aIt = new RecursiveArrayIterator($haystack);
- $it = new RecursiveIteratorIterator($aIt);
-
- while ($it->valid()) {
- if (((isset($index) and ($it->key() == $index)) or !isset($index)) and ($it->current() == $needle)) {
- return $aIt->key();
- }
-
- $it->next();
- }
-
- return false;
+ return \OCP\Util::recursiveArraySearch($haystack, $needle, $index);
}
/**
@@ -297,12 +279,10 @@ class OC_Helper {
* @param string $dir the current folder where the user currently operates
* @param int|float $freeSpace the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
* @return int|float number of bytes representing
+ * @deprecated 5.0.0 - use \OCP\Util::maxUploadFilesize
*/
public static function maxUploadFilesize($dir, $freeSpace = null) {
- if (is_null($freeSpace) || $freeSpace < 0) {
- $freeSpace = self::freeSpace($dir);
- }
- return min($freeSpace, self::uploadLimit());
+ return \OCP\Util::maxUploadFilesize($dir, $freeSpace);
}
/**
@@ -310,33 +290,20 @@ class OC_Helper {
*
* @param string $dir the current folder where the user currently operates
* @return int|float number of bytes representing
+ * @deprecated 7.0.0 - use \OCP\Util::freeSpace
*/
public static function freeSpace($dir) {
- $freeSpace = \OC\Files\Filesystem::free_space($dir);
- if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) {
- $freeSpace = max($freeSpace, 0);
- return $freeSpace;
- } else {
- return (INF > 0)? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
- }
+ return \OCP\Util::freeSpace($dir);
}
/**
* Calculate PHP upload limit
*
* @return int|float PHP upload file size limit
+ * @deprecated 7.0.0 - use \OCP\Util::uploadLimit
*/
public static function uploadLimit() {
- $ini = \OC::$server->get(IniGetWrapper::class);
- $upload_max_filesize = Util::computerFileSize($ini->get('upload_max_filesize')) ?: 0;
- $post_max_size = Util::computerFileSize($ini->get('post_max_size')) ?: 0;
- if ($upload_max_filesize === 0 && $post_max_size === 0) {
- return INF;
- } elseif ($upload_max_filesize === 0 || $post_max_size === 0) {
- return max($upload_max_filesize, $post_max_size); //only the non 0 value counts
- } else {
- return min($upload_max_filesize, $post_max_size);
- }
+ return \OCP\Util::uploadLimit();
}
/**
diff --git a/lib/public/AppFramework/ApiController.php b/lib/public/AppFramework/ApiController.php
index dae80456e26..729582c8505 100644
--- a/lib/public/AppFramework/ApiController.php
+++ b/lib/public/AppFramework/ApiController.php
@@ -58,9 +58,8 @@ abstract class ApiController extends Controller {
#[PublicPage]
#[NoAdminRequired]
public function preflightedCors() {
- if (isset($this->request->server['HTTP_ORIGIN'])) {
- $origin = $this->request->server['HTTP_ORIGIN'];
- } else {
+ $origin = $this->request->getHeader('origin');
+ if ($origin === '') {
$origin = '*';
}
diff --git a/lib/public/AppFramework/App.php b/lib/public/AppFramework/App.php
index 06404baea70..6860de7c324 100644
--- a/lib/public/AppFramework/App.php
+++ b/lib/public/AppFramework/App.php
@@ -9,10 +9,9 @@ declare(strict_types=1);
*/
namespace OCP\AppFramework;
-use OC\AppFramework\Routing\RouteConfig;
-use OC\Route\Router;
use OC\ServerContainer;
-use OCP\Route\IRouter;
+use OCP\IConfig;
+use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -47,7 +46,7 @@ class App {
* @since 6.0.0
*/
public function __construct(string $appName, array $urlParams = []) {
- $runIsSetupDirectly = \OC::$server->getConfig()->getSystemValueBool('debug')
+ $runIsSetupDirectly = Server::get(IConfig::class)->getSystemValueBool('debug')
&& !ini_get('zend.exception_ignore_args');
if ($runIsSetupDirectly) {
@@ -74,7 +73,7 @@ class App {
}
if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) {
- \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), [
+ Server::get(LoggerInterface::class)->error($e->getMessage(), [
'app' => $appName,
'exception' => $e,
]);
@@ -97,35 +96,6 @@ class App {
}
/**
- * This function is to be called to create single routes and restful routes based on the given $routes array.
- *
- * Example code in routes.php of tasks app (it will register two restful resources):
- * $routes = array(
- * 'resources' => array(
- * 'lists' => array('url' => '/tasklists'),
- * 'tasks' => array('url' => '/tasklists/{listId}/tasks')
- * )
- * );
- *
- * $a = new TasksApp();
- * $a->registerRoutes($this, $routes);
- *
- * @param \OCP\Route\IRouter $router
- * @param array $routes
- * @since 6.0.0
- * @suppress PhanAccessMethodInternal
- * @deprecated 20.0.0 Just return an array from your routes.php
- */
- public function registerRoutes(IRouter $router, array $routes) {
- if (!($router instanceof Router)) {
- throw new \RuntimeException('Can only setup routes with real router');
- }
-
- $routeConfig = new RouteConfig($this->container, $router, $routes);
- $routeConfig->register();
- }
-
- /**
* This function is called by the routing component to fire up the frameworks dispatch mechanism.
*
* Example code in routes.php of the task app:
diff --git a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php
index 1681b39ce50..0a0c04f671d 100644
--- a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php
+++ b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php
@@ -30,8 +30,7 @@ class RedirectToDefaultAppResponse extends RedirectResponse {
* @deprecated 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead
*/
public function __construct(int $status = Http::STATUS_SEE_OTHER, array $headers = []) {
- /** @var IURLGenerator $urlGenerator */
- $urlGenerator = \OC::$server->get(IURLGenerator::class);
+ $urlGenerator = \OCP\Server::get(IURLGenerator::class);
parent::__construct($urlGenerator->linkToDefaultPageUrl(), $status, $headers);
}
}
diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php
index 6fc3d4b98ea..8037243d7a4 100644
--- a/lib/public/AppFramework/Http/Response.php
+++ b/lib/public/AppFramework/Http/Response.php
@@ -93,7 +93,6 @@ class Response {
// Set expires header
$expires = new \DateTime();
- /** @var ITimeFactory $time */
$time = \OCP\Server::get(ITimeFactory::class);
$expires->setTimestamp($time->getTime());
$expires->add(new \DateInterval('PT' . $cacheSeconds . 'S'));
@@ -184,10 +183,10 @@ class Response {
if ($this->status === Http::STATUS_NOT_MODIFIED
&& stripos($name, 'x-') === 0) {
/** @var IConfig $config */
- $config = \OC::$server->get(IConfig::class);
+ $config = \OCP\Server::get(IConfig::class);
if ($config->getSystemValueBool('debug', false)) {
- \OC::$server->get(LoggerInterface::class)->error('Setting custom header on a 304 is not supported (Header: {header})', [
+ \OCP\Server::get(LoggerInterface::class)->error('Setting custom header on a 304 is not supported (Header: {header})', [
'header' => $name,
]);
}
@@ -229,7 +228,7 @@ class Response {
/**
* @psalm-suppress UndefinedClass
*/
- $request = \OC::$server->get(IRequest::class);
+ $request = \OCP\Server::get(IRequest::class);
$mergeWith = [
'X-Request-Id' => $request->getId(),
'Cache-Control' => 'no-cache, no-store, must-revalidate',
diff --git a/lib/public/Color.php b/lib/public/Color.php
index c8ba3a1ff15..5523dbd94cb 100644
--- a/lib/public/Color.php
+++ b/lib/public/Color.php
@@ -125,7 +125,7 @@ class Color {
* Calculate steps between two Colors
* @param int $steps start color
* @param Color[] $ends end color
- * @return array{0: int, 1: int, 2: int} [r,g,b] steps for each color to go from $steps to $ends
+ * @return array{0: float, 1: float, 2: float} [r,g,b] steps for each color to go from $steps to $ends
* @since 25.0.0
*/
private static function stepCalc(int $steps, array $ends): array {
diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php
index 9242a230024..6de22caa41e 100644
--- a/lib/public/Defaults.php
+++ b/lib/public/Defaults.php
@@ -29,7 +29,7 @@ class Defaults {
*/
public function __construct(?\OC_Defaults $defaults = null) {
if ($defaults === null) {
- $defaults = \OC::$server->get('ThemingDefaults');
+ $defaults = \OCP\Server::get('ThemingDefaults');
}
$this->defaults = $defaults;
}
diff --git a/lib/public/Diagnostics/IQueryLogger.php b/lib/public/Diagnostics/IQueryLogger.php
index 1973168803d..07c999023da 100644
--- a/lib/public/Diagnostics/IQueryLogger.php
+++ b/lib/public/Diagnostics/IQueryLogger.php
@@ -31,7 +31,7 @@ interface IQueryLogger extends SQLLogger {
* Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to
* be returned with getQueries() method.
*
- * @return mixed
+ * @return void
* @since 8.0.0
*/
public function stopQuery();
diff --git a/lib/public/EventDispatcher/GenericEvent.php b/lib/public/EventDispatcher/GenericEvent.php
index fb0a7677672..7e646c4d6a7 100644
--- a/lib/public/EventDispatcher/GenericEvent.php
+++ b/lib/public/EventDispatcher/GenericEvent.php
@@ -18,10 +18,12 @@ use function array_key_exists;
/**
* Class GenericEvent
*
- * convenience reimplementation of \Symfony\Component\GenericEvent against
+ * convenience re-implementation of \Symfony\Component\GenericEvent against
* \OCP\EventDispatcher\Event
*
* @since 18.0.0
+ * @template-implements ArrayAccess<array-key, mixed>
+ * @template-implements IteratorAggregate<array-key, mixed>
* @deprecated 22.0.0 use \OCP\EventDispatcher\Event
*/
class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
diff --git a/lib/public/Files.php b/lib/public/Files.php
index fb03a4192fc..b12aa463f1a 100644
--- a/lib/public/Files.php
+++ b/lib/public/Files.php
@@ -9,6 +9,8 @@
namespace OCP;
+use OCP\Files\IMimeTypeDetector;
+
/**
* This class provides access to the internal filesystem abstraction layer. Use
* this class exclusively if you want to access files
@@ -67,7 +69,7 @@ class Files {
* @deprecated 14.0.0
*/
public static function getMimeType($path) {
- return \OC::$server->getMimeTypeDetector()->detect($path);
+ return Server::get(IMimeTypeDetector::class)->detect($path);
}
/**
@@ -105,16 +107,4 @@ class Files {
public static function buildNotExistingFileName($path, $filename) {
return \OC_Helper::buildNotExistingFileName($path, $filename);
}
-
- /**
- * Gets the Storage for an app - creates the needed folder if they are not
- * existent
- * @param string $app
- * @return \OC\Files\View
- * @since 5.0.0
- * @deprecated 14.0.0 use IAppData instead
- */
- public static function getStorage($app) {
- return \OC_App::getStorage($app);
- }
}
diff --git a/lib/public/Files_FullTextSearch/Model/AFilesDocument.php b/lib/public/Files_FullTextSearch/Model/AFilesDocument.php
index ba5f504fccf..297d6bc6ffc 100644
--- a/lib/public/Files_FullTextSearch/Model/AFilesDocument.php
+++ b/lib/public/Files_FullTextSearch/Model/AFilesDocument.php
@@ -16,7 +16,7 @@ use OCP\FullTextSearch\Model\IIndexDocument;
* This is mostly used by 3rd party apps that want to complete the IIndexDocument
* with more information about a file before its index:
*
- * \OC::$server->getEventDispatcher()->addListener(
+ * \OCP\Server::get(IEventDispatcher::class)->addListener(
* '\OCA\Files_FullTextSearch::onFileIndexing',
* function(GenericEvent $e) {
* //@var \OCP\Files\Node $file
diff --git a/lib/public/L10N/ILanguageIterator.php b/lib/public/L10N/ILanguageIterator.php
index cba0feefdcf..27f850d4235 100644
--- a/lib/public/L10N/ILanguageIterator.php
+++ b/lib/public/L10N/ILanguageIterator.php
@@ -21,7 +21,7 @@ namespace OCP\L10N;
* if settings are not present or truncating is not applicable, the iterator
* skips to the next valid item itself
*
- *
+ * @template-extends \Iterator<int, string>
* @since 14.0.0
*/
interface ILanguageIterator extends \Iterator {
@@ -36,22 +36,20 @@ interface ILanguageIterator extends \Iterator {
* Move forward to next element
*
* @since 14.0.0
- * @return void
*/
- #[\ReturnTypeWillChange]
- public function next();
+ public function next(): void;
/**
* Return the key of the current element
*
* @since 14.0.0
*/
- public function key():int;
+ public function key(): int;
/**
* Checks if current position is valid
*
* @since 14.0.0
*/
- public function valid():bool;
+ public function valid(): bool;
}
diff --git a/lib/public/Mail/IMailer.php b/lib/public/Mail/IMailer.php
index 18eaef541c0..277f7863184 100644
--- a/lib/public/Mail/IMailer.php
+++ b/lib/public/Mail/IMailer.php
@@ -14,7 +14,7 @@ namespace OCP\Mail;
*
* Example usage:
*
- * $mailer = \OC::$server->get(\OCP\Mail\IMailer::class);
+ * $mailer = \OCP\Server::get(\OCP\Mail\IMailer::class);
* $message = $mailer->createMessage();
* $message->setSubject('Your Subject');
* $message->setFrom(['cloud@domain.org' => 'Nextcloud Notifier']);
diff --git a/lib/public/Profiler/IProfile.php b/lib/public/Profiler/IProfile.php
index ddbad4b4388..89eb709d061 100644
--- a/lib/public/Profiler/IProfile.php
+++ b/lib/public/Profiler/IProfile.php
@@ -17,7 +17,7 @@ use OCP\DataCollector\IDataCollector;
*
* ```php
* <?php
- * $profiler = \OC::$server->get(IProfiler::class);
+ * $profiler = \OCP\Server::get(IProfiler::class);
* $profiles = $profiler->find('/settings/users', 10);
* ```
*
diff --git a/lib/public/Security/ICrypto.php b/lib/public/Security/ICrypto.php
index c2ba4cc9c97..78b0fc14d6d 100644
--- a/lib/public/Security/ICrypto.php
+++ b/lib/public/Security/ICrypto.php
@@ -13,8 +13,8 @@ namespace OCP\Security;
* it will use the secret defined in config.php as key. Additionally the message will be HMAC'd.
*
* Usage:
- * $encryptWithDefaultPassword = \OC::$server->getCrypto()->encrypt('EncryptedText');
- * $encryptWithCustomPassword = \OC::$server->getCrypto()->encrypt('EncryptedText', 'password');
+ * $encryptWithDefaultPassword = \OCP\Server::get(ICrypto::class)->encrypt('EncryptedText');
+ * $encryptWithCustomPassword = \OCP\Server::get(ICrypto::class)->encrypt('EncryptedText', 'password');
*
* @since 8.0.0
*/
diff --git a/lib/public/Security/IHasher.php b/lib/public/Security/IHasher.php
index d985ffe48ab..d0d6e4e9028 100644
--- a/lib/public/Security/IHasher.php
+++ b/lib/public/Security/IHasher.php
@@ -19,10 +19,10 @@ namespace OCP\Security;
*
* Usage:
* // Hashing a message
- * $hash = \OC::$server->get(\OCP\Security\IHasher::class)->hash('MessageToHash');
+ * $hash = \OCP\Server::get(\OCP\Security\IHasher::class)->hash('MessageToHash');
* // Verifying a message - $newHash will contain the newly calculated hash
* $newHash = null;
- * var_dump(\OC::$server->get(\OCP\Security\IHasher::class)->verify('a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', $newHash));
+ * var_dump(\OCP\Server::get(\OCP\Security\IHasher::class)->verify('a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', $newHash));
* var_dump($newHash);
*
* @since 8.0.0
diff --git a/lib/public/Security/ISecureRandom.php b/lib/public/Security/ISecureRandom.php
index aa191ca348f..0f4a79e08e0 100644
--- a/lib/public/Security/ISecureRandom.php
+++ b/lib/public/Security/ISecureRandom.php
@@ -14,7 +14,7 @@ namespace OCP\Security;
* use a fallback.
*
* Usage:
- * \OC::$server->get(ISecureRandom::class)->generate(10);
+ * \OCP\Server::get(ISecureRandom::class)->generate(10);
*
* @since 8.0.0
*/
diff --git a/lib/public/Util.php b/lib/public/Util.php
index d7cfd65ba56..b3111c54fc7 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -51,7 +51,7 @@ class Util {
return $subscriptionRegistry->delegateHasExtendedSupport();
} catch (ContainerExceptionInterface $e) {
}
- return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false);
+ return \OCP\Server::get(IConfig::class)->getSystemValueBool('extendedSupport', false);
}
/**
@@ -60,7 +60,7 @@ class Util {
* @since 8.1.0
*/
public static function setChannel($channel) {
- \OC::$server->getConfig()->setSystemValue('updater.release.channel', $channel);
+ \OCP\Server::get(IConfig::class)->setSystemValue('updater.release.channel', $channel);
}
/**
@@ -182,7 +182,7 @@ class Util {
*/
public static function getScripts(): array {
// Sort scriptDeps into sortedScriptDeps
- $scriptSort = \OC::$server->get(AppScriptSort::class);
+ $scriptSort = \OCP\Server::get(AppScriptSort::class);
$sortedScripts = $scriptSort->sort(self::$scripts, self::$scriptDeps);
// Flatten array and remove duplicates
@@ -209,7 +209,7 @@ class Util {
*/
public static function addTranslations($application, $languageCode = null, $init = false) {
if (is_null($languageCode)) {
- $languageCode = \OC::$server->get(IFactory::class)->findLanguage($application);
+ $languageCode = \OCP\Server::get(IFactory::class)->findLanguage($application);
}
if (!empty($application)) {
$path = "$application/l10n/$languageCode";
@@ -247,7 +247,7 @@ class Util {
* @since 4.0.0 - parameter $args was added in 4.5.0
*/
public static function linkToAbsolute($app, $file, $args = []) {
- $urlGenerator = \OC::$server->getURLGenerator();
+ $urlGenerator = \OCP\Server::get(IURLGenerator::class);
return $urlGenerator->getAbsoluteURL(
$urlGenerator->linkTo($app, $file, $args)
);
@@ -260,7 +260,7 @@ class Util {
* @since 4.0.0
*/
public static function linkToRemote($service) {
- $urlGenerator = \OC::$server->getURLGenerator();
+ $urlGenerator = \OCP\Server::get(IURLGenerator::class);
$remoteBase = $urlGenerator->linkTo('', 'remote.php') . '/' . $service;
return $urlGenerator->getAbsoluteURL(
$remoteBase . (($service[strlen($service) - 1] != '/') ? '/' : '')
@@ -273,7 +273,7 @@ class Util {
* @since 5.0.0
*/
public static function getServerHostName() {
- $host_name = \OC::$server->getRequest()->getServerHost();
+ $host_name = \OCP\Server::get(IRequest::class)->getServerHost();
// strip away port number (if existing)
$colon_pos = strpos($host_name, ':');
if ($colon_pos != false) {
@@ -299,13 +299,13 @@ class Util {
* @since 5.0.0
*/
public static function getDefaultEmailAddress(string $user_part): string {
- $config = \OC::$server->getConfig();
+ $config = \OCP\Server::get(IConfig::class);
$user_part = $config->getSystemValueString('mail_from_address', $user_part);
$host_name = self::getServerHostName();
$host_name = $config->getSystemValueString('mail_domain', $host_name);
$defaultEmailAddress = $user_part . '@' . $host_name;
- $mailer = \OC::$server->get(IMailer::class);
+ $mailer = \OCP\Server::get(IMailer::class);
if ($mailer->validateMailAddress($defaultEmailAddress)) {
return $defaultEmailAddress;
}
@@ -447,7 +447,7 @@ class Util {
*/
public static function callRegister() {
if (self::$token === '') {
- self::$token = \OC::$server->get(CsrfTokenManager::class)->getToken()->getEncryptedValue();
+ self::$token = \OCP\Server::get(CsrfTokenManager::class)->getToken()->getEncryptedValue();
}
return self::$token;
}
@@ -491,7 +491,12 @@ class Util {
* @since 4.5.0
*/
public static function mb_array_change_key_case($input, $case = MB_CASE_LOWER, $encoding = 'UTF-8') {
- return \OC_Helper::mb_array_change_key_case($input, $case, $encoding);
+ $case = ($case != MB_CASE_UPPER) ? MB_CASE_LOWER : MB_CASE_UPPER;
+ $ret = [];
+ foreach ($input as $k => $v) {
+ $ret[mb_convert_case($k, $case, $encoding)] = $v;
+ }
+ return $ret;
}
/**
@@ -505,7 +510,18 @@ class Util {
* @deprecated 15.0.0
*/
public static function recursiveArraySearch($haystack, $needle, $index = null) {
- return \OC_Helper::recursiveArraySearch($haystack, $needle, $index);
+ $aIt = new \RecursiveArrayIterator($haystack);
+ $it = new \RecursiveIteratorIterator($aIt);
+
+ while ($it->valid()) {
+ if (((isset($index) and ($it->key() == $index)) or !isset($index)) and ($it->current() == $needle)) {
+ return $aIt->key();
+ }
+
+ $it->next();
+ }
+
+ return false;
}
/**
@@ -517,7 +533,10 @@ class Util {
* @since 5.0.0
*/
public static function maxUploadFilesize(string $dir, int|float|null $free = null): int|float {
- return \OC_Helper::maxUploadFilesize($dir, $free);
+ if (is_null($free) || $free < 0) {
+ $free = self::freeSpace($dir);
+ }
+ return min($free, self::uploadLimit());
}
/**
@@ -527,7 +546,13 @@ class Util {
* @since 7.0.0
*/
public static function freeSpace(string $dir): int|float {
- return \OC_Helper::freeSpace($dir);
+ $freeSpace = \OC\Files\Filesystem::free_space($dir);
+ if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) {
+ $freeSpace = max($freeSpace, 0);
+ return $freeSpace;
+ } else {
+ return (INF > 0)? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
+ }
}
/**
@@ -537,7 +562,16 @@ class Util {
* @since 7.0.0
*/
public static function uploadLimit(): int|float {
- return \OC_Helper::uploadLimit();
+ $ini = Server::get(IniGetWrapper::class);
+ $upload_max_filesize = self::computerFileSize($ini->get('upload_max_filesize')) ?: 0;
+ $post_max_size = self::computerFileSize($ini->get('post_max_size')) ?: 0;
+ if ($upload_max_filesize === 0 && $post_max_size === 0) {
+ return INF;
+ } elseif ($upload_max_filesize === 0 || $post_max_size === 0) {
+ return max($upload_max_filesize, $post_max_size); //only the non 0 value counts
+ } else {
+ return min($upload_max_filesize, $post_max_size);
+ }
}
/**
@@ -582,7 +616,7 @@ class Util {
*/
public static function needUpgrade() {
if (!isset(self::$needUpgradeCache)) {
- self::$needUpgradeCache = \OC_Util::needUpgrade(\OC::$server->getSystemConfig());
+ self::$needUpgradeCache = \OC_Util::needUpgrade(\OCP\Server::get(\OC\SystemConfig::class));
}
return self::$needUpgradeCache;
}