Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Apr 9, 2024
2 parents adabe99 + 91b1944 commit f17443e
Show file tree
Hide file tree
Showing 63 changed files with 553 additions and 503 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 15 additions & 17 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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
Expand All @@ -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
];
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) : '';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ protected function _prepareLayout()
'after_html' => '</div>'
]);
$this->setChild('top_button', $button);
}

if ($this->getCustomerId()) {
$button = clone $button;
$button->unsId();
$this->setChild('bottom_button', $button);
}

return parent::_prepareLayout();
}

Expand Down
23 changes: 10 additions & 13 deletions app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function _getDeleteCheckbox()
$html = '';
if ((string)$this->getValue()) {
$label = Mage::helper('adminhtml')->__('Delete File');
$html .= '<div>' . $this->getValue() . ' ';
$html .= '<div>' . Mage::helper('adminhtml')->escapeHtml($this->getValue()) . ' ';
$html .= '<input type="checkbox" name="' . parent::getName() . '[delete]" value="1" class="checkbox" id="' . $this->getHtmlId() . '_delete"' . ($this->getDisabled() ? ' disabled="disabled"' : '') . '/>';
$html .= '<label for="' . $this->getHtmlId() . '_delete"' . ($this->getDisabled() ? ' class="disabled"' : '') . '> ' . $label . '</label>';
$html .= '<input type="hidden" name="' . parent::getName() . '[value]" value="' . $this->getValue() . '" />';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<tr class="system-fieldset-sub-head" id="row_%s"><td colspan="5"><h4 id="%s">%s</h4></td></tr>',
$element->getHtmlId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public function renderHeader()
if ($this->getColumn()->getDir()) {
$className = 'sort-arrow-' . $dir;
}
$out = '<a href="#" name="' . $this->getColumn()->getId() . '" title="' . $nDir
. '" class="' . $className . '"><span class="sort-title">'
$out = '<a href="#" title="' . $nDir . '" class="' . $className . '"><span class="sort-title">'
. $this->escapeHtml($this->getColumn()->getHeader()) . '</span></a>';
} else {
$out = $this->escapeHtml($this->getColumn()->getHeader());
Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/Adminhtml/Model/Config/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Api/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -323,6 +324,7 @@ protected function _parseComplexFilter($complexFilter)
*
* @param string $conditionOperator
* @param string $conditionValue
* @param-out string|array $conditionValue
*/
public function formatFilterConditionValue($conditionOperator, &$conditionValue)
{
Expand Down
19 changes: 12 additions & 7 deletions app/code/core/Mage/Api/Model/Server/Handler/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)) {
Expand Down Expand Up @@ -391,19 +393,22 @@ 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) {
throw new Mage_Api_Exception('resource_path_not_callable');
}

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)) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Block/Product/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions app/code/core/Mage/Catalog/Model/Layer/Filter/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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') {
Expand Down
8 changes: 5 additions & 3 deletions app/code/core/Mage/CatalogSearch/Block/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit f17443e

Please sign in to comment.