Skip to content

Commit

Permalink
Merge branch 'main' into improve-stampede-prevention
Browse files Browse the repository at this point in the history
  • Loading branch information
midlan authored Dec 19, 2023
2 parents 9123ef8 + 0e79abc commit 0cc1f80
Show file tree
Hide file tree
Showing 236 changed files with 485 additions and 7,203 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

open_collective: openmage
2 changes: 1 addition & 1 deletion .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:

- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v39
uses: tj-actions/changed-files@v40
with:
files: |
composer.*
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql-config.yml
Expand All @@ -58,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -71,6 +71,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
/app/etc/modules/Cm_RedisSession.xml
/lib/Credis

# TinyMCE library
/js/tinymce

# Add a base setup for running unit Tests with code coverage and send them to SonarCloud
# https://github.com/OpenMage/magento-lts/pull/1836
/dev/testfield
Expand Down
4 changes: 3 additions & 1 deletion app/code/core/Mage/Admin/Model/Resource/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public function loadRules(Mage_Admin_Model_Acl $acl, array $rulesArr)
$acl->deny($role, $resource, $privileges, $assert);
}
} catch (Exception $e) {
Mage::logException($e);
if (Mage::getIsDeveloperMode()) {
Mage::logException($e);
}
}
}
return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function addTab($tabId, $tab)
}

