Skip to content

Commit 8772d0a

Browse files
committed
Search only constructs a db query for alias names if it knows there is one
1 parent bf2d74f commit 8772d0a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/AppBundle/Controller/SearchController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ public function displayAction(
434434
$conditions = $capsConditions;
435435
}
436436
// If there are still no results, try again but with aliases
437-
else {
438-
$cardsData->unaliasCardNames($conditions);
437+
else if ($cardsData->unaliasCardNames($conditions)) {
439438
$rows = $cardsData->get_search_rows($conditions, $sort, $locale);
440439
}
441440
}

src/AppBundle/Service/CardsData.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,12 +971,14 @@ public function unaliasCardNames(array &$conditions)
971971

972972
// Check the conditions are non-empty
973973
if (!$title)
974-
return;
974+
return false;
975975

976976
// If they are the substring of an alias for a card, replace the conditions with that card's name
977977
if ($match = current(preg_grep("/^$title/", array_keys($this->cardAliases)))) {
978978
$conditions = [["_", ":", $this->cardAliases[$match]]];
979+
return true;
979980
}
981+
return false;
980982
}
981983

982984
public function buildQueryFromConditions(array $conditions)

0 commit comments

Comments
 (0)