Skip to content
Merged
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
5 changes: 2 additions & 3 deletions .github/workflows/repair.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ jobs:
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init --force --recursive --depth=1

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -139,4 +138,4 @@ jobs:
- name: Check logs
if: always()
run: |
cat data/nextcloud.log
cat data/nextcloud.log
3 changes: 1 addition & 2 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ jobs:
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
git submodule update --init --force --recursive --depth=1

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Requirements:
- mbstring: *
- when using MySQL, use at least v8.0
]]></description>
<version>16.1.4</version>
<version>16.2.0-dev.0</version>
<licence>agpl</licence>
<author mail="mklehr@gmx.net" homepage="https://marcelklehr.de">Marcel Klehr</author>
<author mail="blizzz@arthur-schiwon.de" homepage="https://www.arthur-schiwon.de">Arthur Schiwon</author>
Expand All @@ -42,7 +42,7 @@ Requirements:
<database>pgsql</database>
<lib>intl</lib>
<lib>mbstring</lib>
<nextcloud min-version="32" max-version="33" />
<nextcloud min-version="32" max-version="34" />
</dependencies>
<background-jobs>
<job>OCA\Bookmarks\BackgroundJobs\CrawlJob</job>
Expand Down
4 changes: 2 additions & 2 deletions lib/AugmentedTemplateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace OCA\Bookmarks;

use OC;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IURLGenerator;

