mirror of
https://github.com/nextcloud/server.git
synced 2026-11-14 06:32:09 +01:00
Dropping the bundled app takes the OCA.Viewer global and the LoadViewer event with it, and apps in the wild still use both: text and recommendations ask the global what it can open, photos opens and closes it, files_pdfviewer re-opens the current file with another handler, and photos, maps and collectives construct the event without checking that it exists, so their pages would fail on the missing class. The global goes back on the page, backed by the package rather than by the app. open() takes the paths and the loose file info apps passed before and turns them into nodes, the getters answer from what the last open() was given, and mimetypes answers by asking the handlers about a file of that type. registerHandler is deliberately not here: it was deprecated in the viewer app in August 2025 and this is where it stops. The event stays as an empty class nobody dispatches. Both live in apps/viewer, which is not an app: it has no appinfo, the server autoloads the event from it and the core viewer init script imports the bridge. The checkers that take every folder in apps/ for an app are told so: .noopenapi, the untranslated list, and a skip in the autoloader checker and in tests/enable_all.php for folders without an appinfo/info.xml. psalm lints it like the others. Every use of the global logs a warning naming the replacement and Nextcloud 39, where the folder and those exceptions go. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
37 lines
962 B
PHP
37 lines
962 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\Viewer\Tests;
|
|
|
|
use OCA\Viewer\Event\LoadViewer;
|
|
use OCP\EventDispatcher\Event;
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
|
use OCP\Server;
|
|
use Test\TestCase;
|
|
|
|
/**
|
|
* The viewer app is gone, but apps still construct its event without
|
|
* checking that it exists: that has to keep working until 39.
|
|
*/
|
|
class LoadViewerTest extends TestCase {
|
|
public function testAppsCanStillDispatchIt(): void {
|
|
$dispatcher = Server::get(IEventDispatcher::class);
|
|
$heard = [];
|
|
$listener = static function (Event $event) use (&$heard): void {
|
|
$heard[] = $event;
|
|
};
|
|
$dispatcher->addListener(LoadViewer::class, $listener);
|
|
|
|
$event = new LoadViewer();
|
|
$dispatcher->dispatchTyped($event);
|
|
$dispatcher->removeListener(LoadViewer::class, $listener);
|
|
|
|
$this->assertSame([$event], $heard);
|
|
}
|
|
}
|