diff --git a/lib/private/DB/AdapterOCI8.php b/lib/private/DB/AdapterOCI8.php index 4660584e5fe7..e2ea8872805f 100644 --- a/lib/private/DB/AdapterOCI8.php +++ b/lib/private/DB/AdapterOCI8.php @@ -40,7 +40,7 @@ public function lastInsertId($table) { public function fixupStatement($statement) { $statement = \preg_replace('( LIKE \?)', '$0 ESCAPE \'\\\'', $statement); - $statement = \preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement); + $statement = \preg_replace('/`(\w+)` ILIKE \?/', "LOWER(`$1`) LIKE LOWER(?) ESCAPE '\\' -- \\'' \n", $statement); // FIXME workaround for singletick matching with regexes in SQLParserUtils::getUnquotedStatementFragments $statement = \str_replace('`', '"', $statement); $statement = \str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement); $statement = \str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement); diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php index 05f8926040c4..f210a5658d5a 100644 --- a/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php +++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/OCIExpressionBuilder.php @@ -157,7 +157,7 @@ public function castColumn($column, $type) { public function iLike($x, $y, $type = null) { $x = $this->helper->quoteColumnName($x); $y = $this->helper->quoteColumnName($y); - return new QueryFunction('REGEXP_LIKE('.$x.', \'^\' || REPLACE('.$y.', \'%\', \'.*\') || \'$\', \'i\')'); + return new QueryFunction("LOWER($x) LIKE LOWER($y) ESCAPE '\\' -- \\'' \n"); // FIXME workaround for singletick matching with regexes in SQLParserUtils::getUnquotedStatementFragments } /** diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index 1cf5cd5eb0a6..8c280e849b23 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -292,29 +292,35 @@ function testSearch() { $file1 = 'folder'; $file2 = 'folder/foobar'; $file3 = 'folder/foo'; + $file4 = 'folder/f[o.o%ba-r'; $data1 = ['size' => 100, 'mtime' => 50, 'mimetype' => 'foo/folder']; $fileData = []; $fileData['foobar'] = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file']; $fileData['foo'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; + $fileData['f[o.o%ba-r'] = ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file']; $this->cache->put($file1, $data1); $this->cache->put($file2, $fileData['foobar']); $this->cache->put($file3, $fileData['foo']); + $this->cache->put($file4, $fileData['f[o.o%ba-r']); - $this->assertCount(2, $this->cache->search('%foo%')); - $this->assertCount(1, $this->cache->search('foo')); - $this->assertCount(1, $this->cache->search('%folder%')); - $this->assertCount(1, $this->cache->search('folder%')); - $this->assertCount(3, $this->cache->search('%')); + $this->assertCount(2, $this->cache->search('%foo%'), "expected 2 when searching for '%foo%'"); + $this->assertCount(1, $this->cache->search('foo'), "expected 1 when searching for 'foo'"); + $this->assertCount(1, $this->cache->search('%folder%'), "expected 1 when searching for '%folder%'"); + $this->assertCount(1, $this->cache->search('folder%'), "expected 1 when searching for 'folder%'"); + $this->assertCount(4, $this->cache->search('%'), "expected 4 when searching for '%'"); // case insensitive search should match the same files - $this->assertCount(2, $this->cache->search('%Foo%')); - $this->assertCount(1, $this->cache->search('Foo')); - $this->assertCount(1, $this->cache->search('%Folder%')); - $this->assertCount(1, $this->cache->search('Folder%')); + $this->assertCount(2, $this->cache->search('%Foo%'), "expected 2 when searching for '%Foo%'"); + $this->assertCount(1, $this->cache->search('Foo'), "expected 1 when searching for 'Foo'"); + $this->assertCount(1, $this->cache->search('%Folder%'), "expected 1 when searching for '%Folder%'"); + $this->assertCount(1, $this->cache->search('Folder%'), "expected 1 when searching for 'Folder%'"); - $this->assertCount(3, $this->cache->searchByMime('foo')); - $this->assertCount(2, $this->cache->searchByMime('foo/file')); + $this->assertCount(4, $this->cache->searchByMime('foo'), "expected 4 when searching for mime 'foo'"); + $this->assertCount(3, $this->cache->searchByMime('foo/file'), "expected 3 when searching for mime 'foo/file'"); + + // oracle uses regexp, + $this->assertCount(1, $this->cache->search('f[o.o%ba-r'), "expected 1 when searching for 'f[o.o%ba-r'"); } function testSearchByTag() {