Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.
Open
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
63 changes: 52 additions & 11 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
* to license@magento.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Core
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


Expand Down Expand Up @@ -466,8 +466,6 @@ public function saveCache($tags=array())
return $this;
}

$this->_saveCache(time(), $cacheLockId, array(), 60);

if (!empty($this->_cacheSections)) {
$xml = clone $this->_xml;
foreach ($this->_cacheSections as $sectionName => $level) {
Expand All @@ -476,17 +474,16 @@ public function saveCache($tags=array())
}
$this->_cachePartsForSave[$this->getCacheId()] = $xml->asNiceXml('', false);
} else {
parent::saveCache($tags);
$this->_removeCache($cacheLockId);
return $this;
return parent::saveCache($tags);
}

$this->_saveCache(time(), $cacheLockId, array(), 60);
$this->removeCache();
foreach ($this->_cachePartsForSave as $cacheId => $cacheData) {
$this->_saveCache($cacheData, $cacheId, $tags, $this->getCacheLifetime());
}
unset($this->_cachePartsForSave);
$this->_removeCache($cacheLockId);

return $this;
}

Expand Down Expand Up @@ -971,6 +968,12 @@ public function loadModulesConfiguration($fileName, $mergeToObject = null, $merg
foreach ($fileName as $configFile) {
$configFile = $this->getModuleDir('etc', $modName).DS.$configFile;
if ($mergeModel->loadFile($configFile)) {

$this->_makeEventsLowerCase(Mage_Core_Model_App_Area::AREA_GLOBAL, $mergeModel);
$this->_makeEventsLowerCase(Mage_Core_Model_App_Area::AREA_FRONTEND, $mergeModel);
$this->_makeEventsLowerCase(Mage_Core_Model_App_Area::AREA_ADMIN, $mergeModel);
$this->_makeEventsLowerCase(Mage_Core_Model_App_Area::AREA_ADMINHTML, $mergeModel);

$mergeToObject->extend($mergeModel, true);
}
}
Expand Down Expand Up @@ -1169,7 +1172,7 @@ public function loadEventObservers($area)
}

foreach ($events as $event) {
$eventName = $event->getName();
$eventName = strtolower($event->getName());
$observers = $event->observers->children();
foreach ($observers as $observer) {
switch ((string)$observer->type) {
Expand Down Expand Up @@ -1646,4 +1649,42 @@ public function getResourceModelClassName($modelClass)
}
return false;
}

/**
* Makes all events to lower-case
*
* @param string $area
* @param Mage_Core_Model_Config_Base $mergeModel
*/
protected function _makeEventsLowerCase($area, Mage_Core_Model_Config_Base $mergeModel)
{
$events = $mergeModel->getNode($area . "/" . Mage_Core_Model_App_Area::PART_EVENTS);
if ($events !== false) {
$children = clone $events->children();
/** @var Mage_Core_Model_Config_Element $event */
foreach ($children as $event) {
if ($this->_isNodeNameHasUpperCase($event)) {
$oldName = $event->getName();
$newEventName = strtolower($oldName);
if (!isset($events->$newEventName)) {
/** @var Mage_Core_Model_Config_Element $newNode */
$newNode = $events->addChild($newEventName, $event);
$newNode->extend($event);
}
unset($events->$oldName);
}
}
}
}

/**
* Checks is event name has upper-case letters
*
* @param Mage_Core_Model_Config_Element $event
* @return bool
*/
protected function _isNodeNameHasUpperCase(Mage_Core_Model_Config_Element $event)
{
return (strtolower($event->getName()) !== (string)$event->getName());
}
}