Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Magento 1.9.3.6 Bugfixes

This repo contains a variety of bug fixes for Magento Open Source version 1.9.3.6.
This repo contains a variety of bug fixes for Magento Open Source version 1.9.4.4.
At this moment, only version 1.9.3.6 is maintained. Some of these fixes might not work on different versions.

To prevent confilicts with rewrites on existing projects, updated core files are moved into app/code/community/Mage and changed.
Expand Down
5 changes: 2 additions & 3 deletions app/code/community/Mage/Adminhtml/Block/Widget/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -204,13 +204,11 @@ protected function _setFieldset($attributes, $fieldset, $exclude=array())
$element->setCanBeEmpty(true);
} else if ($inputType == 'date') {
$element->setImage($this->getSkinUrl('images/grid-cal.gif'));
$element->setLocale(Mage::app()->getLocale()->getLocale());
$element->setFormat(Mage::app()->getLocale()->getDateFormatWithLongYear());
} else if ($inputType == 'datetime') {
$element->setImage($this->getSkinUrl('images/grid-cal.gif'));
$element->setTime(true);
$element->setStyle('width:50%;');
$element->setLocale(Mage::app()->getLocale()->getLocale());
$element->setFormat(
Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
);
Expand Down Expand Up @@ -256,3 +254,4 @@ protected function _getAdditionalElementHtml($element)
}

}

2 changes: 1 addition & 1 deletion app/code/community/Mage/Catalog/Model/Indexer/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -618,3 +618,4 @@ public function getIdxTable($table = null)
return $this->getTable('catalog/product_price_indexer_tmp');
}
}

3 changes: 2 additions & 1 deletion app/code/community/Mage/Catalog/Model/Resource/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -1448,3 +1448,4 @@ public function deleteRewriteRecord($requestPath, $storeId, $rp = false)
$this->_getWriteAdapter()->delete($this->getMainTable(), $conditions);
}
}

82 changes: 43 additions & 39 deletions app/code/community/Mage/Catalog/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_Catalog
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -602,12 +602,29 @@ public function clearStoreInvalidRewrites($storeId = null)
*
* Will try to get unique path by adding -1 -2 etc. between url_key and optional url_suffix
*
* @deprecated use $this->getUnusedPathByUrlKey() instead
* @param int $storeId
* @param string $requestPath
* @param string $idPath
* @return string
*/
public function getUnusedPath($storeId, $requestPath, $idPath)
{
return $this->getUnusedPathByUrlKey($storeId, $requestPath, $idPath, '');
}

