diff --git a/Config.php b/Config.php index 02c04b5..1f02c33 100644 --- a/Config.php +++ b/Config.php @@ -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) */ @@ -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) { @@ -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; } @@ -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); } } @@ -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) { @@ -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()); + } }