/**
* @template S of \OCP\AppFramework\Http::STATUS_*
Expand All @@ -19,7 +19,7 @@
class AugmentedTemplateResponse extends TemplateResponse {
public function render() {
$return = parent::render();
preg_replace('/<link rel="manifest" href="(.*?)">/i', '<link rel="manifest" href="' . OC::$server->getURLGenerator()->linkToRouteAbsolute('bookmarks.web_view.manifest') . '">', $return);
preg_replace('/<link rel="manifest" href="(.*?)">/i', '<link rel="manifest" href="' . \OCP\Server::get(IUrlGenerator::class)->linkToRouteAbsolute('bookmarks.web_view.manifest') . '">', $return);
return $return;
}
}
2 changes: 1 addition & 1 deletion lib/Db/BookmarkMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ private function _filterDuplicated(IQueryBuilder $qb, QueryParameters $params) {
private function _filterFolder(IQueryBuilder $qb, QueryParameters $params): void {
if ($params->getFolder() !== null) {
if ($params->getRecursive()) {
$childFolders = \OC::$server->get(TreeMapper::class)->findByAncestorFolder(TreeMapper::TYPE_FOLDER, $params->getFolder());
$childFolders = \OCP\Server::get(TreeMapper::class)->findByAncestorFolder(TreeMapper::TYPE_FOLDER, $params->getFolder());
$ids = [...array_map(fn (Folder $folder) => $folder->getId(), $childFolders), $params->getFolder()];
$qb->andWhere($qb->expr()->in('tree.parent_folder', $qb->createPositionalParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)));
} else {
Expand Down
24 changes: 11 additions & 13 deletions lib/ExportResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

namespace OCA\Bookmarks;

use OC;
use OC\HintException;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Http\Response;
use OCP\IDateTimeFormatter;
use OCP\IUserSession;

/**
* @psalm-template S of int
Expand All @@ -24,21 +23,20 @@ class ExportResponse extends Response {

public function __construct($returnstring) {
parent::__construct();

$user = OC::$server->getUserSession()->getUser();
if (is_null($user)) {
throw new HintException('User not logged in');
}

$userName = $user->getDisplayName();
$themingDefaults = \OCP\Server::get(ThemingDefaults::class);
$dateTime = \OCP\Server::get(IDateTimeFormatter::class);
$themingDefaults = \OCP\Server::get(ThemingDefaults::class);
$productName = $themingDefaults->getName();
$userName = null;

$user = \OCP\Server::get(IUserSession::class)->getUser();
if ($user !== null) {
$userName = $user->getDisplayName();
}

$export_name = '"' . $productName . ' Bookmarks (' . $userName . ') (' . $dateTime->formatDate(time()) . ').html"';
$export_name = '"' . $productName . ' Bookmarks' . ($userName ? ' (' . $userName . ') ' : '') . '(' . $dateTime->formatDate(time()) . ').html"';
$this->addHeader('Cache-Control', 'private');
$this->addHeader('Content-Type', ' application/stream');
$this->addHeader('Content-Length', strlen($returnstring));
$this->addHeader('Content-Type', 'application/stream');
$this->addHeader('Content-Length', '' . strlen($returnstring));
$this->addHeader('Content-Disposition', 'attachment; filename=' . $export_name);
$this->returnstring = $returnstring;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/Flow/CreateBookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace OCA\Bookmarks\Flow;

use OC;
use OCA\Bookmarks\Exception\AlreadyExistsError;
use OCA\Bookmarks\Exception\UnsupportedOperation;
use OCA\Bookmarks\Exception\UrlParseError;
Expand Down Expand Up @@ -73,12 +72,12 @@ public function __construct(IL10N $l, BookmarkService $bookmarks, IUserSession $
public static function register(IEventDispatcher $dispatcher): void {
if (interface_exists(IManager::class)) {
$dispatcher->addListener(RegisterOperationsEvent::class, static function (RegisterOperationsEvent $event) {
$operation = OC::$server->query(CreateBookmark::class);
$operation = \OCP\Server::get(CreateBookmark::class);
$event->registerOperation($operation);
Util::addScript('bookmarks', 'bookmarks-flow');
});
$dispatcher->addListener(RegisterEntitiesEvent::class, static function (RegisterEntitiesEvent $event) {
$entity = OC::$server->query(Bookmark::class);
$entity = \OCP\Server::get(Bookmark::class);
$event->registerEntity($entity);
Util::addScript('bookmarks', 'bookmarks-flow');
});
Expand Down
8 changes: 8 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
<code><![CDATA[$this->folderController->getFolders()->getData()]]></code>
</UndefinedMethod>
</file>
<file src="lib/Db/BookmarkMapper.php">
<ReservedWord>
<code><![CDATA[Folder]]></code>
</ReservedWord>
</file>
<file src="lib/Db/TreeMapper.php">
<InvalidReturnStatement>
<code><![CDATA[$this->bookmarkMapper->findAll($userId, $params)]]></code>
Expand All @@ -48,6 +53,9 @@
<InvalidTemplateParam>
<code><![CDATA[ExportResponse]]></code>
</InvalidTemplateParam>
<UndefinedClass>
<code><![CDATA[ThemingDefaults]]></code>
</UndefinedClass>
</file>
<file src="lib/Flow/CreateBookmark.php">
<UndefinedClass>
Expand Down
7 changes: 4 additions & 3 deletions tests/BackupManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use OCA\Bookmarks\Service\BookmarkService;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IUserManager;

class BackupManagerTest extends TestCase {
/**
Expand Down Expand Up @@ -47,12 +48,12 @@ protected function setUp(): void {
parent::setUp();
$this->cleanUp();

$this->bookmarks = \OC::$server->query(BookmarkService::class);
$this->backupManager = \OC::$server->query(BackupManager::class);
$this->bookmarks = \OCP\Server::get(BookmarkService::class);
$this->backupManager = \OCP\Server::get(BackupManager::class);
$this->time = $this->createStub(ITimeFactory::class);
$this->backupManager->injectTimeFactory($this->time);

$this->userManager = \OC::$server->getUserManager();
$this->userManager = \OCP\Server::get(IUserManager::class);
$this->user = 'test';
if (!$this->userManager->userExists($this->user)) {
$this->userManager->createUser($this->user, 'password');
Expand Down
43 changes: 21 additions & 22 deletions tests/BookmarkControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OCA\Bookmarks\Tests;

use OC;
use OCA\Bookmarks\Controller\BookmarkController;
use OCA\Bookmarks\Db\Bookmark;
use OCA\Bookmarks\Db\BookmarkMapper;
Expand Down Expand Up @@ -161,12 +160,12 @@ protected function setUp(): void {

$this->user = 'test';
$this->otherUser = 'otheruser';
$this->request = OC::$server->get(IRequest::class);
$this->otherRequest = OC::$server->get(IRequest::class);
$this->request = \OCP\Server::get(IRequest::class);
$this->otherRequest = \OCP\Server::get(IRequest::class);

$this->publicRequest = $this->createMock(IRequest::class);

$this->userManager = OC::$server->get(IUserManager::class);
$this->userManager = \OCP\Server::get(IUserManager::class);
if (!$this->userManager->userExists($this->user)) {
$this->userManager->createUser($this->user, 'password');
}
Expand All @@ -177,27 +176,27 @@ protected function setUp(): void {
$this->otherUserId = $this->userManager->get($this->otherUser)->getUID();

/** @var IFactory $l10nFactory */
$l10nFactory = OC::$server->get(IFactory::class);
$l10nFactory = \OCP\Server::get(IFactory::class);
$l = $l10nFactory->get('bookmarks');
$this->bookmarks = OC::$server->get(BookmarkService::class);
$this->bookmarkMapper = OC::$server->get(BookmarkMapper::class);
$this->tagMapper = OC::$server->get(TagMapper::class);
$this->folderMapper = OC::$server->get(FolderMapper::class);
$this->treeMapper = OC::$server->get(TreeMapper::class);
$this->publicFolderMapper = OC::$server->get(PublicFolderMapper::class);
$this->shareMapper = OC::$server->get(ShareMapper::class);
$this->sharedFolderMapper = OC::$server->get(SharedFolderMapper::class);

