Skip to content

Commit 0487144

Browse files
committed
Remove deprecated searchByTag
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
1 parent b2341cd commit 0487144

File tree

10 files changed

+0
-306
lines changed

10 files changed

+0
-306
lines changed

apps/files_sharing/tests/CacheTest.php

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -238,96 +238,6 @@ function testSearchByMime() {
238238
$this->verifyFiles($check, $results);
239239
}
240240

241-
/**
242-
* Test searching by tag
243-
*/
244-
function testSearchByTag() {
245-
$userId = \OC::$server->getUserSession()->getUser()->getUId();
246-
$id1 = $this->sharedCache->get('bar.txt')['fileid'];
247-
$id2 = $this->sharedCache->get('subdir/another too.txt')['fileid'];
248-
$id3 = $this->sharedCache->get('subdir/not a text file.xml')['fileid'];
249-
$id4 = $this->sharedCache->get('subdir/another.txt')['fileid'];
250-
$tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId);
251-
$tagManager->tagAs($id1, 'tag1');
252-
$tagManager->tagAs($id1, 'tag2');
253-
$tagManager->tagAs($id2, 'tag1');
254-
$tagManager->tagAs($id3, 'tag1');
255-
$tagManager->tagAs($id4, 'tag2');
256-
$results = $this->sharedStorage->getCache()->searchByTag('tag1', $userId);
257-
$check = array(
258-
array(
259-
'name' => 'bar.txt',
260-
'path' => 'bar.txt'
261-
),
262-
array(
263-
'name' => 'another too.txt',
264-
'path' => 'subdir/another too.txt'
265-
),
266-
array(
267-
'name' => 'not a text file.xml',
268-
'path' => 'subdir/not a text file.xml'
269-
),
270-
);
271-
$this->verifyFiles($check, $results);
272-
$tagManager->delete(array('tag1', 'tag2'));
273-
}
274-
275-
/**
276-
* Test searching by tag for multiple sections of the tree
277-
*/
278-
function testSearchByTagTree() {
279-
$userId = \OC::$server->getUserSession()->getUser()->getUId();
280-
$this->sharedStorage->mkdir('subdir/emptydir');
281-
$this->sharedStorage->mkdir('subdir/emptydir2');
282-
$this->ownerStorage->getScanner()->scan('');
283-
$allIds = array(
284-
$this->sharedCache->get('')['fileid'],
285-
$this->sharedCache->get('bar.txt')['fileid'],
286-
$this->sharedCache->get('subdir/another too.txt')['fileid'],
287-
$this->sharedCache->get('subdir/not a text file.xml')['fileid'],
288-
$this->sharedCache->get('subdir/another.txt')['fileid'],
289-
$this->sharedCache->get('subdir/emptydir')['fileid'],
290-
$this->sharedCache->get('subdir/emptydir2')['fileid'],
291-
);
292-
$tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId);
293-
foreach ($allIds as $id) {
294-
$tagManager->tagAs($id, 'tag1');
295-
}
296-
$results = $this->sharedStorage->getCache()->searchByTag('tag1', $userId);
297-
$check = array(
298-
array(
299-
'name' => 'shareddir',
300-
'path' => ''
301-
),
302-
array(
303-
'name' => 'bar.txt',
304-
'path' => 'bar.txt'
305-
),
306-
array(
307-
'name' => 'another.txt',
308-
'path' => 'subdir/another.txt'
309-
),
310-
array(
311-
'name' => 'another too.txt',
312-
'path' => 'subdir/another too.txt'
313-
),
314-
array(
315-
'name' => 'emptydir',
316-
'path' => 'subdir/emptydir'
317-
),
318-
array(
319-
'name' => 'emptydir2',
320-
'path' => 'subdir/emptydir2'
321-
),
322-
array(
323-
'name' => 'not a text file.xml',
324-
'path' => 'subdir/not a text file.xml'
325-
),
326-
);
327-
$this->verifyFiles($check, $results);
328-
$tagManager->delete(array('tag1'));
329-
}
330-
331241
function testGetFolderContentsInRoot() {
332242
$results = $this->user2View->getDirectoryContent('/');
333243

lib/private/Files/Cache/Cache.php

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -723,52 +723,6 @@ public function searchQuery(ISearchQuery $searchQuery) {
723723
return $this->searchResultToCacheEntries($result);
724724
}
725725

726-
/**
727-
* Search for files by tag of a given users.
728-
*
729-
* Note that every user can tag files differently.
730-
*
731-
* @param string|int $tag name or tag id
732-
* @param string $userId owner of the tags
733-
* @return ICacheEntry[] file data
734-
*/
735-
public function searchByTag($tag, $userId) {
736-
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' .
737-
'`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, ' .
738-
'`encrypted`, `etag`, `permissions`, `checksum` ' .
739-
'FROM `*PREFIX*filecache` `file`, ' .
740-
'`*PREFIX*vcategory_to_object` `tagmap`, ' .
741-
'`*PREFIX*vcategory` `tag` ' .
742-
// JOIN filecache to vcategory_to_object
743-
'WHERE `file`.`fileid` = `tagmap`.`objid` ' .
744-
// JOIN vcategory_to_object to vcategory
745-
'AND `tagmap`.`type` = `tag`.`type` ' .
746-
'AND `tagmap`.`categoryid` = `tag`.`id` ' .
747-
// conditions
748-
'AND `file`.`storage` = ? ' .
749-
'AND `tag`.`type` = \'files\' ' .
750-
'AND `tag`.`uid` = ? ';
751-
if (is_int($tag)) {
752-
$sql .= 'AND `tag`.`id` = ? ';
753-
} else {
754-
$sql .= 'AND `tag`.`category` = ? ';
755-
}
756-
$result = $this->connection->executeQuery(
757-
$sql,
758-
[
759-
$this->getNumericStorageId(),
760-
$userId,
761-
$tag
762-
]
763-
);
764-
765-
$files = $result->fetchAll();
766-
767-
return array_map(function (array $data) {
768-
return self::cacheEntryFromData($data, $this->mimetypeLoader);
769-
}, $files);
770-
}
771-
772726
/**
773727
* Re-calculate the folder size and the size of all parent folders
774728
*

lib/private/Files/Cache/FailedCache.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ public function searchByMime($mimetype) {
115115
return [];
116116
}
117117

118-
public function searchByTag($tag, $userId) {
119-
return [];
120-
}
121-
122118
public function searchQuery(ISearchQuery $query) {
123119
return [];
124120
}

lib/private/Files/Cache/Wrapper/CacheJail.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,6 @@ public function searchQuery(ISearchQuery $query) {
247247
return $results;
248248
}
249249

250-
/**
251-
* search for files by mimetype
252-
*
253-
* @param string|int $tag name or tag id
254-
* @param string $userId owner of the tags
255-
* @return array
256-
*/
257-
public function searchByTag($tag, $userId) {
258-
$results = $this->getCache()->searchByTag($tag, $userId);
259-
return $this->formatSearchResults($results);
260-
}
261-
262250
/**
263251
* update the folder size and the size of all parent folders
264252
*

lib/private/Files/Cache/Wrapper/CacheWrapper.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,6 @@ public function searchQuery(ISearchQuery $query) {
240240
return array_map(array($this, 'formatCacheEntry'), $results);
241241
}
242242

243-
/**
244-
* search for files by tag
245-
*
246-
* @param string|int $tag name or tag id
247-
* @param string $userId owner of the tags
248-
* @return ICacheEntry[] file data
249-
*/
250-
public function searchByTag($tag, $userId) {
251-
$results = $this->getCache()->searchByTag($tag, $userId);
252-
return array_map(array($this, 'formatCacheEntry'), $results);
253-
}
254-
255243
/**
256244
* update the folder size and the size of all parent folders
257245
*

lib/private/Lockdown/Filesystem/NullCache.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ public function searchQuery(ISearchQuery $query) {
111111
return [];
112112
}
113113

114-
public function searchByTag($tag, $userId) {
115-
return [];
116-
}
117-
118114
public function getIncomplete() {
119115
return [];
120116
}

lib/public/Files/Cache/ICache.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,6 @@ public function searchByMime($mimetype);
223223
*/
224224
public function searchQuery(ISearchQuery $query);
225225

226-
/**
227-
* Search for files by tag of a given users.
228-
*
229-
* Note that every user can tag files differently.
230-
*
231-
* @param string|int $tag name or tag id
232-
* @param string $userId owner of the tags
233-
* @return ICacheEntry[] file data
234-
* @since 9.0.0
235-
* @deprecated 9.0.0 due to lack of pagination, not all backends might implement this
236-
*/
237-
public function searchByTag($tag, $userId);
238-
239226
/**
240227
* find a folder in the cache which has not been fully scanned
241228
*

tests/lib/Files/Cache/CacheTest.php

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -328,76 +328,6 @@ function testSearch() {
328328
$this->assertEquals(2, count($this->cache->searchByMime('foo/file')));
329329
}
330330

331-
function testSearchByTag() {
332-
$userId = $this->getUniqueId('user');
333-
\OC::$server->getUserManager()->createUser($userId, $userId);
334-
$this->loginAsUser($userId);
335-
$user = new \OC\User\User($userId, null, \OC::$server->getEventDispatcher());
336-
337-
$file1 = 'folder';
338-
$file2 = 'folder/foobar';
339-
$file3 = 'folder/foo';
340-
$file4 = 'folder/foo2';
341-
$file5 = 'folder/foo3';
342-
$data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder');
343-
$fileData = array();
344-
$fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file');
345-
$fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file');
346-
$fileData['foo2'] = array('size' => 25, 'mtime' => 28, 'mimetype' => 'foo/file');
347-
$fileData['foo3'] = array('size' => 88, 'mtime' => 34, 'mimetype' => 'foo/file');
348-
349-
$id1 = $this->cache->put($file1, $data1);
350-
$id2 = $this->cache->put($file2, $fileData['foobar']);
351-
$id3 = $this->cache->put($file3, $fileData['foo']);
352-
$id4 = $this->cache->put($file4, $fileData['foo2']);
353-
$id5 = $this->cache->put($file5, $fileData['foo3']);
354-
355-
$tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId);
356-
$this->assertTrue($tagManager->tagAs($id1, 'tag1'));
357-
$this->assertTrue($tagManager->tagAs($id1, 'tag2'));
358-
$this->assertTrue($tagManager->tagAs($id2, 'tag2'));
359-
$this->assertTrue($tagManager->tagAs($id3, 'tag1'));
360-
$this->assertTrue($tagManager->tagAs($id4, 'tag2'));
361-
362-
// use tag name
363-
$results = $this->cache->searchByTag('tag1', $userId);
364-
365-
$this->assertEquals(2, count($results));
366-
367-
usort($results, function ($value1, $value2) {
368-
return $value1['name'] >= $value2['name'];
369-
});
370-
371-
$this->assertEquals('folder', $results[0]['name']);
372-
$this->assertEquals('foo', $results[1]['name']);
373-
374-
// use tag id
375-
$tags = $tagManager->getTagsForUser($userId);
376-
$this->assertNotEmpty($tags);
377-
$tags = array_filter($tags, function ($tag) {
378-
return $tag->getName() === 'tag2';
379-
});
380-
$results = $this->cache->searchByTag(current($tags)->getId(), $userId);
381-
$this->assertEquals(3, count($results));
382-
383-
usort($results, function ($value1, $value2) {
384-
return $value1['name'] >= $value2['name'];
385-
});
386-
387-
$this->assertEquals('folder', $results[0]['name']);
388-
$this->assertEquals('foo2', $results[1]['name']);
389-
$this->assertEquals('foobar', $results[2]['name']);
390-
391-
$tagManager->delete('tag1');
392-
$tagManager->delete('tag2');
393-
394-
$this->logout();
395-
$user = \OC::$server->getUserManager()->get($userId);
396-
if ($user !== null) {
397-
$user->delete();
398-
}
399-
}
400-
401331
function testSearchQueryByTag() {
402332
$userId = static::getUniqueID('user');
403333
\OC::$server->getUserManager()->createUser($userId, $userId);

tests/lib/Files/Node/FolderTest.php

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -432,57 +432,6 @@ public function testSearchInStorageRoot() {
432432
$this->assertEquals('/bar/foo/qwerty', $result[0]->getPath());
433433
}
434434

435-
public function testSearchByTag() {
436-
$manager = $this->createMock(Manager::class);
437-
/**
438-
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
439-
*/
440-
$view = $this->createMock(View::class);
441-
$root = $this->getMockBuilder(Root::class)
442-
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
443-
->getMock();
444-
$root->expects($this->any())
445-
->method('getUser')
446-
->will($this->returnValue($this->user));
447-
$storage = $this->createMock(Storage::class);
448-
$storage->method('getId')->willReturn('');
449-
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
450-
451-
$mount = $this->createMock(IMountPoint::class);
452-
$mount->expects($this->once())
453-
->method('getStorage')
454-
->will($this->returnValue($storage));
455-
$mount->expects($this->once())
456-
->method('getInternalPath')
457-
->will($this->returnValue('foo'));
458-
459-
$storage->expects($this->once())
460-
->method('getCache')
461-
->will($this->returnValue($cache));
462-
463-
$cache->expects($this->once())
464-
->method('searchByTag')
465-
->with('tag1', 'user1')
466-
->will($this->returnValue(array(
467-
array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain')
468-
)));
469-
470-
$root->expects($this->once())
471-
->method('getMountsIn')
472-
->with('/bar/foo')
473-
->will($this->returnValue(array()));
474-
475-
$root->expects($this->once())
476-
->method('getMount')
477-
->with('/bar/foo')
478-
->will($this->returnValue($mount));
479-
480-
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
481-
$result = $node->searchByTag('tag1', 'user1');
482-
$this->assertEquals(1, count($result));
483-
$this->assertEquals('/bar/foo/qwerty', $result[0]->getPath());
484-
}
485-
486435
public function testSearchSubStorages() {
487436
$manager = $this->createMock(Manager::class);
488437
/**

tests/lib/Lockdown/Filesystem/NullCacheTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ public function testSearchByMime() {
139139
$this->assertSame([], $this->cache->searchByMime('foo'));
140140
}
141141

142-
public function testSearchByTag() {
143-
$this->assertSame([], $this->cache->searchByTag('foo', 'user'));
144-
}
145-
146142
public function testGetIncomplete() {
147143
$this->assertSame([], $this->cache->getIncomplete());
148144
}

0 commit comments

Comments
 (0)