diff --git a/.github/phpstan-baseline.neon b/.github/phpstan-baseline.neon index f0a8d5f1eb0..ca3592a5109 100644 --- a/.github/phpstan-baseline.neon +++ b/.github/phpstan-baseline.neon @@ -747,7 +747,7 @@ parameters: - message: "#^Call to an undefined method Varien_Data_Collection\\:\\:addFieldToFilter\\(\\)\\.$#" - count: 1 + count: 2 path: ../app/code/core/Mage/Adminhtml/Block/Widget/Grid.php - diff --git a/README.md b/README.md index 1ccfa5bf451..3f3b7c478eb 100644 --- a/README.md +++ b/README.md @@ -98,8 +98,9 @@ Most important changes will be listed here, all other changes since `19.4.0` can ### Between Magento 1.9.4.5 and OpenMage 19.x -- bug fixes and PHP 7.x and 8.0 compatibility +- bug fixes and PHP 7.x, 8.0 and 8.1 compatibility - added config cache for system.xml [#1916](https://github.com/OpenMage/magento-lts/pull/1916) +- search for "NULL" in backend grids [#1203](https://github.com/OpenMage/magento-lts/pull/1203) ### Between OpenMage 19.x and 20.x diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index ba1c753f9cb..91fd4dd23aa 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -496,7 +496,14 @@ protected function _addColumnFilterToCollection($column) } else { $cond = $column->getFilter()->getCondition(); if ($field && $cond !== null) { - $this->getCollection()->addFieldToFilter($field , $cond); + $filtered = array_map(static function ($value) { + return is_object($value) ? $value->__toString() : $value; + }, array_values($cond)); + if (in_array('\'%NULL%\'', $filtered, true) || in_array('NULL', $filtered, true)) { + $this->getCollection()->addFieldToFilter($field, ['null' => true]); + } else { + $this->getCollection()->addFieldToFilter($field, $cond); + } } } }