$timeFactory = OC::$server->get(ITimeFactory::class);
$logger = OC::$server->get(LoggerInterface::class);
$urlGenerator = OC::$server->get(IURLGenerator::class);
$htmlExporter = OC::$server->get(HtmlExporter::class);
$this->authorizer = OC::$server->get(Authorizer::class);
$this->folders = OC::$server->get(FolderService::class);
$this->lockManager = OC::$server->get(LockManager::class);
$this->bookmarks = \OCP\Server::get(BookmarkService::class);
$this->bookmarkMapper = \OCP\Server::get(BookmarkMapper::class);
$this->tagMapper = \OCP\Server::get(TagMapper::class);
$this->folderMapper = \OCP\Server::get(FolderMapper::class);
$this->treeMapper = \OCP\Server::get(TreeMapper::class);
$this->publicFolderMapper = \OCP\Server::get(PublicFolderMapper::class);
$this->shareMapper = \OCP\Server::get(ShareMapper::class);
$this->sharedFolderMapper = \OCP\Server::get(SharedFolderMapper::class);

$timeFactory = \OCP\Server::get(ITimeFactory::class);
$logger = \OCP\Server::get(LoggerInterface::class);
$urlGenerator = \OCP\Server::get(IURLGenerator::class);
$htmlExporter = \OCP\Server::get(HtmlExporter::class);
$this->authorizer = \OCP\Server::get(Authorizer::class);
$this->folders = \OCP\Server::get(FolderService::class);
$this->lockManager = \OCP\Server::get(LockManager::class);

/** @var IRootFolder $rootFolder */
$rootFolder = OC::$server->get(IRootFolder::class);
$rootFolder = \OCP\Server::get(IRootFolder::class);

$this->controller = new BookmarkController('bookmarks', $this->request, $l, $this->bookmarkMapper, $this->tagMapper, $this->folderMapper, $this->treeMapper, $this->publicFolderMapper, $timeFactory, $logger, $htmlExporter, $this->authorizer, $this->bookmarks, $this->folders, $rootFolder, $this->lockManager);
$this->otherController = new BookmarkController('bookmarks', $this->request, $l, $this->bookmarkMapper, $this->tagMapper, $this->folderMapper, $this->treeMapper, $this->publicFolderMapper, $timeFactory, $logger, $htmlExporter, $this->authorizer, $this->bookmarks, $this->folders, $rootFolder, $this->lockManager);
Expand Down
9 changes: 4 additions & 5 deletions tests/BookmarkMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OCA\Bookmarks\Tests;

