diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/AppConfig.php | 12 | ||||
-rw-r--r-- | lib/private/DB/Connection.php | 11 | ||||
-rw-r--r-- | lib/private/NavigationManager.php | 19 | ||||
-rw-r--r-- | lib/private/Preview/Generator.php | 2 | ||||
-rw-r--r-- | lib/private/Preview/Movie.php | 13 | ||||
-rw-r--r-- | lib/private/Preview/Watcher.php | 3 | ||||
-rw-r--r-- | lib/private/Preview/WatcherConnector.php | 32 | ||||
-rw-r--r-- | lib/private/Security/Normalizer/IpAddress.php | 15 | ||||
-rw-r--r-- | lib/private/Server.php | 3 | ||||
-rw-r--r-- | lib/private/TaskProcessing/Manager.php | 1 | ||||
-rw-r--r-- | lib/private/Template/JSResourceLocator.php | 2 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 9 | ||||
-rw-r--r-- | lib/private/URLGenerator.php | 5 |
13 files changed, 71 insertions, 56 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index 1228b9c20e3..092d37c3338 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -1423,6 +1423,9 @@ class AppConfig implements IAppConfig { 'globalsiteselector' => [ '/^gss\.jwt\.key$/', ], + 'gpgmailer' => [ + '/^GpgServerKey$/', + ], 'integration_discourse' => [ '/^private_key$/', '/^public_key$/', @@ -1477,6 +1480,9 @@ class AppConfig implements IAppConfig { '/^client_secret$/', '/^oauth_instance_url$/', ], + 'maps' => [ + '/^mapboxAPIKEY$/', + ], 'notify_push' => [ '/^cookie$/', ], @@ -1514,12 +1520,12 @@ class AppConfig implements IAppConfig { '/^slogan$/', '/^url$/', ], - 'user_ldap' => [ - '/^(s..)?ldap_agent_password$/', - ], 'twofactor_gateway' => [ '/^.*token$/', ], + 'user_ldap' => [ + '/^(s..)?ldap_agent_password$/', + ], 'user_saml' => [ '/^idp-x509cert$/', ], diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index eecf83ace95..96dd578b2ef 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -414,7 +414,7 @@ class Connection extends PrimaryReadReplicaConnection { $sql = $this->finishQuery($sql); $this->queriesExecuted++; - $this->logQueryToFile($sql); + $this->logQueryToFile($sql, $params); try { return parent::executeQuery($sql, $params, $types, $qcp); } catch (\Exception $e) { @@ -461,7 +461,7 @@ class Connection extends PrimaryReadReplicaConnection { } $sql = $this->finishQuery($sql); $this->queriesExecuted++; - $this->logQueryToFile($sql); + $this->logQueryToFile($sql, $params); try { return (int)parent::executeStatement($sql, $params, $types); } catch (\Exception $e) { @@ -470,14 +470,19 @@ class Connection extends PrimaryReadReplicaConnection { } } - protected function logQueryToFile(string $sql): void { + protected function logQueryToFile(string $sql, array $params): void { $logFile = $this->systemConfig->getValue('query_log_file'); if ($logFile !== '' && is_writable(dirname($logFile)) && (!file_exists($logFile) || is_writable($logFile))) { $prefix = ''; if ($this->systemConfig->getValue('query_log_file_requestid') === 'yes') { $prefix .= Server::get(IRequestId::class)->getId() . "\t"; } + $postfix = ''; + if ($this->systemConfig->getValue('query_log_file_parameters') === 'yes') { + $postfix .= '; ' . json_encode($params); + } + if ($this->systemConfig->getValue('query_log_file_backtrace') === 'yes') { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); array_pop($trace); diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index c2125bc6f8a..fb0795376bb 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -77,7 +77,7 @@ class NavigationManager implements INavigationManager { $this->closureEntries[] = $entry; return; } - $this->init(); + $this->init(false); $id = $entry['id']; @@ -123,10 +123,6 @@ class NavigationManager implements INavigationManager { */ public function getAll(string $type = 'link'): array { $this->init(); - foreach ($this->closureEntries as $c) { - $this->add($c()); - } - $this->closureEntries = []; $result = $this->entries; if ($type !== 'all') { @@ -212,7 +208,13 @@ class NavigationManager implements INavigationManager { return $this->activeEntry; } - private function init() { + private function init(bool $resolveClosures = true): void { + if ($resolveClosures) { + while ($c = array_pop($this->closureEntries)) { + $this->add($c()); + } + } + if ($this->init) { return; } @@ -420,11 +422,6 @@ class NavigationManager implements INavigationManager { public function get(string $id): ?array { $this->init(); - foreach ($this->closureEntries as $c) { - $this->add($c()); - } - $this->closureEntries = []; - return $this->entries[$id]; } diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index 66069beaecc..b95971d0085 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -119,7 +119,7 @@ class Generator { $maxPreviewImage = null; // only load the image when we need it if ($maxPreview->getSize() === 0) { $maxPreview->delete(); - $this->logger->error("Max preview generated for file {$file->getPath()} has size 0, deleting and throwing exception."); + $this->logger->error('Max preview generated for file {path} has size 0, deleting and throwing exception.', ['path' => $file->getPath()]); throw new NotFoundException('Max preview size 0, invalid!'); } diff --git a/lib/private/Preview/Movie.php b/lib/private/Preview/Movie.php index 46462dfa592..7de543198f4 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -54,10 +54,15 @@ class Movie extends ProviderV2 { $result = null; if ($this->useTempFile($file)) { - // try downloading 5 MB first as it's likely that the first frames are present there - // in some cases this doesn't work for example when the moov atom is at the - // end of the file, so if it fails we fall back to getting the full file - $sizeAttempts = [5242880, null]; + // Try downloading 5 MB first, as it's likely that the first frames are present there. + // In some cases this doesn't work, for example when the moov atom is at the + // end of the file, so if it fails we fall back to getting the full file. + // Unless the file is not local (e.g. S3) as we do not want to download the whole (e.g. 37Gb) file + if ($file->getStorage()->isLocal()) { + $sizeAttempts = [5242880, null]; + } else { + $sizeAttempts = [5242880]; + } } else { // size is irrelevant, only attempt once $sizeAttempts = [null]; diff --git a/lib/private/Preview/Watcher.php b/lib/private/Preview/Watcher.php index abddd7b5acb..21f040d8342 100644 --- a/lib/private/Preview/Watcher.php +++ b/lib/private/Preview/Watcher.php @@ -8,6 +8,7 @@ declare(strict_types=1); */ namespace OC\Preview; +use OCP\Files\FileInfo; use OCP\Files\Folder; use OCP\Files\IAppData; use OCP\Files\Node; @@ -37,7 +38,7 @@ class Watcher { $this->deleteNode($node); } - protected function deleteNode(Node $node) { + protected function deleteNode(FileInfo $node) { // We only handle files if ($node instanceof Folder) { return; diff --git a/lib/private/Preview/WatcherConnector.php b/lib/private/Preview/WatcherConnector.php index ae2a136ca78..c34dd1dde4d 100644 --- a/lib/private/Preview/WatcherConnector.php +++ b/lib/private/Preview/WatcherConnector.php @@ -9,43 +9,33 @@ declare(strict_types=1); namespace OC\Preview; use OC\SystemConfig; +use OCA\Files_Versions\Events\VersionRestoredEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\Node; class WatcherConnector { - /** @var IRootFolder */ - private $root; - - /** @var SystemConfig */ - private $config; - - /** - * WatcherConnector constructor. - * - * @param IRootFolder $root - * @param SystemConfig $config - */ - public function __construct(IRootFolder $root, - SystemConfig $config) { - $this->root = $root; - $this->config = $config; + public function __construct( + private IRootFolder $root, + private SystemConfig $config, + private IEventDispatcher $dispatcher, + ) { } - /** - * @return Watcher - */ private function getWatcher(): Watcher { return \OCP\Server::get(Watcher::class); } - public function connectWatcher() { + public function connectWatcher(): void { // Do not connect if we are not setup yet! if ($this->config->getValue('instanceid', null) !== null) { $this->root->listen('\OC\Files', 'postWrite', function (Node $node) { $this->getWatcher()->postWrite($node); }); - \OC_Hook::connect('\OCP\Versions', 'rollback', $this->getWatcher(), 'versionRollback'); + $this->dispatcher->addListener(VersionRestoredEvent::class, function (VersionRestoredEvent $event) { + $this->getWatcher()->versionRollback(['node' => $event->getVersion()->getSourceFile()]); + }); } } } diff --git a/lib/private/Security/Normalizer/IpAddress.php b/lib/private/Security/Normalizer/IpAddress.php index e40dc9ba96b..4d33a7bd632 100644 --- a/lib/private/Security/Normalizer/IpAddress.php +++ b/lib/private/Security/Normalizer/IpAddress.php @@ -41,10 +41,21 @@ class IpAddress { $config = \OCP\Server::get(IConfig::class); $maskSize = min(64, $config->getSystemValueInt('security.ipv6_normalized_subnet_size', 56)); $maskSize = max(32, $maskSize); - $mask = pack('VVP', (1 << 32) - 1, (1 << $maskSize - 32) - 1, 0); + if (PHP_INT_SIZE === 4) { + if ($maskSize === 64) { + $value = -1; + } elseif ($maskSize === 63) { + $value = PHP_INT_MAX; + } else { + $value = (1 << $maskSize - 32) - 1; + } + // as long as we support 32bit PHP we cannot use the `P` pack formatter (and not overflow 32bit integer) + $mask = pack('VVVV', -1, $value, 0, 0); + } else { + $mask = pack('VVP', (1 << 32) - 1, (1 << $maskSize - 32) - 1, 0); + } $binary = \inet_pton($ip); - return inet_ntop($binary & $mask) . '/' . $maskSize; } diff --git a/lib/private/Server.php b/lib/private/Server.php index 4d79fefd261..545ceacbe81 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -411,7 +411,8 @@ class Server extends ServerContainer implements IServerContainer { $previewConnector = new \OC\Preview\WatcherConnector( $root, - $c->get(SystemConfig::class) + $c->get(SystemConfig::class), + $this->get(IEventDispatcher::class) ); $previewConnector->connectWatcher(); diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index a701c23d56f..9992310dbbb 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -584,6 +584,7 @@ class Manager implements IManager { \OCP\TaskProcessing\TaskTypes\TextToTextChatWithTools::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextChatWithTools::class), \OCP\TaskProcessing\TaskTypes\ContextAgentInteraction::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\ContextAgentInteraction::class), \OCP\TaskProcessing\TaskTypes\TextToTextProofread::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToTextProofread::class), + \OCP\TaskProcessing\TaskTypes\TextToSpeech::ID => \OCP\Server::get(\OCP\TaskProcessing\TaskTypes\TextToSpeech::class), ]; foreach ($context->getTaskProcessingTaskTypes() as $providerServiceRegistration) { diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php index aad999f939a..a6d2d13a2ad 100644 --- a/lib/private/Template/JSResourceLocator.php +++ b/lib/private/Template/JSResourceLocator.php @@ -69,7 +69,7 @@ class JSResourceLocator extends ResourceLocator { || $this->appendScriptIfExist($this->serverroot, "dist/$app-$scriptName") || $this->appendScriptIfExist($appRoot, $script, $appWebRoot) || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script . '.json') - || $this->cacheAndAppendCombineJsonIfExist($appRoot, $script . '.json', $appWebRoot) + || $this->cacheAndAppendCombineJsonIfExist($appRoot, $script . '.json', $app) || $this->appendScriptIfExist($this->serverroot, $theme_dir . 'core/' . $script) || $this->appendScriptIfExist($this->serverroot, 'core/' . $script) || (strpos($scriptName, '/') === -1 && ($this->appendScriptIfExist($this->serverroot, $theme_dir . "dist/core-$scriptName") diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 374972ece22..caffbfceefa 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -144,12 +144,6 @@ class TemplateLayout { $userDisplayName = $user->getDisplayName(); } - $page->assign('enabledThemes', []); - if ($this->appManager->isEnabledForUser('theming') && class_exists('\OCA\Theming\Service\ThemesService')) { - $themesService = Server::get(\OCA\Theming\Service\ThemesService::class); - $page->assign('enabledThemes', $themesService->getEnabledThemes()); - } - $page->assign('user_displayname', $userDisplayName); $page->assign('user_uid', \OC_User::getUser()); break; @@ -200,10 +194,9 @@ class TemplateLayout { // Set body data-theme try { $themesService = Server::get(\OCA\Theming\Service\ThemesService::class); - } catch (\OCP\AppFramework\QueryException) { + } catch (\Exception) { $themesService = null; } - $page->assign('enabledThemes', $themesService?->getEnabledThemes() ?? []); if ($this->config->getSystemValueBool('installed', false)) { diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index ad12fae5144..c78ecac0903 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -304,6 +304,11 @@ class URLGenerator implements IURLGenerator { if ($href === '') { throw new \InvalidArgumentException('Default navigation entry is missing href: ' . $entryId); } + + if (str_starts_with($href, $this->getBaseUrl())) { + return $href; + } + if (str_starts_with($href, '/index.php/') && ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true')) { $href = substr($href, 10); } |