diff --git a/ChangeLog b/ChangeLog index 89028b6d03..a30c3a927b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,7 @@ phpMyAdmin - ChangeLog - issue #18578 Fixed PDF export NULL values gives a type error - issue #18650 Fixed double escaping on foreign key relation link title - issue #18533 Fixed wrong count for simulated queries +- issue #18611 Fixed an error when searching a table without conditions 5.2.1 (2023-02-07) - issue #17522 Fix case where the routes cache file is invalid diff --git a/libraries/classes/Table/Search.php b/libraries/classes/Table/Search.php index 042509e9cc..37d258feb5 100644 --- a/libraries/classes/Table/Search.php +++ b/libraries/classes/Table/Search.php @@ -90,9 +90,12 @@ final class Search // If there are no search criteria set or no unary criteria operators, // return if ( - ! isset($_POST['criteriaValues']) - && ! isset($_POST['criteriaColumnOperators']) - && ! isset($_POST['geom_func']) + ! isset($_POST['criteriaColumnOperators']) + || ( + ! isset($_POST['criteriaValues']) + && ! isset($_POST['criteriaColumnOperators']) + && ! isset($_POST['geom_func']) + ) ) { return ''; } diff --git a/test/classes/Table/SearchTest.php b/test/classes/Table/SearchTest.php index 867c28b10e..faee63a0ec 100644 --- a/test/classes/Table/SearchTest.php +++ b/test/classes/Table/SearchTest.php @@ -238,4 +238,21 @@ class SearchTest extends AbstractTestCase $this->search->buildSqlQuery() ); } + + public function testBuildSqlQueryWithoutConditions(): void + { + $_POST['db'] = 'opengis'; + $_POST['table'] = 'world_cities'; + $_POST['back'] = 'index.php?route=/table/search'; + $_POST['geom_func'] = [2 => ' ']; + $_POST['customWhereClause'] = ''; + $_POST['session_max_rows'] = '25'; + $_POST['orderByColumn'] = '--nil--'; + $_POST['order'] = 'ASC'; + $_POST['submit'] = 'Go'; + $_POST['ajax_request'] = 'true'; + $_POST['displayAllColumns'] = 'true'; + + $this->assertSame('SELECT * FROM `world_cities`', $this->search->buildSqlQuery()); + } }