Skip to content

Commit 93f38e9

Browse files
committed
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](#19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests
1 parent 99b4374 commit 93f38e9

File tree

97 files changed

+1613
-1241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1613
-1241
lines changed

CHANGELOG.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Update as of 6/7/2012
2+
=====================
3+
* Fixed various crashes of visual design editor
4+
* Fixed some layouts that caused visual design editor toolbar disappearing, also fixed some confusing page type labels
5+
* Eliminated "after commit callback" workaround from integration tests by implementing "transparent transactions" capability in integration testing framework
6+
* Refactored admin authentication/authorization in RSS module. Removed program termination and covered the controllers with tests
7+
* 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)
8+
* Github requests:
9+
** [#19](https://github.com/magento/magento2/pull/19) Implemented "soft" dependency between modules and performed several improvements in the related code, covered with tests
10+
111
Update as of 5/31/2012
212
======================
313
* Implemented backend authentication independent of `Mage_Adminhtml` module. Authentication can be disabled

app/Mage.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -659,25 +659,10 @@ public static function run($code = '', $type = 'store', $options = array())
659659
Magento_Profiler::stop('mage');
660660
} catch (Mage_Core_Model_Session_Exception $e) {
661661
header('Location: ' . self::getBaseUrl());
662-
die();
663662
} catch (Mage_Core_Model_Store_Exception $e) {
664-
require_once(self::getBaseDir() . DS . 'pub' . DS . 'errors' . DS . '404.php');
665-
die();
663+
require_once(self::getBaseDir() . '/pub/errors/404.php');
666664
} catch (Exception $e) {
667-
if (self::isInstalled() || self::$_isDownloader) {
668-
self::printException($e);
669-
exit();
670-
}
671-
try {
672-
self::dispatchEvent('mage_run_exception', array('exception' => $e));
673-
if (!headers_sent()) {
674-
header('Location:' . self::getUrl('install'));
675-
} else {
676-
self::printException($e);
677-
}
678-
} catch (Exception $ne) {
679-
self::printException($ne, $e->getMessage());
680-
}
665+
self::printException($e);
681666
}
682667
}
683668

app/code/core/Mage/Api2/view/adminhtml/layout.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@
9292

9393
<adminhtml_api2_role_grid>
9494
<remove name="root"/>
95-
<block type="Mage_Api2_Block_Adminhtml_Roles_Grid" name="api2_roles.grid" output="toHtml"/>
95+
<block type="Mage_Api2_Block_Adminhtml_Roles_Grid" name="api2_roles.grid" output="1"/>
9696
</adminhtml_api2_role_grid>
9797

9898
<adminhtml_api2_role_usersgrid>
9999
<remove name="root"/>
100-
<block type="Mage_Api2_Block_Adminhtml_Roles_Tab_Users" name="adminhtml.role.edit.tab.users" output="toHtml"/>
100+
<block type="Mage_Api2_Block_Adminhtml_Roles_Tab_Users" name="adminhtml.role.edit.tab.users" output="1"/>
101101
</adminhtml_api2_role_usersgrid>
102102

103103
<!-- admin acl users edit page -->

app/code/core/Mage/Catalog/view/frontend/msrp.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,23 @@ Default layout, loads most of the pages
7474
<update handle="MAP_popup" />
7575
</tag_customer_view>
7676

