From 998e306270784e68681263e5aabd8478e6d381db Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Tue, 25 Apr 2023 12:12:14 -0400 Subject: [PATCH 1/7] Fixed unsupported operand types: string - string in app/code/core/Mage/Core/Controller/Varien/Action.php (#3217) Co-authored-by: Ng Kiat Siong --- app/code/core/Mage/Core/Controller/Varien/Action.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php index e5a7629c935..464a75dbc57 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Action.php +++ b/app/code/core/Mage/Core/Controller/Varien/Action.php @@ -994,7 +994,7 @@ protected function _filterDates($array, $dateFields) ]); foreach ($dateFields as $dateField) { - if (array_key_exists($dateField, $array) && !empty($dateField)) { + if ($dateField && !empty($array[$dateField])) { $array[$dateField] = $filterInput->filter($array[$dateField]); $array[$dateField] = $filterInternal->filter($array[$dateField]); } From cb6791b7a114ffa8073f3269ab4ac0d722960a9c Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Wed, 26 Apr 2023 20:46:00 +0100 Subject: [PATCH 2/7] Removed PHPStan stubs (#3210) --- app/code/core/Mage/Captcha/Model/Zend.php | 4 ++-- .../System/Config/Source/Inputtype/Validator.php | 4 ++-- dev/phpstan/stubs/Zend_Captcha_Word.stub | 11 ----------- dev/phpstan/stubs/Zend_Validate_InArray.stub | 9 --------- phpstan.dist.neon | 3 --- 5 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 dev/phpstan/stubs/Zend_Captcha_Word.stub delete mode 100644 dev/phpstan/stubs/Zend_Validate_InArray.stub diff --git a/app/code/core/Mage/Captcha/Model/Zend.php b/app/code/core/Mage/Captcha/Model/Zend.php index 1da978abf2d..c7142e783a6 100644 --- a/app/code/core/Mage/Captcha/Model/Zend.php +++ b/app/code/core/Mage/Captcha/Model/Zend.php @@ -64,7 +64,7 @@ class Mage_Captcha_Model_Zend extends Zend_Captcha_Image implements Mage_Captcha /** * Generated word * - * @var string|null + * @var string */ protected $_word; @@ -483,7 +483,7 @@ protected function _setWord($word) protected function _clearWord() { $this->getSession()->unsetData($this->_getFormIdKey(self::SESSION_WORD)); - $this->_word = null; + $this->_word = ''; return $this; } diff --git a/app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php b/app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php index 842d962c88c..55f5257bf79 100644 --- a/app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php +++ b/app/code/core/Mage/Eav/Model/Adminhtml/System/Config/Source/Inputtype/Validator.php @@ -22,7 +22,7 @@ class Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator extends Zend_Validate_InArray { /** - * @var array|null + * @inheritdoc */ protected $_messageTemplates; @@ -34,7 +34,7 @@ public function __construct() $haystack = $helper->getInputTypesValidatorData(); //reset message template and set custom - $this->_messageTemplates = null; + $this->_messageTemplates = []; $this->_initMessageTemplates(); //parent construct with options diff --git a/dev/phpstan/stubs/Zend_Captcha_Word.stub b/dev/phpstan/stubs/Zend_Captcha_Word.stub deleted file mode 100644 index b1b60b63f70..00000000000 --- a/dev/phpstan/stubs/Zend_Captcha_Word.stub +++ /dev/null @@ -1,11 +0,0 @@ -|null - */ - protected $_messageTemplates; -} diff --git a/phpstan.dist.neon b/phpstan.dist.neon index 5bb1048fdfd..eb99f86b075 100644 --- a/phpstan.dist.neon +++ b/phpstan.dist.neon @@ -71,9 +71,6 @@ parameters: # Instantiated class not found - lib/Varien/Image/Adapter.php - stubFiles: - - dev/phpstan/stubs/Zend_Captcha_Word.stub - - dev/phpstan/stubs/Zend_Validate_InArray.stub level: 4 checkFunctionNameCase: true checkInternalClassCaseSensitivity: true From 2730ef7e24c0baa1339fd6cc53723980c2099dfe Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Wed, 26 Apr 2023 21:01:22 +0100 Subject: [PATCH 3/7] Converted msrp_rwd.js to vanilla javascript (#3214) --- skin/frontend/rwd/default/js/msrp_rwd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skin/frontend/rwd/default/js/msrp_rwd.js b/skin/frontend/rwd/default/js/msrp_rwd.js index fcaf20f9cc2..eaabb64c495 100644 --- a/skin/frontend/rwd/default/js/msrp_rwd.js +++ b/skin/frontend/rwd/default/js/msrp_rwd.js @@ -12,8 +12,8 @@ */ Catalog.Map.showHelp = Catalog.Map.showHelp.wrap(function (parent, event) { - var helpBox = $('map-popup'); - var bodyNode = $$('body')[0]; + var helpBox = document.getElementById('map-popup'); + var bodyNode = document.getElementsByTagName('body')[0]; // Resolve calculation bug in parent so we can actually use these classes... if (helpBox && this != Catalog.Map && Catalog.Map.active != this.link) { From 7dd1c419c453b5da925dc834d02d048320ea1dd5 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 27 Apr 2023 15:54:15 +0100 Subject: [PATCH 4/7] Composer autoloader patch was added to app/Mage.php (#3216) Co-authored-by: Colin Mollenhour --- app/Mage.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Mage.php b/app/Mage.php index 1570ce0b1fa..8a019d43a7a 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -42,6 +42,12 @@ Varien_Autoload::register(); +/** AUTOLOADER PATCH **/ +if (file_exists($autoloaderPath = (getenv('COMPOSER_VENDOR_PATH') ?: BP . DS . 'vendor') . DS . 'autoload.php')) { + require $autoloaderPath; +} +/** AUTOLOADER PATCH **/ + /* Support additional includes, such as composer's vendor/autoload.php files */ foreach (glob(BP . DS . 'app' . DS . 'etc' . DS . 'includes' . DS . '*.php') as $path) { include_once $path; From f4855d44c3ec53f7bd3710a521b834a916b01f96 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 28 Apr 2023 10:30:46 +0100 Subject: [PATCH 5/7] Fixed deprecation warning on Mage_Catalog_Helper_Image (#3201) --- app/code/core/Mage/Catalog/Helper/Image.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/core/Mage/Catalog/Helper/Image.php b/app/code/core/Mage/Catalog/Helper/Image.php index fdc415257e2..abe8cbdb96d 100644 --- a/app/code/core/Mage/Catalog/Helper/Image.php +++ b/app/code/core/Mage/Catalog/Helper/Image.php @@ -564,6 +564,10 @@ protected function getImageFile() */ protected function parseSize($string) { + if ($string === null) { + return false; + } + $size = explode('x', strtolower($string)); if (count($size) === 2) { return [ @@ -571,6 +575,7 @@ protected function parseSize($string) 'heigth' => ($size[1] > 0) ? $size[1] : null, ]; } + return false; } From 7664a3532d3b3be3aebccd41b2506a1e1298ac2e Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 28 Apr 2023 11:12:44 +0100 Subject: [PATCH 6/7] Fixed logging too many exceptions for payment methods (#3181) --- app/code/core/Mage/Payment/Helper/Data.php | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/app/code/core/Mage/Payment/Helper/Data.php b/app/code/core/Mage/Payment/Helper/Data.php index d05dd380f52..5f6f6da6570 100644 --- a/app/code/core/Mage/Payment/Helper/Data.php +++ b/app/code/core/Mage/Payment/Helper/Data.php @@ -26,6 +26,18 @@ class Mage_Payment_Helper_Data extends Mage_Core_Helper_Abstract protected $_moduleName = 'Mage_Payment'; + /** + * Retrieve the class name of the payment method's model + * + * @param $code + * @return string|null + */ + public function getMethodModelClassName($code) + { + $key = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/model'; + return Mage::getStoreConfig($key); + } + /** * Retrieve method model object * @@ -34,8 +46,7 @@ class Mage_Payment_Helper_Data extends Mage_Core_Helper_Abstract */ public function getMethodInstance($code) { - $key = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/model'; - $class = Mage::getStoreConfig($key); + $class = $this->getMethodModelClassName($code); if (is_null($class)) { Mage::logException(new Exception(sprintf('Unknown payment method with code "%s"', $code))); return false; @@ -156,7 +167,13 @@ public function getRecurringProfileMethods($store = null) { $result = []; foreach ($this->getPaymentMethods($store) as $code => $data) { - $method = $this->getMethodInstance($code); + $paymentMethodModelClassName = $this->getMethodModelClassName($code); + if (!$paymentMethodModelClassName) { + continue; + } + + /** @var Mage_Payment_Model_Method_Abstract $method */ + $method = Mage::getModel($paymentMethodModelClassName); if ($method && $method->canManageRecurringProfiles()) { $result[] = $method; } @@ -207,8 +224,9 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit if ((isset($data['title']))) { $methods[$code] = $data['title']; } else { - if ($this->getMethodInstance($code)) { - $methods[$code] = $this->getMethodInstance($code)->getConfigData('title', $store); + $paymentMethodModelClassName = $this->getMethodModelClassName($code); + if ($paymentMethodModelClassName) { + $methods[$code] = Mage::getModel($paymentMethodModelClassName)->getConfigData('title', $store); } } if ($asLabelValue && $withGroups && isset($data['group'])) { From cefa50327a3c076138d70db0effa3f1a917fee6f Mon Sep 17 00:00:00 2001 From: Colin Mollenhour Date: Fri, 28 Apr 2023 17:45:35 -0400 Subject: [PATCH 7/7] Update default XDEBUG_CONFIG to work with PHP 8 and XDebug 3. --- dev/openmage/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/openmage/docker-compose.yml b/dev/openmage/docker-compose.yml index f12b1a44e7c..1ae91aaa292 100644 --- a/dev/openmage/docker-compose.yml +++ b/dev/openmage/docker-compose.yml @@ -10,7 +10,7 @@ services: - ../..:/var/www/html environment: - ENABLE_SENDMAIL=${ENABLE_SENDMAIL:-true} - - XDEBUG_CONFIG=${XDEBUG_CONFIG:-remote_connect_back=1 remote_enable=1 idekey=phpstorm} + - XDEBUG_CONFIG=${XDEBUG_CONFIG:-client_host=host.docker.internal mode=debug force_display_errors=1 start_with_request=yes} - MAGE_IS_DEVELOPER_MODE=${MAGE_IS_DEVELOPER_MODE:-1} links: - mysql