aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-07-25 11:29:33 +0200
committerJoas Schilling <coding@schilljs.com>2023-07-27 09:57:51 +0200
commit4f7de8ed60f528c38af9e4ba988015e9e9abc5dc (patch)
tree655ee4404a11750438b4b5f8b0c8b1023148c3fb
parent582e655c011eaea0cd33d8827a90904d1250cb9b (diff)
downloadnextcloud-server-4f7de8ed60f528c38af9e4ba988015e9e9abc5dc.tar.gz
nextcloud-server-4f7de8ed60f528c38af9e4ba988015e9e9abc5dc.zip
fix!: Remove legacy event dispatching Symfony's GenericEvent
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/Preview/Generator.php10
-rw-r--r--lib/private/PreviewManager.php5
-rw-r--r--lib/private/Server.php1
-rw-r--r--lib/public/IPreview.php6
-rw-r--r--tests/lib/Preview/GeneratorTest.php79
5 files changed, 0 insertions, 101 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index c9949c82a97..4e4571f0857 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -44,8 +44,6 @@ use OCP\IStreamImage;
use OCP\Preview\BeforePreviewFetchedEvent;
use OCP\Preview\IProviderV2;
use OCP\Preview\IVersionedPreviewFile;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
class Generator {
public const SEMAPHORE_ID_ALL = 0x0a11;
@@ -59,8 +57,6 @@ class Generator {
private $appData;
/** @var GeneratorHelper */
private $helper;
- /** @var EventDispatcherInterface */
- private $legacyEventDispatcher;
/** @var IEventDispatcher */
private $eventDispatcher;
@@ -69,14 +65,12 @@ class Generator {
IPreview $previewManager,
IAppData $appData,
GeneratorHelper $helper,
- EventDispatcherInterface $legacyEventDispatcher,
IEventDispatcher $eventDispatcher
) {
$this->config = $config;
$this->previewManager = $previewManager;
$this->appData = $appData;
$this->helper = $helper;
- $this->legacyEventDispatcher = $legacyEventDispatcher;
$this->eventDispatcher = $eventDispatcher;
}
@@ -104,10 +98,6 @@ class Generator {
'mode' => $mode,
];
- $this->legacyEventDispatcher->dispatch(
- IPreview::EVENT,
- new GenericEvent($file, $specification)
- );
$this->eventDispatcher->dispatchTyped(new BeforePreviewFetchedEvent(
$file,
$width,
diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php
index 814235f4212..3af6848686e 100644
--- a/lib/private/PreviewManager.php
+++ b/lib/private/PreviewManager.php
@@ -46,7 +46,6 @@ use OCP\IConfig;
use OCP\IPreview;
use OCP\IServerContainer;
use OCP\Preview\IProviderV2;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use function array_key_exists;
class PreviewManager implements IPreview {
@@ -54,7 +53,6 @@ class PreviewManager implements IPreview {
protected IRootFolder $rootFolder;
protected IAppData $appData;
protected IEventDispatcher $eventDispatcher;
- protected EventDispatcherInterface $legacyEventDispatcher;
private ?Generator $generator = null;
private GeneratorHelper $helper;
protected bool $providerListDirty = false;
@@ -81,7 +79,6 @@ class PreviewManager implements IPreview {
IRootFolder $rootFolder,
IAppData $appData,
IEventDispatcher $eventDispatcher,
- EventDispatcherInterface $legacyEventDispatcher,
GeneratorHelper $helper,
?string $userId,
Coordinator $bootstrapCoordinator,
@@ -93,7 +90,6 @@ class PreviewManager implements IPreview {
$this->rootFolder = $rootFolder;
$this->appData = $appData;
$this->eventDispatcher = $eventDispatcher;
- $this->legacyEventDispatcher = $legacyEventDispatcher;
$this->helper = $helper;
$this->userId = $userId;
$this->bootstrapCoordinator = $bootstrapCoordinator;
@@ -161,7 +157,6 @@ class PreviewManager implements IPreview {
$this->rootFolder,
$this->config
),
- $this->legacyEventDispatcher,
$this->eventDispatcher
);
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 03c03e1b6ed..6239b20beee 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -340,7 +340,6 @@ class Server extends ServerContainer implements IServerContainer {
$c->get(SystemConfig::class)
),
$c->get(IEventDispatcher::class),
- $c->get(SymfonyAdapter::class),
$c->get(GeneratorHelper::class),
$c->get(ISession::class)->get('user_id'),
$c->get(Coordinator::class),
diff --git a/lib/public/IPreview.php b/lib/public/IPreview.php
index 8483587d60e..2758eba8d63 100644
--- a/lib/public/IPreview.php
+++ b/lib/public/IPreview.php
@@ -38,12 +38,6 @@ use OCP\Files\SimpleFS\ISimpleFile;
* @since 6.0.0
*/
interface IPreview {
- /**
- * @since 9.2.0
- * @deprecated 22.0.0
- */
- public const EVENT = self::class . ':' . 'PreviewRequested';
-
public const MODE_FILL = 'fill';
public const MODE_COVER = 'cover';
diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php
index 2216674a34c..c7ffab27592 100644
--- a/tests/lib/Preview/GeneratorTest.php
+++ b/tests/lib/Preview/GeneratorTest.php
@@ -35,8 +35,6 @@ use OCP\IConfig;
use OCP\IPreview;
use OCP\Preview\BeforePreviewFetchedEvent;
use OCP\Preview\IProviderV2;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
class GeneratorTest extends \Test\TestCase {
/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
@@ -54,9 +52,6 @@ class GeneratorTest extends \Test\TestCase {
/** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
private $eventDispatcher;
- /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */
- private $legacyEventDispatcher;
-
/** @var Generator */
private $generator;
@@ -68,14 +63,12 @@ class GeneratorTest extends \Test\TestCase {
$this->appData = $this->createMock(IAppData::class);
$this->helper = $this->createMock(GeneratorHelper::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
- $this->legacyEventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->generator = new Generator(
$this->config,
$this->previewManager,
$this->appData,
$this->helper,
- $this->legacyEventDispatcher,
$this->eventDispatcher
);
}
@@ -112,17 +105,6 @@ class GeneratorTest extends \Test\TestCase {
$previewFolder->method('getDirectoryListing')
->willReturn([$maxPreview, $previewFile]);
- $this->legacyEventDispatcher->expects($this->once())
- ->method('dispatch')
- ->with(
- $this->equalTo(IPreview::EVENT),
- $this->callback(function (GenericEvent $event) use ($file) {
- return $event->getSubject() === $file &&
- $event->getArgument('width') === 100 &&
- $event->getArgument('height') === 100;
- })
- );
-
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
->with(new BeforePreviewFetchedEvent($file, 100, 100, false, IPreview::MODE_FILL));
@@ -251,17 +233,6 @@ class GeneratorTest extends \Test\TestCase {
->method('putContent')
->with('my resized data');
- $this->legacyEventDispatcher->expects($this->once())
- ->method('dispatch')
- ->with(
- $this->equalTo(IPreview::EVENT),
- $this->callback(function (GenericEvent $event) use ($file) {
- return $event->getSubject() === $file &&
- $event->getArgument('width') === 100 &&
- $event->getArgument('height') === 100;
- })
- );
-
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
->with(new BeforePreviewFetchedEvent($file, 100, 100, false, IPreview::MODE_FILL));
@@ -301,19 +272,6 @@ class GeneratorTest extends \Test\TestCase {
->with($this->equalTo('1024-512-crop.png'))
->willThrowException(new NotFoundException());
- $this->legacyEventDispatcher->expects($this->once())
- ->method('dispatch')
- ->with(
- $this->equalTo(IPreview::EVENT),
- $this->callback(function (GenericEvent $event) use ($file) {
- return $event->getSubject() === $file &&
- $event->getArgument('width') === 1024 &&
- $event->getArgument('height') === 512 &&
- $event->getArgument('crop') === true &&
- $event->getArgument('mode') === IPreview::MODE_COVER;
- })
- );
-
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
->with(new BeforePreviewFetchedEvent($file, 1024, 512, true, IPreview::MODE_COVER));
@@ -351,19 +309,6 @@ class GeneratorTest extends \Test\TestCase {
$this->previewManager->expects($this->never())
->method('isMimeSupported');
- $this->legacyEventDispatcher->expects($this->once())
- ->method('dispatch')
- ->with(
- $this->equalTo(IPreview::EVENT),
- $this->callback(function (GenericEvent $event) use ($file) {
- return $event->getSubject() === $file &&
- $event->getArgument('width') === 1024 &&
- $event->getArgument('height') === 512 &&
- $event->getArgument('crop') === true &&
- $event->getArgument('mode') === IPreview::MODE_COVER;
- })
- );
-
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
->with(new BeforePreviewFetchedEvent($file, 1024, 512, true, IPreview::MODE_COVER));
@@ -392,17 +337,6 @@ class GeneratorTest extends \Test\TestCase {
$this->previewManager->method('getProviders')
->willReturn([]);
- $this->legacyEventDispatcher->expects($this->once())
- ->method('dispatch')
- ->with(
- $this->equalTo(IPreview::EVENT),
- $this->callback(function (GenericEvent $event) use ($file) {
- return $event->getSubject() === $file &&
- $event->getArgument('width') === 100 &&
- $event->getArgument('height') === 100;
- })
- );
-
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
->with(new BeforePreviewFetchedEvent($file, 100, 100, false, IPreview::MODE_FILL));
@@ -528,19 +462,6 @@ class GeneratorTest extends \Test\TestCase {
->with($this->equalTo($filename))
->willReturn($preview);
- $this->legacyEventDispatcher->expects($this->once())
- ->method('dispatch')
- ->with(
- $this->equalTo(IPreview::EVENT),
- $this->callback(function (GenericEvent $event) use ($file, $reqX, $reqY, $crop, $mode) {
- return $event->getSubject() === $file &&
- $event->getArgument('width') === $reqX &&
- $event->getArgument('height') === $reqY &&
- $event->getArgument('crop') === $crop &&
- $event->getArgument('mode') === $mode;
- })
- );
-
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
->with(new BeforePreviewFetchedEvent($file, $reqX, $reqY, $crop, $mode));