77-
<MAP_popup translate="label">
78-
<label>Catalog MAP Popup</label>
77+
<MAP_popup>
7978
<reference name="head">
8079
<action method="addJs" ifconfig="sales/msrp/enabled"><file>Mage_Catalog::msrp.js</file></action>
8180
</reference>
8281
<reference name="content">
8382
<block type="Mage_Core_Block_Template" template="Mage_Catalog::msrp/popup.phtml" name="product.tooltip"/>
8483
</reference>
8584
</MAP_popup>
86-
<MAP_price_msrp_item translate="label">
87-
<label>Catalog MAP Price MSRP Item</label>
85+
<MAP_price_msrp_item>
8886
<reference name="catalog_product_price_template">
8987
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_item.phtml</template></action>
9088
</reference>
9189
<reference name="product.clone_prices">
9290
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>product/price_msrp_item.phtml</template></action>
9391
</reference>
9492
</MAP_price_msrp_item>
95-
<MAP_price_msrp_wishlist_item translate="label">
96-
<label>Catalog MAP Price MSRP Wishlist Item</label>
93+
<MAP_price_msrp_wishlist_item>
9794
<reference name="catalog_product_price_template">
9895
<action method="addPriceBlockType"><type>msrp</type><block>Mage_Catalog_Block_Product_Price</block><template>Mage_Wishlist::render/item/price_msrp_item.phtml</template></action>
9996
</reference>

app/code/core/Mage/Checkout/view/frontend/layout.xml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ Default layout, loads most of the pages
9090
</checkout_cart_index>
9191

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

106106
<checkout_cart_configure_type_downloadable translate="label" module="Mage_Downloadable" type="page" parent="checkout_cart_configure">
107-
<label>Configure Cart Item</label>
107+
<label>Configure Cart Item (Downloadable)</label>
108108
<update handle="catalog_product_view_type_downloadable"/>
109109
</checkout_cart_configure_type_downloadable>
110110

111111
<checkout_cart_configure_type_configurable translate="label" module="Mage_Catalog" type="page" parent="checkout_cart_configure">
112-
<label>Configure Cart Item</label>
112+
<label>Configure Cart Item (Configurable)</label>
113113
<update handle="catalog_product_view_type_configurable"/>
114114
</checkout_cart_configure_type_configurable>
115115

116116
<checkout_cart_configure_type_bundle translate="label" module="Mage_Bundle" type="page" parent="checkout_cart_configure">
117-
<label>Configure Bundle Cart Item</label>
117+
<label>Configure Cart Item (Bundle)</label>
118118
<update handle="catalog_product_view_type_bundle"/>
119119
<reference name="product.info.addtocart.bundle">
120120
<action method="setTemplate"><template>Mage_Checkout::cart/item/configure/updatecart.phtml</template></action>
@@ -434,12 +434,4 @@ One page checkout order review block
434434
<block type="Mage_Checkout_Block_Onepage_Failure" name="checkout.failure" template="onepage/failure.phtml"/>
435435
</reference>
436436
</checkout_onepage_failure>
437-
438-
<checkout_onepage_savepayment translate="label">
439-
<label>One Page Checkout Save Payment</label>
440-
</checkout_onepage_savepayment>
441-
442-
<checkout_onepage_reorder translate="label">
443-
<label>One Page Checkout Reorder</label>
444-
</checkout_onepage_reorder>
445437
</layout>

app/code/core/Mage/Core/Helper/Http.php

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,63 +43,60 @@ class Mage_Core_Helper_Http extends Mage_Core_Helper_Abstract
4343
protected $_remoteAddr;
4444

