Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

No more deprecated API usages #4248

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Db/DocumentMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function find($documentId): Document {
$result = $qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('id', $qb->createNamedParameter($documentId)))
->execute();
->executeQuery();

$data = $result->fetch();
$result->closeCursor();
Expand All @@ -59,7 +59,7 @@ public function findAll(): array {
$qb = $this->db->getQueryBuilder();
$result = $qb->select('*')
->from($this->getTableName())
->execute();
->executeQuery();

return $this->findEntities($qb);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Db/SessionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function find($documentId, $sessionId, $token): Session {
->where($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId)))
->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($sessionId)))
->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)))
->execute();
->executeQuery();

$data = $result->fetch();
$result->closeCursor();
Expand Down Expand Up @@ -108,7 +108,7 @@ public function deleteInactiveWithoutSteps($documentId = -1) {
}
$result = $qb
->groupBy('session_id')
->execute();
->executeQuery();
$activeSessions = $result->fetchAll(\PDO::FETCH_COLUMN);
$result->closeCursor();

Expand All @@ -119,14 +119,14 @@ public function deleteInactiveWithoutSteps($documentId = -1) {
$qb->andWhere($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId)));
}
$qb->andWhere($qb->expr()->notIn('id', $qb->createNamedParameter($activeSessions, IQueryBuilder::PARAM_INT_ARRAY)));
return $qb->execute();
return $qb->executeStatement();
}

public function deleteByDocumentId($documentId) {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
->where($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId)));
return $qb->execute();
return $qb->executeStatement();
}

public function isUserInDocument($documentId, $userId): bool {
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/StepMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getLatestVersion($documentId): ?int {
->where($qb->expr()->eq('document_id', $qb->createNamedParameter($documentId)))
->setMaxResults(1)
->orderBy('version', 'DESC')
->execute();
->executeQuery();

$data = $result->fetch();
if ($data === false) {
Expand Down
10 changes: 5 additions & 5 deletions lib/DirectEditing/TextDirectEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\DirectEditing\IEditor;
use OCP\DirectEditing\IToken;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\Util;

Expand All @@ -42,13 +42,13 @@ class TextDirectEditor implements IEditor {
/** @var IL10N */
private $l10n;

/** @var IInitialStateService */
/** @var IInitialState */
private $initialStateService;

/** @var ApiService */
private $apiService;

public function __construct(IL10N $l10n, IInitialStateService $initialStateService, ApiService $apiService) {
public function __construct(IL10N $l10n, IInitialState $initialStateService, ApiService $apiService) {
$this->l10n = $l10n;
$this->initialStateService = $initialStateService;
$this->apiService = $apiService;
Expand Down Expand Up @@ -153,12 +153,12 @@ public function open(IToken $token): Response {
$token->useTokenScope();
try {
$session = $this->apiService->create($token->getFile()->getId());
$this->initialStateService->provideInitialState('text', 'file', [
$this->initialStateService->provideInitialState('file', [
'fileId' => $token->getFile()->getId(),
'mimetype' => $token->getFile()->getMimeType(),
'session' => \json_encode($session->getData())
]);
$this->initialStateService->provideInitialState('text', 'directEditingToken', $token->getToken());
$this->initialStateService->provideInitialState('directEditingToken', $token->getToken());
Util::addScript('text', 'text-text');
return new TemplateResponse('text', 'main', [], 'base');
} catch (InvalidPathException $e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function mention(int $fileId, string $userId): bool {
;

if ($this->manager->getCount($notification) === 0) {
$notification->setDateTime($this->timeFactory->getDateTime());
$notification->setDateTime(\DateTime::createFromImmutable($this->timeFactory->now()));
$this->manager->notify($notification);
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function initSession($documentId, $guestName = null): Session {
if ($this->userId === null) {
$session->setGuestName($guestName);
}
$session->setLastContact($this->timeFactory->getTime());
$session->setLastContact($this->timeFactory->now()->getTimestamp());

$session = $this->sessionMapper->insert($session);
$this->cache->set($session->getToken(), json_encode($session), self::SESSION_VALID_TIME);
Expand Down Expand Up @@ -192,7 +192,7 @@ public function isValidSession($documentId, $sessionId, $token): bool {
return false;
}

$currentTime = $this->timeFactory->getTime();
$currentTime = $this->timeFactory->now()->getTimestamp();
if (($currentTime - $session->getLastContact()) >= 30) {
/*
* We need to update the timestamp.
Expand All @@ -205,7 +205,7 @@ public function isValidSession($documentId, $sessionId, $token): bool {
$this->cache->remove($token);
return false;
}
$session->setLastContact($this->timeFactory->getTime());
$session->setLastContact($this->timeFactory->now()->getTimestamp());
$this->sessionMapper->update($session);
$this->cache->set($token, json_encode($session), self::SESSION_VALID_TIME - 30);
}
Expand Down
5 changes: 4 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
<extraFiles>
<directory name="vendor/nextcloud/ocp" />
</extraFiles>
<issueHandlers>
<issueHandlers>
<DeprecatedMethod>
<errorLevel type="error" />
</DeprecatedMethod>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OC" />
Expand Down