diff --git a/assets/snippets/DocLister/core/DocLister.abstract.php b/assets/snippets/DocLister/core/DocLister.abstract.php index a8204147..5e8dd2d3 100644 --- a/assets/snippets/DocLister/core/DocLister.abstract.php +++ b/assets/snippets/DocLister/core/DocLister.abstract.php @@ -1635,7 +1635,7 @@ protected function getFilters($filter_string) { $this->debug->debug("getFilters: " . $this->debug->dumpData($filter_string), 'getFilter', 1); // the filter parameter tells us, which filters can be used in this query - $filter_string = trim($filter_string, ' ;'); + $filter_string = ltrim(trim($filter_string, ';')); if (!$filter_string) { return; } @@ -1652,7 +1652,7 @@ protected function getFilters($filter_string) /** * С правой стороны не выполняется trim, т.к. там находятся значения. А они могу быть чувствительны к пробелам */ - $subfilter = $this->getFilters(ltrim($filter) . $lastFilter); + $subfilter = $this->getFilters(ltrim($filter) . ltrim($lastFilter)); if (!$subfilter) { $lastFilter = explode(';', $filter, 2); $subfilter = isset($lastFilter[1]) ? $this->getFilters($lastFilter[1]) : ''; diff --git a/tests/DL/Filters/Issue333Test.php b/tests/DL/Filters/Issue333Test.php new file mode 100644 index 00000000..f9553607 --- /dev/null +++ b/tests/DL/Filters/Issue333Test.php @@ -0,0 +1,57 @@ +getMethod($this->DL, 'getFilters'); + $filters = $method->invoke($this->DL, 'testA:is:no'); + + $this->assertEquals(false, $filters); + } + + + public function testB() + { + $out = array( + 'join' => 'LEFT JOIN site_tmplvar_contentvalues as `dltv_testA_1` ON `dltv_testA_1`.`contentid`=`c`.`id` AND `dltv_testA_1`.`tmplvarid`=1', + 'where' => "(`dltv_testA_1`.`value` = 'no ')" + ); + + $method = $this->getMethod($this->DL, 'getFilters'); + $filters = $method->invoke($this->DL, 'AND( tv:testA:is:no )'); + + $this->assertEquals($out, $filters); + } + + public function testC() + { + $out = array( + 'join' => 'LEFT JOIN site_tmplvar_contentvalues as `dltv_testA_1` ON `dltv_testA_1`.`contentid`=`c`.`id` AND `dltv_testA_1`.`tmplvarid`=1', + 'where' => "(`dltv_testA_1`.`value` = 'no')" + ); + + $method = $this->getMethod($this->DL, 'getFilters'); + $filters = $method->invoke($this->DL, 'AND( tv:testA:is:no; )'); + + $this->assertEquals($out, $filters); + } + + public function testD() + { + $out = array( + 'join' => 'LEFT JOIN site_tmplvar_contentvalues as `dltv_testA_2` ON `dltv_testA_2`.`contentid`=`c`.`id` AND `dltv_testA_2`.`tmplvarid`=1 LEFT JOIN site_tmplvars as `d_dltv_testA_2` on `d_dltv_testA_2`.`id` = 1 LEFT JOIN site_tmplvar_contentvalues as `dltv_testB_1` ON `dltv_testB_1`.`contentid`=`c`.`id` AND `dltv_testB_1`.`tmplvarid`=2', + 'where' => "(IFNULL(`dltv_testA_2`.`value`, `d_dltv_testA_2`.`default_text`) = 'no ' AND `dltv_testB_1`.`value` = 'yes')" + ); + + $method = $this->getMethod($this->DL, 'getFilters'); + $filters = $method->invoke($this->DL, 'AND( tvd:testA:is:no ; tv:testB:is:yes; )'); + + $this->assertEquals($out, $filters); + } +}