Skip to content

Commit

Permalink
cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 committed Dec 10, 2024
1 parent 3b657f4 commit 55b4fcc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Helper/GridHelperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,6 @@ public function prepareListingForGrid(array $requestParams, string $requestedLan
$conditionFilters[] = $this->getPermittedPathsByUser('object', $adminUser);
}


$featureJoins = [];
$slugJoins = [];
$featureAndSlugFilters = [];
Expand Down Expand Up @@ -924,9 +923,11 @@ public function createXlsxExportFile(FilesystemOperator $storage, string $fileHa
return $response;
}

/**
* A more performant alternative to "CONCAT(`path`,`key`) LIKE $fullpath"
*/
private function optimizedConcatLike(string $fullpath): string
{
//CONCAT(`path`,`key`) LIKE '" . $fullpath . "%'
$pathParts = explode('/', $fullpath);
$leaf = array_pop($pathParts);
$path = implode('/', $pathParts);
Expand All @@ -938,9 +939,12 @@ private function optimizedConcatLike(string $fullpath): string
)';
}

/**
* A more performant alternative to "CONCAT(`path`,`key`) NOT LIKE $fullpath"
* Set $onlyChildren to true when you want to exclude the folder/element itself
*/
private function optimizedConcatNotLike(string $fullpath, bool $onlyChildren = false): string
{
//CONCAT(`path`,`key`) NOT LIKE '" . $fullpath . "%'
$pathParts = explode('/', $fullpath);
$leaf = array_pop($pathParts);
$path = implode('/', $pathParts);
Expand Down Expand Up @@ -982,7 +986,8 @@ protected function getPermittedPathsByUser(string $type, User $user): string
$exceptionsConcat.= $this->optimizedConcatLike($path);
}
$exceptions = " OR (" . $exceptionsConcat . ")";
$onlyChildren = true; //if allowed children are found, the current folder can be listed but its content is still blocked, can easily done by adding a trailing slash
//if any allowed child is found, the current folder can be listed but its content is still blocked
$onlyChildren = true;
}
$forbiddenPathSql[] = $this->optimizedConcatNotLike($forbiddenPath, $onlyChildren) . $exceptions;
}
Expand All @@ -1008,7 +1013,7 @@ protected function getPermittedPathsByUser(string $type, User $user): string

$forbiddenAndAllowedSql.= ' )';

$allowedTypes[] = $forbiddenAndAllowedSql;
$allowedTypes[] = $forbiddenAndAllowedSql;
}

//if allowedTypes is still empty after getting the workspaces, it means that there are no any main permissions set
Expand Down

0 comments on commit 55b4fcc

Please sign in to comment.