Merge pull request #5446 from nextcloud/backport/5440/stable24
[stable24] Fix small issues around delete/undo
This commit is contained in:
39
.github/workflows/appbuild.yml
vendored
39
.github/workflows/appbuild.yml
vendored
@@ -1,39 +0,0 @@
|
|||||||
name: Package build
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [14.x]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
- name: Set up npm7
|
|
||||||
run: npm i -g npm@7
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: shivammathur/setup-php@2.18.0
|
|
||||||
with:
|
|
||||||
php-version: '7.4'
|
|
||||||
tools: composer
|
|
||||||
- name: install dependencies
|
|
||||||
run: |
|
|
||||||
wget https://github.com/ChristophWurst/krankerl/releases/download/v0.12.2/krankerl_0.12.2_amd64.deb
|
|
||||||
sudo dpkg -i krankerl_0.12.2_amd64.deb
|
|
||||||
- name: package
|
|
||||||
run: |
|
|
||||||
uname -a
|
|
||||||
RUST_BACKTRACE=1 krankerl --version
|
|
||||||
RUST_BACKTRACE=1 krankerl package
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: Deck app tarball
|
|
||||||
path: build/artifacts/deck.tar.gz
|
|
||||||
3
.github/workflows/phpunit.yml
vendored
3
.github/workflows/phpunit.yml
vendored
@@ -62,11 +62,12 @@ jobs:
|
|||||||
path: apps/${{ env.APP_NAME }}
|
path: apps/${{ env.APP_NAME }}
|
||||||
|
|
||||||
- name: Set up php ${{ matrix.php-versions }}
|
- name: Set up php ${{ matrix.php-versions }}
|
||||||
uses: shivammathur/setup-php@2.18.0
|
uses: shivammathur/setup-php@2.24.0
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
tools: phpunit
|
tools: phpunit
|
||||||
extensions: zip, gd, mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql
|
extensions: zip, gd, mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, mysql, pdo_mysql, pgsql, pdo_pgsql
|
||||||
|
ini-file: development
|
||||||
coverage: none
|
coverage: none
|
||||||
|
|
||||||
- name: Set up PHPUnit
|
- name: Set up PHPUnit
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class ResourceProvider implements IProvider {
|
|||||||
|
|
||||||
private function getBoard(IResource $resource) {
|
private function getBoard(IResource $resource) {
|
||||||
try {
|
try {
|
||||||
return $this->boardMapper->find($resource->getId(), false, true);
|
return $this->boardMapper->find((int)$resource->getId(), false, true);
|
||||||
} catch (DoesNotExistException $e) {
|
} catch (DoesNotExistException $e) {
|
||||||
} catch (MultipleObjectsReturnedException $e) {
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -79,12 +79,14 @@ class BoardMapper extends QBMapper implements IPermissionMapper {
|
|||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
* @throws DoesNotExistException
|
* @throws DoesNotExistException
|
||||||
*/
|
*/
|
||||||
public function find($id, $withLabels = false, $withAcl = false): Board {
|
public function find(int $id, bool $withLabels = false, bool $withAcl = false, bool $allowDeleted = false): Board {
|
||||||
if (!isset($this->boardCache[$id])) {
|
if (!isset($this->boardCache[$id])) {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
$deletedWhere = $allowDeleted ? $qb->expr()->gte('deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)) : $qb->expr()->eq('deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT));
|
||||||
$qb->select('*')
|
$qb->select('*')
|
||||||
->from('deck_boards')
|
->from('deck_boards')
|
||||||
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
|
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
|
||||||
|
->andWhere($deletedWhere)
|
||||||
->orderBy('id');
|
->orderBy('id');
|
||||||
$this->boardCache[$id] = $this->findEntity($qb);
|
$this->boardCache[$id] = $this->findEntity($qb);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class BoardService {
|
|||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
* @throws BadRequestException
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public function find($boardId) {
|
public function find($boardId, bool $allowDeleted = false) {
|
||||||
$this->boardServiceValidator->check(compact('boardId'));
|
$this->boardServiceValidator->check(compact('boardId'));
|
||||||
if ($this->boardsCache && isset($this->boardsCache[$boardId])) {
|
if ($this->boardsCache && isset($this->boardsCache[$boardId])) {
|
||||||
return $this->boardsCache[$boardId];
|
return $this->boardsCache[$boardId];
|
||||||
@@ -192,7 +192,7 @@ class BoardService {
|
|||||||
|
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
|
||||||
/** @var Board $board */
|
/** @var Board $board */
|
||||||
$board = $this->boardMapper->find($boardId, true, true);
|
$board = $this->boardMapper->find((int)$boardId, true, true, $allowDeleted);
|
||||||
$this->boardMapper->mapOwner($board);
|
$this->boardMapper->mapOwner($board);
|
||||||
if ($board->getAcl() !== null) {
|
if ($board->getAcl() !== null) {
|
||||||
foreach ($board->getAcl() as $acl) {
|
foreach ($board->getAcl() as $acl) {
|
||||||
@@ -367,7 +367,7 @@ class BoardService {
|
|||||||
$this->boardServiceValidator->check(compact('id'));
|
$this->boardServiceValidator->check(compact('id'));
|
||||||
|
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id, true);
|
||||||
$board->setDeletedAt(0);
|
$board->setDeletedAt(0);
|
||||||
$board = $this->boardMapper->update($board);
|
$board = $this->boardMapper->update($board);
|
||||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_RESTORE);
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_RESTORE);
|
||||||
@@ -388,7 +388,7 @@ class BoardService {
|
|||||||
$this->boardServiceValidator->check(compact('id'));
|
$this->boardServiceValidator->check(compact('id'));
|
||||||
|
|
||||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||||
$board = $this->find($id);
|
$board = $this->find($id, true);
|
||||||
$delete = $this->boardMapper->delete($board);
|
$delete = $this->boardMapper->delete($board);
|
||||||
|
|
||||||
return $delete;
|
return $delete;
|
||||||
|
|||||||
@@ -274,6 +274,14 @@ class CardService {
|
|||||||
if ($archived !== null && $card->getArchived() && $archived === true) {
|
if ($archived !== null && $card->getArchived() && $archived === true) {
|
||||||
throw new StatusException('Operation not allowed. This card is archived.');
|
throw new StatusException('Operation not allowed. This card is archived.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($card->getDeletedAt() !== 0) {
|
||||||
|
if ($deletedAt === null) {
|
||||||
|
// Only allow operations when restoring the card
|
||||||
|
throw new StatusException('Operation not allowed. This card was deleted.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$changes = new ChangeSet($card);
|
$changes = new ChangeSet($card);
|
||||||
if ($card->getLastEditor() !== $this->currentUser && $card->getLastEditor() !== null) {
|
if ($card->getLastEditor() !== $this->currentUser && $card->getLastEditor() !== null) {
|
||||||
$this->activityManager->triggerEvent(
|
$this->activityManager->triggerEvent(
|
||||||
|
|||||||
@@ -194,11 +194,11 @@ class PermissionService {
|
|||||||
* @throws MultipleObjectsReturnedException
|
* @throws MultipleObjectsReturnedException
|
||||||
* @throws DoesNotExistException
|
* @throws DoesNotExistException
|
||||||
*/
|
*/
|
||||||
private function getBoard($boardId): Board {
|
private function getBoard(int $boardId): Board {
|
||||||
if (!isset($this->boardCache[$boardId])) {
|
if (!isset($this->boardCache[(string)$boardId])) {
|
||||||
$this->boardCache[$boardId] = $this->boardMapper->find($boardId, false, true);
|
$this->boardCache[(string)$boardId] = $this->boardMapper->find($boardId, false, true);
|
||||||
}
|
}
|
||||||
return $this->boardCache[$boardId];
|
return $this->boardCache[(string)$boardId];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
1
tests/integration/base-query-count.txt
Normal file
1
tests/integration/base-query-count.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
68024
|
||||||
@@ -131,6 +131,7 @@ class ActivityManagerTest extends TestCase {
|
|||||||
|
|
||||||
public function testCreateEvent() {
|
public function testCreateEvent() {
|
||||||
$board = new Board();
|
$board = new Board();
|
||||||
|
$board->setId(123);
|
||||||
$board->setTitle('');
|
$board->setTitle('');
|
||||||
$this->boardMapper->expects(self::once())
|
$this->boardMapper->expects(self::once())
|
||||||
->method('find')
|
->method('find')
|
||||||
@@ -148,6 +149,7 @@ class ActivityManagerTest extends TestCase {
|
|||||||
|
|
||||||
public function testCreateEventDescription() {
|
public function testCreateEventDescription() {
|
||||||
$board = new Board();
|
$board = new Board();
|
||||||
|
$board->setId(123);
|
||||||
$board->setTitle('');
|
$board->setTitle('');
|
||||||
$this->boardMapper->expects(self::once())
|
$this->boardMapper->expects(self::once())
|
||||||
->method('find')
|
->method('find')
|
||||||
@@ -162,7 +164,9 @@ class ActivityManagerTest extends TestCase {
|
|||||||
->method('find')
|
->method('find')
|
||||||
->willReturn($card);
|
->willReturn($card);
|
||||||
|
|
||||||
$stack = Stack::fromRow([]);
|
$stack = Stack::fromRow([
|
||||||
|
'boardId' => 123,
|
||||||
|
]);
|
||||||
$this->stackMapper->expects(self::any())
|
$this->stackMapper->expects(self::any())
|
||||||
->method('find')
|
->method('find')
|
||||||
->willReturn($stack);
|
->willReturn($stack);
|
||||||
@@ -192,6 +196,7 @@ class ActivityManagerTest extends TestCase {
|
|||||||
|
|
||||||
public function testCreateEventLongDescription() {
|
public function testCreateEventLongDescription() {
|
||||||
$board = new Board();
|
$board = new Board();
|
||||||
|
$board->setId(123);
|
||||||
$board->setTitle('');
|
$board->setTitle('');
|
||||||
$this->boardMapper->expects(self::once())
|
$this->boardMapper->expects(self::once())
|
||||||
->method('find')
|
->method('find')
|
||||||
@@ -205,7 +210,9 @@ class ActivityManagerTest extends TestCase {
|
|||||||
->method('find')
|
->method('find')
|
||||||
->willReturn($card);
|
->willReturn($card);
|
||||||
|
|
||||||
$stack = new Stack();
|
$stack = Stack::fromRow([
|
||||||
|
'boardId' => 123,
|
||||||
|
]);
|
||||||
$this->stackMapper->expects(self::any())
|
$this->stackMapper->expects(self::any())
|
||||||
->method('find')
|
->method('find')
|
||||||
->willReturn($stack);
|
->willReturn($stack);
|
||||||
@@ -235,6 +242,7 @@ class ActivityManagerTest extends TestCase {
|
|||||||
|
|
||||||
public function testCreateEventLabel() {
|
public function testCreateEventLabel() {
|
||||||
$board = Board::fromRow([
|
$board = Board::fromRow([
|
||||||
|
'id' => 123,
|
||||||
'title' => 'My board'
|
'title' => 'My board'
|
||||||
]);
|
]);
|
||||||
$this->boardMapper->expects(self::once())
|
$this->boardMapper->expects(self::once())
|
||||||
@@ -249,7 +257,9 @@ class ActivityManagerTest extends TestCase {
|
|||||||
->method('find')
|
->method('find')
|
||||||
->willReturn($card);
|
->willReturn($card);
|
||||||
|
|
||||||
$stack = Stack::fromParams([]);
|
$stack = Stack::fromRow([
|
||||||
|
'boardId' => 123,
|
||||||
|
]);
|
||||||
$this->stackMapper->expects(self::any())
|
$this->stackMapper->expects(self::any())
|
||||||
->method('find')
|
->method('find')
|
||||||
->willReturn($stack);
|
->willReturn($stack);
|
||||||
|
|||||||
Reference in New Issue
Block a user