Skip to content

Commit 7e15fb0

Browse files
authored
Merge pull request #2951 from nextcloud/fix/adapt-to-files_trash-changes
fix: Adapt to constructor change of TrashItem in files_trashbin
2 parents 923d2ae + 4802942 commit 7e15fb0

File tree

2 files changed

+152
-73
lines changed

2 files changed

+152
-73
lines changed

lib/Trash/GroupTrashItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
IUser $user,
4040
string $mountPoint
4141
) {
42-
parent::__construct($backend, $originalLocation, $deletedTime, $trashPath, $fileInfo, $user);
42+
parent::__construct($backend, $originalLocation, $deletedTime, $trashPath, $fileInfo, $user, null);
4343
$this->mountPoint = $mountPoint;
4444
}
4545

tests/stub.phpstub

Lines changed: 151 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -22,74 +22,130 @@ declare(strict_types=1);
2222
*/
2323

2424
namespace OCA\Files_Trashbin\Trash {
25-
use OCP\Files\Node;
26-
use OCP\Files\Storage\IStorage;
27-
use OCP\IUser;
28-
use OCP\Files\FileInfo;
29-
30-
interface ITrashManager {
25+
/**
26+
* @since 15.0.0
27+
*/
28+
interface ITrashBackend
29+
{
30+
/**
31+
* List all trash items in the root of the trashbin
32+
*
33+
* @return ITrashItem[]
34+
* @since 15.0.0
35+
*/
36+
public function listTrashRoot(\OCP\IUser $user) : array;
37+
/**
38+
* List all trash items in a subfolder in the trashbin
39+
*
40+
* @return ITrashItem[]
41+
* @since 15.0.0
42+
*/
43+
public function listTrashFolder(\OCA\Files_Trashbin\Trash\ITrashItem $folder) : array;
44+
/**
45+
* Restore a trashbin item
46+
*
47+
* @since 15.0.0
48+
*/
49+
public function restoreItem(\OCA\Files_Trashbin\Trash\ITrashItem $item);
50+
/**
51+
* Permanently remove an item from trash
52+
*
53+
* @param ITrashItem $item
54+
* @since 15.0.0
55+
*/
56+
public function removeItem(\OCA\Files_Trashbin\Trash\ITrashItem $item);
57+
/**
58+
* Move a file or folder to trash
59+
*
60+
* @param string $internalPath
61+
* @return bool whether or not the file was moved to trash, if false then the file should be deleted normally
62+
* @since 15.0.0
63+
*/
64+
public function moveToTrash(\OCP\Files\Storage\IStorage $storage, string $internalPath) : bool;
65+
/**
66+
* @param int $fileId
67+
* @return \OCP\Files\Node|null
68+
*/
69+
public function getTrashNodeById(\OCP\IUser $user, int $fileId);
70+
}
71+
interface ITrashManager extends \OCA\Files_Trashbin\Trash\ITrashBackend
72+
{
73+
/**
74+
* Add a backend for the trashbin
75+
*
76+
* @param string $storageType
77+
* @param ITrashBackend $backend
78+
* @since 15.0.0
79+
*/
80+
public function registerBackend(string $storageType, \OCA\Files_Trashbin\Trash\ITrashBackend $backend);
81+
/**
82+
* List all trash items in the root of the trashbin
83+
*
84+
* @return ITrashItem[]
85+
* @since 15.0.0
86+
*/
87+
public function listTrashRoot(\OCP\IUser $user) : array;
88+
/**
89+
* Temporally prevent files from being moved to the trash
90+
*
91+
* @since 15.0.0
92+
*/
3193
public function pauseTrash();
32-
94+
/**
95+
* @since 15.0.0
96+
*/
3397
public function resumeTrash();
3498
}
35-
36-
interface ITrashBackend {
99+
/**
100+
* @since 15.0.0
101+
*/
102+
interface ITrashItem extends \OCP\Files\FileInfo
103+
{
37104
/**
38-
* @return ITrashItem[]
39-
*/
40-
public function listTrashRoot(IUser $user): array;
41-
105+
* Get the trash backend for this item
106+
*
107+
* @since 15.0.0
108+
*/
109+
public function getTrashBackend() : \OCA\Files_Trashbin\Trash\ITrashBackend;
42110
/**
43-
* @return ITrashItem[]
44-
*/
45-
public function listTrashFolder(ITrashItem $folder): array;
46-
111+
* Get the original location for the trash item
112+
*
113+
* @since 15.0.0
114+
*/
115+
public function getOriginalLocation() : string;
47116
/**
48-
* @param ITrashItem $item
49-
*/
50-
public function restoreItem(ITrashItem $item);
51-
52-
public function removeItem(ITrashItem $item);
53-
54-
public function moveToTrash(IStorage $storage, string $internalPath): bool;
55-
117+
* Get the timestamp that the file was moved to trash
118+
*
119+
* @since 15.0.0
120+
*/
121+
public function getDeletedTime() : int;
56122
/**
57-
* @return Node|null
58-
*/
59-
public function getTrashNodeById(IUser $user, int $fileId);
60-
}
61-
62-
interface ITrashItem extends FileInfo {
63-
public function getTrashBackend(): ITrashBackend;
64-
65-
public function getOriginalLocation(): string;
66-
67-
public function getDeletedTime(): int;
68-
69-
public function getTrashPath(): string;
70-
71-
public function isRootItem(): bool;
72-
73-
public function getUser(): IUser;
74-
75-
public function getTitle(): string;
123+
* Get the path of the item relative to the users trashbin
124+
*
125+
* @since 15.0.0
126+
*/
127+
public function getTrashPath() : string;
128+
/**
129+
* Whether the item is a deleted item in the root of the trash, or a file in a subfolder
130+
*
131+
* @since 15.0.0
132+
*/
133+
public function isRootItem() : bool;
134+
/**
135+
* Get the user for which this trash item applies
136+
*
137+
* @since 15.0.0
138+
*/
139+
public function getUser() : \OCP\IUser;
140+
/**
141+
* @since 30.0.0
142+
*/
143+
public function getDeletedBy() : ?\OCP\IUser;
144+
public function getTitle() : string;
76145
}
77-
78146
class TrashItem implements \OCA\Files_Trashbin\Trash\ITrashItem
79147
{
80-
/** @var ITrashBackend */
81-
private $backend;
82-
/** @var string */
83-
private $orignalLocation;
84-
/** @var int */
85-
private $deletedTime;
86-
/** @var string */
87-
private $trashPath;
88-
/** @var FileInfo */
89-
private $fileInfo;
90-
/** @var IUser */
91-
private $user;
92-
public function __construct(\OCA\Files_Trashbin\Trash\ITrashBackend $backend, string $originalLocation, int $deletedTime, string $trashPath, \OCP\Files\FileInfo $fileInfo, \OCP\IUser $user)
148+
public function __construct(private \OCA\Files_Trashbin\Trash\ITrashBackend $backend, private string $originalLocation, private int $deletedTime, private string $trashPath, private \OCP\Files\FileInfo $fileInfo, private \OCP\IUser $user, private ?\OCP\IUser $deletedBy)
93149
{
94150
}
95151
public function getTrashBackend() : \OCA\Files_Trashbin\Trash\ITrashBackend
@@ -194,6 +250,9 @@ namespace OCA\Files_Trashbin\Trash {
194250
public function getParentId() : int
195251
{
196252
}
253+
public function getDeletedBy() : ?\OCP\IUser
254+
{
255+
}
197256
/**
198257
* @inheritDoc
199258
* @return array<string, int|string|bool|float|string[]|int[]>
@@ -261,27 +320,47 @@ namespace OCA\Files_Sharing\Event {
261320
}
262321
}
263322

264-
namespace OCA\Files_Trashbin {
265-
class Expiration {
266323

324+
namespace OCA\Files_Trashbin {
325+
class Expiration
326+
{
327+
// how long do we keep files in the trash bin if no other value is defined in the config file (unit: days)
267328
public const DEFAULT_RETENTION_OBLIGATION = 30;
268329
public const NO_OBLIGATION = -1;
269-
270-
public function setRetentionObligation(string $obligation) {}
271-
272-
/** @return bool */
273-
public function isEnabled() {}
274-
330+
public function __construct(\OCP\IConfig $config, \OCP\AppFramework\Utility\ITimeFactory $timeFactory)
331+
{
332+
}
333+
public function setRetentionObligation(string $obligation)
334+
{
335+
}
275336
/**
276-
* @param int $timestamp
277-
* @param bool $quotaExceeded
278-
* @return bool
279-
*/
280-
public function isExpired($timestamp, $quotaExceeded = false) {}
337+
* Is trashbin expiration enabled
338+
* @return bool
339+
*/
340+
public function isEnabled()
341+
{
342+
}
343+
/**
344+
* Check if given timestamp in expiration range
345+
* @param int $timestamp
346+
* @param bool $quotaExceeded
347+
* @return bool
348+
*/
349+
public function isExpired($timestamp, $quotaExceeded = false)
350+
{
351+
}
352+
/**
353+
* @return bool|int
354+
*/
355+
public function getMaxAgeAsTimestamp()
356+
{
357+
}
358+
private function parseRetentionObligation()
359+
{
360+
}
281361
}
282362
}
283363

284-
285364
namespace OCA\Files_Versions\Versions {
286365
use OCP\Files\File;
287366
use OCP\Files\FileInfo;

0 commit comments

Comments
 (0)