Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/public/Util/UserSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class UserSearch {
* UserSearch constructor.
*
* @param IConfig $config
* @since 10.0.8
*/
public function __construct(IConfig $config) {
$this->config = $config;
Expand All @@ -51,6 +52,7 @@ public function __construct(IConfig $config) {
/**
* @param string $pattern
* @return bool
* @since 10.0.8
*/
public function isSearchable($pattern) {
$trimmed = trim($pattern);
Expand All @@ -61,6 +63,7 @@ public function isSearchable($pattern) {
* Get minimal allowed size to search users
*
* @return mixed
* @since 10.0.8
*/
public function getSearchMinLength() {
return $this->config->getSystemValue('user.search_min_length', 4);
Expand Down
19 changes: 9 additions & 10 deletions tests/lib/Repair/RepairOrphanedSubshareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testPopulateDBAndRemoveOrphanShares() {
//Lets create 10 entries in oc_share to share
$parentReshareCount = 1;
for($i=1; $i <= 10; $i++) {
$time = time();
$time = 1522762088 + $i * 60;
if ($i <= 5) {
$shareWithUser = $user1;
$uidOwner = 'admin';
Expand Down Expand Up @@ -185,7 +185,7 @@ public function testLargeSharesWithOrphans() {
$firstIdSet = false;
foreach ($totalUsers as $user) {
for($i=1; $i <= 100; $i++) {
$time = time();
$time = 1522762088 + $i * 60;
$userIndex = array_search($user, $totalUsers, true);
if (($userIndex+1) === count($totalUsers)) {
break;
Expand Down Expand Up @@ -247,25 +247,24 @@ public function testLargeSharesWithOrphans() {
}
}

//Now lets randomly delete 100 folders of admin to create orphan shares
//We would remove 20 id's from oc_share
$rowId = 20;
while($rowId > 0) {
//$randomRow = (string)rand(1,100);
$randomRow = (string)mt_rand($pareReshareCountRest,$pareReshareCountRest + 100);
$rowIds = [2, 4, 9, 11, 12,
22, 33, 44, 29, 46,
60, 71, 81, 88, 51,
91, 90, 65, 75, 95];
foreach($rowIds as $rowId) {
$qb = $this->connection->getQueryBuilder();
//Check if the row is there before deleting
$result = $qb->select('id')
->from('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($randomRow)))
->where($qb->expr()->eq('id', $qb->createNamedParameter($rowId+ $pareReshareCountRest)))
->execute()->fetchAll();
if (count($result) === 0) {
continue;
}
$qb->delete('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($randomRow)))
->where($qb->expr()->eq('id', $qb->createNamedParameter($rowId+ $pareReshareCountRest)))
->execute();
$rowId--;
}

//Now run the repair step and verify there are no more
Expand Down