Skip to content

Commit

Permalink
Use ORDER BY FIELD() instead of FIND_IN_SET()
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 11, 2019
1 parent 30fd341 commit cc06c20
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions core-bundle/src/Routing/RouteProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,11 @@ private function findPages(array $candidates): array
{
$ids = [];
$aliases = [];
$set = [];

foreach ($candidates as $candidate) {
if (is_numeric($candidate)) {
$ids[] = (int) $candidate;
} else {
$set[] = $candidate;
$aliases[] = $this->database->quote($candidate);
}
}
Expand All @@ -492,8 +490,8 @@ private function findPages(array $candidates): array

$options = [];

if (!empty($set)) {
$options['order'] = sprintf('FIND_IN_SET(alias, %s)', $this->database->quote(implode(',', $set)));
if (!empty($aliases)) {
$options['order'] = sprintf('FIELD(alias, %s)', implode(',', $aliases));
}

/** @var PageModel $pageModel */
Expand Down

0 comments on commit cc06c20

Please sign in to comment.