Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Command/PageTrashCleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

namespace OCA\Collectives\Command;

use OC;
use OCA\Collectives\Db\CollectiveMapper;
use OCA\Collectives\Service\MissingDependencyException;
use OCA\Collectives\Service\NotFoundException;
use OCA\Collectives\Service\NotPermittedException;
use OCA\Collectives\Trash\PageTrashBackend;
use OCP\App\IAppManager;
use OCP\Server;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -34,7 +34,7 @@ public function __construct(
) {
parent::__construct();
if ($appManager->isEnabledForUser('files_trashbin')) {
$this->trashBackend = OC::$server->get(PageTrashBackend::class);
$this->trashBackend = Server::get(PageTrashBackend::class);
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Model/PageInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use OCP\Files\File;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\L10N\IFactory;
use OCP\Server;

class PageInfo implements JsonSerializable {
public const INDEX_PAGE_TITLE = 'Readme';
Expand Down Expand Up @@ -237,7 +239,7 @@ public function fromFile(
if (strcmp($file->getName(), self::INDEX_PAGE_TITLE . self::SUFFIX) === 0) {
if ($parentId === 0) {
// Landing page
$this->setTitle(\OC::$server->getL10N('collectives')->t('Landing page'));
$this->setTitle(Server::get(IFactory::class)->get('collectives')->t('Landing page'));
} else {
// Index page
$this->setTitle(basename($dirName));
Expand Down
21 changes: 19 additions & 2 deletions lib/Mount/CollectiveFolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\IUser;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Server;

class CollectiveFolderManager {
private const SKELETON_DIR = 'skeleton';
Expand Down Expand Up @@ -89,8 +90,8 @@ public function getRootFolder(): Folder {
private function getCurrentUID(): ?string {
try {
// wopi requests are not logged in, instead we need to get the editor user from the access token
if (strpos($this->request->getRawPathInfo(), 'apps/richdocuments/wopi') && class_exists('OCA\Richdocuments\Db\WopiMapper')) {
$wopiMapper = OC::$server->query('OCA\Richdocuments\Db\WopiMapper');
if (strpos($this->request->getRawPathInfo(), 'apps/richdocuments/wopi') && class_exists(\OCA\Richdocuments\Db\WopiMapper::class)) {
$wopiMapper = Server::get(\OCA\Richdocuments\Db\WopiMapper::class);
$token = $this->request->getParam('access_token');
if ($token) {
return $wopiMapper->getPathForToken($token)->getEditorUid();
Expand Down Expand Up @@ -210,6 +211,22 @@ private function getSkeletonFolder(Folder $folder): Folder {
/**
* @throws NotFoundException
* @throws \OCP\DB\Exception
* @return array{
* folder_id: int,
* fileid: int,
* storage: int,
* path: string,
* name: string,
* mimetype: string,
* mimepart: string,
* size: int|float,
* mtime: int,
* storage_mtime: int,
* etag: string,
* encrytped: bool,
* parent: int,
* permissions: int,
* }
*/
public function getFolderFileCache(int $id, string $name): array {
$qb = $this->connection->getQueryBuilder();
Expand Down
5 changes: 3 additions & 2 deletions lib/Mount/NoExcludePropagatorStorageWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

namespace OCA\Collectives\Mount;

use OC;
use OC\Files\Cache\Propagator;
use OC\Files\Storage\Storage;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\IDBConnection;
use OCP\Server;

class NoExcludePropagatorStorageWrapper extends Wrapper {
/**
Expand All @@ -26,7 +27,7 @@ public function getPropagator($storage = null): Propagator {
$storage = $this;
}
if (!isset($storage->propagator)) {
$storage->propagator = new Propagator($storage, OC::$server->getDatabaseConnection());
$storage->propagator = new Propagator($storage, Server::get(IDBConnection::class));
}
return $storage->propagator;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/CollectiveService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace OCA\Collectives\Service;

use OC;
use OC\Files\Node\File;
use OCA\Circles\Model\Member;
use OCA\Collectives\Db\Collective;
use OCA\Collectives\Db\CollectiveMapper;
Expand All @@ -26,10 +24,12 @@
use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\File;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException as FilesNotFoundException;
use OCP\Files\NotPermittedException as FilesNotPermittedException;
use OCP\IL10N;
use OCP\Server;
use Symfony\Component\String\Slugger\SluggerInterface;

class CollectiveService extends CollectiveServiceBase {
Expand All @@ -56,13 +56,13 @@ public function __construct(

private function initPageTrashBackend(): void {
if ($this->appManager->isEnabledForUser('files_trashbin')) {
$this->pageTrashBackend = OC::$server->get(PageTrashBackend::class);
$this->pageTrashBackend = Server::get(PageTrashBackend::class);
}
}

private function initPageVersionsBackend(): void {
if ($this->appManager->isEnabledForUser('files_versions')) {
$this->pageVersionsBackend = OC::$server->get(VersionsBackend::class);
$this->pageVersionsBackend = Server::get(VersionsBackend::class);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Service/PageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
namespace OCA\Collectives\Service;

use Exception;
use OC;
use OC_Util;
use OCA\Collectives\Db\Collective;
use OCA\Collectives\Db\Page;
Expand All @@ -32,6 +31,7 @@
use OCP\IConfig;
use OCP\IUserManager;
use OCP\Lock\LockedException;
use OCP\Server;
use Psr\Container\ContainerInterface;
use Symfony\Component\String\Slugger\SluggerInterface;

Expand Down Expand Up @@ -64,7 +64,7 @@ public function __construct(

private function initTrashBackend(): void {
if ($this->appManager->isEnabledForUser('files_trashbin')) {
$this->trashBackend = OC::$server->get(PageTrashBackend::class);
$this->trashBackend = Server::get(PageTrashBackend::class);
}
}

Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
<errorLevel type="suppress">
<referencedClass name="Doctrine\DBAL\Types\Type" />
<referencedClass name="OCP\SetupCheck\ISetupCheck" />
<referencedClass name="OCA\Richdocuments\Db\WopiMapper" />
</errorLevel>
</UndefinedClass>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<referencedClass name="OCA\Richdocuments\Db\WopiMapper" />
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace BackgroundJob;

use OC\Files\FileInfo;
use OC\User\User;
use OCA\Collectives\Db\CollectiveMapper;
use OCA\Collectives\Mount\CollectiveFolderManager;
Expand All @@ -18,6 +17,7 @@
use OCA\Collectives\Versions\VersionsBackend;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\FileInfo;
use OCP\IDBConnection;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerInterface;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fs/NodeHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace Unit\Fs;

use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OCA\Collectives\Fs\NodeHelper;
use OCA\Collectives\Service\NotFoundException;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\IDBConnection;
use OCP\IL10N;
use PHPUnit\Framework\TestCase;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fs/UserFolderHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace Unit\Fs;

use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OCA\Collectives\Db\Collective;
use OCA\Collectives\Fs\UserFolderHelper;
use OCA\Collectives\Service\NotPermittedException;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\IAppConfig;
use OCP\IConfig;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Search/PageContentProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Unit\Service;

use OC\Files\Node\Folder;
use OC\Search\SearchQuery;
use OCA\Collectives\Db\Collective;
use OCA\Collectives\Search\PageContentProvider;
Expand All @@ -18,6 +17,7 @@
use OCA\Collectives\Service\PageService;
use OCA\Collectives\Service\SearchService;
use OCP\App\IAppManager;
use OCP\Files\Folder;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Service/AttachmentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace Unit\Service;

use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OCA\Collectives\Service\AttachmentService;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\IPreview;
use PHPUnit\Framework\TestCase;

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Service/CollectiveServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace Unit\Service;

use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OCA\Circles\Model\Circle;
use OCA\Circles\Model\Member;
use OCA\Collectives\Db\Collective;
Expand All @@ -29,6 +27,8 @@
use OCA\Collectives\Service\UnprocessableEntityException;
use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\IL10N;
use PHPUnit\Framework\TestCase;
use Symfony\Component\String\Slugger\SluggerInterface;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Service/CollectiveShareServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Unit\Service;

use OC\Files\Node\Folder;
use OC\Share20\Share;
use OCA\Collectives\Db\Collective;
use OCA\Collectives\Db\CollectiveShare;
Expand All @@ -20,6 +19,7 @@
use OCA\Collectives\Service\PageService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\Files\Folder;
use OCP\IL10N;
use OCP\Lock\LockedException;
use OCP\Share\Exceptions\GenericShareException;
Expand Down
11 changes: 5 additions & 6 deletions tests/Unit/Service/PageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

use OC\App\AppManager;
use OC\Files\Mount\MountPoint;
use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OCA\Circles\Model\Member;
use OCA\Collectives\Db\Collective;
use OCA\Collectives\Db\Page;
Expand All @@ -27,6 +25,9 @@
use OCA\Collectives\Service\NotPermittedException;
use OCA\Collectives\Service\PageService;
use OCA\Collectives\Service\SessionService;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException as FilesNotFoundException;
use OCP\IConfig;
use OCP\IUserManager;
Expand Down Expand Up @@ -198,7 +199,7 @@ public function testGetIndexPageFileBrokenIndex(): void {
PageService::getIndexPageFile($folder);
}

private function prepareFile(string $fileName, Folder $parent, MountPoint $mountPoint, int $id = 1): File {
private function prepareFile(string $fileName, Folder $parent, IMountPoint $mountPoint, int $id = 1): File {
$file = $this->createMock(File::class);
$file->method('getId')
->willReturn($id);
Expand Down Expand Up @@ -309,9 +310,7 @@ public function testGetPagesFromFolderRecursive(): void {
$folder->method('getName')
->willReturn('testfolder');

$mountPoint = $this->getMockBuilder(MountPoint::class)
->disableOriginalConstructor()
->getMock();
$mountPoint = $this->createMock(IMountPoint::class);
$mountPoint->method('getMountPoint')->willReturn('/files/user/Collectives/collective/');

$indexFile = $this->prepareFile('Readme.md', $folder, $mountPoint, 101);
Expand Down
7 changes: 1 addition & 6 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<files psalm-version="6.14.3@d0b040a91f280f071c1abcb1b77ce3822058725a">
<file src="lib/Fs/UserFolderHelper.php">
<UndefinedClass>
<code><![CDATA[$e]]></code>
Expand All @@ -16,11 +16,6 @@
<code><![CDATA[$maskedStorage]]></code>
</InvalidArgument>
</file>
<file src="lib/Service/CollectiveService.php">
<UndefinedClass>
<code><![CDATA[File]]></code>
</UndefinedClass>
</file>
<file src="lib/Service/PageService.php">
<UndefinedClass>
<code><![CDATA[$this->pushQueue]]></code>
Expand Down
4 changes: 0 additions & 4 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ declare(strict_types=1);
*/

namespace {
use OCP\IServerContainer;

class OC {
static $CLI = false;
/** @var string */
static $WEBROOT;
/** @var IServerContainer */
static $server;
}
}

Expand Down
Loading