if (!($this->_tabs[$tabId] instanceof Mage_Adminhtml_Block_Widget_Tab_Interface)) {
throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration for %s %s.', $tabId, $tab));
}
} else {
throw new Exception(Mage::helper('adminhtml')->__('Wrong tab configuration.'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function _beforeSave()
$file['tmp_name'] = $tmpName[$this->getGroupId()]['fields'][$this->getField()]['value'];
$name = $_FILES['groups']['name'];
$file['name'] = $name[$this->getGroupId()]['fields'][$this->getField()]['value'];
$uploader = new Mage_Core_Model_File_Uploader($file);
$uploader = Mage::getModel('core/file_uploader', $file);
$uploader->setAllowedExtensions($this->_getAllowedExtensions());
$uploader->setAllowRenameFiles(true);
$this->addValidators($uploader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Mage_Adminhtml_Catalog_Product_GalleryController extends Mage_Adminhtml_Co
public function uploadAction()
{
try {
$uploader = new Mage_Core_Model_File_Uploader('image');
$uploader = Mage::getModel('core/file_uploader', 'image');
$uploader->setAllowedExtensions(Varien_Io_File::ALLOWED_IMAGES_EXTENSIONS);
$uploader->addValidateCallback(
'catalog_product_image',
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Catalog/Helper/Product/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ public function getConvertTable()
*/
public function format($string)
{
return strtr($string, $this->getConvertTable());
return $string === null ? '' : strtr($string, $this->getConvertTable());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function _getWebsiteRates()
protected function _getAdditionalUniqueFields($objectArray)
{
$uniqueFields = parent::_getAdditionalUniqueFields($objectArray);
$uniqueFields['qty'] = $objectArray['price_qty'] * 1;
$uniqueFields['qty'] = (float) $objectArray['price_qty'];
return $uniqueFields;
}

Expand Down
35 changes: 30 additions & 5 deletions app/code/core/Mage/Catalog/Model/Product/Type/Grouped.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Mage_Catalog_Model_Product_Type_Grouped extends Mage_Catalog_Model_Product
*
* @var string
*/
protected $_keyAssociatedProducts = '_cache_instance_associated_products';
protected $_keyAssociatedProducts = '_cache_instance_associated_products';

/**
* Cache key for Associated Product Ids
Expand All @@ -42,21 +42,46 @@ class Mage_Catalog_Model_Product_Type_Grouped extends Mage_Catalog_Model_Product
*
* @var string
*/
protected $_keyStatusFilters = '_cache_instance_status_filters';
protected $_keyStatusFilters = '_cache_instance_status_filters';

/**
* Product is composite properties
*
* @var bool
*/
protected $_isComposite = true;
protected $_isComposite = true;

/**
* Product is configurable
*
* @var bool
*/
protected $_canConfigure = true;
protected $_canConfigure = true;

/**
* Attributes used in associated products
*
* @var string|string[]
*/
protected $_attributesUsedInAssociatedProducts = '*';

/**
* @return string|string[]
*/
public function getAttributesUsedInAssociatedProducts()
{
return $this->_attributesUsedInAssociatedProducts;
}

/**
* @param string|string[] $attribute
* @return $this
*/
public function setAttributesUsedInAssociatedProducts($attribute)
{
$this->_attributesUsedInAssociatedProducts = $attribute;
return $this;
}

/**
* Return relation info about used products
Expand Down Expand Up @@ -123,7 +148,7 @@ public function getAssociatedProducts($product = null)
}

$collection = $this->getAssociatedProductCollection($product)
->addAttributeToSelect('*')
->addAttributeToSelect($this->getAttributesUsedInAssociatedProducts())
->addFilterByRequiredOptions()
->setPositionOrder()
->addStoreFilter($this->getStoreFilter($product))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ protected function _getAttributeValue($attributeId, $value, $storeId)
}
}

$value = preg_replace("#\s+#siu", ' ', trim(strip_tags($value)));
$value = $value === null ? '' : preg_replace("#\s+#siu", ' ', trim(strip_tags($value)));

return $value;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function deleteFile($target)
*/
public function uploadFile($targetPath, $type = null)
{
$uploader = new Mage_Core_Model_File_Uploader('image');
$uploader = Mage::getModel('core/file_uploader', 'image');
if ($allowed = $this->getAllowedExtensions($type)) {
$uploader->setAllowedExtensions($allowed);
}
Expand Down
3 changes: 3 additions & 0 deletions app/code/core/Mage/Core/Model/File/Validator/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public function validate($filePath)
{
list($imageWidth, $imageHeight, $fileType) = getimagesize($filePath);
if ($fileType) {
if ($fileType === IMAGETYPE_ICO) {
return null;
}
if ($this->isImageType($fileType)) {
// Config 'general/reprocess_images/active' is deprecated, replacement is the following:
$imageQuality = Mage::getStoreConfig('admin/security/reprocess_image_quality');
Expand Down
25 changes: 13 additions & 12 deletions app/code/core/Mage/Core/Model/Resource/Db/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Reso
*
* @var array
*/
protected $_connections = [];
protected $_connections = [];

/**
* Resource model name that contains entities (names of tables)
Expand All @@ -59,7 +59,7 @@ abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Reso
*
* @var array
*/
protected $_tables = [];
protected $_tables = [];

/**
* Main table name
Expand All @@ -80,21 +80,21 @@ abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Reso
*
* @var bool
*/
protected $_isPkAutoIncrement = true;
protected $_isPkAutoIncrement = true;

/**
* Use is object new method for save of object
*
* @var bool
*/
protected $_useIsObjectNew = false;
protected $_useIsObjectNew = false;

/**
* Fields List for update in forsedSave
*
* @var array
*/
protected $_fieldsForUpdate = [];
protected $_fieldsForUpdate = [];

/**
* Fields of main table
Expand All @@ -118,7 +118,7 @@ abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Reso
*
* @var array|null
*/
protected $_uniqueFields = null;
protected $_uniqueFields = null;

/**
* Serializable fields declaration
Expand All @@ -132,7 +132,7 @@ abstract class Mage_Core_Model_Resource_Db_Abstract extends Mage_Core_Model_Reso
*
* @var array
*/
protected $_serializableFields = [];
protected $_serializableFields = [];

/**
* Standard resource model initialization
Expand Down Expand Up @@ -405,8 +405,8 @@ protected function _getLoadSelect($field, $value, $object)
throw new Exception("Column \"{$field}\" does not exist in table \"{$this->getMainTable()}\"");
}

$value = $this->_getReadAdapter()->prepareColumnValue($fields[$field], $value);
$field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field));
$value = $this->_getReadAdapter()->prepareColumnValue($fields[$field], $value);
$field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field));
return $this->_getReadAdapter()->select()
->from($this->getMainTable())
->where($field . '=?', $value);
Expand Down Expand Up @@ -644,7 +644,8 @@ protected function _checkUnique(Mage_Core_Model_Abstract $object)
[
'field' => $fields,
'title' => $fields
]];
]
];
}

$data = new Varien_Object($this->_prepareDataForSave($object));
Expand All @@ -656,10 +657,10 @@ protected function _checkUnique(Mage_Core_Model_Abstract $object)

if (is_array($unique['field'])) {
foreach ($unique['field'] as $field) {
$select->where($field . '=?', trim($data->getData($field)));
$select->where($field . '=?', trim((string)$data->getData($field)));
}
} else {
$select->where($unique['field'] . '=?', trim($data->getData($unique['field'])));
$select->where($unique['field'] . '=?', trim((string)$data->getData($unique['field'])));
}

if ($object->getId() || $object->getId() === '0') {
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Model/Store/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function _loadStores()
if ($this->getDefaultStoreId() == $storeId) {
$this->_defaultStore = $store;
}
$this->_storesCount ++;
$this->_storesCount++;
}
}

Expand All @@ -145,7 +145,7 @@ public function setStores($stores)
if ($this->getDefaultStoreId() == $storeId) {
$this->_defaultStore = $store;
}
$this->_storesCount ++;
$this->_storesCount++;
}
}

Expand Down
8 changes: 4 additions & 4 deletions app/code/core/Mage/Core/Model/Website.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected function _loadGroups()
if ($this->getDefaultGroupId() == $groupId) {
$this->_defaultGroup = $group;
}
$this->_groupsCount ++;
$this->_groupsCount++;
}
}

Expand All @@ -251,7 +251,7 @@ public function setGroups($groups)
if ($this->getDefaultGroupId() == $groupId) {
$this->_defaultGroup = $group;
}
$this->_groupsCount ++;
$this->_groupsCount++;
}
return $this;
}
Expand Down Expand Up @@ -339,7 +339,7 @@ protected function _loadStores()
if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $storeId) {
$this->_defaultStore = $store;
}
$this->_storesCount ++;
$this->_storesCount++;
}
}

Expand All @@ -360,7 +360,7 @@ public function setStores($stores)
if ($this->getDefaultGroup() && $this->getDefaultGroup()->getDefaultStoreId() == $storeId) {
$this->_defaultStore = $store;
}
$this->_storesCount ++;
$this->_storesCount++;
}
}

Expand Down
18 changes: 7 additions & 11 deletions app/code/core/Mage/Dataflow/Model/Convert/Adapter/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ class Mage_Dataflow_Model_Convert_Adapter_Http extends Mage_Dataflow_Model_Conve
public function load()
{
if (!$_FILES) {
?>
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
</form>
<?php
echo '<form method="POST" enctype="multipart/form-data">';
echo 'File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>';
echo '</form>';
exit;
}
if (!empty($_FILES['io_file']['tmp_name'])) {
Expand All @@ -52,15 +50,13 @@ public function save()
public function loadFile()
{
if (!$_FILES) {
?>
<form method="POST" enctype="multipart/form-data">
File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>
</form>
<?php
echo '<form method="POST" enctype="multipart/form-data">';
echo 'File to upload: <input type="file" name="io_file"/> <input type="submit" value="Upload"/>';
echo '</form>';
exit;
}
if (!empty($_FILES['io_file']['tmp_name'])) {
$uploader = new Mage_Core_Model_File_Uploader('io_file');
$uploader = Mage::getModel('core/file_uploader', 'io_file');
$uploader->setAllowedExtensions(['csv','xml']);
$path = Mage::app()->getConfig()->getTempVarDir() . '/import/';
$uploader->save($path);
Expand Down
Loading

0 comments on commit 0cc1f80

Please sign in to comment.