4545
/**
46-
* Validate and retrieve user and password from HTTP
46+
* Extract "login" and "password" credentials from HTTP-request
4747
*
48+
* Returns plain array with 2 items: login and password respectively
49+
*
50+
* @param Zend_Controller_Request_Http $request
4851
* @return array
4952
*/
50-
public function authValidate($headers = null)
53+
public function getHttpAuthCredentials(Zend_Controller_Request_Http $request)
5154
{
52-
if(!is_null($headers)) {
53-
$_SERVER = $headers;
54-
}
55-
55+
$server = $request->getServer();
5656
$user = '';
5757
$pass = '';
5858

59-
// moshe's fix for CGI
60-
if (empty($_SERVER['HTTP_AUTHORIZATION'])) {
61-
foreach ($_SERVER as $k=>$v) {
62-
if (substr($k, -18)==='HTTP_AUTHORIZATION' && !empty($v)) {
63-
$_SERVER['HTTP_AUTHORIZATION'] = $v;
59+
if (empty($server['HTTP_AUTHORIZATION'])) {
60+
foreach ($server as $k => $v) {
61+
if (substr($k, -18) === 'HTTP_AUTHORIZATION' && !empty($v)) {
62+
$server['HTTP_AUTHORIZATION'] = $v;
6463
break;
6564
}
6665
}
6766
}
6867

69-
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
70-
$user = $_SERVER['PHP_AUTH_USER'];
71-
$pass = $_SERVER['PHP_AUTH_PW'];
68+
if (isset($server['PHP_AUTH_USER']) && isset($server['PHP_AUTH_PW'])) {
69+
$user = $server['PHP_AUTH_USER'];
70+
$pass = $server['PHP_AUTH_PW'];
7271
}
73-
// IIS Note:: For HTTP Authentication to work with IIS,
74-
// the PHP directive cgi.rfc2616_headers must be set to 0 (the default value).
75-
elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
76-
$auth = $_SERVER['HTTP_AUTHORIZATION'];
72+
/**
73+
* IIS Note: for HTTP authentication to work with IIS,
74+
* the PHP directive cgi.rfc2616_headers must be set to 0 (the default value).
75+
*/
76+
elseif (!empty($server['HTTP_AUTHORIZATION'])) {
77+
$auth = $server['HTTP_AUTHORIZATION'];
7778
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
7879
}
79-
elseif (!empty($_SERVER['Authorization'])) {
80-
$auth = $_SERVER['Authorization'];
80+
elseif (!empty($server['Authorization'])) {
81+
$auth = $server['Authorization'];
8182
list($user, $pass) = explode(':', base64_decode(substr($auth, strpos($auth, " ") + 1)));
8283
}
8384

84-
if (!$user || !$pass) {
85-
$this->authFailed();
86-
}
87-
8885
return array($user, $pass);
8986
}
9087

9188
/**
92-
* Send auth failed Headers and exit
89+
* Set "auth failed" headers to the specified response object
9390
*
91+
* @param Zend_Controller_Response_Http $response
92+
* @param string $realm
9493
*/
95-
public function authFailed()
94+
public function failHttpAuthentication(Zend_Controller_Response_Http $response, $realm)
9695
{
97-
Mage::app()->getResponse()
98-
->setHeader('HTTP/1.1','401 Unauthorized')
99-
->setHeader('WWW-Authenticate','Basic realm="RSS Feeds"')
96+
$response->setHeader('HTTP/1.1', '401 Unauthorized')
97+
->setHeader('WWW-Authenticate', 'Basic realm="' . $realm . '"')
10098
->setBody('<h1>401 Unauthorized</h1>')
101-
->sendResponse();
102-
exit;
99+
;
103100
}
104101

105102
/**

app/code/core/Mage/Core/Model/Config.php

Lines changed: 5 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -752,21 +752,6 @@ public function addAllowedModules($module)
752752
return $this;
753753
}
754754

755-
/**
756-
* Define if module is allowed
757-
*
758-
* @param string $moduleName
759-
* @return bool
760-
*/
761-
protected function _isAllowedModule($moduleName)
762-
{
763-
if (empty($this->_allowedModules)) {
764-
return true;
765-
} else {
766-
return in_array($moduleName, $this->_allowedModules);
767-
}
768-
}
769-
770755
/**
771756
* Load declared modules configuration
772757
*
@@ -776,112 +761,25 @@ protected function _loadDeclaredModules()
776761
{
777762
$moduleFiles = $this->_getDeclaredModuleFiles();
778763
if (!$moduleFiles) {
779-
return ;
764+
return $this;
780765
}
781766

782767
Magento_Profiler::start('load_modules_declaration');
783768

784-
$unsortedConfig = new Mage_Core_Model_Config_Base();
785-
$unsortedConfig->loadString('<config/>');
786-
$fileConfig = new Mage_Core_Model_Config_Base();
787-
788-
// load modules declarations
789-
foreach ($moduleFiles as $file) {
790-
$fileConfig->loadFile($file);
769+
$unsortedConfig = new Mage_Core_Model_Config_Base('<config/>');
770+
foreach ($moduleFiles as $oneConfigFile) {
771+
$fileConfig = new Mage_Core_Model_Config_Base($oneConfigFile);
791772
$unsortedConfig->extend($fileConfig);
792773
}
793774

794-
$moduleDepends = array();
795-
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
796-
if (!$this->_isAllowedModule($moduleName)) {
797-
continue;
798-
}
799-
800-
$depends = array();
801-
if ($moduleNode->depends) {
802-
foreach ($moduleNode->depends->children() as $depend) {
803-
$depends[$depend->getName()] = true;
804-
}
805-
}
806-
$moduleDepends[$moduleName] = array(
807-
'module' => $moduleName,
808-
'depends' => $depends,
809-
'active' => ('true' === (string)$moduleNode->active ? true : false),
810-
);
811-
}
812-
813-
// check and sort module dependence
814-
$moduleDepends = $this->_sortModuleDepends($moduleDepends);
815-
816-
// create sorted config
817-
$sortedConfig = new Mage_Core_Model_Config_Base();
818-
$sortedConfig->loadString('<config><modules/></config>');
819-
820-
foreach ($unsortedConfig->getNode()->children() as $nodeName => $node) {
821-
if ($nodeName != 'modules') {
822-
$sortedConfig->getNode()->appendChild($node);
823-
}
824-
}
825-
826-
foreach ($moduleDepends as $moduleProp) {
827-
$node = $unsortedConfig->getNode('modules/'.$moduleProp['module']);
828-
$sortedConfig->getNode('modules')->appendChild($node);
829-
}
775+
$sortedConfig = new Mage_Core_Model_Config_Module($unsortedConfig, $this->_allowedModules);
830776

831777
$this->extend($sortedConfig);
832778

833779
Magento_Profiler::stop('load_modules_declaration');
834780
return $this;
835781
}
836782

837-
/**
838-
* Sort modules and check depends
839-
*
840-
* @param array $modules
841-
* @return array
842-
*/
843-
protected function _sortModuleDepends($modules)
844-
{
845-
foreach ($modules as $moduleName => $moduleProps) {
846-
$depends = $moduleProps['depends'];
847-
foreach ($moduleProps['depends'] as $depend => $true) {
848-
if ($moduleProps['active'] && ((!isset($modules[$depend])) || empty($modules[$depend]['active']))) {
849-
Mage::throwException(
850-
Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" requires module "%2$s".', $moduleName, $depend)
851-
);
852-
}
853-
$depends = array_merge($depends, $modules[$depend]['depends']);
854-
}
855-
$modules[$moduleName]['depends'] = $depends;
856-
}
857-
$modules = array_values($modules);
858-
859-
$size = count($modules) - 1;
860-
for ($i = $size; $i >= 0; $i--) {
861-
for ($j = $size; $i < $j; $j--) {
862-
if (isset($modules[$i]['depends'][$modules[$j]['module']])) {
863-
$value = $modules[$i];
864-
$modules[$i] = $modules[$j];
865-
$modules[$j] = $value;
866-
}
867-
}
868-
}
869-
870-
$definedModules = array();
871-
foreach ($modules as $moduleProp) {
872-
foreach ($moduleProp['depends'] as $dependModule => $true) {
873-
if (!isset($definedModules[$dependModule])) {
874-
Mage::throwException(
875-
Mage::helper('Mage_Core_Helper_Data')->__('Module "%1$s" cannot depend on "%2$s".', $moduleProp['module'], $dependModule)
876-
);
877-
}
878-
}
879-
$definedModules[$moduleProp['module']] = true;
880-
}
881-
882-
return $modules;
883-
}
884-
885783
/**
886784
* Determine whether provided name begins from any available modules, according to namespaces priority
887785
* If matched, returns as the matched module "factory" name or a fully qualified module name

0 commit comments

Comments
 (0)