Rephrase ratio search so that it works across databases, fixes #759
This commit is contained in:
parent
6d074cfef8
commit
d19f9cb287
2 changed files with 2 additions and 2 deletions
|
@ -171,7 +171,6 @@ class Index extends Extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||||
{
|
{
|
||||||
if (is_null($event->term)) {
|
if (is_null($event->term)) {
|
||||||
|
@ -196,7 +195,7 @@ class Index extends Extension
|
||||||
} elseif (preg_match("/^ratio([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+):(\d+)$/i", $event->term, $matches)) {
|
} elseif (preg_match("/^ratio([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+):(\d+)$/i", $event->term, $matches)) {
|
||||||
$cmp = preg_replace('/^:/', '=', $matches[1]);
|
$cmp = preg_replace('/^:/', '=', $matches[1]);
|
||||||
$args = ["width{$this->stpen}"=>int_escape($matches[2]), "height{$this->stpen}"=>int_escape($matches[3])];
|
$args = ["width{$this->stpen}"=>int_escape($matches[2]), "height{$this->stpen}"=>int_escape($matches[3])];
|
||||||
$event->add_querylet(new Querylet("width / height $cmp :width{$this->stpen} / :height{$this->stpen}", $args));
|
$event->add_querylet(new Querylet("width / :width{$this->stpen} $cmp height / :height{$this->stpen}", $args));
|
||||||
} elseif (preg_match("/^(filesize|id)([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+[kmg]?b?)$/i", $event->term, $matches)) {
|
} elseif (preg_match("/^(filesize|id)([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+[kmg]?b?)$/i", $event->term, $matches)) {
|
||||||
$col = $matches[1];
|
$col = $matches[1];
|
||||||
$cmp = ltrim($matches[2], ":") ?: "=";
|
$cmp = ltrim($matches[2], ":") ?: "=";
|
||||||
|
|
|
@ -129,6 +129,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
||||||
{
|
{
|
||||||
$image_ids = $this->testUpload();
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["hash=1234567890"], []);
|
$this->assert_search_results(["hash=1234567890"], []);
|
||||||
|
$this->assert_search_results(["ratio=42:12345"], []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
|
|
Reference in a new issue