function testAddAccept() { $query = $this->connection->prepare(' INSERT INTO `*PREFIX*share_external` (`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `remote_id`, `accepted`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) '); for ($i = 0; $i < 10; $i++) { $query->execute(array('remote', 'token', 'password', 'name', 'owner', 'user', 'mount point', $i, $i, 0)); } $query = $this->connection->prepare('SELECT `id` FROM `*PREFIX*share_external`'); $query->execute(); $dummyEntries = $query->fetchAll(); $this->assertSame(10, count($dummyEntries)); $m = new Migration(); $m->addAcceptRow(); // verify result $query = $this->connection->prepare('SELECT `accepted` FROM `*PREFIX*share_external`'); $query->execute(); $results = $query->fetchAll(); $this->assertSame(10, count($results)); foreach ($results as $r) { $this->assertSame(1, (int) $r['accepted']); } // cleanup $cleanup = $this->connection->prepare('DELETE FROM `*PREFIX*share_external`'); $cleanup->execute(); }
public function test1001DeepReshares() { $parent = null; for ($i = 0; $i < 1001; $i++) { $query = $this->connection->getQueryBuilder(); $query->insert($this->table)->values(['share_type' => $query->createParameter('share_type'), 'share_with' => $query->createParameter('share_with'), 'uid_owner' => $query->createParameter('uid_owner'), 'uid_initiator' => $query->createParameter('uid_initiator'), 'parent' => $query->createParameter('parent'), 'item_type' => $query->createParameter('item_type'), 'item_source' => $query->createParameter('item_source'), 'item_target' => $query->createParameter('item_target'), 'file_source' => $query->createParameter('file_source'), 'file_target' => $query->createParameter('file_target'), 'permissions' => $query->createParameter('permissions'), 'stime' => $query->createParameter('stime')])->setParameter('share_type', \OCP\Share::SHARE_TYPE_USER)->setParameter('share_with', 'user' . ($i + 1))->setParameter('uid_owner', 'user' . $i)->setParameter('uid_initiator', null)->setParameter('parent', $parent)->setParameter('item_type', 'file')->setParameter('item_source', '2')->setParameter('item_target', '/2')->setParameter('file_source', 2)->setParameter('file_target', '/foobar')->setParameter('permissions', 31)->setParameter('stime', time()); $this->assertSame(1, $query->execute()); $parent = $query->getLastInsertId(); } $this->migration->removeReShares(); $this->migration->updateInitiatorInfo(); $qb = $this->connection->getQueryBuilder(); $stmt = $qb->select('id', 'share_with', 'uid_owner', 'uid_initiator', 'parent')->from('share')->orderBy('id', 'asc')->execute(); $i = 0; while ($share = $stmt->fetch()) { $this->assertEquals('user' . ($i + 1), $share['share_with']); $this->assertEquals('user' . $i, $share['uid_initiator']); $this->assertEquals('user0', $share['uid_owner']); $this->assertEquals(null, $share['parent']); $i++; } $stmt->closeCursor(); $this->assertEquals(1001, $i); }
<?php use OCA\Files_Sharing\Migration; $installedVersion = \OC::$server->getConfig()->getAppValue('files_sharing', 'installed_version'); // Migration OC7 -> OC8 if (version_compare($installedVersion, '0.6.0', '<')) { $m = new Migration(); $m->addAcceptRow(); }
/** * @author Björn Schießle <*****@*****.**> * @author Joas Schilling <*****@*****.**> * @author Morris Jobke <*****@*****.**> * * @copyright Copyright (c) 2016, ownCloud, Inc. * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License, version 3, * along with this program. If not, see <http://www.gnu.org/licenses/> * */ use OCA\Files_Sharing\Migration; $installedVersion = \OC::$server->getConfig()->getAppValue('files_sharing', 'installed_version'); // Migration OC8.2 -> OC9 if (version_compare($installedVersion, '0.9.1', '<')) { $m = new Migration(\OC::$server->getDatabaseConnection()); $m->removeReShares(); $m->updateInitiatorInfo(); } \OC::$server->getJobList()->add('OCA\\Files_sharing\\Lib\\DeleteOrphanedSharesJob'); \OC::$server->getJobList()->add('OCA\\Files_sharing\\ExpireSharesJob');