use OC;
use OCA\Bookmarks\Db;
use OCA\Bookmarks\Exception\AlreadyExistsError;
use OCA\Bookmarks\Exception\UrlParseError;
Expand Down Expand Up @@ -51,11 +50,11 @@ protected function setUp(): void {
/**
* @var Db\BookmarkMapper
*/
$this->bookmarkMapper = OC::$server->get(Db\BookmarkMapper::class);
$this->treeMapper = OC::$server->get(Db\TreeMapper::class);
$this->folderMapper = OC::$server->get(Db\FolderMapper::class);
$this->bookmarkMapper = \OCP\Server::get(Db\BookmarkMapper::class);
$this->treeMapper = \OCP\Server::get(Db\TreeMapper::class);
$this->folderMapper = \OCP\Server::get(Db\FolderMapper::class);

$this->userManager = OC::$server->get(IUserManager::class);
$this->userManager = \OCP\Server::get(IUserManager::class);
$this->user = 'test';
if (!$this->userManager->userExists($this->user)) {
$this->userManager->createUser($this->user, 'password');
Expand Down
11 changes: 6 additions & 5 deletions tests/FindTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OCA\Bookmarks\QueryParameters;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\QueryException;
use OCP\IUserManager;

class FindTest extends TestCase {
/**
Expand Down Expand Up @@ -55,12 +56,12 @@ protected function setUp(): void {
parent::setUp();
$this->cleanUp();

$this->bookmarkMapper = \OC::$server->query(Db\BookmarkMapper::class);
$this->tagMapper = \OC::$server->query(Db\TagMapper::class);
$this->folderMapper = \OC::$server->query(Db\FolderMapper::class);
$this->treeMapper = \OC::$server->query(Db\TreeMapper::class);
$this->bookmarkMapper = \OCP\Server::get(Db\BookmarkMapper::class);
$this->tagMapper = \OCP\Server::get(Db\TagMapper::class);
$this->folderMapper = \OCP\Server::get(Db\FolderMapper::class);
$this->treeMapper = \OCP\Server::get(Db\TreeMapper::class);

$this->userManager = \OC::$server->getUserManager();
$this->userManager = \OCP\Server::get(IUserManager::class);
$this->user = 'test';
if (!$this->userManager->userExists($this->user)) {
$this->userManager->createUser($this->user, 'password');
Expand Down
33 changes: 16 additions & 17 deletions tests/FolderControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OCA\Bookmarks\Tests;

use OC;
use OCA\Bookmarks\Controller\FoldersController;
use OCA\Bookmarks\Db\Bookmark;
use OCA\Bookmarks\Db\BookmarkMapper;
Expand Down Expand Up @@ -92,11 +91,11 @@ protected function setUp(): void {

$this->user = 'test';
$this->otherUser = 'otheruser';
$this->request = OC::$server->get(IRequest::class);
$this->request = \OCP\Server::get(IRequest::class);

$this->publicRequest = $this->createMock(IRequest::class);

$this->userManager = OC::$server->get(IUserManager::class);
$this->userManager = \OCP\Server::get(IUserManager::class);
if (!$this->userManager->userExists($this->user)) {
$this->userManager->createUser($this->user, 'password');
}
Expand All @@ -106,13 +105,13 @@ protected function setUp(): void {
}
$this->otherUserId = $this->userManager->get($this->otherUser)->getUID();

$this->bookmarkMapper = OC::$server->get(BookmarkMapper::class);
$this->tagMapper = OC::$server->get(TagMapper::class);
$this->folderMapper = OC::$server->get(FolderMapper::class);
$this->treeMapper = OC::$server->get(TreeMapper::class);
$this->publicFolderMapper = OC::$server->get(PublicFolderMapper::class);
$this->shareMapper = OC::$server->get(ShareMapper::class);
$this->sharedFolderMapper = OC::$server->get(SharedFolderMapper::class);
$this->bookmarkMapper = \OCP\Server::get(BookmarkMapper::class);
$this->tagMapper = \OCP\Server::get(TagMapper::class);
$this->folderMapper = \OCP\Server::get(FolderMapper::class);
$this->treeMapper = \OCP\Server::get(TreeMapper::class);
$this->publicFolderMapper = \OCP\Server::get(PublicFolderMapper::class);
$this->shareMapper = \OCP\Server::get(ShareMapper::class);
$this->sharedFolderMapper = \OCP\Server::get(SharedFolderMapper::class);
$this->emptyCache = $emptyCache = $this->createMock(ICache::class);
$emptyCache->method('get')->willReturn(null);
$emptyCache->method('set')->willReturn(true);
Expand All @@ -127,13 +126,13 @@ protected function setUp(): void {
$this->shareMapper,
$this->sharedFolderMapper,
$this->cacheFactory,
OC::$server->get(ContainerInterface::class),
\OCP\Server::get(ContainerInterface::class),
$this->tagMapper,
);
$this->folders = OC::$server->get(FolderService::class);
$this->bookmarks = OC::$server->get(BookmarkService::class);
$this->groupManager = OC::$server->get(IGroupManager::class);
$loggerInterface = OC::$server->get(LoggerInterface::class);
$this->folders = \OCP\Server::get(FolderService::class);
$this->bookmarks = \OCP\Server::get(BookmarkService::class);
$this->groupManager = \OCP\Server::get(IGroupManager::class);
$loggerInterface = \OCP\Server::get(LoggerInterface::class);

$this->group = $this->groupManager->createGroup('foobar');
$this->group->addUser($this->userManager->get($this->otherUser));
Expand All @@ -149,7 +148,7 @@ protected function setUp(): void {
$this->treeMapper,
$userSession,
$this->sharedFolderMapper,
OC::$server->get(ICrypto::class),
\OCP\Server::get(ICrypto::class),
$this->userManager,
);

Expand Down Expand Up @@ -271,7 +270,7 @@ public function testHash(bool $useCache): void {
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->cacheFactory->method('createDistributed')
->willReturnCallback(fn ()
=> OC::$server->get(ICacheFactory::class)
=> \OCP\Server::get(ICacheFactory::class)
->createDistributed(time() . '' . random_int(0, 1000000))
);
}
Expand Down
Loading
Loading