diff --git a/.github/workflows/check-files.yml b/.github/workflows/check-files.yml index 3c99af19932..1c463234dbd 100644 --- a/.github/workflows/check-files.yml +++ b/.github/workflows/check-files.yml @@ -75,7 +75,7 @@ jobs: - name: Get changed files id: changed-files-specific - uses: tj-actions/changed-files@v42 + uses: tj-actions/changed-files@v44 with: files: | composer.* diff --git a/README.md b/README.md index 1188b21c7f7..6f223fed277 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ In a nutshell: ## Requirements -- PHP 7.4 to 8.2 +- PHP 7.4 to 8.3 - MySQL 5.7+ (8.0+ recommended) or MariaDB - optional: Redis 5.x, 6.x and 7.0.x are supported diff --git a/app/Mage.php b/app/Mage.php index 101ec4bb752..60b63294ec5 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -176,25 +176,23 @@ public static function getVersionInfo() * Gets the current OpenMage version string * @link https://openmage.github.io/supported-versions.html * @link https://semver.org/ - * - * @return string */ public static function getOpenMageVersion(): string { $info = self::getOpenMageVersionInfo(); $versionString = "{$info['major']}.{$info['minor']}.{$info['patch']}"; - if ($info['stability'] || $info['number']) { - $versionString .= '-'; - if ($info['stability'] && $info['number']) { - $versionString .= implode('.', [$info['stability'], $info['number']]); - } else { - $versionString .= implode('', [$info['stability'], $info['number']]); - } + + if ($info['stability'] && $info['number']) { + return "{$versionString}-{$info['stability']}.{$info['number']}"; + } + if ($info['stability']) { + return "{$versionString}-{$info['stability']}"; } - return trim( - $versionString, - '.-' - ); + if ($info['number']) { + return "{$versionString}-{$info['number']}"; + } + + return $versionString; } /** @@ -215,7 +213,7 @@ public static function getOpenMageVersionInfo(): array if (self::getOpenMageMajorVersion() === 20) { return [ 'major' => '20', - 'minor' => '4', + 'minor' => '6', 'patch' => '0', 'stability' => '', // beta,alpha,rc 'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9 @@ -225,7 +223,7 @@ public static function getOpenMageVersionInfo(): array return [ 'major' => '19', 'minor' => '5', - 'patch' => '2', + 'patch' => '3', 'stability' => '', // beta,alpha,rc 'number' => '', // 1,2,3,0.3.7,x.7.z.92 @see https://semver.org/#spec-item-9 ]; @@ -603,10 +601,10 @@ public static function getResourceSingleton($modelClass = '', array $arguments = } /** - * @deprecated, use self::helper() + * Retrieve block object * * @param string $type - * @return object + * @return Mage_Core_Block_Abstract|false */ public static function getBlockSingleton($type) { diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php index 5e0f8ff0a66..c650493d903 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Wishlist/Grid/Renderer/Description.php @@ -24,6 +24,6 @@ class Mage_Adminhtml_Block_Customer_Edit_Tab_Wishlist_Grid_Renderer_Description public function render(Varien_Object $row) { $value = $row->getData($this->getColumn()->getIndex()); - return is_string($value) ? nl2br(htmlspecialchars($value)) : ''; + return $value !== null ? nl2br(htmlspecialchars($value)) : ''; } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php index 042117158c3..5916951616f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Sidebar.php @@ -31,13 +31,12 @@ protected function _prepareLayout() 'after_html' => '' ]); $this->setChild('top_button', $button); - } - if ($this->getCustomerId()) { $button = clone $button; $button->unsId(); $this->setChild('bottom_button', $button); } + return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php index e0e614ff27c..a38a7d8db43 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php @@ -50,12 +50,12 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge protected $_configFields; /** - * @var Mage_Adminhtml_Block_System_Config_Form_Fieldset + * @var Mage_Adminhtml_Block_System_Config_Form_Fieldset|false */ protected $_defaultFieldsetRenderer; /** - * @var Mage_Adminhtml_Block_System_Config_Form_Field + * @var Mage_Adminhtml_Block_System_Config_Form_Field|false */ protected $_defaultFieldRenderer; @@ -147,12 +147,10 @@ public function initForm() */ protected function _initGroup($form, $group, $section, $parentElement = null) { - if ($group->frontend_model) { - $fieldsetRenderer = Mage::getBlockSingleton((string)$group->frontend_model); - } else { - $fieldsetRenderer = $this->_defaultFieldsetRenderer; - } - + /** @var Mage_Adminhtml_Block_System_Config_Form_Fieldset $fieldsetRenderer */ + $fieldsetRenderer = $group->frontend_model + ? Mage::getBlockSingleton((string)$group->frontend_model) + : $this->_defaultFieldsetRenderer; $fieldsetRenderer->setForm($this) ->setConfigData($this->_configData); @@ -276,11 +274,10 @@ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labe } $data = $this->_configDataObject->getConfigDataValue($path, $inherit, $this->_configData); - if ($element->frontend_model) { - $fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model); - } else { - $fieldRenderer = $this->_defaultFieldRenderer; - } + /** @var Mage_Adminhtml_Block_System_Config_Form_Field $fieldRenderer */ + $fieldRenderer = $element->frontend_model + ? Mage::getBlockSingleton((string)$element->frontend_model) + : $this->_defaultFieldRenderer; $fieldRenderer->setForm($this); $fieldRenderer->setConfigData($this->_configData); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/File.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/File.php index a9e440c5f73..5956fc4f137 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/File.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/File.php @@ -43,7 +43,7 @@ protected function _getDeleteCheckbox() $html = ''; if ((string)$this->getValue()) { $label = Mage::helper('adminhtml')->__('Delete File'); - $html .= '
' . $this->getValue() . ' '; + $html .= '
' . Mage::helper('adminhtml')->escapeHtml($this->getValue()) . ' '; $html .= 'getDisabled() ? ' disabled="disabled"' : '') . '/>'; $html .= ''; $html .= ''; diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Heading.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Heading.php index ff764506e9a..a482b36370e 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Heading.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Heading.php @@ -29,7 +29,6 @@ class Mage_Adminhtml_Block_System_Config_Form_Field_Heading extends Mage_Adminht */ public function render(Varien_Data_Form_Element_Abstract $element) { - $useContainerId = $element->getData('use_container_id'); return sprintf( '

%s

', $element->getHtmlId(), diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php index 3e563417748..40c2a54fd93 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php @@ -92,7 +92,7 @@ public function getValue($key, $default = '', $defaultNew = null) } $value = $this->getData($key); - return $this->escapeHtml(is_string($value) && strlen($value) > 0 ? $value : $default); + return $this->escapeHtml($value !== null && strlen($value) > 0 ? $value : $default); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php index 436131036c8..eebb7e33318 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Abstract.php @@ -124,8 +124,7 @@ public function renderHeader() if ($this->getColumn()->getDir()) { $className = 'sort-arrow-' . $dir; } - $out = '' + $out = '' . $this->escapeHtml($this->getColumn()->getHeader()) . ''; } else { $out = $this->escapeHtml($this->getColumn()->getHeader()); diff --git a/app/code/core/Mage/Adminhtml/Model/Config/Data.php b/app/code/core/Mage/Adminhtml/Model/Config/Data.php index add8890fd4c..9df3c531950 100644 --- a/app/code/core/Mage/Adminhtml/Model/Config/Data.php +++ b/app/code/core/Mage/Adminhtml/Model/Config/Data.php @@ -357,6 +357,7 @@ protected function _getPathConfig($path, $full = true) * @param string $path * @param null|bool $inherit * @param null|array $configData + * @param-out bool $inherit * @return Varien_Simplexml_Element */ public function getConfigDataValue($path, &$inherit = null, $configData = null) diff --git a/app/code/core/Mage/Api/Helper/Data.php b/app/code/core/Mage/Api/Helper/Data.php index c216a164058..4616a2e6e1e 100644 --- a/app/code/core/Mage/Api/Helper/Data.php +++ b/app/code/core/Mage/Api/Helper/Data.php @@ -223,7 +223,8 @@ public function packArrayToObject(array $arr) /** * Convert objects and arrays to array recursively * - * @param array|object $data + * @param array|object $data + * @param-out array $data */ public function toArray(&$data) { @@ -323,6 +324,7 @@ protected function _parseComplexFilter($complexFilter) * * @param string $conditionOperator * @param string $conditionValue + * @param-out string|array $conditionValue */ public function formatFilterConditionValue($conditionOperator, &$conditionValue) { diff --git a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php index 5ad0ad18ad8..a3f55d0998b 100644 --- a/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php +++ b/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php @@ -270,11 +270,14 @@ public function call($sessionId, $apiPath, $args = []) } $methodInfo = $resources->$resourceName->methods->$methodName; + $method = (isset($methodInfo->method) ? (string) $methodInfo->method : $methodName); - try { - $method = (isset($methodInfo->method) ? (string) $methodInfo->method : $methodName); + if (!isset($resources->$resourceName->model)) { + throw new Mage_Api_Exception('resource_path_not_callable'); + } - $modelName = $this->_prepareResourceModelName((string) $resources->$resourceName->model); + try { + $modelName = $this->_prepareResourceModelName((string)$resources->$resourceName->model); try { $model = Mage::getModel($modelName); if ($model instanceof Mage_Api_Model_Resource_Abstract) { @@ -285,7 +288,6 @@ public function call($sessionId, $apiPath, $args = []) } if (method_exists($model, $method)) { - $result = []; if (isset($methodInfo->arguments) && ((string)$methodInfo->arguments) == 'array') { $result = $model->$method((is_array($args) ? $args : [$args])); } elseif (!is_array($args)) { @@ -391,11 +393,15 @@ public function multiCall($sessionId, array $calls = [], $options = []) } $methodInfo = $resources->$resourceName->methods->$methodName; + $method = (isset($methodInfo->method) ? (string) $methodInfo->method : $methodName); - try { - $method = (isset($methodInfo->method) ? (string) $methodInfo->method : $methodName); + if (!isset($resources->$resourceName->model)) { + throw new Mage_Api_Exception('resource_path_not_callable'); + } + try { $modelName = $this->_prepareResourceModelName((string) $resources->$resourceName->model); + try { $model = Mage::getModel($modelName); } catch (Exception $e) { @@ -403,7 +409,6 @@ public function multiCall($sessionId, array $calls = [], $options = []) } if (method_exists($model, $method)) { - $callResult = []; if (isset($methodInfo->arguments) && ((string)$methodInfo->arguments) == 'array') { $callResult = $model->$method((is_array($args) ? $args : [$args])); } elseif (!is_array($args)) { diff --git a/app/code/core/Mage/Catalog/Block/Product/List.php b/app/code/core/Mage/Catalog/Block/Product/List.php index 0f16169fa92..8e6a05a1228 100644 --- a/app/code/core/Mage/Catalog/Block/Product/List.php +++ b/app/code/core/Mage/Catalog/Block/Product/List.php @@ -44,7 +44,7 @@ class Mage_Catalog_Block_Product_List extends Mage_Catalog_Block_Product_Abstrac /** * Product Collection * - * @var Mage_Eav_Model_Entity_Collection_Abstract|null + * @var Mage_Catalog_Model_Resource_Product_Collection|null */ protected $_productCollection; diff --git a/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php b/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php index 9f0baa9353b..5037bbb133f 100644 --- a/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php +++ b/app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php @@ -78,6 +78,10 @@ public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) return $this; } $text = $this->_getOptionText($filter); + if (!is_string($text)) { + return $this; + } + if ($filter && strlen($text)) { $this->_getResource()->applyFilterToCollection($this, $filter); $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter)); diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2.php index fece8550ae6..2a2995f27c7 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Tierprice/Api/V2.php @@ -45,7 +45,7 @@ public function prepareTierPrices($product, $tierPrices = null) } if (!isset($tierPrice->website) || $tierPrice->website == 'all') { - $tierPrice->website = 0; + $tierPrice->website = 0; // @phpstan-ignore-line } else { try { $tierPrice->website = Mage::app()->getWebsite($tierPrice->website)->getId(); @@ -59,7 +59,7 @@ public function prepareTierPrices($product, $tierPrices = null) } if (!isset($tierPrice->customer_group_id)) { - $tierPrice->customer_group_id = 'all'; + $tierPrice->customer_group_id = 'all'; // @phpstan-ignore-line } if ($tierPrice->customer_group_id == 'all') { diff --git a/app/code/core/Mage/CatalogSearch/Block/Term.php b/app/code/core/Mage/CatalogSearch/Block/Term.php index 9606a6cf0ea..10503bc18ab 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Term.php +++ b/app/code/core/Mage/CatalogSearch/Block/Term.php @@ -60,10 +60,12 @@ protected function _loadTerms() $temp[$term->getName()] = $term; $termKeys[] = $term->getName(); } - natcasesort($termKeys); - foreach ($termKeys as $termKey) { - $this->_terms[$termKey] = $temp[$termKey]; + if (isset($termKeys)) { + natcasesort($termKeys); + foreach ($termKeys as $termKey) { + $this->_terms[$termKey] = $temp[$termKey]; + } } } return $this; diff --git a/app/code/core/Mage/Contacts/controllers/IndexController.php b/app/code/core/Mage/Contacts/controllers/IndexController.php index 12f9ba6739a..42cf817ed77 100644 --- a/app/code/core/Mage/Contacts/controllers/IndexController.php +++ b/app/code/core/Mage/Contacts/controllers/IndexController.php @@ -21,10 +21,12 @@ */ class Mage_Contacts_IndexController extends Mage_Core_Controller_Front_Action { - public const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email'; - public const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity'; - public const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template'; - public const XML_PATH_ENABLED = 'contacts/contacts/enabled'; + public const XML_PATH_ENABLED = 'contacts/contacts/enabled'; + public const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity'; + public const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email'; + public const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template'; + public const XML_PATH_AUTO_REPLY_ENABLED = 'contacts/auto_reply/enabled'; + public const XML_PATH_AUTO_REPLY_EMAIL_TEMPLATE = 'contacts/auto_reply/email_template'; /** * @return $this @@ -61,23 +63,21 @@ public function postAction() $postObject = new Varien_Object(); $postObject->setData($post); + // check data $error = false; - if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) { $error = true; - } - - if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) { + } elseif (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) { $error = true; - } - - if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) { + } elseif (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) { $error = true; } if ($error) { - throw new Exception(); + Mage::throwException($this->__('Unable to submit your request. Please, try again later')); } + + // send email $mailTemplate = Mage::getModel('core/email_template'); /** @var Mage_Core_Model_Email_Template $mailTemplate */ $mailTemplate->setDesignConfig(['area' => 'frontend']) @@ -91,24 +91,36 @@ public function postAction() ); if (!$mailTemplate->getSentSuccess()) { - throw new Exception(); + Mage::throwException($this->__('Unable to submit your request. Please, try again later')); } - $translate->setTranslateInline(true); - - Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.')); - $this->_redirect('*/*/'); + // send auto reply email to customer + if (Mage::getStoreConfigFlag(self::XML_PATH_AUTO_REPLY_ENABLED)) { + $mailTemplate = Mage::getModel('core/email_template'); + /** @var Mage_Core_Model_Email_Template $mailTemplate */ + $mailTemplate->setDesignConfig(['area' => 'frontend']) + ->setReplyTo(Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT)) + ->sendTransactional( + Mage::getStoreConfig(self::XML_PATH_AUTO_REPLY_EMAIL_TEMPLATE), + Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), + $post['email'], + null, + ['data' => $postObject] + ); + } - return; - } catch (Exception $e) { $translate->setTranslateInline(true); - - Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later')); - $this->_redirect('*/*/'); - return; + Mage::getSingleton('customer/session')->addSuccess($this->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.')); + } catch (Mage_Core_Exception $e) { + $translate->setTranslateInline(true); + Mage::logException($e); + Mage::getSingleton('customer/session')->addError($e->getMessage()); + } catch (Exception $e) { + Mage::logException($e); + Mage::getSingleton('customer/session')->addError($this->__('Unable to submit your request. Please, try again later')); } - } else { - $this->_redirect('*/*/'); } + + $this->_redirect('*/*/'); } } diff --git a/app/code/core/Mage/Contacts/etc/config.xml b/app/code/core/Mage/Contacts/etc/config.xml index 951dbaa6d24..0234162fc4e 100644 --- a/app/code/core/Mage/Contacts/etc/config.xml +++ b/app/code/core/Mage/Contacts/etc/config.xml @@ -62,10 +62,14 @@ contact_form.html text + + + contact_form_auto_reply.html + html + - @@ -77,7 +81,6 @@ - diff --git a/app/code/core/Mage/Contacts/etc/system.xml b/app/code/core/Mage/Contacts/etc/system.xml index 9b0c674f17b..dfdcaffcb49 100644 --- a/app/code/core/Mage/Contacts/etc/system.xml +++ b/app/code/core/Mage/Contacts/etc/system.xml @@ -50,34 +50,62 @@ 1 1 + + + select + adminhtml/system_config_source_email_identity + 10 + 1 + 1 + 1 + validate-email required-entry - 10 + 20 1 1 1 - - + + select - adminhtml/system_config_source_email_identity - 20 + adminhtml/system_config_source_email_template + 30 1 1 1 - + + + + + + 50 + 1 + 1 + 1 + + + + Warning! Enabling this feature may cause unwanted messages to be sent to people whose email addresses are being used abusively. Please make sure that you have implemented security measures before enabling (e.g. CAPTCHA, HoneySpam).]]> + select + adminhtml/system_config_source_yesno + 91 + 1 + 1 + 1 + select adminhtml/system_config_source_email_template - 30 + 92 1 1 1 - + diff --git a/app/code/core/Mage/Core/Model/Input/Filter.php b/app/code/core/Mage/Core/Model/Input/Filter.php index afcdbe395d3..0fa3e22411b 100644 --- a/app/code/core/Mage/Core/Model/Input/Filter.php +++ b/app/code/core/Mage/Core/Model/Input/Filter.php @@ -204,6 +204,7 @@ public function filter($data) * @param array $data * @param array|null $filters * @param bool $isFilterListSimple + * @param-out array $filters * @return array * @throws Exception Exception when filter is not found or not instance of defined instances */ diff --git a/app/code/core/Mage/Core/Model/Translate/Inline.php b/app/code/core/Mage/Core/Model/Translate/Inline.php index cc9202d18fa..c1c080239f7 100644 --- a/app/code/core/Mage/Core/Model/Translate/Inline.php +++ b/app/code/core/Mage/Core/Model/Translate/Inline.php @@ -182,6 +182,7 @@ public function processAjaxPost($translate) * Strip inline translations from text * * @param array|string $body + * @param-out array|string|null $body * @return $this */ public function stripInlineTranslations(&$body) @@ -200,6 +201,7 @@ public function stripInlineTranslations(&$body) * Replace translate templates to HTML fragments * * @param array|string $body + * @param-out array|string|null $body * @return $this */ public function processResponseBody(&$body) diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php index 062c74a7efa..df89ba23189 100644 --- a/app/code/core/Mage/Customer/controllers/AccountController.php +++ b/app/code/core/Mage/Customer/controllers/AccountController.php @@ -55,7 +55,7 @@ public function preDispatch() parent::preDispatch(); if (!$this->getRequest()->isDispatched()) { - return; + return $this; } $action = strtolower($this->getRequest()->getActionName()); @@ -199,7 +199,7 @@ protected function _loginPostRedirect() $referer = $this->getRequest()->getParam(Helper::REFERER_QUERY_PARAM_NAME); if ($referer) { // Rebuild referer URL to handle the case when SID was changed - $referer = $this->_getModel('core/url') + $referer = Mage::getModel('core/url') ->getRebuiltUrl($this->_getHelper('core')->urlDecodeAndEscape($referer)); if ($this->_isUrlInternal($referer)) { $session->setBeforeAuthUrl($referer); @@ -362,7 +362,7 @@ protected function _getCustomer() { $customer = $this->_getFromRegistry('current_customer'); if (!$customer) { - $customer = $this->_getModel('customer/customer')->setId(null); + $customer = Mage::getModel('customer/customer')->setId(null); } if ($this->getRequest()->getParam('is_subscribed', false)) { $customer->setIsSubscribed(1); @@ -442,8 +442,7 @@ protected function _getCustomerErrors($customer) */ protected function _getCustomerForm($customer) { - /** @var Mage_Customer_Model_Form $customerForm */ - $customerForm = $this->_getModel('customer/form'); + $customerForm = Mage::getModel('customer/form'); $customerForm->setFormCode('customer_account_create'); $customerForm->setEntity($customer); return $customerForm; @@ -492,10 +491,8 @@ protected function _dispatchRegisterSuccess($customer) protected function _getErrorsOnCustomerAddress($customer) { $errors = []; - /** @var Mage_Customer_Model_Address $address */ - $address = $this->_getModel('customer/address'); - /** @var Mage_Customer_Model_Form $addressForm */ - $addressForm = $this->_getModel('customer/form'); + $address = Mage::getModel('customer/address'); + $addressForm = Mage::getModel('customer/form'); $addressForm->setFormCode('customer_register_address') ->setEntity($address); @@ -518,6 +515,7 @@ protected function _getErrorsOnCustomerAddress($customer) } /** + * @deprecated Use Mage::getModel() instead for PHPStan and IDE type hinting. * Get model by path * * @param string $path @@ -610,9 +608,8 @@ public function confirmAction() // load customer by id (try/catch in case if it throws exceptions) try { - /** @var Mage_Customer_Model_Customer $customer */ - $customer = $this->_getModel('customer/customer')->load($id); - if ((!$customer) || (!$customer->getId())) { + $customer = Mage::getModel('customer/customer')->load($id); + if (!$customer->getId()) { throw new Exception('Failed to load customer by id.'); } } catch (Exception $e) { @@ -656,7 +653,7 @@ public function confirmAction() */ public function confirmationAction() { - $customer = $this->_getModel('customer/customer'); + $customer = Mage::getModel('customer/customer'); if ($this->_getSession()->isLoggedIn()) { $this->_redirect('*/*/'); return; @@ -731,10 +728,7 @@ public function forgotPasswordPostAction() { $email = (string) $this->getRequest()->getPost('email'); if ($email) { - /** - * @var Mage_Customer_Model_Flowpassword $flowPassword - */ - $flowPassword = $this->_getModel('customer/flowpassword'); + $flowPassword = Mage::getModel('customer/flowpassword'); $flowPassword->setEmail($email)->save(); if (!$flowPassword->checkCustomerForgotPasswordFlowEmail($email)) { @@ -757,9 +751,7 @@ public function forgotPasswordPostAction() return; } - /** @var Mage_Customer_Model_Customer $customer */ - $customer = $this->_getModel('customer/customer'); - $customer + $customer = Mage::getModel('customer/customer') ->setWebsiteId(Mage::app()->getStore()->getWebsiteId()) ->loadByEmail($email); @@ -859,8 +851,7 @@ public function resetPasswordPostAction() if (iconv_strlen($password) <= 0) { $errorMessages[] = $this->_getHelper('customer')->__('New password field cannot be empty.'); } - /** @var Mage_Customer_Model_Customer $customer */ - $customer = $this->_getModel('customer/customer')->load($customerId); + $customer = Mage::getModel('customer/customer')->load($customerId); $customer->setPassword($password); $customer->setPasswordConfirmation($passwordConfirmation); @@ -900,19 +891,18 @@ public function resetPasswordPostAction() } /** - * @return mixed + * @return string|false */ protected function getCustomerId() { $customerId = $this->getRequest()->getQuery("id"); if (strlen($customerId) > 12) { - /** @var Mage_Customer_Model_Resource_Customer_Collection $customerCollection */ - $customerCollection = $this->_getModel('customer/customer') + $customerCollection = Mage::getModel('customer/customer') ->getCollection() ->addAttributeToSelect(['rp_customer_id']) ->addFieldToFilter('rp_customer_id', $customerId); $customerId = count($customerCollection) === 1 - ? $customerId = $customerCollection->getFirstItem()->getId() + ? $customerCollection->getFirstItem()->getId() : false; } @@ -937,8 +927,7 @@ protected function _validateResetPasswordLinkToken($customerId, $resetPasswordLi throw Mage::exception('Mage_Core', $this->_getHelper('customer')->__('Invalid password reset token.')); } - /** @var Mage_Customer_Model_Customer $customer */ - $customer = $this->_getModel('customer/customer')->load($customerId); + $customer = Mage::getModel('customer/customer')->load($customerId); if (!$customer || !$customer->getId()) { throw Mage::exception('Mage_Core', $this->_getHelper('customer')->__('Wrong customer account specified.')); } @@ -988,8 +977,7 @@ public function editPostAction() if ($this->getRequest()->isPost()) { $customer = $this->_getSession()->getCustomer(); $customer->setOldEmail($customer->getEmail()); - /** @var Mage_Customer_Model_Form $customerForm */ - $customerForm = $this->_getModel('customer/form'); + $customerForm = Mage::getModel('customer/form'); $customerForm->setFormCode('customer_account_edit') ->setEntity($customer); diff --git a/app/code/core/Mage/Dataflow/Model/Profile.php b/app/code/core/Mage/Dataflow/Model/Profile.php index 219611f8c33..bcda3ae1856 100644 --- a/app/code/core/Mage/Dataflow/Model/Profile.php +++ b/app/code/core/Mage/Dataflow/Model/Profile.php @@ -85,8 +85,9 @@ protected function _afterLoad() protected function _beforeSave() { parent::_beforeSave(); - $actionsXML = $this->getData('actions_xml') ?? ''; - if (strlen($actionsXML) < 0 && + $actionsXML = $this->getData('actions_xml'); + // @phpstan-ignore-next-line because of https://github.com/phpstan/phpstan/issues/10570 + if ($actionsXML !== null && strlen($actionsXML) < 0 && @simplexml_load_string('' . $actionsXML . '', null, LIBXML_NOERROR) === false ) { Mage::throwException(Mage::helper('dataflow')->__("Actions XML is not valid.")); diff --git a/app/code/core/Mage/Downloadable/Model/Link/Api/V2.php b/app/code/core/Mage/Downloadable/Model/Link/Api/V2.php index 5781ecdbe0d..dde76835853 100644 --- a/app/code/core/Mage/Downloadable/Model/Link/Api/V2.php +++ b/app/code/core/Mage/Downloadable/Model/Link/Api/V2.php @@ -25,6 +25,7 @@ class Mage_Downloadable_Model_Link_Api_V2 extends Mage_Downloadable_Model_Link_A * Clean the object, leave only property values * * @param object $var + * @param-out array $var */ protected function _prepareData(&$var) { diff --git a/app/code/core/Mage/Downloadable/Model/Link/Api/Validator.php b/app/code/core/Mage/Downloadable/Model/Link/Api/Validator.php index 09df3fd53a8..9e7cfae71bd 100644 --- a/app/code/core/Mage/Downloadable/Model/Link/Api/Validator.php +++ b/app/code/core/Mage/Downloadable/Model/Link/Api/Validator.php @@ -208,6 +208,7 @@ public function validateNumOfDownloads(&$var) * Validate variable, in case of fault loads default entity. * * @param int|bool $var + * @param-out int $var */ public function validateUnlimited(&$var) { diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php index ff8c566997b..e8b6c69a9fc 100644 --- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php +++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Filter.php @@ -445,7 +445,7 @@ public function getRowUrl($row) * Prepare collection by setting page number, sorting etc.. * * @param Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection - * @return Mage_Eav_Model_Resource_Entity_Attribute_Collection + * @return Mage_Core_Model_Resource_Db_Collection_Abstract|null */ public function prepareCollection(Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection) { diff --git a/app/code/core/Mage/Oauth/Model/Server.php b/app/code/core/Mage/Oauth/Model/Server.php index 618f8c5e2d7..3ca44181a77 100644 --- a/app/code/core/Mage/Oauth/Model/Server.php +++ b/app/code/core/Mage/Oauth/Model/Server.php @@ -309,7 +309,7 @@ protected function _initToken() if (self::REQUEST_TOKEN == $this->_requestType) { $this->_validateVerifierParam(); - if (!hash_equals($this->_token->getVerifier(), $this->_protocolParams['oauth_verifier'])) { + if (!hash_equals((string)$this->_token->getVerifier(), $this->_protocolParams['oauth_verifier'])) { $this->_throwException('', self::ERR_VERIFIER_INVALID); } if (!hash_equals((string)$this->_token->getConsumerId(), (string)$this->_consumer->getId())) { diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php index 6851a4c4ae1..83009a0083b 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php @@ -29,7 +29,9 @@ public function render(Varien_Data_Form_Element_Abstract $element) { $countryCode = Mage::helper('paypal')->getConfigurationCountryCode(); if ($countryCode === 'DE') { - return Mage::getBlockSingleton('paypal/adminhtml_System_config_field_hidden')->render($element); + /** @var Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden $block */ + $block = Mage::getBlockSingleton('paypal/adminhtml_System_config_field_hidden'); + return $block->render($element); } return parent::render($element); diff --git a/app/code/core/Mage/Paypal/Model/Api/Standard.php b/app/code/core/Mage/Paypal/Model/Api/Standard.php index ea5a0dd5429..a557e757e0d 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Standard.php +++ b/app/code/core/Mage/Paypal/Model/Api/Standard.php @@ -196,7 +196,7 @@ protected function _exportLineItems(array &$request, $i = 1) /** * Import address object, if set, to the request * - * @param array $request + * @param array|Varien_Object $request */ protected function _importAddress(&$request) { diff --git a/app/code/core/Mage/Sales/Model/Observer.php b/app/code/core/Mage/Sales/Model/Observer.php index e24b9986af7..9fd3f68e2df 100644 --- a/app/code/core/Mage/Sales/Model/Observer.php +++ b/app/code/core/Mage/Sales/Model/Observer.php @@ -275,8 +275,7 @@ public function prepareProductEditFormRecurringProfile($observer) $dependencies = $block ->addFieldMap('is_recurring', 'product[is_recurring]') ->addFieldMap($profileElement->getHtmlId(), $profileElement->getName()) - ->addFieldDependence($profileElement->getName(), 'product[is_recurring]', '1') - ->addConfigOptions(['levels_up' => 2]); + ->addFieldDependence($profileElement->getName(), 'product[is_recurring]', '1'); $observer->getEvent()->getResult()->output .= $dependencies->toHtml(); } diff --git a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php index 6aab8828d3c..7457514faea 100644 --- a/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/core/Mage/Sales/Model/Order/Payment/Transaction.php @@ -675,13 +675,11 @@ protected function _loadChildren() $child->setOrderPaymentObject($payment); } $this->_children[$child->getId()] = $child; - if ($this->_identifiedChildren !== false) { - $childTxnId = $child->getTxnId(); - if (!$childTxnId || $childTxnId == '0') { - $this->_identifiedChildren = false; - } else { - $this->_identifiedChildren[$child->getTxnId()] = $child; - } + $childTxnId = $child->getTxnId(); + if (!$childTxnId || $childTxnId == '0') { + $this->_identifiedChildren = false; + } else { + $this->_identifiedChildren[$child->getTxnId()] = $child; } } if ($this->_identifiedChildren === false) { diff --git a/app/code/core/Mage/Sales/etc/wsdl.xml b/app/code/core/Mage/Sales/etc/wsdl.xml index 45d31869d4e..0124534ab0e 100644 --- a/app/code/core/Mage/Sales/etc/wsdl.xml +++ b/app/code/core/Mage/Sales/etc/wsdl.xml @@ -275,6 +275,11 @@ + + + + + diff --git a/app/code/core/Mage/Sales/etc/wsi.xml b/app/code/core/Mage/Sales/etc/wsi.xml index a7b825dabc2..95a063341a8 100644 --- a/app/code/core/Mage/Sales/etc/wsi.xml +++ b/app/code/core/Mage/Sales/etc/wsi.xml @@ -276,6 +276,11 @@ + + + + + diff --git a/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php b/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php index acbf4ee5096..a0686257b2a 100644 --- a/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/core/Mage/Shipping/Model/Resource/Carrier/Tablerate.php @@ -108,24 +108,38 @@ public function getRate(Mage_Shipping_Model_Rate_Request $request) $select = $adapter->select() ->from($this->getMainTable()) ->where('website_id = :website_id') - ->order(['dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC']) + ->order(['dest_country_id DESC', 'dest_region_id DESC', 'LENGTH(dest_zip) DESC', 'dest_zip DESC', 'condition_value DESC']) ->limit(1); - // Render destination condition - $orWhere = '(' . implode(') OR (', [ + $conditions = [ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", + "dest_country_id = :country_id AND dest_region_id = '0' AND dest_zip = :postcode", + "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = :postcode", + "dest_country_id = '0' AND dest_region_id = '0' AND dest_zip = :postcode", + "dest_country_id = :country_id AND dest_region_id = '0' AND dest_zip = ''" + ]; - // Handle asterix in dest_zip field - "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'", - "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'", - "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'", - "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'", + // Handle asterix in dest_zip field + $conditions[] = "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'"; + $conditions[] = "dest_country_id = :country_id AND dest_region_id = '0' AND dest_zip = '*'"; + $conditions[] = "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'"; + $conditions[] = "dest_country_id = '0' AND dest_region_id = '0' AND dest_zip = '*'"; + + $i = 0; + $postcode = $request->getDestPostcode(); + while (strlen($postcode) > 1) { + $i++; + $postcode = substr($postcode, 0, -1); + $bind[':wildcard_postcode_' . $i] = "{$postcode}*"; + $conditions[] = "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :wildcard_postcode_{$i}"; + $conditions[] = "dest_country_id = :country_id AND dest_region_id = '0' AND dest_zip = :wildcard_postcode_{$i}"; + $conditions[] = "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = :wildcard_postcode_{$i}"; + $conditions[] = "dest_country_id = '0' AND dest_region_id = '0' AND dest_zip = :wildcard_postcode_{$i}"; + } - "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", - "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode", - "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'", - ]) . ')'; + // Render destination condition + $orWhere = '(' . implode(') OR (', $conditions) . ')'; $select->where($orWhere); // Render condition by condition name diff --git a/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml b/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml index fd4b3fde3db..21cad63b11b 100644 --- a/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml +++ b/app/design/adminhtml/default/default/template/catalog/category/edit/form.phtml @@ -198,10 +198,10 @@ grid.reloadParams = {'selected_products[]':categoryProducts.keys()}; } function categoryProductRowClick(grid, event){ - var trElement = Event.findElement(event, 'tr'); + var tdElement = Event.findElement(event, 'td'); var isInput = Event.element(event).tagName == 'INPUT'; - if(trElement){ - var checkbox = Element.getElementsBySelector(trElement, 'input'); + if(tdElement){ + var checkbox = Element.getElementsBySelector(tdElement, 'input'); if(checkbox[0]){ var checked = isInput ? checkbox[0].checked : !checkbox[0].checked; .setCheckboxChecked(checkbox[0], checked); diff --git a/app/design/adminhtml/default/default/template/widget/grid.phtml b/app/design/adminhtml/default/default/template/widget/grid.phtml index d28723ea8ca..d24045dedc3 100644 --- a/app/design/adminhtml/default/default/template/widget/grid.phtml +++ b/app/design/adminhtml/default/default/template/widget/grid.phtml @@ -114,7 +114,7 @@ $numColumns = count($this->getColumns()); getHeadersVisibility()): ?> getColumns() as $_column): ?> - getHeaderHtmlProperty() ?>>getHeaderHtml() ?> + getHeaderHtmlProperty() ?> data-column-id="getId() ?>">getHeaderHtml() ?> diff --git a/app/design/frontend/rwd/default/template/checkout/cart/minicart.phtml b/app/design/frontend/rwd/default/template/checkout/cart/minicart.phtml index 9192938a8a9..f25de8109ed 100644 --- a/app/design/frontend/rwd/default/template/checkout/cart/minicart.phtml +++ b/app/design/frontend/rwd/default/template/checkout/cart/minicart.phtml @@ -28,7 +28,7 @@ } ?> - -