/**
* Get requestPath that was not used yet.
*
* Will try to get unique path by adding -1 -2 etc. between url_key and optional url_suffix
*
* @param int $storeId
* @param string $requestPath
* @param string $idPath
* @param string $urlKey
* @return string
*/
public function getUnusedPathByUrlKey($storeId, $requestPath, $idPath, $urlKey)
{
if (strpos($idPath, 'product') !== false) {
$suffix = $this->getProductUrlSuffix($storeId);
Expand Down Expand Up @@ -645,21 +662,22 @@ public function getUnusedPath($storeId, $requestPath, $idPath)
}
// match request_url abcdef1234(-12)(.html) pattern
$match = array();
$regularExpression = '#^([0-9a-z/-]+?)(-([0-9]+))?('.preg_quote($suffix).')?$#i';
$regularExpression = '#(?P<prefix>(.*/)?' . preg_quote($urlKey) . ')(-(?P<increment>[0-9]+))?(?P<suffix>'
. preg_quote($suffix) . ')?$#i';
if (!preg_match($regularExpression, $requestPath, $match)) {
return $this->getUnusedPath($storeId, '-', $idPath);
return $this->getUnusedPathByUrlKey($storeId, '-', $idPath, $urlKey);
}
$match[1] = $match[1] . '-';
$match[4] = isset($match[4]) ? $match[4] : '';
$match['prefix'] = $match['prefix'] . '-';
$match['suffix'] = isset($match['suffix']) ? $match['suffix'] : '';

$lastRequestPath = $this->getResource()
->getLastUsedRewriteRequestIncrement($match[1], $match[4], $storeId);
->getLastUsedRewriteRequestIncrement($match['prefix'], $match['suffix'], $storeId);
if ($lastRequestPath) {
$match[3] = $lastRequestPath;
$match['increment'] = $lastRequestPath;
}
return $match[1]
. (isset($match[3]) ? ($match[3]+1) : '1')
. $match[4];
return $match['prefix']
. (isset($match['increment']) ? ($match['increment'] + 1) : '1')
. $match['suffix'];
}
else {
return $requestPath;
Expand Down Expand Up @@ -699,7 +717,6 @@ public function getCategoryRequestPath($category, $parentPath)
{
$storeId = $category->getStoreId();
$idPath = $this->generatePath('id', null, $category);
$suffix = $this->getCategoryUrlSuffix($storeId);

if (isset($this->_rewrites[$idPath])) {
$this->_rewrite = $this->_rewrites[$idPath];
Expand All @@ -713,42 +730,27 @@ public function getCategoryRequestPath($category, $parentPath)
$urlKey = $this->getCategoryModel()->formatUrlKey($category->getUrlKey());
}

$categoryUrlSuffix = $this->getCategoryUrlSuffix($category->getStoreId());
$categoryUrlSuffix = $this->getCategoryUrlSuffix($storeId);
if (null === $parentPath) {
$parentPath = $this->getResource()->getCategoryParentPath($category);
}
elseif ($parentPath == '/') {
$parentPath = '';
}
$parentPath = Mage::helper('catalog/category')->getCategoryUrlPath($parentPath,
true, $category->getStoreId());
$parentPath = Mage::helper('catalog/category')->getCategoryUrlPath($parentPath, true, $storeId);

$requestPath = $parentPath . $urlKey;

if (isset($existingRequestPath) && $existingRequestPath == $requestPath . $suffix) {
$regexp = '/^' . preg_quote($requestPath, '/') . '(\-[0-9]+)?' . preg_quote($categoryUrlSuffix, '/') . '$/i';
if (isset($existingRequestPath) && preg_match($regexp, $existingRequestPath)) {
return $existingRequestPath;
}

if (isset($existingRequestPath) && $this->_checkExistingRequestPath($existingRequestPath, $category, $suffix, $requestPath)) {
return $existingRequestPath;
}

if ($this->_deleteOldTargetPath($requestPath, $idPath, $storeId)) {
$fullPath = $requestPath . $categoryUrlSuffix;
if ($this->_deleteOldTargetPath($fullPath, $idPath, $storeId)) {
return $requestPath;
}

$validatedPath = $this->getResource()->checkRequestPaths(
array($requestPath.$suffix, $requestPath.'-'.$category->getId().$suffix),
$storeId
);

if ($validatedPath) {
return $validatedPath;
}

return $this->getUnusedPath($category->getStoreId(), $requestPath,
$this->generatePath('id', null, $category)
);
return $this->getUnusedPathByUrlKey($storeId, $fullPath, $this->generatePath('id', null, $category), $urlKey);
}

/**
Expand Down Expand Up @@ -936,8 +938,8 @@ public function generatePath($type = 'target', $product = null, $category = null
$parentPath = Mage::helper('catalog/category')->getCategoryUrlPath($parentPath,
true, $category->getStoreId());

return $this->getUnusedPath($category->getStoreId(), $parentPath . $urlKey . $categoryUrlSuffix,
$this->generatePath('id', null, $category)
return $this->getUnusedPathByUrlKey($category->getStoreId(), $parentPath . $urlKey . $categoryUrlSuffix,
$this->generatePath('id', null, $category), $urlKey
);
}

Expand All @@ -958,14 +960,15 @@ public function generatePath($type = 'target', $product = null, $category = null
$this->_addCategoryUrlPath($category);
$categoryUrl = Mage::helper('catalog/category')->getCategoryUrlPath($category->getUrlPath(),
false, $category->getStoreId());
return $this->getUnusedPath($category->getStoreId(), $categoryUrl . '/' . $urlKey . $productUrlSuffix,
$this->generatePath('id', $product, $category)
return $this->getUnusedPathByUrlKey(
$category->getStoreId(), $categoryUrl . '/' . $urlKey . $productUrlSuffix,
$this->generatePath('id', $product, $category), $urlKey
);
}

// for product only
return $this->getUnusedPath($category->getStoreId(), $urlKey . $productUrlSuffix,
$this->generatePath('id', $product)
return $this->getUnusedPathByUrlKey(
$category->getStoreId(), $urlKey . $productUrlSuffix, $this->generatePath('id', $product), $urlKey
);
}

Expand Down Expand Up @@ -1011,3 +1014,4 @@ protected function _saveRewriteHistory($rewriteData, $rewrite)
return $this;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_CatalogRule
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down
3 changes: 2 additions & 1 deletion app/code/community/Mage/CatalogRule/Model/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_CatalogRule
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -311,6 +311,7 @@ protected function _getAllRules()
{
return $this->getResourceCollection()->getItems();
}

/**
* Apply all price rules, invalidate related cache and refresh price index
*
Expand Down
38 changes: 33 additions & 5 deletions app/code/community/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @category Mage
* @package Mage_Core
* @copyright Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
* @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand Down Expand Up @@ -72,9 +72,6 @@ class Mage_Core_Helper_Data extends Mage_Core_Helper_Abstract
Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
);

/** @var string $_moduleName Compatibility for translations, and maybe other stuff which uses module names. */
protected $_moduleName = 'Mage_Core';


/**
* @return Mage_Core_Model_Encryption
Expand Down Expand Up @@ -257,7 +254,7 @@ public function getRandomString($len, $chars = null)
$chars = self::CHARS_LOWERS . self::CHARS_UPPERS . self::CHARS_DIGITS;
}
for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) {
$str .= $chars[mt_rand(0, $lc)];
$str .= $chars[random_int(0, $lc)];
}
return $str;
}
Expand All @@ -273,11 +270,41 @@ public function getHash($password, $salt = false)
return $this->getEncryptor()->getHash($password, $salt);
}

/**
* Generate password hash for user
*
* @param string $password
* @param mixed $salt
* @return string
*/
public function getHashPassword($password, $salt = false)
{
$encryptionModel = $this->getEncryptor();
$latestVersionHash = $this->getVersionHash($encryptionModel);
if ($latestVersionHash == $encryptionModel::HASH_VERSION_SHA512) {
return $this->getEncryptor()->getHashPassword($password, $salt);
}
return $this->getEncryptor()->getHashPassword($password, Mage_Admin_Model_User::HASH_SALT_EMPTY);
}

public function validateHash($password, $hash)
{
return $this->getEncryptor()->validateHash($password, $hash);
}

/**
* Get encryption method depending on the presence of the function - password_hash.
*
* @param Mage_Core_Model_Encryption $encryptionModel
* @return int
*/
public function getVersionHash(Mage_Core_Model_Encryption $encryptionModel)
{
return function_exists('password_hash')
? $encryptionModel::HASH_VERSION_LATEST
: $encryptionModel::HASH_VERSION_SHA512;
}

/**
* Retrieve store identifier
*
Expand Down Expand Up @@ -936,3 +963,4 @@ public function unEscapeCSVData($data)
return $data;
}
}

Loading