Skip to content

Commit

Permalink
Update as of 6/7/2012
Browse files Browse the repository at this point in the history
* Fixed various crashes of visual design editor
* Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels
* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework
* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests
* Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code)
* Github requests:
** [#19](#19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests
  • Loading branch information
magento-team committed Jun 7, 2012
1 parent 99b4374 commit 93f38e9
Show file tree
Hide file tree
Showing 97 changed files with 1,613 additions and 1,241 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Update as of 6/7/2012
=====================
* Fixed various crashes of visual design editor
* Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels
* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework
* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests
* Removed HTML-report feature of copy-paste detector which never worked anyway (`dev/tests/static/framework/Inspection/CopyPasteDetector/html_report.xslt` and all related code)
* Github requests:
** [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests

Update as of 5/31/2012
======================
* Implemented backend authentication independent of `Mage_Adminhtml` module. Authentication can be disabled
Expand Down
19 changes: 2 additions & 17 deletions app/Mage.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,25 +659,10 @@ public static function run($code = '', $type = 'store', $options = array())
Magento_Profiler::stop('mage');
} catch (Mage_Core_Model_Session_Exception $e) {
header('Location: ' . self::getBaseUrl());
die();
} catch (Mage_Core_Model_Store_Exception $e) {
require_once(self::getBaseDir() . DS . 'pub' . DS . 'errors' . DS . '404.php');
die();
require_once(self::getBaseDir() . '/pub/errors/404.php');
} catch (Exception $e) {
if (self::isInstalled() || self::$_isDownloader) {
self::printException($e);
exit();
}
try {
self::dispatchEvent('mage_run_exception', array('exception' => $e));
if (!headers_sent()) {
header('Location:' . self::getUrl('install'));
} else {
self::printException($e);
}
} catch (Exception $ne) {
self::printException($ne, $e->getMessage());
}
self::printException($e);
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Api2/view/adminhtml/layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@

<adminhtml_api2_role_grid>
<remove name="root"/>
<block type="Mage_Api2_Block_Adminhtml_Roles_Grid" name="api2_roles.grid" output="toHtml"/>
<block type="Mage_Api2_Block_Adminhtml_Roles_Grid" name="api2_roles.grid" output="1"/>
</adminhtml_api2_role_grid>

<adminhtml_api2_role_usersgrid>
<remove name="root"/>
<block type="Mage_Api2_Block_Adminhtml_Roles_Tab_Users" name="adminhtml.role.edit.tab.users" output="toHtml"/>
<block type="Mage_Api2_Block_Adminhtml_Roles_Tab_Users" name="adminhtml.role.edit.tab.users" output="1"/>
</adminhtml_api2_role_usersgrid>

<!-- admin acl users edit page -->
Expand Down
9 changes: 3 additions & 6 deletions app/code/core/Mage/Catalog/view/frontend/msrp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,23 @@ Default layout, loads most of the pages
<update handle="MAP_popup" />
</tag_customer_view>

<MAP_popup translate="label">
<label>Catalog MAP Popup</label>
<MAP_popup>
<reference name="head">
<action method="addJs" ifconfig="sales/msrp/enabled"><file>Mage_Catalog::msrp.js</file></action>
</reference>
<reference name="content">
<block type="Mage_Core_Block_Template" template="Mage_Catalog::msrp/popup.phtml" name="product.tooltip"/>
</reference>
</MAP_popup>
<MAP_price_msrp_item translate="label">
<label>Catalog MAP Price MSRP Item</label>
<MAP_price_msrp_item>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_item.phtml</template></action>
</reference>
<reference name="product.clone_prices">
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_item.phtml</template></action>
</reference>
</MAP_price_msrp_item>
<MAP_price_msrp_wishlist_item translate="label">
<label>Catalog MAP Price MSRP Wishlist Item</label>
<MAP_price_msrp_wishlist_item>
<reference name="catalog_product_price_template">
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>Mage_Wishlist::render/item/price_msrp_item.phtml</template></action>
</reference>
Expand Down
18 changes: 5 additions & 13 deletions app/code/core/Mage/Checkout/view/frontend/layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ Default layout, loads most of the pages
</checkout_cart_index>

<checkout_cart_configure translate="label" type="page" parent="catalog_product_view">
<label>Configure Cart Item</label>
<label>Configure Cart Item (Any)</label>
<update handle="catalog_product_view"/>
<reference name="product.info">
<block type="Mage_Checkout_Block_Cart_Item_Configure" name="checkout.cart.item.configure.block"></block>
<block type="Mage_Checkout_Block_Cart_Item_Configure" name="checkout.cart.item.configure.block"/>
</reference>
<reference name="product.info.addtocart">
<action method="setTemplate"><template>Mage_Checkout::cart/item/configure/updatecart.phtml</template></action>
Expand All @@ -104,17 +104,17 @@ Default layout, loads most of the pages
</checkout_cart_configure>

<checkout_cart_configure_type_downloadable translate="label" module="Mage_Downloadable" type="page" parent="checkout_cart_configure">
<label>Configure Cart Item</label>
<label>Configure Cart Item (Downloadable)</label>
<update handle="catalog_product_view_type_downloadable"/>
</checkout_cart_configure_type_downloadable>

<checkout_cart_configure_type_configurable translate="label" module="Mage_Catalog" type="page" parent="checkout_cart_configure">
<label>Configure Cart Item</label>
<label>Configure Cart Item (Configurable)</label>
<update handle="catalog_product_view_type_configurable"/>
</checkout_cart_configure_type_configurable>

<checkout_cart_configure_type_bundle translate="label" module="Mage_Bundle" type="page" parent="checkout_cart_configure">
<label>Configure Bundle Cart Item</label>
<label>Configure Cart Item (Bundle)</label>
<update handle="catalog_product_view_type_bundle"/>
<reference name="product.info.addtocart.bundle">
<action method="setTemplate"><template>Mage_Checkout::cart/item/configure/updatecart.phtml</template></action>
Expand Down Expand Up @@ -434,12 +434,4 @@ One page checkout order review block
<block type="Mage_Checkout_Block_Onepage_Failure" name="checkout.failure" template="onepage/failure.phtml"/>
</reference>
</checkout_onepage_failure>

<checkout_onepage_savepayment translate="label">
<label>One Page Checkout Save Payment</label>
</checkout_onepage_savepayment>

<checkout_onepage_reorder translate="label">
<label>One Page Checkout Reorder</label>
</checkout_onepage_reorder>
</layout>
59 changes: 28 additions & 31 deletions app/code/core/Mage/Core/Helper/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,63 +43,60 @@ class Mage_Core_Helper_Http extends Mage_Core_Helper_Abstract
protected $_remoteAddr;

/**
* Validate and retrieve user and password from HTTP
* Extract "login" and "password" credentials from HTTP-request
*
* Returns plain array with 2 items: login and password respectively
*
* @param Zend_Controller_Request_Http $request
* @return array
*/
public function authValidate($headers = null)
public function getHttpAuthCredentials(Zend_Controller_Request_Http $request)
{
if(!is_null($headers)) {
$_SERVER = $headers;
}

$server = $request->getServer();
$user = '';
$pass = '';

// moshe's fix for CGI
if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
foreach ($_SERVER as $k=>$v) {
if (substr($k, -18)==='HTTP_AUTHORIZATION' && !empty($v)) {
$_SERVER['HTTP_AUTHORIZATION'] = $v;
if (empty($server['HTTP_AUTHORIZATION'])) {
foreach ($server as $k => $v) {
if (substr($k, -18) === 'HTTP_AUTHORIZATION' && !empty($v)) {
$server['HTTP_AUTHORIZATION'] = $v;
break;
}
}
}

if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
if (isset($server['PHP_AUTH_USER']) && isset($server['PHP_AUTH_PW'])) {
$user = $server['PHP_AUTH_USER'];
$pass = $server['PHP_AUTH_PW'];
}
// IIS Note:: For HTTP Authentication to work with IIS,
// the PHP directive cgi.rfc2616_headers must be set to 0 (the default value).
elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
$auth = $_SERVER['HTTP_AUTHORIZATION'];
/**
* IIS Note: for HTTP authentication to work with IIS,
* the PHP directive cgi.rfc2616_headers must be set to 0 (the default value).
*/
elseif (!empty($server['HTTP_AUTHORIZATION'])) {
$auth = $server['HTTP_AUTHORIZATION'];
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
}
elseif (!empty($_SERVER['Authorization'])) {
$auth = $_SERVER['Authorization'];
elseif (!empty($server['Authorization'])) {
$auth = $server['Authorization'];
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
}

if (!$user || !$pass) {
$this->authFailed();
}

return array($user, $pass);
}

/**
* Send auth failed Headers and exit
* Set "auth failed" headers to the specified response object
*
* @param Zend_Controller_Response_Http $response
* @param string $realm
*/
public function authFailed()
public function failHttpAuthentication(Zend_Controller_Response_Http $response, $realm)
{
Mage::app()->getResponse()
->setHeader('HTTP/1.1','401 Unauthorized')
->setHeader('WWW-Authenticate','Basic realm="RSS Feeds"')
$response->setHeader('HTTP/1.1', '401 Unauthorized')
->setHeader('WWW-Authenticate', 'Basic realm="' . $realm . '"')
->setBody('<h1>401 Unauthorized</h1>')
->sendResponse();
exit;
;
}

/**
Expand Down
112 changes: 5 additions & 107 deletions app/code/core/Mage/Core/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,21 +752,6 @@ public function addAllowedModules($module)
return $this;
}

/**
* Define if module is allowed
*
* @param string $moduleName
* @return bool
*/
protected function _isAllowedModule($moduleName)
{
if (empty($this->_allowedModules)) {
return true;
} else {
return in_array($moduleName, $this->_allowedModules);
}
}

/**
* Load declared modules configuration
*
Expand All @@ -776,112 +761,25 @@ protected function _loadDeclaredModules()
{
$moduleFiles = $this->_getDeclaredModuleFiles();
if (!$moduleFiles) {
return ;
return $this;
}

Magento_Profiler::start('load_modules_declaration');

$unsortedConfig = new Mage_Core_Model_Config_Base();
$unsortedConfig->loadString('<config/>');
$fileConfig = new Mage_Core_Model_Config_Base();

// load modules declarations
foreach ($moduleFiles as $file) {
$fileConfig->loadFile($file);
$unsortedConfig = new Mage_Core_Model_Config_Base('<config/>');
foreach ($moduleFiles as $oneConfigFile) {
$fileConfig = new Mage_Core_Model_Config_Base($oneConfigFile);
$unsortedConfig->extend($fileConfig);
}

$moduleDepends = array();
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
if (!$this->_isAllowedModule($moduleName)) {
continue;
}

$depends = array();
if ($moduleNode->depends) {
foreach ($moduleNode->depends->children() as $depend) {
$depends[$depend->getName()] = true;
}
}
$moduleDepends[$moduleName] = array(
'module' => $moduleName,
'depends' => $depends,
'active' => ('true' === (string)$moduleNode->active ? true : false),
);
}

// check and sort module dependence
$moduleDepends = $this->_sortModuleDepends($moduleDepends);

// create sorted config
$sortedConfig = new Mage_Core_Model_Config_Base();
$sortedConfig->loadString('<config><modules/></config>');

foreach ($unsortedConfig->getNode()->children() as $nodeName => $node) {
if ($nodeName != 'modules') {
$sortedConfig->getNode()->appendChild($node);
}
}

foreach ($moduleDepends as $moduleProp) {
$node = $unsortedConfig->getNode('modules/'.$moduleProp['module']);
$sortedConfig->getNode('modules')->appendChild($node);
}
$sortedConfig = new Mage_Core_Model_Config_Module($unsortedConfig, $this->_allowedModules);

$this->extend($sortedConfig);

Magento_Profiler::stop('load_modules_declaration');
return $this;
}

/**
* Sort modules and check depends
*
* @param array $modules
* @return array
*/
protected function _sortModuleDepends($modules)
{
foreach ($modules as $moduleName => $moduleProps) {
$depends = $moduleProps['depends'];
foreach ($moduleProps['depends'] as $depend => $true) {
if ($moduleProps['active'] && ((!isset($modules[$depend])) || empty($modules[$depend]['active']))) {
Mage::throwException(
Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" requires module "%2$s".', $moduleName, $depend)
);
}
$depends = array_merge($depends, $modules[$depend]['depends']);
}
$modules[$moduleName]['depends'] = $depends;
}
$modules = array_values($modules);

$size = count($modules) - 1;
for ($i = $size; $i >= 0; $i--) {
for ($j = $size; $i < $j; $j--) {
if (isset($modules[$i]['depends'][$modules[$j]['module']])) {
$value = $modules[$i];
$modules[$i] = $modules[$j];
$modules[$j] = $value;
}
}
}

$definedModules = array();
foreach ($modules as $moduleProp) {
foreach ($moduleProp['depends'] as $dependModule => $true) {
if (!isset($definedModules[$dependModule])) {
Mage::throwException(
Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" cannot depend on "%2$s".', $moduleProp['module'], $dependModule)
);
}
}
$definedModules[$moduleProp['module']] = true;
}

return $modules;
}

/**
* Determine whether provided name begins from any available modules, according to namespaces priority
* If matched, returns as the matched module "factory" name or a fully qualified module name
Expand Down
Loading

0 comments on commit 93f38e9

Please sign in to comment.