]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove deprecated searchByTag 16456/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Thu, 18 Jul 2019 13:06:55 +0000 (15:06 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 26 Jul 2019 10:29:19 +0000 (12:29 +0200)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/files_sharing/tests/CacheTest.php
lib/private/Files/Cache/Cache.php
lib/private/Files/Cache/FailedCache.php
lib/private/Files/Cache/Wrapper/CacheJail.php
lib/private/Files/Cache/Wrapper/CacheWrapper.php
lib/private/Lockdown/Filesystem/NullCache.php
lib/public/Files/Cache/ICache.php
tests/lib/Files/Cache/CacheTest.php
tests/lib/Files/Node/FolderTest.php
tests/lib/Lockdown/Filesystem/NullCacheTest.php

index c891f56f3d3df665c53d1e3e812a3406328ed773..7bcb707a82ba2c6a5aa561959dcb0023020658f2 100644 (file)
@@ -238,96 +238,6 @@ class CacheTest extends TestCase {
                $this->verifyFiles($check, $results);
        }
 
-       /**
-        * Test searching by tag
-        */
-       function testSearchByTag() {
-               $userId = \OC::$server->getUserSession()->getUser()->getUId();
-               $id1 = $this->sharedCache->get('bar.txt')['fileid'];
-               $id2 = $this->sharedCache->get('subdir/another too.txt')['fileid'];
-               $id3 = $this->sharedCache->get('subdir/not a text file.xml')['fileid'];
-               $id4 = $this->sharedCache->get('subdir/another.txt')['fileid'];
-               $tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId);
-               $tagManager->tagAs($id1, 'tag1');
-               $tagManager->tagAs($id1, 'tag2');
-               $tagManager->tagAs($id2, 'tag1');
-               $tagManager->tagAs($id3, 'tag1');
-               $tagManager->tagAs($id4, 'tag2');
-               $results = $this->sharedStorage->getCache()->searchByTag('tag1', $userId);
-               $check = array(
-                               array(
-                                       'name' => 'bar.txt',
-                                       'path' => 'bar.txt'
-                               ),
-                               array(
-                                       'name' => 'another too.txt',
-                                       'path' => 'subdir/another too.txt'
-                               ),
-                               array(
-                                       'name' => 'not a text file.xml',
-                                       'path' => 'subdir/not a text file.xml'
-                               ),
-                       );
-               $this->verifyFiles($check, $results);
-               $tagManager->delete(array('tag1', 'tag2'));
-       }
-
-       /**
-        * Test searching by tag for multiple sections of the tree
-        */
-       function testSearchByTagTree() {
-               $userId = \OC::$server->getUserSession()->getUser()->getUId();
-               $this->sharedStorage->mkdir('subdir/emptydir');
-               $this->sharedStorage->mkdir('subdir/emptydir2');
-               $this->ownerStorage->getScanner()->scan('');
-               $allIds = array(
-                       $this->sharedCache->get('')['fileid'],
-                       $this->sharedCache->get('bar.txt')['fileid'],
-                       $this->sharedCache->get('subdir/another too.txt')['fileid'],
-                       $this->sharedCache->get('subdir/not a text file.xml')['fileid'],
-                       $this->sharedCache->get('subdir/another.txt')['fileid'],
-                       $this->sharedCache->get('subdir/emptydir')['fileid'],
-                       $this->sharedCache->get('subdir/emptydir2')['fileid'],
-               );
-               $tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId);
-               foreach ($allIds as $id) {
-                       $tagManager->tagAs($id, 'tag1');
-               }
-               $results = $this->sharedStorage->getCache()->searchByTag('tag1', $userId);
-               $check = array(
-                               array(
-                                       'name' => 'shareddir',
-                                       'path' => ''
-                               ),
-                               array(
-                                       'name' => 'bar.txt',
-                                       'path' => 'bar.txt'
-                               ),
-                               array(
-                                       'name' => 'another.txt',
-                                       'path' => 'subdir/another.txt'
-                               ),
-                               array(
-                                       'name' => 'another too.txt',
-                                       'path' => 'subdir/another too.txt'
-                               ),
-                               array(
-                                       'name' => 'emptydir',
-                                       'path' => 'subdir/emptydir'
-                               ),
-                               array(
-                                       'name' => 'emptydir2',
-                                       'path' => 'subdir/emptydir2'
-                               ),
-                               array(
-                                       'name' => 'not a text file.xml',
-                                       'path' => 'subdir/not a text file.xml'
-                               ),
-                       );
-               $this->verifyFiles($check, $results);
-               $tagManager->delete(array('tag1'));
-       }
-
        function testGetFolderContentsInRoot() {
                $results = $this->user2View->getDirectoryContent('/');
 
index 6843c3166aef204bbff465cbdb544af79ffdc7ad..6958e07be564a28967d1a8deb73bae89b10e741b 100644 (file)
@@ -723,52 +723,6 @@ class Cache implements ICache {
                return $this->searchResultToCacheEntries($result);
        }
 
-       /**
-        * Search for files by tag of a given users.
-        *
-        * Note that every user can tag files differently.
-        *
-        * @param string|int $tag name or tag id
-        * @param string $userId owner of the tags
-        * @return ICacheEntry[] file data
-        */
-       public function searchByTag($tag, $userId) {
-               $sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, ' .
-                       '`mimetype`, `mimepart`, `size`, `mtime`, `storage_mtime`, ' .
-                       '`encrypted`, `etag`, `permissions`, `checksum` ' .
-                       'FROM `*PREFIX*filecache` `file`, ' .
-                       '`*PREFIX*vcategory_to_object` `tagmap`, ' .
-                       '`*PREFIX*vcategory` `tag` ' .
-                       // JOIN filecache to vcategory_to_object
-                       'WHERE `file`.`fileid` = `tagmap`.`objid` ' .
-                       // JOIN vcategory_to_object to vcategory
-                       'AND `tagmap`.`type` = `tag`.`type` ' .
-                       'AND `tagmap`.`categoryid` = `tag`.`id` ' .
-                       // conditions
-                       'AND `file`.`storage` = ? ' .
-                       'AND `tag`.`type` = \'files\' ' .
-                       'AND `tag`.`uid` = ? ';
-               if (is_int($tag)) {
-                       $sql .= 'AND `tag`.`id` = ? ';
-               } else {
-                       $sql .= 'AND `tag`.`category` = ? ';
-               }
-               $result = $this->connection->executeQuery(
-                       $sql,
-                       [
-                               $this->getNumericStorageId(),
-                               $userId,
-                               $tag
-                       ]
-               );
-
-               $files = $result->fetchAll();
-
-               return array_map(function (array $data) {
-                       return self::cacheEntryFromData($data, $this->mimetypeLoader);
-               }, $files);
-       }
-
        /**
         * Re-calculate the folder size and the size of all parent folders
         *
index b64d66dc697783509d77151c11d6f6a8d3977a6c..8fb1623894c663a6d44f369a99d09a0f8ecefa64 100644 (file)
@@ -115,10 +115,6 @@ class FailedCache implements ICache {
                return [];
        }
 
-       public function searchByTag($tag, $userId) {
-               return [];
-       }
-
        public function searchQuery(ISearchQuery $query) {
                return [];
        }
index 7e113d1367853f33f6ec9aa6f79902fb80603a28..44402e3382afb98f402999e0d4ca2c6a06cd65aa 100644 (file)
@@ -247,18 +247,6 @@ class CacheJail extends CacheWrapper {
                return $results;
        }
 
-       /**
-        * search for files by mimetype
-        *
-        * @param string|int $tag name or tag id
-        * @param string $userId owner of the tags
-        * @return array
-        */
-       public function searchByTag($tag, $userId) {
-               $results = $this->getCache()->searchByTag($tag, $userId);
-               return $this->formatSearchResults($results);
-       }
-
        /**
         * update the folder size and the size of all parent folders
         *
index 223e678f323f8f4b8606e1548311cb8f88cd07d0..6d7f1876e29a598d1ddb2da3a13c729a7126e8e9 100644 (file)
@@ -240,18 +240,6 @@ class CacheWrapper extends Cache {
                return array_map(array($this, 'formatCacheEntry'), $results);
        }
 
-       /**
-        * search for files by tag
-        *
-        * @param string|int $tag name or tag id
-        * @param string $userId owner of the tags
-        * @return ICacheEntry[] file data
-        */
-       public function searchByTag($tag, $userId) {
-               $results = $this->getCache()->searchByTag($tag, $userId);
-               return array_map(array($this, 'formatCacheEntry'), $results);
-       }
-
        /**
         * update the folder size and the size of all parent folders
         *
index d45d1781abe7ffac9c9ec0110529d7f1e15b8a5a..6ac02abb740f2dc31ed9a1de30b4611815654742 100644 (file)
@@ -111,10 +111,6 @@ class NullCache implements ICache {
                return [];
        }
 
-       public function searchByTag($tag, $userId) {
-               return [];
-       }
-
        public function getIncomplete() {
                return [];
        }
index 3207356cb76f43011193dd9fac5a4e91d6a1ffa6..b7845ccb88e1a6d745d1b6b7f184abc90c34f2c0 100644 (file)
@@ -223,19 +223,6 @@ interface ICache {
         */
        public function searchQuery(ISearchQuery $query);
 
-       /**
-        * Search for files by tag of a given users.
-        *
-        * Note that every user can tag files differently.
-        *
-        * @param string|int $tag name or tag id
-        * @param string $userId owner of the tags
-        * @return ICacheEntry[] file data
-        * @since 9.0.0
-        * @deprecated 9.0.0 due to lack of pagination, not all backends might implement this
-        */
-       public function searchByTag($tag, $userId);
-
        /**
         * find a folder in the cache which has not been fully scanned
         *
index f94b4f5707868d92f216a21254b9ddca623c46c6..eaea1692fe23705bde5f61e9f99c3c793b46f0cb 100644 (file)
@@ -328,76 +328,6 @@ class CacheTest extends \Test\TestCase {
                $this->assertEquals(2, count($this->cache->searchByMime('foo/file')));
        }
 
-       function testSearchByTag() {
-               $userId = $this->getUniqueId('user');
-               \OC::$server->getUserManager()->createUser($userId, $userId);
-               $this->loginAsUser($userId);
-               $user = new \OC\User\User($userId, null, \OC::$server->getEventDispatcher());
-
-               $file1 = 'folder';
-               $file2 = 'folder/foobar';
-               $file3 = 'folder/foo';
-               $file4 = 'folder/foo2';
-               $file5 = 'folder/foo3';
-               $data1 = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder');
-               $fileData = array();
-               $fileData['foobar'] = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file');
-               $fileData['foo'] = array('size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file');
-               $fileData['foo2'] = array('size' => 25, 'mtime' => 28, 'mimetype' => 'foo/file');
-               $fileData['foo3'] = array('size' => 88, 'mtime' => 34, 'mimetype' => 'foo/file');
-
-               $id1 = $this->cache->put($file1, $data1);
-               $id2 = $this->cache->put($file2, $fileData['foobar']);
-               $id3 = $this->cache->put($file3, $fileData['foo']);
-               $id4 = $this->cache->put($file4, $fileData['foo2']);
-               $id5 = $this->cache->put($file5, $fileData['foo3']);
-
-               $tagManager = \OC::$server->getTagManager()->load('files', [], false, $userId);
-               $this->assertTrue($tagManager->tagAs($id1, 'tag1'));
-               $this->assertTrue($tagManager->tagAs($id1, 'tag2'));
-               $this->assertTrue($tagManager->tagAs($id2, 'tag2'));
-               $this->assertTrue($tagManager->tagAs($id3, 'tag1'));
-               $this->assertTrue($tagManager->tagAs($id4, 'tag2'));
-
-               // use tag name
-               $results = $this->cache->searchByTag('tag1', $userId);
-
-               $this->assertEquals(2, count($results));
-
-               usort($results, function ($value1, $value2) {
-                       return $value1['name'] >= $value2['name'];
-               });
-
-               $this->assertEquals('folder', $results[0]['name']);
-               $this->assertEquals('foo', $results[1]['name']);
-
-               // use tag id
-               $tags = $tagManager->getTagsForUser($userId);
-               $this->assertNotEmpty($tags);
-               $tags = array_filter($tags, function ($tag) {
-                       return $tag->getName() === 'tag2';
-               });
-               $results = $this->cache->searchByTag(current($tags)->getId(), $userId);
-               $this->assertEquals(3, count($results));
-
-               usort($results, function ($value1, $value2) {
-                       return $value1['name'] >= $value2['name'];
-               });
-
-               $this->assertEquals('folder', $results[0]['name']);
-               $this->assertEquals('foo2', $results[1]['name']);
-               $this->assertEquals('foobar', $results[2]['name']);
-
-               $tagManager->delete('tag1');
-               $tagManager->delete('tag2');
-
-               $this->logout();
-               $user = \OC::$server->getUserManager()->get($userId);
-               if ($user !== null) {
-                       $user->delete();
-               }
-       }
-
        function testSearchQueryByTag() {
                $userId = static::getUniqueID('user');
                \OC::$server->getUserManager()->createUser($userId, $userId);
index e1ee96c37ecc8ed7bec983613e8583ae39c5ddcc..daac67cae237d3baf52fbe61b4f9555ee4a1ccdd 100644 (file)
@@ -432,57 +432,6 @@ class FolderTest extends NodeTest {
                $this->assertEquals('/bar/foo/qwerty', $result[0]->getPath());
        }
 
-       public function testSearchByTag() {
-               $manager = $this->createMock(Manager::class);
-               /**
-                * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
-                */
-               $view = $this->createMock(View::class);
-               $root = $this->getMockBuilder(Root::class)
-                       ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
-                       ->getMock();
-               $root->expects($this->any())
-                       ->method('getUser')
-                       ->will($this->returnValue($this->user));
-               $storage = $this->createMock(Storage::class);
-               $storage->method('getId')->willReturn('');
-               $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
-
-               $mount = $this->createMock(IMountPoint::class);
-               $mount->expects($this->once())
-                       ->method('getStorage')
-                       ->will($this->returnValue($storage));
-               $mount->expects($this->once())
-                       ->method('getInternalPath')
-                       ->will($this->returnValue('foo'));
-
-               $storage->expects($this->once())
-                       ->method('getCache')
-                       ->will($this->returnValue($cache));
-
-               $cache->expects($this->once())
-                       ->method('searchByTag')
-                       ->with('tag1', 'user1')
-                       ->will($this->returnValue(array(
-                               array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain')
-                       )));
-
-               $root->expects($this->once())
-                       ->method('getMountsIn')
-                       ->with('/bar/foo')
-                       ->will($this->returnValue(array()));
-
-               $root->expects($this->once())
-                       ->method('getMount')
-                       ->with('/bar/foo')
-                       ->will($this->returnValue($mount));
-
-               $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
-               $result = $node->searchByTag('tag1', 'user1');
-               $this->assertEquals(1, count($result));
-               $this->assertEquals('/bar/foo/qwerty', $result[0]->getPath());
-       }
-
        public function testSearchSubStorages() {
                $manager = $this->createMock(Manager::class);
                /**
index 3a4e3f3a40238881aae02d0ca516885e2af7362f..7773241fca17c0200661c35865cd447b877afd9e 100644 (file)
@@ -139,10 +139,6 @@ class NulLCacheTest extends \Test\TestCase {
                $this->assertSame([], $this->cache->searchByMime('foo'));
        }
 
-       public function testSearchByTag() {
-               $this->assertSame([], $this->cache->searchByTag('foo', 'user'));
-       }
-
        public function testGetIncomplete() {
                $this->assertSame([], $this->cache->getIncomplete());
        }