From 07bac538e289a0eaa22ea31465c125d100e96f23 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 24 Apr 2026 16:28:52 -0400 Subject: [PATCH 1/3] chore(previews): drop long deprecated registerProvider from IPreview Signed-off-by: Josh --- lib/public/IPreview.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/public/IPreview.php b/lib/public/IPreview.php index 56c31430f4959..b4ebf4a439f2d 100644 --- a/lib/public/IPreview.php +++ b/lib/public/IPreview.php @@ -5,8 +5,6 @@ * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ -// use OCP namespace for all classes that are considered public. -// This means that they should be used by apps instead of the internal Nextcloud classes namespace OCP; @@ -35,19 +33,6 @@ interface IPreview { */ public const MODE_COVER = 'cover'; - /** - * In order to improve lazy loading a closure can be registered which will be - * called in case preview providers are actually requested - * - * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider - * @param ProviderClosure $callable - * @since 8.1.0 - * @see \OCP\AppFramework\Bootstrap\IRegistrationContext::registerPreviewProvider - * - * @deprecated 23.0.0 Register your provider via the IRegistrationContext when booting the app - */ - public function registerProvider(string $mimeTypeRegex, Closure $callable): void; - /** * Get all providers * @return array> From bf9d97ec5a614b497abbc60deb97caf4e016b9ae Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 24 Apr 2026 16:50:28 -0400 Subject: [PATCH 2/3] chore(previews): registerProvider->registerProviderClosure in PreviewManager No longer part of the public interface. Just an internal utility function. Apps/etc register in other ways and still end up here appropriately. Signed-off-by: Josh --- lib/private/PreviewManager.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 578c256aac068..197eed3e77af4 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -107,8 +107,7 @@ public function __construct( * @param string $mimeTypeRegex Regex with the mime types that are supported by this provider * @param ProviderClosure $callable */ - #[\Override] - public function registerProvider(string $mimeTypeRegex, Closure $callable): void { + private function registerProviderClosure(string $mimeTypeRegex, Closure $callable): void { if (!$this->enablePreviews) { return; } @@ -300,7 +299,7 @@ protected function getEnabledDefaultProvider(): array { */ protected function registerCoreProvider(string $class, string $mimeType, array $options = []): void { if (in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) { - $this->registerProvider($mimeType, function () use ($class, $options) { + $this->registerProviderClosure($mimeType, function () use ($class, $options): IProviderV2 { return new $class($options); }); } @@ -426,7 +425,7 @@ private function registerBootstrapProviders(): void { } $this->loadedBootstrapProviders[$key] = null; - $this->registerProvider($provider->getMimeTypeRegex(), function () use ($provider): IProviderV2|false { + $this->registerProviderClosure($provider->getMimeTypeRegex(), function () use ($provider): IProviderV2|false { try { return $this->container->get($provider->getService()); } catch (NotFoundExceptionInterface) { From 3c1cf25002c3d77b7ff0f5be26f20b6e81fe9d87 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 24 Apr 2026 21:19:05 -0400 Subject: [PATCH 3/3] chore(previews): let psalm know about $class typing Signed-off-by: Josh --- lib/private/PreviewManager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 197eed3e77af4..3672d812095c0 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -300,6 +300,7 @@ protected function getEnabledDefaultProvider(): array { protected function registerCoreProvider(string $class, string $mimeType, array $options = []): void { if (in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) { $this->registerProviderClosure($mimeType, function () use ($class, $options): IProviderV2 { + /** @var IProviderV2 $class */ return new $class($options); }); }