mirror of https://github.com/nextcloud/bookmarks
Clean up PHP code inspection warnings
This commit is contained in:
parent
71ec4bf2fd
commit
c94c3cb01d
|
@ -30,10 +30,10 @@ Requirements:
|
|||
<screenshot small-thumbnail="https://raw.githubusercontent.com/nextcloud/bookmarks/master/screenshots/Bookmarks-small.png">https://raw.githubusercontent.com/nextcloud/bookmarks/master/screenshots/Bookmarks.png</screenshot>
|
||||
|
||||
<dependencies>
|
||||
<php min-version="7.2" />
|
||||
<php min-version="7.3" />
|
||||
<lib>intl</lib>
|
||||
<lib>mbstring</lib>
|
||||
<nextcloud min-version="18" max-version="21" />
|
||||
<nextcloud min-version="20" max-version="21" />
|
||||
</dependencies>
|
||||
<background-jobs>
|
||||
<job>OCA\Bookmarks\BackgroundJobs\CrawlJob</job>
|
||||
|
|
|
@ -90,7 +90,7 @@ class ActivityPublisher implements IEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
public function publishShare(ChangeEvent $event) {
|
||||
public function publishShare(ChangeEvent $event): void {
|
||||
$activity = $this->activityManager->generateEvent();
|
||||
$activity->setApp($this->appName);
|
||||
$activity->setType('bookmarks');
|
||||
|
@ -125,7 +125,7 @@ class ActivityPublisher implements IEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
public function publishFolder(ChangeEvent $event) {
|
||||
public function publishFolder(ChangeEvent $event): void {
|
||||
$activity = $this->activityManager->generateEvent();
|
||||
$activity->setApp($this->appName);
|
||||
$activity->setType('bookmarks');
|
||||
|
@ -177,7 +177,7 @@ class ActivityPublisher implements IEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
public function publishBookmark(ChangeEvent $event) {
|
||||
public function publishBookmark(ChangeEvent $event): void {
|
||||
$activity = $this->activityManager->generateEvent();
|
||||
$activity->setApp($this->appName);
|
||||
$activity->setType('bookmarks');
|
||||
|
|
|
@ -4,18 +4,20 @@
|
|||
namespace OCA\Bookmarks\Activity;
|
||||
|
||||
use OCP\Activity\IFilter;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
|
||||
class Filter implements IFilter {
|
||||
/**
|
||||
* @var \OCP\IL10N
|
||||
* @var IL10N
|
||||
*/
|
||||
private $l;
|
||||
/**
|
||||
* @var \OCP\IURLGenerator
|
||||
* @var IURLGenerator
|
||||
*/
|
||||
private $urlGenerator;
|
||||
|
||||
public function __construct(\OCP\IL10N $l, \OCP\IURLGenerator $urlGenerator) {
|
||||
public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
|
||||
$this->l = $l;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace OCA\Bookmarks\Activity;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCA\Bookmarks\Db\TreeMapper;
|
||||
use OCP\Activity\IEvent;
|
||||
use OCP\Activity\IManager;
|
||||
use OCP\Activity\IProvider;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
use OCP\L10N\IFactory;
|
||||
|
@ -29,7 +31,7 @@ class Provider implements IProvider {
|
|||
*/
|
||||
private $activityManager;
|
||||
/**
|
||||
* @var \OCP\IL10N
|
||||
* @var IL10N
|
||||
*/
|
||||
private $l;
|
||||
/**
|
||||
|
@ -50,7 +52,7 @@ class Provider implements IProvider {
|
|||
*/
|
||||
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
|
||||
if ($event->getApp() !== 'bookmarks') {
|
||||
throw new \InvalidArgumentException();
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->l = $this->languageFactory->get('bookmarks', $language);
|
||||
|
@ -199,7 +201,7 @@ class Provider implements IProvider {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException();
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
|
||||
if ($event->getObjectType() === TreeMapper::TYPE_FOLDER && !str_contains($event->getSubject(), 'deleted')) {
|
||||
|
|
|
@ -24,12 +24,13 @@
|
|||
|
||||
namespace OCA\Bookmarks;
|
||||
|
||||
use OC;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
||||
class AugmentedTemplateResponse extends TemplateResponse {
|
||||
public function render() {
|
||||
$return = parent::render();
|
||||
$return = preg_replace('/<link rel="manifest" href="(.*?)">/i', '<link rel="manifest" href="'.\OC::$server->getURLGenerator()->linkToRouteAbsolute('bookmarks.web_view.manifest').'">', $return);
|
||||
$return = preg_replace('/<link rel="manifest" href="(.*?)">/i', '<link rel="manifest" href="'. OC::$server->getURLGenerator()->linkToRouteAbsolute('bookmarks.web_view.manifest').'">', $return);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use OCA\Bookmarks\Db\Bookmark;
|
|||
use OCA\Bookmarks\Db\BookmarkMapper;
|
||||
use OCA\Bookmarks\Service\BookmarkPreviewer;
|
||||
use OCA\Bookmarks\Service\CrawlService;
|
||||
use OCP\Http\Client\IClient;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\IConfig;
|
||||
|
||||
|
@ -27,7 +28,7 @@ class CrawlJob extends TimedJob {
|
|||
*/
|
||||
private $clientService;
|
||||
/**
|
||||
* @var \OCP\Http\Client\IClient
|
||||
* @var IClient
|
||||
*/
|
||||
private $client;
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace OCA\Bookmarks\Controller;
|
|||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Contract\IImage;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
use OCA\Bookmarks\Db\BookmarkMapper;
|
||||
|
@ -405,12 +406,12 @@ class BookmarkController extends ApiController {
|
|||
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $url
|
||||
* @param string $title
|
||||
* @param string $description
|
||||
* @param array $tags
|
||||
* @param array $folders
|
||||
* @param int|null $id
|
||||
* @param string|null $url
|
||||
* @param string|null $title
|
||||
* @param string|null $description
|
||||
* @param array|null $tags
|
||||
* @param array|null $folders
|
||||
* @return JSONResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
|
@ -535,7 +536,7 @@ class BookmarkController extends ApiController {
|
|||
return new RedirectResponse($this->url->getAbsoluteURL('/index.php/svg/core/places/link?color=666666'));
|
||||
}
|
||||
return $this->doImageResponse($image);
|
||||
} catch (DoesNotExistException|MultipleObjectsReturnedException|\Exception $e) {
|
||||
} catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) {
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
}
|
||||
|
@ -561,7 +562,7 @@ class BookmarkController extends ApiController {
|
|||
return new RedirectResponse($this->url->getAbsoluteURL('/index.php/svg/core/places/link?color=666666'));
|
||||
}
|
||||
return $this->doImageResponse($image);
|
||||
} catch (DoesNotExistException|MultipleObjectsReturnedException|\Exception $e) {
|
||||
} catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) {
|
||||
return new NotFoundResponse();
|
||||
}
|
||||
}
|
||||
|
@ -569,7 +570,7 @@ class BookmarkController extends ApiController {
|
|||
/**
|
||||
* @param $image
|
||||
* @return DataDisplayResponse
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function doImageResponse(?IImage $image): Response {
|
||||
if ($image === null || $image->getData() === null) {
|
||||
|
@ -700,7 +701,6 @@ class BookmarkController extends ApiController {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $folder
|
||||
* @return JSONResponse
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
|
@ -717,7 +717,6 @@ class BookmarkController extends ApiController {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $folder
|
||||
* @return JSONResponse
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
|
|
|
@ -52,7 +52,7 @@ class FoldersController extends ApiController {
|
|||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $rootFolderId = null;
|
||||
private $rootFolderId;
|
||||
/**
|
||||
* @var HashManager
|
||||
*/
|
||||
|
@ -146,7 +146,7 @@ class FoldersController extends ApiController {
|
|||
* @param $folder
|
||||
* @return array
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws MultipleObjectsReturnedException|UnsupportedOperation
|
||||
*/
|
||||
private function _returnFolderAsArray($folder): array {
|
||||
if ($folder instanceof Folder) {
|
||||
|
@ -167,6 +167,8 @@ class FoldersController extends ApiController {
|
|||
$returnFolder['parent_folder'] = $this->toExternalFolderId($parent->getId());
|
||||
return $returnFolder;
|
||||
}
|
||||
|
||||
throw new UnsupportedOperation('Expected folder or Shared Folder');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -305,8 +307,8 @@ class FoldersController extends ApiController {
|
|||
|
||||
/**
|
||||
* @param int $folderId
|
||||
* @param string $title
|
||||
* @param int $parent_folder
|
||||
* @param string|null $title
|
||||
* @param int|null $parent_folder
|
||||
* @return JSONResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
|
@ -475,7 +477,6 @@ class FoldersController extends ApiController {
|
|||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
* @PublicPage
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function createFolderPublicToken($folderId): DataResponse {
|
||||
if (!Authorizer::hasPermission(Authorizer::PERM_RESHARE, $this->authorizer->getPermissionsForFolder($folderId, $this->request))) {
|
||||
|
|
|
@ -10,10 +10,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Controller;
|
||||
|
||||
use OCA\Bookmarks\Exception\AlreadyExistsError;
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Exception\UnsupportedOperation;
|
||||
use OCA\Bookmarks\Exception\UrlParseError;
|
||||
use OCA\Bookmarks\Exception\UserLimitExceededError;
|
||||
use OCA\Bookmarks\Service\Authorizer;
|
||||
use OCA\Bookmarks\Service\BookmarkService;
|
||||
use OCP\AppFramework\ApiController;
|
||||
|
@ -64,7 +62,6 @@ class InternalBookmarkController extends ApiController {
|
|||
* @param bool|null $archived
|
||||
* @return DataResponse
|
||||
*
|
||||
* @throws UrlParseError
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getBookmarks(
|
||||
|
@ -79,7 +76,7 @@ class InternalBookmarkController extends ApiController {
|
|||
$url = null,
|
||||
$unavailable = null,
|
||||
$archived = null
|
||||
) {
|
||||
): DataResponse {
|
||||
return $this->publicController->getBookmarks($page, $tags, $conjunction, $sortby, $search, $limit, $untagged, $folder, $url, $unavailable, $archived);
|
||||
}
|
||||
|
||||
|
@ -89,29 +86,13 @@ class InternalBookmarkController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getSingleBookmark($id) {
|
||||
public function getSingleBookmark($id): JSONResponse {
|
||||
return $this->publicController->getSingleBookmark($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $title
|
||||
* @param string $description
|
||||
* @param array $tags
|
||||
* @return JSONResponse
|
||||
*
|
||||
* @throws AlreadyExistsError
|
||||
* @throws UserLimitExceededError
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function newBookmark($url = "", $title = null, $description = "", $tags = [], $folders = []) {
|
||||
return $this->publicController->newBookmark($url, $title, $description, $tags, $folders);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param string $url
|
||||
* @param string $title
|
||||
* @param string|null $title
|
||||
* @param string $description
|
||||
* @param array $tags
|
||||
* @param array $folders
|
||||
|
@ -119,7 +100,22 @@ class InternalBookmarkController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function editBookmark($id = null, $url = null, $title = null, $description = "", $tags = [], $folders = null) {
|
||||
public function newBookmark($url = "", $title = null, $description = "", $tags = [], $folders = []): JSONResponse {
|
||||
return $this->publicController->newBookmark($url, $title, $description, $tags, $folders);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $id
|
||||
* @param string|null $url
|
||||
* @param string|null $title
|
||||
* @param string $description
|
||||
* @param array $tags
|
||||
* @param array|null $folders
|
||||
* @return JSONResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function editBookmark($id = null, $url = null, $title = null, $description = "", $tags = [], $folders = null): JSONResponse {
|
||||
return $this->publicController->editBookmark($id, $url, $title, $description, $tags, $folders);
|
||||
}
|
||||
|
||||
|
@ -129,7 +125,7 @@ class InternalBookmarkController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function deleteBookmark($id = -1) {
|
||||
public function deleteBookmark($id = -1): JSONResponse {
|
||||
return $this->publicController->deleteBookmark($id);
|
||||
}
|
||||
|
||||
|
@ -138,7 +134,7 @@ class InternalBookmarkController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function deleteAllBookmarks() {
|
||||
public function deleteAllBookmarks(): DataResponse {
|
||||
try {
|
||||
$this->bookmarks->deleteAll($this->userId);
|
||||
} catch (UnsupportedOperation|DoesNotExistException|MultipleObjectsReturnedException $e) {
|
||||
|
@ -152,9 +148,8 @@ class InternalBookmarkController extends ApiController {
|
|||
* @param string $url
|
||||
* @return JSONResponse
|
||||
* @NoAdminRequired
|
||||
* @throws UrlParseError
|
||||
*/
|
||||
public function clickBookmark($url = "") {
|
||||
public function clickBookmark($url = ""): JSONResponse {
|
||||
return $this->publicController->clickBookmark($url);
|
||||
}
|
||||
|
||||
|
@ -163,7 +158,7 @@ class InternalBookmarkController extends ApiController {
|
|||
* @return JSONResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function importBookmark($folder = null) {
|
||||
public function importBookmark($folder = null): JSONResponse {
|
||||
return $this->publicController->importBookmark($folder);
|
||||
}
|
||||
|
||||
|
@ -172,7 +167,7 @@ class InternalBookmarkController extends ApiController {
|
|||
* @return Response
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function exportBookmark() {
|
||||
public function exportBookmark(): Response {
|
||||
return $this->publicController->exportBookmark();
|
||||
}
|
||||
|
||||
|
@ -183,9 +178,9 @@ class InternalBookmarkController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getBookmarkImage($id) {
|
||||
public function getBookmarkImage($id): Response {
|
||||
return $this->publicController->getBookmarkImage($id);
|
||||
}
|
||||
|
||||
|
@ -196,9 +191,9 @@ class InternalBookmarkController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getBookmarkFavicon($id) {
|
||||
public function getBookmarkFavicon($id): Response {
|
||||
return $this->publicController->getBookmarkFavicon($id);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Controller;
|
||||
|
||||
use OCA\Bookmarks\Service\Authorizer;
|
||||
use OCP\AppFramework\ApiController;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
|
@ -12,7 +13,7 @@ class InternalFoldersController extends ApiController {
|
|||
/** @var FoldersController */
|
||||
private $controller;
|
||||
|
||||
public function __construct($appName, $request, $userId, FoldersController $controller, \OCA\Bookmarks\Service\Authorizer $authorizer) {
|
||||
public function __construct($appName, $request, $userId, FoldersController $controller, Authorizer $authorizer) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->controller = $controller;
|
||||
|
@ -28,7 +29,7 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function addFolder($title = '', $parent_folder = -1) {
|
||||
public function addFolder($title = '', $parent_folder = -1): JSONResponse {
|
||||
return $this->controller->addFolder($title, $parent_folder);
|
||||
}
|
||||
|
||||
|
@ -40,7 +41,7 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getFolderChildrenOrder($folderId, $layers) {
|
||||
public function getFolderChildrenOrder($folderId, $layers): JSONResponse {
|
||||
return $this->controller->getFolderChildrenOrder($folderId, $layers);
|
||||
}
|
||||
|
||||
|
@ -51,7 +52,7 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function setFolderChildrenOrder($folderId, $data = []) {
|
||||
public function setFolderChildrenOrder($folderId, $data = []): JSONResponse {
|
||||
return $this->controller->setFolderChildrenOrder($folderId, $data);
|
||||
}
|
||||
|
||||
|
@ -61,7 +62,7 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function deleteFolder($folderId) {
|
||||
public function deleteFolder($folderId): JSONResponse {
|
||||
return $this->controller->deleteFolder($folderId);
|
||||
}
|
||||
|
||||
|
@ -72,7 +73,7 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function addToFolder($folderId, $bookmarkId) {
|
||||
public function addToFolder($folderId, $bookmarkId): JSONResponse {
|
||||
return $this->controller->addToFolder($folderId, $bookmarkId);
|
||||
}
|
||||
|
||||
|
@ -83,19 +84,19 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function removeFromFolder($folderId, $bookmarkId) {
|
||||
public function removeFromFolder($folderId, $bookmarkId): JSONResponse {
|
||||
return $this->controller->removeFromFolder($folderId, $bookmarkId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $folderId
|
||||
* @param string $title
|
||||
* @param null $parent_folder
|
||||
* @param string|null $title
|
||||
* @param int|null $parent_folder
|
||||
* @return JSONResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function editFolder($folderId, $title = null, $parent_folder = null) {
|
||||
public function editFolder(int $folderId, $title = null, $parent_folder = null): JSONResponse: JSONResponse {
|
||||
return $this->controller->editFolder($folderId, $title, $parent_folder);
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,7 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function hashFolder($folderId, $fields = ['title', 'url']) {
|
||||
public function hashFolder($folderId, $fields = ['title', 'url']): JSONResponse {
|
||||
return $this->controller->hashFolder($folderId, $fields);
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ class InternalFoldersController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getFolders($root = -1, $layers = -1) {
|
||||
public function getFolders($root = -1, $layers = -1): JSONResponse {
|
||||
return $this->controller->getFolders($root, $layers);
|
||||
}
|
||||
|
||||
|
@ -126,7 +127,7 @@ class InternalFoldersController extends ApiController {
|
|||
* @return DataResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getFolderPublicToken($folderId) {
|
||||
public function getFolderPublicToken($folderId): DataResponse {
|
||||
return $this->controller->getFolderPublicToken($folderId);
|
||||
}
|
||||
|
||||
|
@ -135,7 +136,7 @@ class InternalFoldersController extends ApiController {
|
|||
* @return DataResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function createFolderPublicToken($folderId) {
|
||||
public function createFolderPublicToken($folderId): DataResponse {
|
||||
return $this->controller->createFolderPublicToken($folderId);
|
||||
}
|
||||
|
||||
|
@ -144,7 +145,7 @@ class InternalFoldersController extends ApiController {
|
|||
* @return DataResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function deleteFolderPublicToken($folderId) {
|
||||
public function deleteFolderPublicToken($folderId): DataResponse {
|
||||
return $this->controller->deleteFolderPublicToken($folderId);
|
||||
}
|
||||
|
||||
|
@ -153,7 +154,7 @@ class InternalFoldersController extends ApiController {
|
|||
* @return DataResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getShares($folderId) {
|
||||
public function getShares($folderId): DataResponse {
|
||||
return $this->controller->getShares($folderId);
|
||||
}
|
||||
|
||||
|
@ -166,7 +167,7 @@ class InternalFoldersController extends ApiController {
|
|||
* @return DataResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function createShare($folderId, $participant, $type, $canWrite = false, $canShare = false) {
|
||||
public function createShare($folderId, $participant, $type, $canWrite = false, $canShare = false): DataResponse {
|
||||
return $this->controller->createShare($folderId, $participant, $type, $canWrite, $canShare);
|
||||
}
|
||||
|
||||
|
@ -177,7 +178,7 @@ class InternalFoldersController extends ApiController {
|
|||
* @return DataResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function editShare($shareId, $canWrite = false, $canShare = false) {
|
||||
public function editShare($shareId, $canWrite = false, $canShare = false): DataResponse {
|
||||
return $this->controller->editShare($shareId, $canWrite, $canShare);
|
||||
}
|
||||
|
||||
|
@ -186,7 +187,7 @@ class InternalFoldersController extends ApiController {
|
|||
* @return DataResponse
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function deleteShare($shareId) {
|
||||
public function deleteShare($shareId): DataResponse {
|
||||
return $this->controller->deleteShare($shareId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class InternalTagsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function deleteTag($old_name = "") {
|
||||
public function deleteTag($old_name = ""): JSONResponse {
|
||||
return $this->publicController->deleteTag($old_name);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class InternalTagsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function renameTag($old_name = "", $new_name = "", $name = '') {
|
||||
public function renameTag($old_name = "", $new_name = "", $name = ''): JSONResponse {
|
||||
return $this->publicController->renameTag($old_name, $new_name, $name);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class InternalTagsController extends ApiController {
|
|||
* @NoAdminRequired
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function fullTags($count) {
|
||||
public function fullTags($count): JSONResponse {
|
||||
return $this->publicController->fullTags($count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,14 @@
|
|||
|
||||
namespace OCA\Bookmarks\Controller;
|
||||
|
||||
use Exception;
|
||||
use OCP\AppFramework\ApiController;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OCP\Util;
|
||||
|
||||
class SettingsController extends ApiController {
|
||||
|
||||
|
@ -33,7 +36,7 @@ class SettingsController extends ApiController {
|
|||
/** @var string */
|
||||
private $userId;
|
||||
/**
|
||||
* @var \OCP\IL10N
|
||||
* @var IL10N
|
||||
*/
|
||||
private $l;
|
||||
|
||||
|
@ -42,10 +45,10 @@ class SettingsController extends ApiController {
|
|||
* @param IRequest $request
|
||||
* @param string $userId
|
||||
* @param IConfig $config
|
||||
* @param \OCP\IL10N $l
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(
|
||||
$appName, $request, $userId, IConfig $config, \OCP\IL10N $l
|
||||
$appName, $request, $userId, IConfig $config, IL10N $l
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->config = $config;
|
||||
|
@ -53,7 +56,7 @@ class SettingsController extends ApiController {
|
|||
$this->l = $l;
|
||||
}
|
||||
|
||||
private function getSetting(string $key, string $name, $default) {
|
||||
private function getSetting(string $key, string $name, $default): JSONResponse {
|
||||
try {
|
||||
$userValue = $this->config->getUserValue(
|
||||
$this->userId,
|
||||
|
@ -61,15 +64,15 @@ class SettingsController extends ApiController {
|
|||
$key,
|
||||
$default
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
\OCP\Util::writeLog('bookmarks', $e->getMessage(), \OCP\Util::ERROR);
|
||||
} catch (Exception $e) {
|
||||
Util::writeLog('bookmarks', $e->getMessage(), Util::ERROR);
|
||||
return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return new JSONResponse([$name => $userValue], Http::STATUS_OK);
|
||||
}
|
||||
|
||||
private function setSetting($key, $value) {
|
||||
private function setSetting($key, $value): JSONResponse {
|
||||
try {
|
||||
$this->config->setUserValue(
|
||||
$this->userId,
|
||||
|
@ -77,7 +80,7 @@ class SettingsController extends ApiController {
|
|||
$key,
|
||||
$value
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return new JSONResponse(['status' => 'error'], Http::STATUS_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
@ -91,7 +94,7 @@ class SettingsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getSorting() {
|
||||
public function getSorting(): JSONResponse {
|
||||
return $this->getSetting('sorting', 'sorting', 'lastmodified');
|
||||
}
|
||||
|
||||
|
@ -103,7 +106,7 @@ class SettingsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function setSorting($sorting = "") {
|
||||
public function setSorting($sorting = ""): JSONResponse {
|
||||
$legalArguments = ['title', 'added', 'clickcount', 'lastmodified', 'index'];
|
||||
if (!in_array($sorting, $legalArguments)) {
|
||||
return new JSONResponse(['status' => 'error'], Http::STATUS_BAD_REQUEST);
|
||||
|
@ -121,7 +124,7 @@ class SettingsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getViewMode() {
|
||||
public function getViewMode(): JSONResponse {
|
||||
return $this->getSetting('viewMode', 'viewMode', 'grid');
|
||||
}
|
||||
|
||||
|
@ -133,7 +136,7 @@ class SettingsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function setViewMode($viewMode = "") {
|
||||
public function setViewMode($viewMode = ""): JSONResponse {
|
||||
$legalArguments = ['grid', 'list'];
|
||||
if (!in_array($viewMode, $legalArguments)) {
|
||||
return new JSONResponse(['status' => 'error'], Http::STATUS_BAD_REQUEST);
|
||||
|
@ -151,7 +154,7 @@ class SettingsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getLimit() {
|
||||
public function getLimit(): JSONResponse {
|
||||
$limit = (int)$this->config->getAppValue('bookmarks', 'performance.maxBookmarksperAccount', 0);
|
||||
return new JSONResponse(['limit' => $limit], Http::STATUS_OK);
|
||||
}
|
||||
|
@ -163,7 +166,7 @@ class SettingsController extends ApiController {
|
|||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function getArchivePath() {
|
||||
public function getArchivePath(): JSONResponse {
|
||||
return $this->getSetting(
|
||||
'archive.filePath',
|
||||
'archivePath',
|
||||
|
@ -174,11 +177,12 @@ class SettingsController extends ApiController {
|
|||
/**
|
||||
* set user-defined archive path
|
||||
*
|
||||
* @param string $archivePath
|
||||
* @return JSONResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function setArchivePath($archivePath) {
|
||||
public function setArchivePath(string $archivePath): JSONResponse: JSONResponse {
|
||||
return $this->setSetting('archive.filePath', $archivePath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class TagsController extends ApiController {
|
|||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*/
|
||||
public function deleteTag($old_name = "") {
|
||||
public function deleteTag($old_name = ""): JSONResponse {
|
||||
if ($old_name === "") {
|
||||
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class TagsController extends ApiController {
|
|||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*/
|
||||
public function renameTag($old_name = "", $new_name = "", $name = '') {
|
||||
public function renameTag($old_name = "", $new_name = "", $name = ''): JSONResponse {
|
||||
if ($new_name === '') {
|
||||
$new_name = $name;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class TagsController extends ApiController {
|
|||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*/
|
||||
public function fullTags($count = false) {
|
||||
public function fullTags($count = false): JSONResponse {
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ use OCP\AppFramework\Http\StreamResponse;
|
|||
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class WebViewController extends Controller {
|
||||
|
@ -52,7 +53,7 @@ class WebViewController extends Controller {
|
|||
*/
|
||||
private $folderMapper;
|
||||
/**
|
||||
* @var \OCP\IURLGenerator
|
||||
* @var IURLGenerator
|
||||
*/
|
||||
private $urlGenerator;
|
||||
/**
|
||||
|
@ -75,11 +76,11 @@ class WebViewController extends Controller {
|
|||
* @param PublicFolderMapper $publicFolderMapper
|
||||
* @param IUserManager $userManager
|
||||
* @param FolderMapper $folderMapper
|
||||
* @param \OCP\IURLGenerator $urlGenerator
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param \OCP\IInitialStateService $initialState
|
||||
* @param FoldersController $folderController
|
||||
*/
|
||||
public function __construct($appName, $request, $userId, IL10N $l, PublicFolderMapper $publicFolderMapper, IUserManager $userManager, \OCA\Bookmarks\Db\FolderMapper $folderMapper, \OCP\IURLGenerator $urlGenerator, \OCP\IInitialStateService $initialState, \OCA\Bookmarks\Controller\FoldersController $folderController) {
|
||||
public function __construct($appName, $request, $userId, IL10N $l, PublicFolderMapper $publicFolderMapper, IUserManager $userManager, FolderMapper $folderMapper, IURLGenerator $urlGenerator, \OCP\IInitialStateService $initialState, \OCA\Bookmarks\Controller\FoldersController $folderController) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->userId = $userId;
|
||||
$this->l = $l;
|
||||
|
|
|
@ -76,11 +76,11 @@ class Bookmark extends Entity {
|
|||
return $array;
|
||||
}
|
||||
|
||||
public function markPreviewCreated() {
|
||||
public function markPreviewCreated(): void {
|
||||
$this->setLastPreview(time());
|
||||
}
|
||||
|
||||
public function incrementClickcount() {
|
||||
public function incrementClickcount(): void {
|
||||
$this->setClickcount($this->clickcount + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ use OCP\DB\QueryBuilder\IQueryFunction;
|
|||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use PDO;
|
||||
use function call_user_func;
|
||||
|
||||
/**
|
||||
* Class BookmarkMapper
|
||||
|
@ -115,7 +117,7 @@ class BookmarkMapper extends QBMapper {
|
|||
if ($hasTags !== false) {
|
||||
return BookmarkWithTagsAndParent::fromRow($row);
|
||||
}
|
||||
return \call_user_func($this->entityClass .'::fromRow', $row);
|
||||
return call_user_func($this->entityClass .'::fromRow', $row);
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,7 +196,7 @@ class BookmarkMapper extends QBMapper {
|
|||
->from('bookmarks', 'b')
|
||||
->where($qb->expr()->eq('b.user_id', $qb->createPositionalParameter($userId)));
|
||||
|
||||
$count = $qb->execute()->fetch(\PDO::FETCH_COLUMN)[0];
|
||||
$count = $qb->execute()->fetch(PDO::FETCH_COLUMN)[0];
|
||||
|
||||
return (int)$count;
|
||||
}
|
||||
|
@ -355,7 +357,7 @@ class BookmarkMapper extends QBMapper {
|
|||
))
|
||||
->andWhere($qb->expr()->isNotNull('b.archived_file'));
|
||||
|
||||
return $qb->execute()->fetch(\PDO::FETCH_COLUMN);
|
||||
return $qb->execute()->fetch(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -376,7 +378,7 @@ class BookmarkMapper extends QBMapper {
|
|||
))
|
||||
->andWhere($qb->expr()->eq('b.available', $qb->createPositionalParameter(false, IQueryBuilder::PARAM_BOOL)));
|
||||
|
||||
return $qb->execute()->fetch(\PDO::FETCH_COLUMN);
|
||||
return $qb->execute()->fetch(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -480,7 +482,7 @@ class BookmarkMapper extends QBMapper {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Bookmark $entity
|
||||
* @param Entity $entity
|
||||
* @return Entity
|
||||
* @throws AlreadyExistsError
|
||||
* @throws UrlParseError
|
||||
|
@ -514,11 +516,11 @@ class BookmarkMapper extends QBMapper {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Bookmark $entity
|
||||
* @param Entity $entity
|
||||
* @return Entity
|
||||
* @throws AlreadyExistsError
|
||||
* @throws UrlParseError
|
||||
* @throws UserLimitExceededError
|
||||
* @throws AlreadyExistsError
|
||||
*/
|
||||
public function insertOrUpdate(Entity $entity): Entity {
|
||||
$params = new QueryParameters();
|
||||
|
@ -544,7 +546,7 @@ class BookmarkMapper extends QBMapper {
|
|||
->select($qb->func()->count('id'))
|
||||
->from('bookmarks')
|
||||
->where($qb->expr()->eq('user_id', $qb->createPositionalParameter($userId)));
|
||||
return $qb->execute()->fetch(\PDO::FETCH_COLUMN);
|
||||
return $qb->execute()->fetch(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,18 +15,6 @@ class BookmarkWithTagsAndParent extends Bookmark {
|
|||
public static $columns = ['id', 'url', 'title', 'description', 'lastmodified', 'added', 'clickcount', 'last_preview', 'available', 'archived_file', 'user_id', 'tags', 'folders'];
|
||||
public static $fields = ['id', 'url', 'title', 'description', 'lastmodified', 'added', 'clickcount', 'lastPreview', 'available', 'archivedFile', 'userId', 'tags', 'folders'];
|
||||
|
||||
public static function fromArray($props) {
|
||||
$bookmark = new Bookmark();
|
||||
foreach ($props as $prop => $val) {
|
||||
$bookmark->{'set' . $prop}($val);
|
||||
}
|
||||
return $bookmark;
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function toArray(): array {
|
||||
$array = [];
|
||||
foreach (self::$fields as $field) {
|
||||
|
|
|
@ -27,7 +27,7 @@ class Folder extends Entity {
|
|||
$this->addType('userId', 'string');
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
public function toArray(): array {
|
||||
return ['id' => $this->id, 'title' => $this->title, 'userId' => $this->userId];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ namespace OCA\Bookmarks\Db;
|
|||
use Exception;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\AppFramework\Db\QBMapper;
|
||||
use OCP\IDBConnection;
|
||||
use RangeException;
|
||||
|
||||
/**
|
||||
* Class PublicFolderMapper
|
||||
|
@ -34,7 +36,7 @@ class PublicFolderMapper extends QBMapper {
|
|||
* @param string $id
|
||||
* @return Entity
|
||||
* @throws DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function find(string $id): Entity {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
|
@ -50,7 +52,7 @@ class PublicFolderMapper extends QBMapper {
|
|||
* @param int $folderId
|
||||
* @return Entity
|
||||
* @throws DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function findByFolder(int $folderId): Entity {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
|
@ -79,7 +81,7 @@ class PublicFolderMapper extends QBMapper {
|
|||
/**
|
||||
* @param Entity $publicFolder
|
||||
* @return Entity
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insert(Entity $publicFolder): Entity {
|
||||
|
@ -97,7 +99,7 @@ class PublicFolderMapper extends QBMapper {
|
|||
/**
|
||||
* @param Entity $publicFolder
|
||||
* @return Entity
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function insertOrUpdate(Entity $publicFolder): Entity {
|
||||
try {
|
||||
|
@ -105,7 +107,7 @@ class PublicFolderMapper extends QBMapper {
|
|||
} catch (DoesNotExistException $e) {
|
||||
return $this->insert($publicFolder);
|
||||
}
|
||||
$this->update($publicFolder);
|
||||
return $this->update($publicFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,7 +124,7 @@ class PublicFolderMapper extends QBMapper {
|
|||
* @param string $keyspace A string of all possible characters
|
||||
* to select from
|
||||
* @return string
|
||||
* @throws \RangeException
|
||||
* @throws RangeException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function randomString(
|
||||
|
@ -130,7 +132,7 @@ class PublicFolderMapper extends QBMapper {
|
|||
string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||
): string {
|
||||
if ($length < 1) {
|
||||
throw new \RangeException('Length must be a positive integer');
|
||||
throw new RangeException('Length must be a positive integer');
|
||||
}
|
||||
$pieces = [];
|
||||
$max = mb_strlen($keyspace, '8bit') - 1;
|
||||
|
|
|
@ -47,7 +47,7 @@ class Share extends Entity {
|
|||
$this->addType('createdAt', 'integer');
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
public function toArray(): array {
|
||||
return ['id' => $this->id, 'folderId' => $this->folderId, 'owner' => $this->owner, 'participant' => $this->participant, 'type' => $this->type, 'canWrite' => $this->canWrite, 'canShare' => $this->canShare, 'createdAt' => $this->createdAt];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ class ShareMapper extends QBMapper {
|
|||
return parent::insertOrUpdate($sharedFolder);
|
||||
}
|
||||
|
||||
public function findBySharedFolder(int $id) {
|
||||
public function findBySharedFolder(int $id): Entity {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select(array_map(static function ($c) {
|
||||
return 's.' . $c;
|
||||
|
|
|
@ -33,7 +33,7 @@ class SharedFolder extends Entity {
|
|||
$this->addType('title', 'string');
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
public function toArray(): array {
|
||||
return ['title' => $this->title, 'userId' => $this->userId];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
|
|||
use OCP\AppFramework\Db\Entity;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\AppFramework\Db\QBMapper;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +22,7 @@ class SharedFolderMapper extends QBMapper {
|
|||
*/
|
||||
protected $db;
|
||||
/**
|
||||
* @var \OCP\EventDispatcher\IEventDispatcher
|
||||
* @var IEventDispatcher
|
||||
*/
|
||||
private $eventDispatcher;
|
||||
|
||||
|
@ -29,9 +30,9 @@ class SharedFolderMapper extends QBMapper {
|
|||
* TagMapper constructor.
|
||||
*
|
||||
* @param IDBConnection $db
|
||||
* @param \OCP\EventDispatcher\IEventDispatcher $eventDispatcher
|
||||
* @param IEventDispatcher $eventDispatcher
|
||||
*/
|
||||
public function __construct(IDBConnection $db, \OCP\EventDispatcher\IEventDispatcher $eventDispatcher) {
|
||||
public function __construct(IDBConnection $db, IEventDispatcher $eventDispatcher) {
|
||||
parent::__construct($db, 'bookmarks_shared_folders', SharedFolder::class);
|
||||
$this->db = $db;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
|
@ -101,7 +102,7 @@ class SharedFolderMapper extends QBMapper {
|
|||
*/
|
||||
public function findByParticipant(int $type, string $participant): array {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select(array_map(function ($c) {
|
||||
$qb->select(array_map(static function ($c) {
|
||||
return 'p.' . $c;
|
||||
}, SharedFolder::$columns))
|
||||
->from('bookmarks_shared_folders', 'p')
|
||||
|
@ -189,7 +190,7 @@ class SharedFolderMapper extends QBMapper {
|
|||
return $this->findEntity($qb);
|
||||
}
|
||||
|
||||
public function findByParticipantAndUser(int $type, string $participant, string $userId) {
|
||||
public function findByParticipantAndUser(int $type, string $participant, string $userId): array {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select(array_map(static function ($c) {
|
||||
return 'p.' . $c;
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace OCA\Bookmarks\Db;
|
|||
use Doctrine\DBAL\Driver\Statement;
|
||||
use InvalidArgumentException;
|
||||
use OCP\IDBConnection;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Class TagMapper
|
||||
|
@ -69,7 +70,7 @@ class TagMapper {
|
|||
$qb->expr()->eq('tr.type', $qb->createPositionalParameter(TreeMapper::TYPE_SHARE)))
|
||||
)
|
||||
->groupBy('t.tag');
|
||||
return $qb->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return $qb->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +85,7 @@ class TagMapper {
|
|||
->from('bookmarks_tags', 't')
|
||||
->where($qb->expr()->eq('t.bookmark_id', $qb->createPositionalParameter($bookmarkId)));
|
||||
|
||||
return $qb->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
return $qb->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,8 +130,8 @@ class TagMapper {
|
|||
return;
|
||||
}
|
||||
$currentTags = $this->findByBookmark($bookmarkId);
|
||||
$tags = array_filter($tags, function ($tag) use ($currentTags) {
|
||||
return !in_array($tag, $currentTags);
|
||||
$tags = array_filter($tags, static function ($tag) use ($currentTags) {
|
||||
return !in_array($tag, $currentTags, true);
|
||||
});
|
||||
foreach ($tags as $tag) {
|
||||
$tag = trim($tag);
|
||||
|
@ -188,7 +189,7 @@ class TagMapper {
|
|||
->where($qb->expr()->eq('tgs.tag', $qb->createNamedParameter($new)))
|
||||
->andWhere($qb->expr()->eq('bm.user_id', $qb->createNamedParameter($userId)))
|
||||
->andWhere($qb->expr()->eq('t.tag', $qb->createNamedParameter($old)));
|
||||
$duplicates = $qb->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
$duplicates = $qb->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
if (count($duplicates) !== 0) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb
|
||||
|
@ -206,7 +207,7 @@ class TagMapper {
|
|||
->innerJoin('tgs', 'bookmarks', 'bm', $qb->expr()->eq('tgs.bookmark_id', 'bm.id'))
|
||||
->where($qb->expr()->eq('tgs.tag', $qb->createNamedParameter($old)))
|
||||
->andWhere($qb->expr()->eq('bm.user_id', $qb->createNamedParameter($userId)));
|
||||
$bookmarks = $qb->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
$bookmarks = $qb->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
if (count($bookmarks) !== 0) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb
|
||||
|
@ -218,7 +219,7 @@ class TagMapper {
|
|||
}
|
||||
}
|
||||
|
||||
public function deleteTag($userId, string $old) {
|
||||
public function deleteTag($userId, string $old): void {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb
|
||||
->select('t.bookmark_id')
|
||||
|
@ -226,7 +227,7 @@ class TagMapper {
|
|||
->innerJoin('t', 'bookmarks', 'bm', $qb->expr()->eq('t.bookmark_id', 'bm.id'))
|
||||
->where($qb->expr()->eq('t.tag', $qb->createNamedParameter($old)))
|
||||
->andWhere($qb->expr()->eq('bm.user_id', $qb->createNamedParameter($userId)));
|
||||
$affectedBookmarks = $qb->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
$affectedBookmarks = $qb->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
if (count($affectedBookmarks) !== 0) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb
|
||||
|
|
|
@ -17,6 +17,8 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
use OCP\ICache;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use PDO;
|
||||
use function call_user_func;
|
||||
|
||||
/**
|
||||
* Class TreeMapper
|
||||
|
@ -127,7 +129,7 @@ class TreeMapper extends QBMapper {
|
|||
* @return Entity the entity
|
||||
*/
|
||||
protected function mapRowToEntityWithClass(array $row, string $entityClass): Entity {
|
||||
return \call_user_func($entityClass . '::fromRow', $row);
|
||||
return call_user_func($entityClass . '::fromRow', $row);
|
||||
}
|
||||
|
||||
|
||||
|
@ -680,7 +682,7 @@ class TreeMapper extends QBMapper {
|
|||
->select($qb->func()->count('index', 'count'))
|
||||
->from('bookmarks_tree')
|
||||
->where($qb->expr()->eq('parent_folder', $qb->createPositionalParameter($folderId)));
|
||||
return $qb->execute()->fetch(\PDO::FETCH_COLUMN);
|
||||
return $qb->execute()->fetch(PDO::FETCH_COLUMN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -696,7 +698,7 @@ class TreeMapper extends QBMapper {
|
|||
->innerJoin('b', 'bookmarks_tree', 't', $qb->expr()->eq('t.id', 'b.id'))
|
||||
->where($qb->expr()->eq('t.parent_folder', $qb->createPositionalParameter($folderId)))
|
||||
->andWhere($qb->expr()->eq('t.type', $qb->createPositionalParameter(self::TYPE_BOOKMARK)));
|
||||
$countChildren = $qb->execute()->fetch(\PDO::FETCH_COLUMN);
|
||||
$countChildren = $qb->execute()->fetch(PDO::FETCH_COLUMN);
|
||||
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb
|
||||
|
@ -705,7 +707,7 @@ class TreeMapper extends QBMapper {
|
|||
->innerJoin('f', 'bookmarks_tree', 't', $qb->expr()->eq('t.id', 'f.id'))
|
||||
->where($qb->expr()->eq('t.parent_folder', $qb->createPositionalParameter($folderId)))
|
||||
->andWhere($qb->expr()->eq('t.type', $qb->createPositionalParameter(self::TYPE_FOLDER)));
|
||||
$childFolders = $qb->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
$childFolders = $qb->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
foreach ($childFolders as $subFolderId) {
|
||||
$countChildren += $this->countBookmarksInFolder($subFolderId);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
namespace OCA\Bookmarks;
|
||||
|
||||
use OC;
|
||||
use OC\HintException;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
|
||||
|
@ -33,14 +34,16 @@ class ExportResponse extends Response {
|
|||
private $returnstring;
|
||||
|
||||
public function __construct($returnstring) {
|
||||
$user = \OC::$server->getUserSession()->getUser();
|
||||
parent::__construct();
|
||||
|
||||
$user = OC::$server->getUserSession()->getUser();
|
||||
if (is_null($user)) {
|
||||
throw new HintException('User not logged in');
|
||||
}
|
||||
|
||||
$userName = $user->getDisplayName();
|
||||
$productName = \OC::$server->getThemingDefaults()->getName();
|
||||
$dateTime = \OC::$server->getDateTimeFormatter();
|
||||
$productName = OC::$server->getThemingDefaults()->getName();
|
||||
$dateTime = OC::$server->getDateTimeFormatter();
|
||||
|
||||
$export_name = '"' . $productName . ' Bookmarks (' . $userName . ') (' . $dateTime->formatDate(time()) . ').html"';
|
||||
$this->addHeader("Cache-Control", "private");
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace OCA\Bookmarks\Flow;
|
||||
|
||||
use Exception;
|
||||
use OC;
|
||||
use OC\Files\View;
|
||||
use OCA\Bookmarks\Service\BookmarkService;
|
||||
use OCA\WorkflowEngine\Entity\File;
|
||||
use OCP\EventDispatcher\Event;
|
||||
|
@ -10,10 +13,13 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||
use OCP\Files\Folder;
|
||||
use OCP\Files\Node;
|
||||
use OCP\IL10N;
|
||||
use OCP\ILogger;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Util;
|
||||
use OCP\WorkflowEngine\EntityContext\IUrl;
|
||||
use OCP\WorkflowEngine\IManager;
|
||||
use OCP\WorkflowEngine\IOperation;
|
||||
use OCP\WorkflowEngine\IRuleMatcher;
|
||||
|
||||
|
@ -33,15 +39,15 @@ class CreateBookmark implements IOperation {
|
|||
*/
|
||||
private $session;
|
||||
/**
|
||||
* @var \OCP\IURLGenerator
|
||||
* @var IURLGenerator
|
||||
*/
|
||||
private $urlGenerator;
|
||||
/**
|
||||
* @var \OCP\ILogger
|
||||
* @var ILogger
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
public function __construct(IL10N $l, BookmarkService $bookmarks, IUserSession $session, \OCP\IURLGenerator $urlGenerator, \OCP\ILogger $logger) {
|
||||
public function __construct(IL10N $l, BookmarkService $bookmarks, IUserSession $session, IURLGenerator $urlGenerator, ILogger $logger) {
|
||||
$this->l = $l;
|
||||
$this->bookmarks = $bookmarks;
|
||||
$this->session = $session;
|
||||
|
@ -50,15 +56,15 @@ class CreateBookmark implements IOperation {
|
|||
}
|
||||
|
||||
public static function register(IEventDispatcher $dispatcher): void {
|
||||
if (interface_exists('\OCP\WorkflowEngine\IManager')) {
|
||||
if (interface_exists(IManager::class)) {
|
||||
@include_once __DIR__ . '/../../vendor/autoload.php';
|
||||
$dispatcher->addListener(\OCP\WorkflowEngine\IManager::EVENT_NAME_REG_OPERATION, static function ($event) {
|
||||
$operation = \OC::$server->query(CreateBookmark::class);
|
||||
$dispatcher->addListener(IManager::EVENT_NAME_REG_OPERATION, static function ($event) {
|
||||
$operation = OC::$server->query(CreateBookmark::class);
|
||||
$event->getSubject()->registerOperation($operation);
|
||||
Util::addScript('bookmarks', 'flow');
|
||||
});
|
||||
$dispatcher->addListener(\OCP\WorkflowEngine\IManager::EVENT_NAME_REG_ENTITY, static function ($event) {
|
||||
$entity = \OC::$server->query(Bookmark::class);
|
||||
$dispatcher->addListener(IManager::EVENT_NAME_REG_ENTITY, static function ($event) {
|
||||
$entity = OC::$server->query(Bookmark::class);
|
||||
$event->getSubject()->registerEntity($entity);
|
||||
Util::addScript('bookmarks', 'flow');
|
||||
});
|
||||
|
@ -147,9 +153,9 @@ class CreateBookmark implements IOperation {
|
|||
|
||||
|
||||
try {
|
||||
$view = new \OC\Files\View('/' . $userId . '/files');
|
||||
$view = new View('/' . $userId . '/files');
|
||||
$text = $view->file_get_contents($path);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@ namespace OCA\Bookmarks;
|
|||
|
||||
class Helper {
|
||||
public static function getDomainWithoutExt($name) {
|
||||
$pos = strripos($name, '.');
|
||||
$pos = strrpos($name, '.');
|
||||
if ($pos === false) {
|
||||
return $name;
|
||||
} else {
|
||||
return substr($name, 0, $pos);
|
||||
}
|
||||
|
||||
return substr($name, 0, $pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,11 @@ use OCA\Bookmarks\Db\Share;
|
|||
use OCA\Bookmarks\Db\SharedFolderMapper;
|
||||
use OCA\Bookmarks\Db\ShareMapper;
|
||||
use OCA\Bookmarks\Db\TreeMapper;
|
||||
use OCA\Bookmarks\Exception\UnsupportedOperation;
|
||||
use OCA\Bookmarks\Service\BookmarkService;
|
||||
use OCA\Bookmarks\Service\FolderService;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Group\Events\BeforeGroupDeletedEvent;
|
||||
|
@ -58,9 +61,9 @@ class UserGroupListener implements IEventListener {
|
|||
|
||||
/**
|
||||
* @param Event $event
|
||||
* @throws \OCA\Bookmarks\Exception\UnsupportedOperation
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function handle(Event $event): void {
|
||||
if ($event instanceof BeforeUserDeletedEvent) {
|
||||
|
@ -79,9 +82,9 @@ class UserGroupListener implements IEventListener {
|
|||
|
||||
/**
|
||||
* @param IUser $user
|
||||
* @throws \OCA\Bookmarks\Exception\UnsupportedOperation
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function preDeleteUser(IUser $user): void {
|
||||
$this->bookmarks->deleteAll($user->getUID());
|
||||
|
@ -105,9 +108,9 @@ class UserGroupListener implements IEventListener {
|
|||
/**
|
||||
* @param IGroup $group
|
||||
* @param IUser $user
|
||||
* @throws \OCA\Bookmarks\Exception\UnsupportedOperation
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function preRemoveUser(IGroup $group, IUser $user): void {
|
||||
$sharedFoldersToDelete = $this->sharedFolderMapper->findByParticipantAndUser(IShare::TYPE_GROUP, $group->getGID(), $user->getUID());
|
||||
|
@ -119,9 +122,9 @@ class UserGroupListener implements IEventListener {
|
|||
/**
|
||||
* @param IGroup $group
|
||||
* @param IUser $user
|
||||
* @throws \OCA\Bookmarks\Exception\UnsupportedOperation
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function postAddUser(IGroup $group, IUser $user): void {
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Http;
|
||||
|
||||
use Exception;
|
||||
use GuzzleHttp\Psr7;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use OCP\Http\Client\IClient;
|
||||
|
@ -35,11 +36,11 @@ class Client implements ClientInterface {
|
|||
*
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* @throws \Psr\Http\Client\ClientException If an error happens while processing the request.
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sendRequest(RequestInterface $request): ResponseInterface {
|
||||
if ($request->getMethod() === 'GET' || $request->getMethod() === 'OPTIONS') {
|
||||
$method = $request->getMethod();
|
||||
if ($method === 'GET' || $method === 'OPTIONS') {
|
||||
$ncRes = $this->nextcloudClient->{strtolower($request->getMethod())}($request->getUri(), ['timeout' => 10]);
|
||||
$res = new Response();
|
||||
|
||||
|
@ -50,8 +51,8 @@ class Client implements ClientInterface {
|
|||
return $res
|
||||
->withStatus($ncRes->getStatusCode())
|
||||
->withBody(Psr7\stream_for($ncRes->getBody()));
|
||||
} else {
|
||||
throw new \Exception('Can only send GET or OPTIONS requests'); // XXX: How should Streams be sent using nextcloud?
|
||||
}
|
||||
|
||||
throw new Exception('Can only send GET or OPTIONS requests'); // XXX: How should Streams be sent using nextcloud?
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class Image implements IImage {
|
|||
}
|
||||
|
||||
public static function deserialize(string $json): Image {
|
||||
$image = json_decode($json, true);
|
||||
$image = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
|
||||
return new Image($image['contentType'], $image['data'] ? base64_decode($image['data']) : null);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,6 @@ class Image implements IImage {
|
|||
return json_encode([
|
||||
'contentType' => $this->getContentType(),
|
||||
'data' => base64_encode($this->getData()),
|
||||
]);
|
||||
], JSON_THROW_ON_ERROR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,16 @@ use OCA\Bookmarks\Db\FolderMapper;
|
|||
use OCA\Bookmarks\Db\Share;
|
||||
use OCA\Bookmarks\Db\SharedFolderMapper;
|
||||
use OCA\Bookmarks\Db\ShareMapper;
|
||||
use OCA\Bookmarks\Exception\UnsupportedOperation;
|
||||
use OCA\Bookmarks\Service\FolderService;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
use OCP\Share\IShare;
|
||||
use PDO;
|
||||
|
||||
class GroupSharesUpdateRepairStep implements IRepairStep {
|
||||
/**
|
||||
|
@ -20,7 +25,7 @@ class GroupSharesUpdateRepairStep implements IRepairStep {
|
|||
*/
|
||||
private $db;
|
||||
/**
|
||||
* @var \OCP\IGroupManager
|
||||
* @var IGroupManager
|
||||
*/
|
||||
private $groupManager;
|
||||
/**
|
||||
|
@ -40,7 +45,7 @@ class GroupSharesUpdateRepairStep implements IRepairStep {
|
|||
*/
|
||||
private $sharedFolderMapper;
|
||||
|
||||
public function __construct(IDBConnection $db, \OCP\IGroupManager $groupManager, FolderService $folders, ShareMapper $shareMapper, FolderMapper $folderMapper, SharedFolderMapper $sharedFolderMapper) {
|
||||
public function __construct(IDBConnection $db, IGroupManager $groupManager, FolderService $folders, ShareMapper $shareMapper, FolderMapper $folderMapper, SharedFolderMapper $sharedFolderMapper) {
|
||||
$this->db = $db;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->folders = $folders;
|
||||
|
@ -58,9 +63,9 @@ class GroupSharesUpdateRepairStep implements IRepairStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @throws \OCA\Bookmarks\Exception\UnsupportedOperation
|
||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
$deleted = 0;
|
||||
|
@ -83,7 +88,7 @@ class GroupSharesUpdateRepairStep implements IRepairStep {
|
|||
->from('bookmarks_shared_folders', 'sf')
|
||||
->join('sf', 'bookmarks_shared_to_shares', 't', $qb->expr()->eq('t.shared_folder_id', 'sf.id'))
|
||||
->where($qb->expr()->eq('t.share_id', $qb->createPositionalParameter($groupShare['id'])));
|
||||
$usersInShare = $qb->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
$usersInShare = $qb->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
$group = $this->groupManager->get($groupShare['participant']);
|
||||
if ($group === null) {
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace OCA\Bookmarks\Migration;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
use PDO;
|
||||
|
||||
class OrphanedSharesRepairStep implements IRepairStep {
|
||||
/**
|
||||
|
@ -42,7 +43,7 @@ class OrphanedSharesRepairStep implements IRepairStep {
|
|||
->join('f', 'bookmarks_shared_to_shares', 't', $qb->expr()->eq('f.id', 't.shared_folder_id'))
|
||||
->where($qb->expr()->eq('t.share_id', $qb->createPositionalParameter($share)))
|
||||
->execute()
|
||||
->fetchAll(\PDO::FETCH_COLUMN);
|
||||
->fetchAll(PDO::FETCH_COLUMN);
|
||||
foreach ($folders as $folderId) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->delete('bookmarks_tree')
|
||||
|
@ -50,7 +51,6 @@ class OrphanedSharesRepairStep implements IRepairStep {
|
|||
->andWhere($qb->expr()->eq('id', $qb->createPositionalParameter($folderId)))
|
||||
->execute();
|
||||
}
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$this->db->executeQuery('DELETE sf FROM *PREFIX*bookmarks_shared_folders sf JOIN *PREFIX*bookmarks_shared_to_shares t ON sf.id = t.shared_folder_id WHERE t.share_id = ?', [$share]);
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->delete('bookmarks_shares')
|
||||
|
@ -66,7 +66,7 @@ class OrphanedSharesRepairStep implements IRepairStep {
|
|||
->leftJoin('p', 'bookmarks_folders', 'f', $qb->expr()->eq('f.id', 'p.folder_id'))
|
||||
->where($qb->expr()->isNull('f.id'))
|
||||
->execute()
|
||||
->fetchAll(\PDO::FETCH_COLUMN);
|
||||
->fetchAll(PDO::FETCH_COLUMN);
|
||||
$i = 0;
|
||||
foreach ($publics as $publicId) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -19,19 +20,19 @@ class Version000014000Date20181002094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
|
@ -142,10 +143,10 @@ class Version000014000Date20181002094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('id', 'user_id')->from('bookmarks');
|
||||
$bookmarks = $query->execute()->fetchAll();
|
||||
|
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Auto-generated migration step: Please modify to your needs!
|
||||
|
@ -19,19 +21,19 @@ class Version000014000Date20181029094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
$table = $schema->getTable('bookmarks_folders');
|
||||
|
@ -51,14 +53,14 @@ class Version000014000Date20181029094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('id')->from('bookmarks_folders');
|
||||
$folders = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);
|
||||
array_push($folders, -1);
|
||||
$folders = $query->execute()->fetchAll(PDO::FETCH_COLUMN);
|
||||
$folders[] = -1;
|
||||
foreach ($folders as $folder) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb
|
||||
|
@ -76,7 +78,7 @@ class Version000014000Date20181029094721 extends SimpleMigrationStep {
|
|||
$childBookmarks = $qb->execute()->fetchAll();
|
||||
|
||||
$children = array_merge($childFolders, $childBookmarks);
|
||||
$children = array_map(function ($child) {
|
||||
$children = array_map(static function ($child) {
|
||||
return $child['bookmark_id'] ?
|
||||
['type' => 'bookmark', 'id' => $child['bookmark_id']]
|
||||
: ['type' => 'folder', 'id' => $child['id']];
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -19,19 +20,19 @@ class Version000016005Date20190402094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
$table = $schema->getTable('bookmarks_folders_bookmarks');
|
||||
|
@ -45,9 +46,9 @@ class Version000016005Date20190402094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -19,19 +20,19 @@ class Version001000007Date20190721094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
$table = $schema->getTable('bookmarks');
|
||||
|
@ -47,9 +48,9 @@ class Version001000007Date20190721094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -19,20 +21,20 @@ class Version003000000Date20191123094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
$table = $schema->getTable('bookmarks');
|
||||
|
@ -169,10 +171,10 @@ class Version003000000Date20191123094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->selectDistinct('user_id')->from('bookmarks');
|
||||
$usersQuery = $qb->execute();
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -19,20 +21,20 @@ class Version003000000Date20191129094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
$schema->dropTable('bookmarks_folders_bookmarks');
|
||||
|
@ -46,9 +48,9 @@ class Version003000000Date20191129094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
|
@ -20,20 +22,20 @@ class Version003000009Date20200505094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
$table = $schema->getTable('bookmarks_tree');
|
||||
|
@ -46,9 +48,9 @@ class Version003000009Date20200505094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -19,20 +21,20 @@ class Version003001000Date20200526094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
if (!$schema->hasTable('bookmarks_shared_to_shares')) {
|
||||
|
@ -63,10 +65,10 @@ class Version003001000Date20200526094721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
// Find all shared folders
|
||||
$sharedFolders = $qb->select('sf.share_id', 'sf.id', 's.folder_id', 'sf.user_id')
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -19,20 +21,20 @@ class Version003001000Date20200526124721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
if ($schema->hasTable('bookmarks_shared_folders')) {
|
||||
|
@ -44,9 +46,9 @@ class Version003001000Date20200526124721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
|
@ -20,20 +22,20 @@ class Version003004000Date20200807124721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
if ($schema->hasTable('bookmarks')) {
|
||||
|
@ -50,9 +52,9 @@ class Version003004000Date20200807124721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace OCA\Bookmarks\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\IDBConnection;
|
||||
|
@ -20,20 +22,20 @@ class Version003004000Date20200817124721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
if ($schema->hasTable('bookmarks')) {
|
||||
|
@ -47,9 +49,9 @@ class Version003004000Date20200817124721 extends SimpleMigrationStep {
|
|||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
|
||||
namespace OCA\Bookmarks;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class QueryParameters {
|
||||
public const CONJ_AND = 'and';
|
||||
public const CONJ_OR = 'or';
|
||||
|
||||
private $limit = 10;
|
||||
private $offset = 0;
|
||||
private $sortBy = null;
|
||||
private $sortBy;
|
||||
private $conjunction = self::CONJ_AND;
|
||||
private $folder = null;
|
||||
private $url = null;
|
||||
private $folder;
|
||||
private $url;
|
||||
private $untagged = false;
|
||||
private $unavailable = false;
|
||||
private $archived = false;
|
||||
|
@ -121,7 +123,7 @@ class QueryParameters {
|
|||
*/
|
||||
public function setConjunction(string $conjunction): QueryParameters {
|
||||
if ($conjunction !== self::CONJ_AND && $conjunction !== self::CONJ_OR) {
|
||||
throw new \InvalidArgumentException("Conjunction value must be 'and' or 'or'");
|
||||
throw new InvalidArgumentException("Conjunction value must be 'and' or 'or'");
|
||||
}
|
||||
$this->conjunction = $conjunction;
|
||||
return $this;
|
||||
|
@ -130,7 +132,7 @@ class QueryParameters {
|
|||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getFolder() {
|
||||
public function getFolder(): ?int {
|
||||
return $this->folder;
|
||||
}
|
||||
|
||||
|
@ -163,7 +165,7 @@ class QueryParameters {
|
|||
* @return boolean
|
||||
*/
|
||||
public function getUnavailable(): bool {
|
||||
return (boolean) $this->unavailable;
|
||||
return $this->unavailable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +181,7 @@ class QueryParameters {
|
|||
* @return boolean
|
||||
*/
|
||||
public function getArchived(): bool {
|
||||
return (boolean) $this->archived;
|
||||
return $this->archived;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,7 +57,8 @@ class Provider implements IProvider {
|
|||
$params = new QueryParameters();
|
||||
$params->setLimit($query->getLimit());
|
||||
$params->setOffset($query->getCursor() ?? 0);
|
||||
$bookmarks = $this->bookmarkMapper->findAll($user->getUID(), explode(' ', $query->getTerm()), $params);
|
||||
$params->setSearch(explode(' ', $query->getTerm()));
|
||||
$bookmarks = $this->bookmarkMapper->findAll($user->getUID(), $params);
|
||||
|
||||
$results = array_map(function (Bookmark $bookmark) {
|
||||
$favicon = $this->url->linkToRouteAbsolute('bookmarks.internal_bookmark_controller.get_bookmark_favicon', ['id' => $bookmark->getId()]);
|
||||
|
|
|
@ -3,5 +3,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Search;
|
||||
|
||||
class SearchResultEntry extends \OCP\Search\ASearchResultEntry {
|
||||
use OCP\Search\ASearchResultEntry;
|
||||
|
||||
class SearchResultEntry extends ASearchResultEntry {
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class Authorizer {
|
|||
*/
|
||||
private $publicMapper;
|
||||
|
||||
private $userId = null;
|
||||
private $userId;
|
||||
private $token = null;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ use OCA\Bookmarks\Exception\UserLimitExceededError;
|
|||
use OCA\Bookmarks\QueryParameters;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
|
||||
class BookmarkService {
|
||||
/**
|
||||
|
@ -57,7 +58,7 @@ class BookmarkService {
|
|||
*/
|
||||
private $folders;
|
||||
/**
|
||||
* @var \OCP\EventDispatcher\IEventDispatcher
|
||||
* @var IEventDispatcher
|
||||
*/
|
||||
private $eventDispatcher;
|
||||
|
||||
|
@ -73,9 +74,9 @@ class BookmarkService {
|
|||
* @param BookmarkPreviewer $bookmarkPreviewer
|
||||
* @param FaviconPreviewer $faviconPreviewer
|
||||
* @param FolderService $folders
|
||||
* @param \OCP\EventDispatcher\IEventDispatcher $eventDispatcher
|
||||
* @param IEventDispatcher $eventDispatcher
|
||||
*/
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, FolderMapper $folderMapper, TagMapper $tagMapper, TreeMapper $treeMapper, Authorizer $authorizer, LinkExplorer $linkExplorer, BookmarkPreviewer $bookmarkPreviewer, FaviconPreviewer $faviconPreviewer, \OCA\Bookmarks\Service\FolderService $folders, \OCP\EventDispatcher\IEventDispatcher $eventDispatcher) {
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, FolderMapper $folderMapper, TagMapper $tagMapper, TreeMapper $treeMapper, Authorizer $authorizer, LinkExplorer $linkExplorer, BookmarkPreviewer $bookmarkPreviewer, FaviconPreviewer $faviconPreviewer, FolderService $folders, IEventDispatcher $eventDispatcher) {
|
||||
$this->bookmarkMapper = $bookmarkMapper;
|
||||
$this->treeMapper = $treeMapper;
|
||||
$this->authorizer = $authorizer;
|
||||
|
@ -160,8 +161,6 @@ class BookmarkService {
|
|||
* @param $folders
|
||||
* @return Bookmark
|
||||
* @throws AlreadyExistsError
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws UrlParseError
|
||||
* @throws UserLimitExceededError
|
||||
* @throws UnsupportedOperation
|
||||
|
@ -183,6 +182,7 @@ class BookmarkService {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
* @param null $id
|
||||
* @param string|null $url
|
||||
* @param string|null $title
|
||||
|
@ -287,7 +287,7 @@ class BookmarkService {
|
|||
* @throws MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
*/
|
||||
public function removeFromFolder($folderId, $bookmarkId) {
|
||||
public function removeFromFolder($folderId, $bookmarkId): void {
|
||||
$this->treeMapper->removeFromFolders(TreeMapper::TYPE_BOOKMARK, $bookmarkId, [$folderId]);
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ class BookmarkService {
|
|||
* @throws UrlParseError
|
||||
* @throws UserLimitExceededError
|
||||
*/
|
||||
public function addToFolder($folderId, $bookmarkId) {
|
||||
public function addToFolder($folderId, $bookmarkId): void {
|
||||
/**
|
||||
* @var $folder Folder
|
||||
*/
|
||||
|
@ -337,6 +337,7 @@ class BookmarkService {
|
|||
/**
|
||||
* @param $userId
|
||||
* @param string $url
|
||||
* @return Bookmark
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function findByUrl($userId, $url = ''): Bookmark {
|
||||
|
@ -357,7 +358,6 @@ class BookmarkService {
|
|||
* @throws UrlParseError
|
||||
*/
|
||||
public function click(int $id): void {
|
||||
$params = new QueryParameters();
|
||||
/** @var Bookmark $bookmark */
|
||||
$bookmark = $this->bookmarkMapper->find($id);
|
||||
$bookmark->incrementClickcount();
|
||||
|
@ -383,8 +383,6 @@ class BookmarkService {
|
|||
* @return IImage|null
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws \OCP\Files\NotFoundException
|
||||
* @throws \OCP\Files\NotPermittedException
|
||||
*/
|
||||
public function getFavicon($id): ?IImage {
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service;
|
||||
|
||||
use DateTime;
|
||||
use DOMDocument;
|
||||
use DOMNode;
|
||||
use DOMXPath;
|
||||
use OCA\Bookmarks\Exception\HtmlParseError;
|
||||
use const LIBXML_PARSEHUGE;
|
||||
|
||||
/**
|
||||
* Bookmark parser
|
||||
|
@ -20,7 +25,7 @@ class BookmarksParser {
|
|||
/**
|
||||
* DOMXPath
|
||||
*
|
||||
* @var \DOMXPath
|
||||
* @var DOMXPath
|
||||
*/
|
||||
private $xpath;
|
||||
/**
|
||||
|
@ -82,7 +87,7 @@ class BookmarksParser {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isValid($doctype) {
|
||||
public static function isValid($doctype): bool {
|
||||
return self::DOCTYPE === $doctype;
|
||||
}
|
||||
|
||||
|
@ -99,15 +104,15 @@ class BookmarksParser {
|
|||
* @throws HtmlParseError
|
||||
*/
|
||||
public function parse($input, $ignorePersonalToolbarFolder = true, $includeFolderTags = true, $useDateTimeObjects = true) {
|
||||
$document = new \DOMDocument();
|
||||
$document = new DOMDocument();
|
||||
$document->preserveWhiteSpace = false;
|
||||
if (empty($input)) {
|
||||
throw new HtmlParseError("The input shouldn't be empty");
|
||||
}
|
||||
if (false === $document->loadHTML($input, \LIBXML_PARSEHUGE)) {
|
||||
if (false === $document->loadHTML($input, LIBXML_PARSEHUGE)) {
|
||||
throw new HtmlParseError('The HTML value does not appear to be valid Netscape Bookmark File Format HTML.');
|
||||
}
|
||||
$this->xpath = new \DOMXPath($document);
|
||||
$this->xpath = new DOMXPath($document);
|
||||
$this->ignorePersonalToolbarFolder = $ignorePersonalToolbarFolder;
|
||||
$this->includeFolderTags = $includeFolderTags;
|
||||
$this->useDateTimeObjects = $useDateTimeObjects;
|
||||
|
@ -123,9 +128,9 @@ class BookmarksParser {
|
|||
/**
|
||||
* Traverses a DOMNode
|
||||
*
|
||||
* @param \DOMNode $node
|
||||
* @param DOMNode|null $node
|
||||
*/
|
||||
private function traverse(\DOMNode $node = null) {
|
||||
private function traverse(DOMNode $node = null): void: void {
|
||||
$query = './*';
|
||||
$entries = $this->xpath->query($query, $node ?: null);
|
||||
if (!$entries) {
|
||||
|
@ -166,9 +171,9 @@ class BookmarksParser {
|
|||
/**
|
||||
* Add a folder from a \DOMNode
|
||||
*
|
||||
* @param \DOMNode $node
|
||||
* @param DOMNode $node
|
||||
*/
|
||||
private function addFolder(\DOMNode $node): void {
|
||||
private function addFolder(DOMNode $node): void {
|
||||
$folder = [
|
||||
'title' => $node->textContent,
|
||||
'children' => [],
|
||||
|
@ -194,9 +199,9 @@ class BookmarksParser {
|
|||
/**
|
||||
* Add a bookmark from a \DOMNode
|
||||
*
|
||||
* @param \DOMNode $node
|
||||
* @param DOMNode $node
|
||||
*/
|
||||
private function addBookmark(\DOMNode $node): void {
|
||||
private function addBookmark(DOMNode $node): void {
|
||||
$bookmark = [
|
||||
'title' => $node->textContent,
|
||||
'description' => '',
|
||||
|
@ -216,9 +221,9 @@ class BookmarksParser {
|
|||
/**
|
||||
* Add a bookmark from a \DOMNode
|
||||
*
|
||||
* @param \DOMNode $node
|
||||
* @param DOMNode $node
|
||||
*/
|
||||
private function addDescription(\DOMNode $node): void {
|
||||
private function addDescription(DOMNode $node): void {
|
||||
$count = count($this->bookmarks);
|
||||
if ($count === 0) {
|
||||
return;
|
||||
|
@ -230,10 +235,10 @@ class BookmarksParser {
|
|||
/**
|
||||
* Get attributes of a \DOMNode
|
||||
*
|
||||
* @param \DOMNode $node
|
||||
* @param DOMNode $node
|
||||
* @return array
|
||||
*/
|
||||
private function getAttributes(\DOMNode $node): array {
|
||||
private function getAttributes(DOMNode $node): array {
|
||||
$attributes = [];
|
||||
$length = $node->attributes->length;
|
||||
for ($i = 0; $i < $length; ++$i) {
|
||||
|
@ -249,12 +254,12 @@ class BookmarksParser {
|
|||
}
|
||||
if ($this->useDateTimeObjects) {
|
||||
if (isset($attributes['add_date'])) {
|
||||
$added = new \DateTime();
|
||||
$added = new DateTime();
|
||||
$added->setTimestamp((int)$attributes['add_date']);
|
||||
$attributes['add_date'] = $added;
|
||||
}
|
||||
if (isset($attributes['last_modified'])) {
|
||||
$modified = new \DateTime();
|
||||
$modified = new DateTime();
|
||||
$modified->setTimestamp((int)$attributes['last_modified']);
|
||||
$attributes['last_modified'] = $modified;
|
||||
}
|
||||
|
@ -272,7 +277,7 @@ class BookmarksParser {
|
|||
*/
|
||||
private function getCurrentFolderTags(): array {
|
||||
$tags = [];
|
||||
array_walk_recursive($this->currentFolder, function ($tag, $key) use (&$tags) {
|
||||
array_walk_recursive($this->currentFolder, static function ($tag, $key) use (&$tags) {
|
||||
if ('name' === $key) {
|
||||
$tags[] = $tag;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service;
|
||||
|
||||
use Exception;
|
||||
use Mimey\MimeTypes;
|
||||
use OC\User\NoUserException;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
|
@ -16,6 +17,7 @@ use OCP\Files\NotPermittedException;
|
|||
use OCP\Http\Client\IClientService;
|
||||
use OCP\Http\Client\IResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\Lock\LockedException;
|
||||
|
||||
class CrawlService {
|
||||
|
@ -42,11 +44,19 @@ class CrawlService {
|
|||
private $path;
|
||||
private $rootFolder;
|
||||
/**
|
||||
* @var \OCP\IL10N
|
||||
* @var IL10N
|
||||
*/
|
||||
private $l;
|
||||
/**
|
||||
* @var MimeTypes
|
||||
*/
|
||||
private $mimey;
|
||||
/**
|
||||
* @var \OCP\Http\Client\IClient
|
||||
*/
|
||||
private $client;
|
||||
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, BookmarkPreviewer $bookmarkPreviewer, FaviconPreviewer $faviconPreviewer, IClientService $clientService, IConfig $config, IRootFolder $rootFolder, \OCP\IL10N $l) {
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, BookmarkPreviewer $bookmarkPreviewer, FaviconPreviewer $faviconPreviewer, IClientService $clientService, IConfig $config, IRootFolder $rootFolder, IL10N $l) {
|
||||
$this->bookmarkMapper = $bookmarkMapper;
|
||||
$this->bookmarkPreviewer = $bookmarkPreviewer;
|
||||
$this->faviconPreviewer = $faviconPreviewer;
|
||||
|
@ -60,14 +70,13 @@ class CrawlService {
|
|||
|
||||
/**
|
||||
* @param Bookmark $bookmark
|
||||
* @throws \OCA\Bookmarks\Exception\UrlParseError
|
||||
* @throws UrlParseError
|
||||
*/
|
||||
public function crawl(Bookmark $bookmark): void {
|
||||
try {
|
||||
/** @var IResponse $resp */
|
||||
$resp = $this->client->get($bookmark->getUrl());
|
||||
$available = $resp->getStatusCode() !== 404;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$available = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service;
|
||||
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Contract\IBookmarkPreviewer;
|
||||
use OCA\Bookmarks\Contract\IImage;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
|
@ -134,7 +135,7 @@ class FaviconPreviewer implements IBookmarkPreviewer {
|
|||
protected function fetchImage($url): ?Image {
|
||||
try {
|
||||
$response = $this->client->get($url, ['timeout' => self::HTTP_TIMEOUT]);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->logger->debug($e, ['app' => 'bookmarks']);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class FileCache implements ICache {
|
|||
* @return int
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
public function size($key) {
|
||||
public function size($key): int {
|
||||
$result = 0;
|
||||
if ($this->hasKey($key)) {
|
||||
$result = $this->storage->getFile($key)->getSize();
|
||||
|
@ -124,7 +124,7 @@ class FileCache implements ICache {
|
|||
*
|
||||
* @throws NotPermittedException
|
||||
*/
|
||||
public function gc() {
|
||||
public function gc(): void {
|
||||
foreach ($this->storage->getDirectoryListing() as $file) {
|
||||
if (time() - self::TIMEOUT > $file->getMTime()) {
|
||||
$file->delete();
|
||||
|
|
|
@ -77,7 +77,7 @@ class FolderService {
|
|||
* @param IL10N $l10n
|
||||
* @param IEventDispatcher $eventDispatcher
|
||||
*/
|
||||
public function __construct(FolderMapper $folderMapper, TreeMapper $treeMapper, ShareMapper $shareMapper, SharedFolderMapper $sharedFolderMapper, PublicFolderMapper $publicFolderMapper, IGroupManager $groupManager, \OCA\Bookmarks\Service\HtmlImporter $htmlImporter, IL10N $l10n, IEventDispatcher $eventDispatcher) {
|
||||
public function __construct(FolderMapper $folderMapper, TreeMapper $treeMapper, ShareMapper $shareMapper, SharedFolderMapper $sharedFolderMapper, PublicFolderMapper $publicFolderMapper, IGroupManager $groupManager, HtmlImporter $htmlImporter, IL10N $l10n, IEventDispatcher $eventDispatcher) {
|
||||
$this->folderMapper = $folderMapper;
|
||||
$this->treeMapper = $treeMapper;
|
||||
$this->shareMapper = $shareMapper;
|
||||
|
@ -90,13 +90,12 @@ class FolderService {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
* @param $title
|
||||
* @param $parent_folder
|
||||
* @param $parentFolderId
|
||||
* @return Folder
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function create($title, $parentFolderId): Folder {
|
||||
/**
|
||||
|
@ -365,7 +364,6 @@ class FolderService {
|
|||
* @return array
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws UnsupportedOperation
|
||||
* @throws AlreadyExistsError
|
||||
* @throws HtmlParseError
|
||||
* @throws UnauthorizedAccessError
|
||||
|
|
|
@ -64,7 +64,6 @@ class HashManager {
|
|||
/**
|
||||
* @param string $type
|
||||
* @param int $folderId
|
||||
* @param string $userId
|
||||
* @return string
|
||||
*/
|
||||
private function getCacheKey(string $type, int $folderId) : string {
|
||||
|
@ -144,7 +143,7 @@ class HashManager {
|
|||
$folder['title'] = $entity->getTitle();
|
||||
}
|
||||
$folder['children'] = $childHashes;
|
||||
$hash[$selector] = hash('sha256', json_encode($folder, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
$hash[$selector] = hash('sha256', json_encode($folder, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
$this->cache->set($key, $hash, 60 * 60 * 24);
|
||||
return $hash[$selector];
|
||||
|
@ -175,7 +174,7 @@ class HashManager {
|
|||
$bookmark[$field] = $entity->{'get' . $field}();
|
||||
}
|
||||
}
|
||||
$hash[$selector] = hash('sha256', json_encode($bookmark, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
$hash[$selector] = hash('sha256', json_encode($bookmark, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
$this->cache->set($key, $hash, 60 * 60 * 24);
|
||||
return $hash[$selector];
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ class HtmlExporter {
|
|||
* @param BookmarkMapper $bookmarkMapper
|
||||
* @param FolderMapper $folderMapper
|
||||
* @param TagMapper $tagMapper
|
||||
* @param TreeMapper $treeMapper
|
||||
*/
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, FolderMapper $folderMapper, TagMapper $tagMapper, TreeMapper $treeMapper) {
|
||||
$this->bookmarkMapper = $bookmarkMapper;
|
||||
|
|
|
@ -53,6 +53,7 @@ class HtmlImporter {
|
|||
* @param BookmarkMapper $bookmarkMapper
|
||||
* @param FolderMapper $folderMapper
|
||||
* @param TagMapper $tagMapper
|
||||
* @param TreeMapper $treeMapper
|
||||
* @param BookmarksParser $bookmarksParser
|
||||
*/
|
||||
public function __construct(BookmarkMapper $bookmarkMapper, FolderMapper $folderMapper, TagMapper $tagMapper, TreeMapper $treeMapper, BookmarksParser $bookmarksParser) {
|
||||
|
@ -66,8 +67,8 @@ class HtmlImporter {
|
|||
/**
|
||||
* @brief Import Bookmarks from html formatted file
|
||||
* @param int $userId
|
||||
* @param string $file Content to import
|
||||
* @param int $rootFolder
|
||||
* @param string|null $file Content to import
|
||||
* @param int|null $rootFolder
|
||||
* @return array
|
||||
* @throws DoesNotExistException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
|
@ -163,9 +164,9 @@ class HtmlImporter {
|
|||
* @param array $bookmark
|
||||
* @param null $index
|
||||
* @return Bookmark|Entity
|
||||
* @throws UrlParseError
|
||||
* @throws AlreadyExistsError
|
||||
* @throws UnsupportedOperation
|
||||
* @throws UrlParseError
|
||||
* @throws UserLimitExceededError
|
||||
*/
|
||||
private function importBookmark($userId, int $folderId, array $bookmark, $index = null) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service;
|
||||
|
||||
use Exception;
|
||||
use Marcelklehr\LinkPreview\Client as LinkPreview;
|
||||
use OCA\Bookmarks\Http\Client;
|
||||
use OCA\Bookmarks\Http\RequestFactory;
|
||||
|
@ -16,6 +17,10 @@ class LinkExplorer {
|
|||
private $logger;
|
||||
|
||||
private $config;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $enabled;
|
||||
|
||||
public function __construct(IClientService $clientService, ILogger $logger, IConfig $config) {
|
||||
$client = $clientService->newClient();
|
||||
|
@ -31,7 +36,7 @@ class LinkExplorer {
|
|||
* @param string $url Url to load and analyze
|
||||
* @return array Metadata for url;
|
||||
*/
|
||||
public function get($url) {
|
||||
public function get($url): array {
|
||||
$data = ['url' => $url];
|
||||
|
||||
if ($this->enabled === 'false') {
|
||||
|
@ -42,7 +47,7 @@ class LinkExplorer {
|
|||
try {
|
||||
libxml_use_internal_errors(false);
|
||||
$preview = $this->linkPreview->getLink($url)->getPreview();
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->logger->debug($e, ['app' => 'bookmarks']);
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service\Previewers;
|
||||
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Contract\IBookmarkPreviewer;
|
||||
use OCA\Bookmarks\Contract\IImage;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
use OCA\Bookmarks\Image;
|
||||
use OCA\Bookmarks\Service\FileCache;
|
||||
use OCA\Bookmarks\Service\LinkExplorer;
|
||||
use OCP\Http\Client\IClient;
|
||||
use OCP\Http\Client\IClientService;
|
||||
|
@ -44,7 +44,6 @@ class DefaultBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
private $logger;
|
||||
|
||||
/**
|
||||
* @param FileCache $cache
|
||||
* @param LinkExplorer $linkExplorer
|
||||
* @param IClientService $clientService
|
||||
* @param ILogger $logger
|
||||
|
@ -85,7 +84,7 @@ class DefaultBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
protected function fetchImage($url): ?Image {
|
||||
try {
|
||||
$response = $this->client->get($url, ['timeout' => self::HTTP_TIMEOUT]);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->logger->debug($e, ['app' => 'bookmarks']);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service\Previewers;
|
||||
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Contract\IBookmarkPreviewer;
|
||||
use OCA\Bookmarks\Contract\IImage;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
|
@ -70,7 +71,7 @@ class PageresBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
* @param string $serverPath
|
||||
* @param string $url
|
||||
* @return Image|null
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function fetchImage(string $serverPath, string $url): ?Image {
|
||||
$tempPath = $this->tempManager->getTemporaryFile('.png');
|
||||
|
@ -98,7 +99,7 @@ class PageresBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
$retries++;
|
||||
}
|
||||
|
||||
throw new \Exception("Pageres Error\nCommand: {$cmd}\nOutput: " . implode(' ' . PHP_EOL, $output) . PHP_EOL);
|
||||
throw new Exception("Pageres Error\nCommand: {$cmd}\nOutput: " . implode(' ' . PHP_EOL, $output) . PHP_EOL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service\Previewers;
|
||||
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Contract\IBookmarkPreviewer;
|
||||
use OCA\Bookmarks\Contract\IImage;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
|
@ -93,8 +94,8 @@ class ScreeenlyBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
],
|
||||
'timeout' => self::HTTP_TIMEOUT,
|
||||
]);
|
||||
$body = json_decode($response->getBody(), true);
|
||||
} catch (\Exception $e) {
|
||||
$body = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (Exception $e) {
|
||||
$this->logger->logException($e, ['app' => 'bookmarks']);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service\Previewers;
|
||||
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Contract\IBookmarkPreviewer;
|
||||
use OCA\Bookmarks\Contract\IImage;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
|
@ -47,6 +48,10 @@ class ScreenshotMachineBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
private $width = 800;
|
||||
|
||||
private $height = 800;
|
||||
/**
|
||||
* @var FileCache
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
public function __construct(FileCache $cache, IConfig $config, IClientService $clientService, ILogger $logger) {
|
||||
$this->config = $config;
|
||||
|
@ -91,7 +96,7 @@ class ScreenshotMachineBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
return null;
|
||||
}
|
||||
$body = $response->getBody();
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->logger->logException($e, ['app' => 'bookmarks']);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace OCA\Bookmarks\Service\Previewers;
|
||||
|
||||
use Exception;
|
||||
use OCA\Bookmarks\Contract\IBookmarkPreviewer;
|
||||
use OCA\Bookmarks\Contract\IImage;
|
||||
use OCA\Bookmarks\Db\Bookmark;
|
||||
|
@ -94,7 +95,7 @@ class WebshotBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
if (200 !== $response->getStatusCode()) {
|
||||
return null;
|
||||
}
|
||||
$data = json_decode($response->getBody(), true);
|
||||
$data = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
// get it
|
||||
$response = $this->client->get($this->apiUrl . $data->id);
|
||||
|
@ -103,7 +104,7 @@ class WebshotBookmarkPreviewer implements IBookmarkPreviewer {
|
|||
return null;
|
||||
}
|
||||
$body = $response->getBody();
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->logger->logException($e, ['app' => 'bookmarks']);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class UrlNormalizer {
|
|||
* @return string
|
||||
* @throws UrlParseError
|
||||
*/
|
||||
public function normalize($urlString) {
|
||||
public function normalize($urlString): string {
|
||||
if (isset($this->cache[$urlString])) {
|
||||
return $this->cache[$urlString];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue