From d19f9cb287968c61dac10103422de3d4b13d4ccb Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 14 Oct 2020 10:20:43 +0100 Subject: [PATCH] Rephrase ratio search so that it works across databases, fixes #759 --- ext/index/main.php | 3 +-- ext/index/test.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/index/main.php b/ext/index/main.php index 50cdd235..e8b6fec5 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -171,7 +171,6 @@ class Index extends Extension } } - public function onSearchTermParse(SearchTermParseEvent $event) { if (is_null($event->term)) { @@ -196,7 +195,7 @@ class Index extends Extension } elseif (preg_match("/^ratio([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])(\d+):(\d+)$/i", $event->term, $matches)) { $cmp = preg_replace('/^:/', '=', $matches[1]); $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)) { $col = $matches[1]; $cmp = ltrim($matches[2], ":") ?: "="; diff --git a/ext/index/test.php b/ext/index/test.php index 5ffbfa9e..e1399cd1 100644 --- a/ext/index/test.php +++ b/ext/index/test.php @@ -129,6 +129,7 @@ class IndexTest extends ShimmiePHPUnitTestCase { $image_ids = $this->testUpload(); $this->assert_search_results(["hash=1234567890"], []); + $this->assert_search_results(["ratio=42:12345"], []); } /** @depends testUpload */