From 9e776428328bbaa27f160666b5a01e70032a2cb5 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 15 Oct 2025 20:12:06 +0200 Subject: [PATCH 01/13] check for correct block --- .../Block/Catalog/Category/Tab/Attributes.php | 5 +++- .../Catalog/Product/Edit/Tab/Attributes.php | 5 +++- .../Adminhtml/Block/Cms/Block/Edit/Form.php | 5 +++- .../Block/Cms/Page/Edit/Tab/Content.php | 5 +++- .../Adminhtml/Block/Newsletter/Queue/Edit.php | 5 +++- .../Block/Newsletter/Template/Edit.php | 7 +++-- .../core/Mage/Adminhtml/Block/Page/Head.php | 4 +++ .../System/Convert/Gui/Edit/Tab/Wizard.php | 3 ++- .../Block/System/Email/Template/Edit/Form.php | 6 ++--- .../Block/Widget/Grid/Column/Filter/Date.php | 3 ++- .../controllers/Api/RoleController.php | 5 +++- .../Catalog/CategoryController.php | 8 ++++-- .../Catalog/Product/ReviewController.php | 5 +++- .../Catalog/Product/SetController.php | 6 ++++- .../controllers/Catalog/ProductController.php | 10 +++++-- .../controllers/Catalog/SearchController.php | 5 +++- .../Permissions/RoleController.php | 5 +++- .../controllers/System/DesignController.php | 10 ++++--- .../controllers/UrlrewriteController.php | 7 ++++- .../core/Mage/Catalog/Block/Breadcrumbs.php | 5 ++-- .../core/Mage/Catalog/Block/Category/View.php | 15 +++++------ .../Catalog/Block/Product/Compare/List.php | 6 ++--- .../Mage/Catalog/Block/Product/Gallery.php | 5 ++-- .../core/Mage/Catalog/Block/Product/View.php | 17 ++++++------ .../Block/Product/View/Options/Type/Date.php | 3 ++- .../core/Mage/CatalogSearch/Block/Result.php | 6 ++++- .../Block/Multishipping/Address/Select.php | 5 ++-- .../Block/Multishipping/Addresses.php | 5 ++-- .../Checkout/Block/Multishipping/Billing.php | 7 ++--- .../Checkout/Block/Multishipping/Overview.php | 7 ++--- .../Checkout/Block/Multishipping/Shipping.php | 5 ++-- .../Multishipping/AddressController.php | 26 ++++++++++++------- .../controllers/OnepageController.php | 7 ++++- app/code/core/Mage/Cms/Block/Page.php | 3 +-- .../Mage/Core/Controller/Varien/Action.php | 8 +++--- app/code/core/Mage/Core/Model/Layout.php | 15 +++++++++++ .../core/Mage/Customer/Block/Address/Book.php | 6 +++-- .../core/Mage/Customer/Block/Address/Edit.php | 5 ++-- .../Mage/Customer/Block/Form/Register.php | 6 ++++- .../controllers/AccountController.php | 20 +++++++++++--- .../controllers/CustomerController.php | 6 ++--- .../controllers/ManageController.php | 6 ++++- .../Review/controllers/CustomerController.php | 11 ++++++-- app/code/core/Mage/Rss/Block/List.php | 13 +++++----- .../Mage/Sales/Block/Order/Creditmemo.php | 7 +++-- app/code/core/Mage/Sales/Block/Order/Info.php | 7 +++-- .../core/Mage/Sales/Block/Order/Invoice.php | 7 +++-- .../core/Mage/Sales/Block/Order/Print.php | 7 +++-- .../Sales/Block/Order/Print/Creditmemo.php | 7 +++-- .../Mage/Sales/Block/Order/Print/Invoice.php | 7 +++-- .../Mage/Sales/Block/Order/Print/Shipment.php | 7 +++-- .../core/Mage/Sales/Block/Order/Shipment.php | 7 +++-- app/code/core/Mage/Sales/Block/Order/View.php | 7 +++-- .../Sales/controllers/OrderController.php | 5 +++- .../core/Mage/Tag/Block/Product/Result.php | 7 ++++- .../Tag/controllers/CustomerController.php | 11 ++++++-- .../Mage/Wishlist/Block/Customer/Sharing.php | 6 ++--- .../Mage/Wishlist/Block/Customer/Wishlist.php | 7 ++--- .../Mage/Wishlist/Block/Share/Wishlist.php | 6 ++--- 59 files changed, 283 insertions(+), 149 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php index 69a0530a47c..ed30f5399c6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php @@ -41,7 +41,10 @@ protected function _prepareLayout() { parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php index 477acc43716..8cae8fd7fe9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php @@ -23,7 +23,10 @@ protected function _prepareLayout() if ($this->isModuleEnabled('Mage_Cms', 'catalog') && Mage::getSingleton('cms/wysiwyg_config')->isEnabled() ) { - $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php index 76b7f57e16f..fb5d24849d0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php @@ -31,7 +31,10 @@ protected function _prepareLayout() { parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php index 32d667b4baf..18cf00a2e4f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php @@ -21,7 +21,10 @@ protected function _prepareLayout() { parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php index 44a107a0461..4b6ac52d5b4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php @@ -73,7 +73,10 @@ protected function _prepareLayout() { // Load Wysiwyg on demand and Prepare layout if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } } $this->setChild( diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php index d8eace9d156..3a6028e3954 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php @@ -37,8 +37,11 @@ public function getModel() protected function _prepareLayout() { // Load Wysiwyg on demand and Prepare layout - if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) { - $block->setCanLoadTinyMce(true); + if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } } $this->setChild( diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Head.php b/app/code/core/Mage/Adminhtml/Block/Page/Head.php index 76e4db54b45..46e46f25a92 100644 --- a/app/code/core/Mage/Adminhtml/Block/Page/Head.php +++ b/app/code/core/Mage/Adminhtml/Block/Page/Head.php @@ -11,6 +11,10 @@ * Adminhtml header block * * @package Mage_Adminhtml + * + * @method $this setCanLoadExtJs(bool $value) + * @method $this setCanLoadRulesJs(bool $value) + * @method $this setContainerCssClass(string $value) */ class Mage_Adminhtml_Block_Page_Head extends Mage_Page_Block_Html_Head { diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php index e13ffe52f33..646f17c068c 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php @@ -43,7 +43,8 @@ public function __construct() */ protected function _prepareLayout() { - if ($head = $this->getLayout()->getBlock('head')) { + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { $head->setCanLoadCalendarJs(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php index ebe87a96333..5044e1f44f1 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php @@ -22,10 +22,10 @@ class Mage_Adminhtml_Block_System_Email_Template_Edit_Form extends Mage_Adminhtm */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $head */ - $head = $this->getLayout()->getBlock('head'); + $head = $this->getLayout()->getBlockHead(); if ($head) { - $head->addItem('js', 'prototype/window.js') + $head + ->addItem('js', 'prototype/window.js') ->addItem('js_css', 'prototype/windows/themes/default.css') ->addCss('lib/prototype/windows/themes/magento.css') ->addItem('js', 'mage/adminhtml/variables.js'); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php index dbef983c21a..d99d1ad686c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php @@ -22,7 +22,8 @@ class Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date extends Mage_Adminhtml */ protected function _prepareLayout() { - if ($head = $this->getLayout()->getBlock('head')) { + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { $head->setCanLoadCalendarJs(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php index 1be265f3791..4009b0fb379 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php @@ -83,7 +83,10 @@ public function editRoleAction() $this->_addBreadcrumb($breadCrumb, $breadCrumbTitle); - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadExtJs(true); + } $this->_addLeft( $this->getLayout()->createBlock('adminhtml/api_editroles'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php index f010fd56f9e..9ba11448764 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php @@ -183,8 +183,12 @@ public function editAction() $this->loadLayout(); $this->_setActiveMenu('catalog/categories'); - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true) - ->setContainerCssClass('catalog-categories'); + + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadExtJs(true); + $head->setContainerCssClass('catalog-categories'); + } $this->_addBreadcrumb( Mage::helper('catalog')->__('Manage Catalog Categories'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php index 58e9b31a87e..1d18c948de9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php @@ -105,7 +105,10 @@ public function newAction() $this->loadLayout(); $this->_setActiveMenu('catalog/reviews_ratings/reviews/all'); - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } $this->_addContent($this->getLayout()->createBlock('adminhtml/review_add')); $this->_addContent($this->getLayout()->createBlock('adminhtml/review_product_grid')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php index 55aac9b0f59..18caf59b1a7 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php @@ -64,7 +64,11 @@ public function editAction() $this->loadLayout(); $this->_setActiveMenu('catalog/attributes/sets'); - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } $this->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog')); $this->_addBreadcrumb( diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index 5c06f0e07ae..88f4d7c87e4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -215,7 +215,10 @@ public function newAction() $this->_setActiveMenu('catalog/products'); } - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadExtJs(true); + } $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { @@ -268,7 +271,10 @@ public function editAction() ); } - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadExtJs(true); + } $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php index 738f51b1a09..187e13cbc1a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php @@ -70,7 +70,10 @@ public function editAction() $this->_title($id ? $model->getQueryText() : $this->__('New Search')); - $this->getLayout()->getBlock('head')->setCanLoadRulesJs(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadRulesJs(true); + } $this->getLayout()->getBlock('catalog_search_edit') ->setData('action', $this->getUrl('*/catalog_search/save')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php index 4ee87116edd..d106853aded 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php @@ -109,7 +109,10 @@ public function editRoleAction() $this->_addBreadcrumb($breadCrumb, $breadCrumbTitle); - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } $this->_addContent( $this->getLayout()->createBlock('adminhtml/permissions_buttons') diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index 9d1a0557450..b0e2cf685ba 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -55,10 +55,14 @@ public function editAction() $this->loadLayout(); $this->_setActiveMenu('system/design'); - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); - $id = (int) $this->getRequest()->getParam('id'); - $design = Mage::getModel('core/design'); + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadTinyMce(true); + } + + $id = (int) $this->getRequest()->getParam('id'); + $design = Mage::getModel('core/design'); if ($id) { $design->load($id); diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php index 4022a6601fe..780fe7e99a0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -76,7 +76,12 @@ public function editAction() $this->loadLayout(); $this->_setActiveMenu('catalog/urlrewrite'); $this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit')); - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + + $head = $this->getLayout()->getBlockHeadAdminhtml(); + if ($head) { + $head->setCanLoadExtJs(true); + } + $this->renderLayout(); } diff --git a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php index 7c640db210c..40723a4dd6a 100644 --- a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php +++ b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php @@ -50,8 +50,9 @@ protected function _prepareLayout() $title[] = $breadcrumb['label']; } - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle(implode($this->getTitleSeparator(), array_reverse($title))); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(implode($this->getTitleSeparator(), array_reverse($title))); } } diff --git a/app/code/core/Mage/Catalog/Block/Category/View.php b/app/code/core/Mage/Catalog/Block/Category/View.php index 483677dd244..757107347f7 100644 --- a/app/code/core/Mage/Catalog/Block/Category/View.php +++ b/app/code/core/Mage/Catalog/Block/Category/View.php @@ -24,26 +24,25 @@ protected function _prepareLayout() $this->getLayout()->createBlock('catalog/breadcrumbs'); - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { + $head = $this->getLayout()->getBlockHead(); + if ($head) { $category = $this->getCurrentCategory(); if ($title = $category->getMetaTitle()) { - $headBlock->setTitle($title); + $head->setTitle($title); } if ($description = $category->getMetaDescription()) { - $headBlock->setDescription($description); + $head->setDescription($description); } if ($keywords = $category->getMetaKeywords()) { - $headBlock->setKeywords($keywords); + $head->setKeywords($keywords); } /** @var Mage_Catalog_Helper_Category $helper */ $helper = $this->helper('catalog/category'); if ($helper->canUseCanonicalTag()) { - $headBlock->addLinkRel('canonical', $category->getUrl()); + $head->addLinkRel('canonical', $category->getUrl()); } /* @@ -51,7 +50,7 @@ protected function _prepareLayout() */ if ($this->isRssCatalogEnable() && $this->isTopCategory()) { $title = $this->helper('rss')->__('%s RSS Feed', $this->getCurrentCategory()->getName()); - $headBlock->addItem('rss', $this->getRssLink(), 'title="' . $title . '"'); + $head->addItem('rss', $this->getRssLink(), 'title="' . $title . '"'); } } diff --git a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php index 964eac1fd8b..1e12c8b77ee 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php +++ b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php @@ -67,9 +67,9 @@ public function getAddToWishlistUrl($product) */ protected function _prepareLayout() { - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head->getDefaultTitle()); } return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Catalog/Block/Product/Gallery.php b/app/code/core/Mage/Catalog/Block/Product/Gallery.php index 6238b2ddb01..d2096dfedbf 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Gallery.php +++ b/app/code/core/Mage/Catalog/Block/Product/Gallery.php @@ -19,8 +19,9 @@ class Mage_Catalog_Block_Product_Gallery extends Mage_Core_Block_Template */ protected function _prepareLayout() { - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle($this->getProduct()->getMetaTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->getProduct()->getMetaTitle()); } return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Catalog/Block/Product/View.php b/app/code/core/Mage/Catalog/Block/Product/View.php index e0aa94f89b7..9bedaccde92 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View.php +++ b/app/code/core/Mage/Catalog/Block/Product/View.php @@ -37,35 +37,34 @@ protected function _prepareLayout() { $this->getLayout()->createBlock('catalog/breadcrumbs'); - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { + $head = $this->getLayout()->getBlockHead(); + if ($head) { $product = $this->getProduct(); $title = $product->getMetaTitle(); if ($title) { - $headBlock->setTitle($title); + $head->setTitle($title); } $keyword = $product->getMetaKeyword(); $currentCategory = Mage::registry('current_category'); if ($keyword) { - $headBlock->setKeywords($keyword); + $head->setKeywords($keyword); } elseif ($currentCategory) { - $headBlock->setKeywords($product->getName()); + $head->setKeywords($product->getName()); } $description = $product->getMetaDescription(); if ($description) { - $headBlock->setDescription(($description)); + $head->setDescription(($description)); } else { - $headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255)); + $head->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255)); } /** @var Mage_Catalog_Helper_Product $helper */ $helper = $this->helper('catalog/product'); if ($helper->canUseCanonicalTag()) { $params = ['_ignore_category' => true]; - $headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params)); + $head->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params)); } } diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php b/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php index d8fd9d3a126..7aa629b1744 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php +++ b/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php @@ -28,7 +28,8 @@ class Mage_Catalog_Block_Product_View_Options_Type_Date extends Mage_Catalog_Blo */ protected function _prepareLayout() { - if ($head = $this->getLayout()->getBlock('head')) { + $head = $this->getLayout()->getBlockHead(); + if ($head) { $head->setCanLoadCalendarJs(true); } diff --git a/app/code/core/Mage/CatalogSearch/Block/Result.php b/app/code/core/Mage/CatalogSearch/Block/Result.php index 8746f0ea4d3..1a80460020d 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Result.php @@ -64,7 +64,11 @@ protected function _prepareLayout() // modify page title $title = $this->__("Search results for: '%s'", $helper->getEscapedQueryText()); - $this->getLayout()->getBlock('head')->setTitle($title); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($title); + } return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php index 001e60b5545..2240baa1324 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php @@ -19,8 +19,9 @@ class Mage_Checkout_Block_Multishipping_Address_Select extends Mage_Checkout_Blo */ protected function _prepareLayout() { - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $head->getDefaultTitle()); } return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php index 1f350fd2d1c..905da6b4983 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php @@ -29,8 +29,9 @@ public function getCheckout() */ protected function _prepareLayout() { - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $head->getDefaultTitle()); } return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php index 72bcf899939..88001512e88 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php @@ -19,9 +19,10 @@ class Mage_Checkout_Block_Multishipping_Billing extends Mage_Payment_Block_Form_ */ protected function _prepareLayout() { - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle( - Mage::helper('checkout')->__('Billing Information - %s', $headBlock->getDefaultTitle()), + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle( + Mage::helper('checkout')->__('Billing Information - %s', $head->getDefaultTitle()), ); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php index 473a616dda5..11828d45b74 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php @@ -42,9 +42,10 @@ public function getCheckout() */ protected function _prepareLayout() { - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle( - $this->__('Review Order - %s', $headBlock->getDefaultTitle()), + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle( + $this->__('Review Order - %s', $head->getDefaultTitle()), ); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php index 18f511e0275..b456ab0a29c 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php @@ -29,8 +29,9 @@ public function getCheckout() */ protected function _prepareLayout() { - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $head->getDefaultTitle()); } return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php index 26913a46a20..55f84f9efc5 100644 --- a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php +++ b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php @@ -47,8 +47,9 @@ public function newShippingAction() ->setSuccessUrl(Mage::getUrl('*/*/shippingSaved')) ->setErrorUrl(Mage::getUrl('*/*/*')); - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { @@ -83,8 +84,9 @@ public function editShippingAction() ->setSuccessUrl(Mage::getUrl('*/*/editShippingPost', ['id' => $this->getRequest()->getParam('id')])) ->setErrorUrl(Mage::getUrl('*/*/*')); - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { @@ -124,8 +126,9 @@ public function newBillingAction() ->setErrorUrl(Mage::getUrl('*/*/*')) ->setBackUrl(Mage::getUrl('*/*/selectBilling')); - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } } @@ -142,8 +145,9 @@ public function editAddressAction() ->setErrorUrl(Mage::getUrl('*/*/*', ['id' => $this->getRequest()->getParam('id')])) ->setBackUrl(Mage::getUrl('*/*/selectBilling')); - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } } @@ -162,8 +166,10 @@ public function editBillingAction() ->setSuccessUrl(Mage::getUrl('*/*/saveBilling', ['id' => $this->getRequest()->getParam('id')])) ->setErrorUrl(Mage::getUrl('*/*/*', ['id' => $this->getRequest()->getParam('id')])) ->setBackUrl(Mage::getUrl('*/multishipping/overview')); - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle($addressForm->getTitle() . ' - ' . $headBlock->getDefaultTitle()); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } } diff --git a/app/code/core/Mage/Checkout/controllers/OnepageController.php b/app/code/core/Mage/Checkout/controllers/OnepageController.php index 780a42a6179..135e4fc1be7 100644 --- a/app/code/core/Mage/Checkout/controllers/OnepageController.php +++ b/app/code/core/Mage/Checkout/controllers/OnepageController.php @@ -202,7 +202,12 @@ public function indexAction() $this->getOnepage()->initCheckout(); $this->loadLayout(); $this->_initLayoutMessages('customer/session'); - $this->getLayout()->getBlock('head')->setTitle($this->__('Checkout')); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Checkout')); + } + $this->renderLayout(); } diff --git a/app/code/core/Mage/Cms/Block/Page.php b/app/code/core/Mage/Cms/Block/Page.php index 8d2606e7fd6..f8b57a692cf 100644 --- a/app/code/core/Mage/Cms/Block/Page.php +++ b/app/code/core/Mage/Cms/Block/Page.php @@ -89,8 +89,7 @@ protected function _prepareLayout() $root->addBodyClass('cms-' . $page->getIdentifier()); } - /** @var Mage_Page_Block_Html_Head $head */ - $head = $this->getLayout()->getBlock('head'); + $head = $this->getLayout()->getBlockHead(); if ($head) { $head->setTitle($page->getTitle()); $head->setKeywords($page->getMetaKeywords()); diff --git a/app/code/core/Mage/Core/Controller/Varien/Action.php b/app/code/core/Mage/Core/Controller/Varien/Action.php index 4c0ed4887f6..d6579bf5b6d 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Action.php +++ b/app/code/core/Mage/Core/Controller/Varien/Action.php @@ -979,16 +979,16 @@ protected function _title($text = null, $resetIfExists = true) protected function _renderTitles() { if ($this->_isLayoutLoaded && $this->_titles) { - $titleBlock = $this->getLayout()->getBlock('head'); - if ($titleBlock) { + $head = $this->getLayout()->getBlockHead(); + if ($head) { if (!$this->_removeDefaultTitle) { - $title = trim($titleBlock->getTitle()); + $title = trim($head->getTitle()); if ($title) { array_unshift($this->_titles, $title); } } - $titleBlock->setTitle(implode(' / ', array_reverse($this->_titles))); + $head->setTitle(implode(' / ', array_reverse($this->_titles))); } } } diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 3c81706a903..292d47e47f0 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -547,6 +547,21 @@ public function getBlock($name) return $this->_blocks[$name] ?? false; } + public function getBlockBreadcrumbs(): Mage_Adminhtml_Block_Widget_Breadcrumbs|false + { + return $this->getBlock('head'); + } + + public function getBlockHead(): Mage_Page_Block_Html_Head|false + { + return $this->getBlock('head'); + } + + public function getBlockHeadAdminhtml(): Mage_Adminhtml_Block_Page_Head|false + { + return $this->getBlock('head'); + } + /** * Add a block to output * diff --git a/app/code/core/Mage/Customer/Block/Address/Book.php b/app/code/core/Mage/Customer/Block/Address/Book.php index f53f15d7322..3ec91b00d25 100644 --- a/app/code/core/Mage/Customer/Block/Address/Book.php +++ b/app/code/core/Mage/Customer/Block/Address/Book.php @@ -22,8 +22,10 @@ class Mage_Customer_Block_Address_Book extends Mage_Core_Block_Template */ protected function _prepareLayout() { - $this->getLayout()->getBlock('head') - ->setTitle(Mage::helper('customer')->__('Address Book')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('customer')->__('Address Book')); + } return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Customer/Block/Address/Edit.php b/app/code/core/Mage/Customer/Block/Address/Edit.php index b4e1a97ac87..7197c11c345 100644 --- a/app/code/core/Mage/Customer/Block/Address/Edit.php +++ b/app/code/core/Mage/Customer/Block/Address/Edit.php @@ -49,8 +49,9 @@ protected function _prepareLayout() ->setSuffix($this->getCustomer()->getSuffix()); } - if ($headBlock = $this->getLayout()->getBlock('head')) { - $headBlock->setTitle($this->getTitle()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->getTitle()); } if ($postedData = Mage::getSingleton('customer/session')->getAddressFormData(true)) { diff --git a/app/code/core/Mage/Customer/Block/Form/Register.php b/app/code/core/Mage/Customer/Block/Form/Register.php index ff2a0ae6bcb..075980abeff 100644 --- a/app/code/core/Mage/Customer/Block/Form/Register.php +++ b/app/code/core/Mage/Customer/Block/Form/Register.php @@ -31,7 +31,11 @@ class Mage_Customer_Block_Form_Register extends Mage_Directory_Block_Data */ protected function _prepareLayout() { - $this->getLayout()->getBlock('head')->setTitle(Mage::helper('customer')->__('Create New Customer Account')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('customer')->__('Create New Customer Account')); + } + return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php index 88f348e7ebd..e8c806d232d 100644 --- a/app/code/core/Mage/Customer/controllers/AccountController.php +++ b/app/code/core/Mage/Customer/controllers/AccountController.php @@ -102,7 +102,12 @@ public function indexAction() $this->getLayout()->getBlock('content')->append( $this->getLayout()->createBlock('customer/account_dashboard'), ); - $this->getLayout()->getBlock('head')->setTitle($this->__('My Account')); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('My Account')); + } + $this->renderLayout(); } @@ -120,7 +125,12 @@ public function loginAction() $this->loadLayout(); $this->_initLayoutMessages('customer/session'); $this->_initLayoutMessages('catalog/session'); - $this->getLayout()->getBlock('head')->setTitle($this->__('Customer Login')); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Customer Login')); + } + $this->renderLayout(); } @@ -976,7 +986,11 @@ public function editAction() $customer->setChangePassword(1); } - $this->getLayout()->getBlock('head')->setTitle($this->__('Account Information')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Account Information')); + } + $this->getLayout()->getBlock('messages')->setEscapeMessageFlag(true); $this->renderLayout(); } diff --git a/app/code/core/Mage/Downloadable/controllers/CustomerController.php b/app/code/core/Mage/Downloadable/controllers/CustomerController.php index 2cac2326938..75202adccaa 100644 --- a/app/code/core/Mage/Downloadable/controllers/CustomerController.php +++ b/app/code/core/Mage/Downloadable/controllers/CustomerController.php @@ -41,9 +41,9 @@ public function productsAction() $block->setRefererUrl($this->_getRefererUrl()); } - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle(Mage::helper('downloadable')->__('My Downloadable Products')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('downloadable')->__('My Downloadable Products')); } $this->renderLayout(); diff --git a/app/code/core/Mage/Newsletter/controllers/ManageController.php b/app/code/core/Mage/Newsletter/controllers/ManageController.php index c470c40d6e6..a87eae11d51 100644 --- a/app/code/core/Mage/Newsletter/controllers/ManageController.php +++ b/app/code/core/Mage/Newsletter/controllers/ManageController.php @@ -39,7 +39,11 @@ public function indexAction() $block->setRefererUrl($this->_getRefererUrl()); } - $this->getLayout()->getBlock('head')->setTitle($this->__('Newsletter Subscription')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Newsletter Subscription')); + } + $this->renderLayout(); } diff --git a/app/code/core/Mage/Review/controllers/CustomerController.php b/app/code/core/Mage/Review/controllers/CustomerController.php index dbdb6f184d9..628d35cd4d5 100644 --- a/app/code/core/Mage/Review/controllers/CustomerController.php +++ b/app/code/core/Mage/Review/controllers/CustomerController.php @@ -64,7 +64,10 @@ public function indexAction() $block->setRefererUrl($this->_getRefererUrl()); } - $this->getLayout()->getBlock('head')->setTitle($this->__('My Product Reviews')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('My Product Reviews')); + } $this->renderLayout(); } @@ -82,7 +85,11 @@ public function viewAction() $navigationBlock->setActive('review/customer'); } - $this->getLayout()->getBlock('head')->setTitle($this->__('Review Details')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Review Details')); + } + $this->renderLayout(); } } diff --git a/app/code/core/Mage/Rss/Block/List.php b/app/code/core/Mage/Rss/Block/List.php index 12e7bbe5867..ece91b12358 100644 --- a/app/code/core/Mage/Rss/Block/List.php +++ b/app/code/core/Mage/Rss/Block/List.php @@ -26,12 +26,13 @@ class Mage_Rss_Block_List extends Mage_Core_Block_Template */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $head */ - $head = $this->getLayout()->getBlock('head'); - $feeds = $this->getRssMiscFeeds(); - if ($head && !empty($feeds)) { - foreach ($feeds as $feed) { - $head->addItem('rss', $feed['url'], 'title="' . $feed['label'] . '"'); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $feeds = $this->getRssMiscFeeds(); + if (!empty($feeds)) { + foreach ($feeds as $feed) { + $head->addItem('rss', $feed['url'], 'title="' . $feed['label'] . '"'); + } } } diff --git a/app/code/core/Mage/Sales/Block/Order/Creditmemo.php b/app/code/core/Mage/Sales/Block/Order/Creditmemo.php index 4dfc7722afe..7fd5df5a8f1 100644 --- a/app/code/core/Mage/Sales/Block/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Block/Order/Creditmemo.php @@ -25,10 +25,9 @@ protected function _construct() */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/Info.php b/app/code/core/Mage/Sales/Block/Order/Info.php index 0e41f3c0819..58a25d5891d 100644 --- a/app/code/core/Mage/Sales/Block/Order/Info.php +++ b/app/code/core/Mage/Sales/Block/Order/Info.php @@ -27,10 +27,9 @@ protected function _construct() */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/Invoice.php b/app/code/core/Mage/Sales/Block/Order/Invoice.php index 23cb0629619..b2babe8e279 100644 --- a/app/code/core/Mage/Sales/Block/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Block/Order/Invoice.php @@ -25,10 +25,9 @@ protected function _construct() */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/Print.php b/app/code/core/Mage/Sales/Block/Order/Print.php index 9569cca8164..9e7da40a620 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print.php +++ b/app/code/core/Mage/Sales/Block/Order/Print.php @@ -19,10 +19,9 @@ class Mage_Sales_Block_Order_Print extends Mage_Sales_Block_Items_Abstract */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Print Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Print Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php b/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php index 3dbf346bc48..a95ae030bea 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php +++ b/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php @@ -19,10 +19,9 @@ class Mage_Sales_Block_Order_Print_Creditmemo extends Mage_Sales_Block_Items_Abs */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php b/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php index 5a732ed677a..2b648f1d317 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php +++ b/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php @@ -19,10 +19,9 @@ class Mage_Sales_Block_Order_Print_Invoice extends Mage_Sales_Block_Items_Abstra */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php b/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php index 76050b3426c..d6c55789415 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php +++ b/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php @@ -57,10 +57,9 @@ protected function _beforeToHtml() */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/Shipment.php b/app/code/core/Mage/Sales/Block/Order/Shipment.php index a617f67231d..3c3aae85b34 100644 --- a/app/code/core/Mage/Sales/Block/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Block/Order/Shipment.php @@ -25,10 +25,9 @@ protected function _construct() */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/Block/Order/View.php b/app/code/core/Mage/Sales/Block/Order/View.php index 7d5d2a9ed5c..98a02ebffd8 100644 --- a/app/code/core/Mage/Sales/Block/Order/View.php +++ b/app/code/core/Mage/Sales/Block/Order/View.php @@ -25,10 +25,9 @@ protected function _construct() */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Head $headBlock */ - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); } /** @var Mage_Payment_Helper_Data $helper */ diff --git a/app/code/core/Mage/Sales/controllers/OrderController.php b/app/code/core/Mage/Sales/controllers/OrderController.php index 5aac4ac668f..e4f38b98b6c 100644 --- a/app/code/core/Mage/Sales/controllers/OrderController.php +++ b/app/code/core/Mage/Sales/controllers/OrderController.php @@ -40,7 +40,10 @@ public function historyAction() $this->loadLayout(); $this->_initLayoutMessages('catalog/session'); - $this->getLayout()->getBlock('head')->setTitle($this->__('My Orders')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('My Orders')); + } if ($block = $this->getLayout()->getBlock('customer.account.link.back')) { $block->setRefererUrl($this->_getRefererUrl()); diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index 9cf2873f73a..7c981dfcd53 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -35,7 +35,12 @@ public function getTag() protected function _prepareLayout() { $title = $this->getHeaderText(); - $this->getLayout()->getBlock('head')->setTitle($title); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($title); + } + $this->getLayout()->getBlock('root')->setHeaderTitle($title); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Tag/controllers/CustomerController.php b/app/code/core/Mage/Tag/controllers/CustomerController.php index 26f477e26d9..ba419adbba5 100644 --- a/app/code/core/Mage/Tag/controllers/CustomerController.php +++ b/app/code/core/Mage/Tag/controllers/CustomerController.php @@ -53,7 +53,10 @@ public function indexAction() $block->setRefererUrl($this->_getRefererUrl()); } - $this->getLayout()->getBlock('head')->setTitle(Mage::helper('tag')->__('My Tags')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('tag')->__('My Tags')); + } $this->renderLayout(); } @@ -76,7 +79,11 @@ public function viewAction() } $this->_initLayoutMessages('checkout/session'); - $this->getLayout()->getBlock('head')->setTitle(Mage::helper('tag')->__('My Tags')); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle(Mage::helper('tag')->__('My Tags')); + } $this->renderLayout(); } else { $this->_forward('noRoute'); diff --git a/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php b/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php index 867b94beec9..be3218646dd 100644 --- a/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php +++ b/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php @@ -28,9 +28,9 @@ class Mage_Wishlist_Block_Customer_Sharing extends Mage_Core_Block_Template */ protected function _prepareLayout() { - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('Wishlist Sharing')); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('Wishlist Sharing')); } return $this; diff --git a/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php b/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php index bc936a2322b..1530ee64054 100644 --- a/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php +++ b/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php @@ -39,9 +39,10 @@ protected function _prepareCollection($collection) protected function _prepareLayout() { parent::_prepareLayout(); - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->__('My Wishlist')); + + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->__('My Wishlist')); } return $this; diff --git a/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php b/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php index 374e2628638..f6fcc8a5afb 100644 --- a/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php +++ b/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php @@ -31,9 +31,9 @@ protected function _prepareLayout() { parent::_prepareLayout(); - $headBlock = $this->getLayout()->getBlock('head'); - if ($headBlock) { - $headBlock->setTitle($this->getHeader()); + $head = $this->getLayout()->getBlockHead(); + if ($head) { + $head->setTitle($this->getHeader()); } return $this; From 873a5de9f5ce4ba9e0a8fbabfe928f41629e57bd Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 15 Oct 2025 22:14:13 +0200 Subject: [PATCH 02/13] check for correct block --- .../Block/Catalog/Category/Tab/Attributes.php | 2 +- .../Catalog/Product/Edit/Tab/Attributes.php | 2 +- .../Adminhtml/Block/Cms/Block/Edit/Form.php | 2 +- .../Block/Cms/Page/Edit/Tab/Content.php | 2 +- .../Adminhtml/Block/Newsletter/Queue/Edit.php | 2 +- .../Block/Newsletter/Template/Edit.php | 2 +- .../core/Mage/Adminhtml/Block/Page/Menu.php | 2 ++ .../System/Convert/Gui/Edit/Tab/Wizard.php | 2 +- app/code/core/Mage/Adminhtml/Block/Widget.php | 7 ++-- .../Block/Widget/Grid/Column/Filter/Date.php | 2 +- .../core/Mage/Adminhtml/Controller/Action.php | 16 ++++++--- .../controllers/Api/RoleController.php | 2 +- .../Catalog/CategoryController.php | 2 +- .../Catalog/Product/ReviewController.php | 2 +- .../Catalog/Product/SetController.php | 2 +- .../controllers/Catalog/ProductController.php | 4 +-- .../controllers/Catalog/SearchController.php | 2 +- .../Permissions/RoleController.php | 2 +- .../controllers/System/ConfigController.php | 7 ++-- .../controllers/System/DesignController.php | 2 +- .../controllers/UrlrewriteController.php | 2 +- .../core/Mage/Catalog/Block/Breadcrumbs.php | 9 +++-- .../controllers/CategoryController.php | 3 +- .../CatalogSearch/Block/Advanced/Form.php | 4 +-- .../CatalogSearch/Block/Advanced/Result.php | 3 +- .../core/Mage/CatalogSearch/Block/Result.php | 4 +-- .../controllers/OnepageController.php | 7 +++- app/code/core/Mage/Cms/Block/Page.php | 6 ++-- app/code/core/Mage/Core/Model/Layout.php | 21 +++++++++-- app/code/core/Mage/Page/Helper/Layout.php | 16 ++++----- .../Paypal/Controller/Express/Abstract.php | 9 +++-- .../Review/controllers/ProductController.php | 12 +++---- app/code/core/Mage/Sales/Helper/Guest.php | 35 ++++++++++--------- .../core/Mage/Tag/Block/Product/Result.php | 6 +++- 34 files changed, 114 insertions(+), 89 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php index ed30f5399c6..61305e1363f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php @@ -41,7 +41,7 @@ protected function _prepareLayout() { parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php index 8cae8fd7fe9..cd85b1e6ffb 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php @@ -23,7 +23,7 @@ protected function _prepareLayout() if ($this->isModuleEnabled('Mage_Cms', 'catalog') && Mage::getSingleton('cms/wysiwyg_config')->isEnabled() ) { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php index fb5d24849d0..fdb10e53577 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php @@ -31,7 +31,7 @@ protected function _prepareLayout() { parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php index 18cf00a2e4f..945aa34b0af 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php @@ -21,7 +21,7 @@ protected function _prepareLayout() { parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php index 4b6ac52d5b4..764c76dcac0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php @@ -73,7 +73,7 @@ protected function _prepareLayout() { // Load Wysiwyg on demand and Prepare layout if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php index 3a6028e3954..04cefdfccc0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php @@ -38,7 +38,7 @@ protected function _prepareLayout() { // Load Wysiwyg on demand and Prepare layout if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php index 91e1e41abc3..b6fb5083e51 100644 --- a/app/code/core/Mage/Adminhtml/Block/Page/Menu.php +++ b/app/code/core/Mage/Adminhtml/Block/Page/Menu.php @@ -12,6 +12,8 @@ * * @package Mage_Adminhtml * + * @method $this setActive(string $menuPath) + * @method string getActive() * @method $this setAdditionalCacheKeyInfo(array $cacheKeyInfo) * @method array getAdditionalCacheKeyInfo() */ diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php index 646f17c068c..be2057442ea 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php @@ -43,7 +43,7 @@ public function __construct() */ protected function _prepareLayout() { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadCalendarJs(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Widget.php b/app/code/core/Mage/Adminhtml/Block/Widget.php index cc6c2b8f88c..b0690baa4a6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget.php @@ -54,9 +54,10 @@ public function getCurrentUrl($params = []) protected function _addBreadcrumb($label, $title = null, $link = null) { - /** @var Mage_Adminhtml_Block_Widget_Breadcrumbs $block */ - $block = $this->getLayout()->getBlock('breadcrumbs'); - $block->addLink($label, $title, $link); + $block = $this->getLayout()->getBlockAdminhtmlBreadcrumbs(); + if ($block) { + $block->addLink($label, $title, $link); + } } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php index d99d1ad686c..9192554123e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php @@ -22,7 +22,7 @@ class Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date extends Mage_Adminhtml */ protected function _prepareLayout() { - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadCalendarJs(true); } diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php index 375e1cc72ef..66a33f37407 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Action.php +++ b/app/code/core/Mage/Adminhtml/Controller/Action.php @@ -98,9 +98,13 @@ protected function _getHelper() * * @return $this */ - protected function _setActiveMenu($menuPath) + protected function _setActiveMenu(string $menuPath) { - $this->getLayout()->getBlock('menu')->setActive($menuPath); + $block = $this->getLayout()->getBlockAdminhtmlMenu(); + if ($block) { + $block->setActive($menuPath); + } + return $this; } @@ -109,9 +113,11 @@ protected function _setActiveMenu($menuPath) */ protected function _addBreadcrumb($label, $title, $link = null) { - /** @var Mage_Adminhtml_Block_Widget_Breadcrumbs $block */ - $block = $this->getLayout()->getBlock('breadcrumbs'); - $block->addLink($label, $title, $link); + $block = $this->getLayout()->getBlockAdminhtmlBreadcrumbs(); + if ($block) { + $block->addLink($label, $title, $link); + } + return $this; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php index 4009b0fb379..f1b2ca0cef4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php @@ -83,7 +83,7 @@ public function editRoleAction() $this->_addBreadcrumb($breadCrumb, $breadCrumbTitle); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadExtJs(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php index 9ba11448764..408c38b76cf 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/CategoryController.php @@ -184,7 +184,7 @@ public function editAction() $this->loadLayout(); $this->_setActiveMenu('catalog/categories'); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadExtJs(true); $head->setContainerCssClass('catalog-categories'); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php index 1d18c948de9..77134ea9f65 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php @@ -105,7 +105,7 @@ public function newAction() $this->loadLayout(); $this->_setActiveMenu('catalog/reviews_ratings/reviews/all'); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php index 18caf59b1a7..2f5ea945fa1 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php @@ -65,7 +65,7 @@ public function editAction() $this->loadLayout(); $this->_setActiveMenu('catalog/attributes/sets'); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index 88f4d7c87e4..17595ddf1ab 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -215,7 +215,7 @@ public function newAction() $this->_setActiveMenu('catalog/products'); } - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadExtJs(true); } @@ -271,7 +271,7 @@ public function editAction() ); } - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadExtJs(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php index 187e13cbc1a..addc27da7c6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php @@ -70,7 +70,7 @@ public function editAction() $this->_title($id ? $model->getQueryText() : $this->__('New Search')); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadRulesJs(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php index d106853aded..5d95304d224 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php @@ -109,7 +109,7 @@ public function editRoleAction() $this->_addBreadcrumb($breadCrumb, $breadCrumbTitle); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php index 33bc2f15b17..de73d7f9b71 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php @@ -85,9 +85,10 @@ public function editAction() $this->_setActiveMenu('system/config'); - /** @var Mage_Adminhtml_Block_Page_Menu $block */ - $block = $this->getLayout()->getBlock('menu'); - $block->setAdditionalCacheKeyInfo([$current]); + $block = $this->getLayout()->getBlockAdminhtmlMenu(); + if ($block) { + $block->setAdditionalCacheKeyInfo([$current]); + } $this->_addBreadcrumb( Mage::helper('adminhtml')->__('System'), diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index b0e2cf685ba..f5fef6408b5 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -56,7 +56,7 @@ public function editAction() $this->loadLayout(); $this->_setActiveMenu('system/design'); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadTinyMce(true); } diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php index 780fe7e99a0..3dacb75914d 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -77,7 +77,7 @@ public function editAction() $this->_setActiveMenu('catalog/urlrewrite'); $this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit')); - $head = $this->getLayout()->getBlockHeadAdminhtml(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { $head->setCanLoadExtJs(true); } diff --git a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php index 40723a4dd6a..85b8ea49968 100644 --- a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php +++ b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php @@ -33,10 +33,9 @@ public function getTitleSeparator($store = null) */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbsBlock */ - $breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'); - if ($breadcrumbsBlock) { - $breadcrumbsBlock->addCrumb('home', [ + $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); + if ($breadcrumbs) { + $breadcrumbs->addCrumb('home', [ 'label' => Mage::helper('catalog')->__('Home'), 'title' => Mage::helper('catalog')->__('Go to Home Page'), 'link' => Mage::getBaseUrl(), @@ -46,7 +45,7 @@ protected function _prepareLayout() $path = Mage::helper('catalog')->getBreadcrumbPath(); foreach ($path as $name => $breadcrumb) { - $breadcrumbsBlock->addCrumb($name, $breadcrumb); + $breadcrumbs->addCrumb($name, $breadcrumb); $title[] = $breadcrumb['label']; } diff --git a/app/code/core/Mage/Catalog/controllers/CategoryController.php b/app/code/core/Mage/Catalog/controllers/CategoryController.php index d6197f7eb71..d76ab8e6dcb 100644 --- a/app/code/core/Mage/Catalog/controllers/CategoryController.php +++ b/app/code/core/Mage/Catalog/controllers/CategoryController.php @@ -149,8 +149,7 @@ public function viewAction() $this->getLayout()->helper('page/layout')->applyTemplate($settings->getPageLayout()); } - /** @var Mage_Page_Block_Html $root */ - $root = $this->getLayout()->getBlock('root'); + $root = $this->getLayout()->getBlockRoot(); if ($root) { $root->addBodyClass('categorypath-' . $category->getUrlPath()) ->addBodyClass('category-' . $category->getUrlKey()); diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php index 1537449ccef..b9002620cea 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php @@ -19,9 +19,7 @@ class Mage_CatalogSearch_Block_Advanced_Form extends Mage_Core_Block_Template */ public function _prepareLayout() { - // add Home breadcrumb - /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ - $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); + $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); if ($breadcrumbs) { $breadcrumbs->addCrumb('home', [ 'label' => Mage::helper('catalogsearch')->__('Home'), diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php index d420e5cc822..153e37ade5a 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php @@ -21,8 +21,7 @@ class Mage_CatalogSearch_Block_Advanced_Result extends Mage_Core_Block_Template */ protected function _prepareLayout() { - /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ - $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); + $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); if ($breadcrumbs) { $breadcrumbs->addCrumb('home', [ 'label' => Mage::helper('catalogsearch')->__('Home'), diff --git a/app/code/core/Mage/CatalogSearch/Block/Result.php b/app/code/core/Mage/CatalogSearch/Block/Result.php index 1a80460020d..5258ce0c51d 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Result.php @@ -46,9 +46,7 @@ protected function _prepareLayout() /** @var Mage_CatalogSearch_Helper_Data $helper */ $helper = $this->helper('catalogsearch'); - // add Home breadcrumb - /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ - $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); + $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); if ($breadcrumbs) { $title = $this->__("Search results for: '%s'", $helper->getQueryText()); diff --git a/app/code/core/Mage/Checkout/controllers/OnepageController.php b/app/code/core/Mage/Checkout/controllers/OnepageController.php index 135e4fc1be7..5c9ff533449 100644 --- a/app/code/core/Mage/Checkout/controllers/OnepageController.php +++ b/app/code/core/Mage/Checkout/controllers/OnepageController.php @@ -157,7 +157,12 @@ protected function _getAdditionalHtml() */ protected function _getReviewHtml() { - return $this->getLayout()->getBlock('root')->toHtml(); + $root = $this->getLayout()->getBlockRoot(); + if ($root) { + return $root->toHtml(); + } + + return ''; } /** diff --git a/app/code/core/Mage/Cms/Block/Page.php b/app/code/core/Mage/Cms/Block/Page.php index f8b57a692cf..61ef698e93f 100644 --- a/app/code/core/Mage/Cms/Block/Page.php +++ b/app/code/core/Mage/Cms/Block/Page.php @@ -48,11 +48,10 @@ protected function _prepareLayout() { $page = $this->getPage(); $breadcrumbsArray = []; - $breadcrumbs = null; // show breadcrumbs if (Mage::getStoreConfig('web/default/show_cms_breadcrumbs') - && ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) + && ($breadcrumbs = $this->getLayout()->getBlockBreadcrumbs()) && ($page->getIdentifier() !== Mage::getStoreConfig('web/default/cms_home_page')) && ($page->getIdentifier() !== Mage::getStoreConfig('web/default/cms_no_route')) ) { @@ -83,8 +82,7 @@ protected function _prepareLayout() } } - /** @var Mage_Page_Block_Html $root */ - $root = $this->getLayout()->getBlock('root'); + $root = $this->getLayout()->getBlockRoot(); if ($root) { $root->addBodyClass('cms-' . $page->getIdentifier()); } diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 292d47e47f0..a4429b0f150 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -547,19 +547,34 @@ public function getBlock($name) return $this->_blocks[$name] ?? false; } - public function getBlockBreadcrumbs(): Mage_Adminhtml_Block_Widget_Breadcrumbs|false + public function getBlockAdminhtmlBreadcrumbs(): Mage_Adminhtml_Block_Widget_Breadcrumbs|false + { + return $this->getBlock('breadcrumbs'); + } + + public function getBlockAdminhtmlHead(): Mage_Adminhtml_Block_Page_Head|false { return $this->getBlock('head'); } + public function getBlockAdminhtmlMenu(): Mage_Adminhtml_Block_Page_Menu|false + { + return $this->getBlock('menu'); + } + + public function getBlockBreadcrumbs(): Mage_Page_Block_Html_Breadcrumbs|false + { + return $this->getBlock('breadcrumbs'); + } + public function getBlockHead(): Mage_Page_Block_Html_Head|false { return $this->getBlock('head'); } - public function getBlockHeadAdminhtml(): Mage_Adminhtml_Block_Page_Head|false + public function getBlockRoot(): Mage_Page_Block_Html|false { - return $this->getBlock('head'); + return $this->getBlock('root'); } /** diff --git a/app/code/core/Mage/Page/Helper/Layout.php b/app/code/core/Mage/Page/Helper/Layout.php index b3e305bd733..9a4ebc6cbe5 100644 --- a/app/code/core/Mage/Page/Helper/Layout.php +++ b/app/code/core/Mage/Page/Helper/Layout.php @@ -56,13 +56,10 @@ public function applyTemplate($pageLayout = null) return $this; } - if ($this->getLayout()->getBlock('root') && - !$this->getLayout()->getBlock('root')->getIsHandle() - ) { + $root = $this->getLayout()->getBlockRoot(); + if ($root && !$root->getIsHandle()) { // If not applied handle - $this->getLayout() - ->getBlock('root') - ->setTemplate($pageLayout->getTemplate()); + $root->setTemplate($pageLayout->getTemplate()); } return $this; @@ -75,10 +72,9 @@ public function applyTemplate($pageLayout = null) */ public function getCurrentPageLayout() { - if ($this->getLayout()->getBlock('root') && - $this->getLayout()->getBlock('root')->getLayoutCode() - ) { - return $this->_getConfig()->getPageLayout($this->getLayout()->getBlock('root')->getLayoutCode()); + $root = $this->getLayout()->getBlockRoot(); + if ($root && $root->getLayoutCode()) { + return $this->_getConfig()->getPageLayout($root->getLayoutCode()); } // All loaded handles diff --git a/app/code/core/Mage/Paypal/Controller/Express/Abstract.php b/app/code/core/Mage/Paypal/Controller/Express/Abstract.php index 94abdd6df11..3ea5b70b3a2 100644 --- a/app/code/core/Mage/Paypal/Controller/Express/Abstract.php +++ b/app/code/core/Mage/Paypal/Controller/Express/Abstract.php @@ -264,9 +264,12 @@ public function saveShippingMethodAction() $this->_checkout->updateShippingMethod($this->getRequest()->getParam('shipping_method')); if ($isAjax) { $this->loadLayout('paypal_express_review_details'); - $this->getResponse()->setBody($this->getLayout()->getBlock('root') - ->setQuote($this->_getQuote()) - ->toHtml()); + + $root = $this->getLayout()->getBlockRoot(); + if ($root) { + $this->getResponse()->setBody($root->setQuote($this->_getQuote())->toHtml()); + } + return; } } catch (Mage_Core_Exception $e) { diff --git a/app/code/core/Mage/Review/controllers/ProductController.php b/app/code/core/Mage/Review/controllers/ProductController.php index 2269f38dbb8..950e81281eb 100644 --- a/app/code/core/Mage/Review/controllers/ProductController.php +++ b/app/code/core/Mage/Review/controllers/ProductController.php @@ -223,16 +223,16 @@ public function listAction() $this->_initProductLayout($product); - // update breadcrumbs - /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbsBlock */ - $breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs'); - if ($breadcrumbsBlock) { - $breadcrumbsBlock->addCrumb('product', [ + $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); + if ($breadcrumbs) { + $breadcrumbs->addCrumb('product', [ 'label' => $product->getName(), 'link' => $product->getProductUrl(), 'readonly' => true, ]); - $breadcrumbsBlock->addCrumb('reviews', ['label' => Mage::helper('review')->__('Product Reviews')]); + $breadcrumbs->addCrumb('reviews', [ + 'label' => Mage::helper('review')->__('Product Reviews') + ]); } $this->renderLayout(); diff --git a/app/code/core/Mage/Sales/Helper/Guest.php b/app/code/core/Mage/Sales/Helper/Guest.php index 87333408882..4cd58ff9f3c 100644 --- a/app/code/core/Mage/Sales/Helper/Guest.php +++ b/app/code/core/Mage/Sales/Helper/Guest.php @@ -124,23 +124,24 @@ public function loadValidOrder() */ public function getBreadcrumbs($controller) { - /** @var Mage_Page_Block_Html_Breadcrumbs $breadcrumbs */ - $breadcrumbs = $controller->getLayout()->getBlock('breadcrumbs'); - $breadcrumbs->addCrumb( - 'home', - [ - 'label' => $this->__('Home'), - 'title' => $this->__('Go to Home Page'), - 'link' => Mage::getBaseUrl(), - ], - ); - $breadcrumbs->addCrumb( - 'cms_page', - [ - 'label' => $this->__('Order Information'), - 'title' => $this->__('Order Information'), - ], - ); + $breadcrumbs = $controller->getLayout()->getBlockBreadcrumbs(); + if ($breadcrumbs) { + $breadcrumbs->addCrumb( + 'home', + [ + 'label' => $this->__('Home'), + 'title' => $this->__('Go to Home Page'), + 'link' => Mage::getBaseUrl(), + ], + ); + $breadcrumbs->addCrumb( + 'cms_page', + [ + 'label' => $this->__('Order Information'), + 'title' => $this->__('Order Information'), + ], + ); + } } /** diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index 7c981dfcd53..9a3dde5390b 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -41,7 +41,11 @@ protected function _prepareLayout() $head->setTitle($title); } - $this->getLayout()->getBlock('root')->setHeaderTitle($title); + $root = $this->getLayout()->getBlockRoot(); + if ($root) { + $root->setHeaderTitle($title); + } + return parent::_prepareLayout(); } From 2d6b372204dbdf99233616ec29ab72d0b1a6b7f3 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 15 Oct 2025 22:22:47 +0200 Subject: [PATCH 03/13] typos --- .../Adminhtml/controllers/Catalog/Product/ReviewController.php | 2 +- .../Adminhtml/controllers/Catalog/Product/SetController.php | 2 +- .../Mage/Adminhtml/controllers/Permissions/RoleController.php | 2 +- .../core/Mage/Adminhtml/controllers/System/DesignController.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php index 77134ea9f65..ca5743d7d75 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php @@ -107,7 +107,7 @@ public function newAction() $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { - $head->setCanLoadTinyMce(true); + $head->setCanLoadExtJs(true); } $this->_addContent($this->getLayout()->createBlock('adminhtml/review_add')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php index 2f5ea945fa1..28ba09872f7 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php @@ -67,7 +67,7 @@ public function editAction() $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { - $head->setCanLoadTinyMce(true); + $head->setCanLoadExtJs(true); } $this->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php index 5d95304d224..895315adf32 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php @@ -111,7 +111,7 @@ public function editRoleAction() $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { - $head->setCanLoadTinyMce(true); + $head->setCanLoadExtJs(true); } $this->_addContent( diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index f5fef6408b5..f71a7213b03 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -58,7 +58,7 @@ public function editAction() $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { - $head->setCanLoadTinyMce(true); + $head->setCanLoadExtJs(true); } $id = (int) $this->getRequest()->getParam('id'); From 5613451a2c206cbbcb6cca6e5ad817986b3d77d1 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 15 Oct 2025 22:26:39 +0200 Subject: [PATCH 04/13] phpcs-fixer --- app/code/core/Mage/Review/controllers/ProductController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Review/controllers/ProductController.php b/app/code/core/Mage/Review/controllers/ProductController.php index 950e81281eb..d1234ba7933 100644 --- a/app/code/core/Mage/Review/controllers/ProductController.php +++ b/app/code/core/Mage/Review/controllers/ProductController.php @@ -231,7 +231,7 @@ public function listAction() 'readonly' => true, ]); $breadcrumbs->addCrumb('reviews', [ - 'label' => Mage::helper('review')->__('Product Reviews') + 'label' => Mage::helper('review')->__('Product Reviews'), ]); } From 64c2654db62ce4b9baf506527b99fab353fabe45 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 20 Oct 2025 10:05:07 +0200 Subject: [PATCH 05/13] refactor --- .../Block/Catalog/Category/Tab/Attributes.php | 4 +- .../Catalog/Product/Edit/Tab/Attributes.php | 4 +- .../Adminhtml/Block/Cms/Block/Edit/Form.php | 4 +- .../Block/Cms/Page/Edit/Tab/Content.php | 4 +- .../Adminhtml/Block/Newsletter/Queue/Edit.php | 4 +- .../Block/Newsletter/Template/Edit.php | 4 +- .../System/Convert/Gui/Edit/Tab/Wizard.php | 4 +- .../Block/System/Email/Template/Edit/Form.php | 11 ++-- app/code/core/Mage/Adminhtml/Block/Widget.php | 4 +- .../Block/Widget/Grid/Column/Filter/Date.php | 4 +- .../core/Mage/Adminhtml/Controller/Action.php | 8 +-- .../controllers/Api/RoleController.php | 4 +- .../Catalog/Product/ReviewController.php | 4 +- .../Catalog/Product/SetController.php | 4 +- .../controllers/Catalog/ProductController.php | 8 +-- .../controllers/Catalog/SearchController.php | 4 +- .../Permissions/RoleController.php | 4 +- .../controllers/System/ConfigController.php | 4 +- .../controllers/System/DesignController.php | 4 +- .../controllers/UrlrewriteController.php | 4 +- .../core/Mage/Catalog/Block/Breadcrumbs.php | 4 +- .../Catalog/Block/Product/Compare/List.php | 4 +- .../Mage/Catalog/Block/Product/Gallery.php | 4 +- .../Block/Product/View/Options/Type/Date.php | 4 +- .../controllers/CategoryController.php | 4 +- .../CatalogSearch/Block/Advanced/Form.php | 5 +- .../CatalogSearch/Block/Advanced/Result.php | 10 +-- .../core/Mage/CatalogSearch/Block/Result.php | 7 +-- .../Block/Multishipping/Address/Select.php | 4 +- .../Block/Multishipping/Addresses.php | 4 +- .../Checkout/Block/Multishipping/Billing.php | 8 +-- .../Checkout/Block/Multishipping/Overview.php | 8 +-- .../Checkout/Block/Multishipping/Shipping.php | 4 +- .../Multishipping/AddressController.php | 20 ++---- .../controllers/OnepageController.php | 4 +- app/code/core/Mage/Cms/Block/Page.php | 4 +- app/code/core/Mage/Core/Model/Layout.php | 62 +++++++++++++++---- .../core/Mage/Customer/Block/Address/Book.php | 4 +- .../core/Mage/Customer/Block/Address/Edit.php | 4 +- .../Mage/Customer/Block/Form/Register.php | 4 +- .../controllers/AccountController.php | 12 +--- .../controllers/CustomerController.php | 4 +- .../controllers/ManageController.php | 4 +- .../Review/controllers/CustomerController.php | 8 +-- .../Mage/Sales/Block/Order/Creditmemo.php | 4 +- app/code/core/Mage/Sales/Block/Order/Info.php | 4 +- .../core/Mage/Sales/Block/Order/Invoice.php | 4 +- .../core/Mage/Sales/Block/Order/Print.php | 4 +- .../Sales/Block/Order/Print/Creditmemo.php | 4 +- .../Mage/Sales/Block/Order/Print/Invoice.php | 4 +- .../Mage/Sales/Block/Order/Print/Shipment.php | 4 +- .../core/Mage/Sales/Block/Order/Shipment.php | 4 +- app/code/core/Mage/Sales/Block/Order/View.php | 4 +- .../Sales/controllers/OrderController.php | 4 +- .../core/Mage/Tag/Block/Product/Result.php | 8 +-- .../Tag/controllers/CustomerController.php | 8 +-- .../Mage/Wishlist/Block/Customer/Sharing.php | 4 +- .../Mage/Wishlist/Block/Customer/Wishlist.php | 4 +- .../Mage/Wishlist/Block/Share/Wishlist.php | 4 +- 59 files changed, 137 insertions(+), 226 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php index 61305e1363f..ef5383092d8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tab/Attributes.php @@ -42,9 +42,7 @@ protected function _prepareLayout() parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadTinyMce(true); - } + $head?->setCanLoadTinyMce(true); } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php index cd85b1e6ffb..2b7d0ca94e7 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes.php @@ -24,9 +24,7 @@ protected function _prepareLayout() && Mage::getSingleton('cms/wysiwyg_config')->isEnabled() ) { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadTinyMce(true); - } + $head?->setCanLoadTinyMce(true); } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php index fdb10e53577..fed6ef20e02 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit/Form.php @@ -32,9 +32,7 @@ protected function _prepareLayout() parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadTinyMce(true); - } + $head?->setCanLoadTinyMce(true); } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php index 945aa34b0af..036b241412d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php @@ -22,9 +22,7 @@ protected function _prepareLayout() parent::_prepareLayout(); if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadTinyMce(true); - } + $head?->setCanLoadTinyMce(true); } return $this; diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php index 764c76dcac0..df32c9783c4 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php @@ -74,9 +74,7 @@ protected function _prepareLayout() // Load Wysiwyg on demand and Prepare layout if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadTinyMce(true); - } + $head?->setCanLoadTinyMce(true); } $this->setChild( diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php index 04cefdfccc0..e4220477092 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php @@ -39,9 +39,7 @@ protected function _prepareLayout() // Load Wysiwyg on demand and Prepare layout if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadTinyMce(true); - } + $head?->setCanLoadTinyMce(true); } $this->setChild( diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php index be2057442ea..90cf9295e05 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php @@ -44,9 +44,7 @@ public function __construct() protected function _prepareLayout() { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadCalendarJs(true); - } + $head?->setCanLoadCalendarJs(true); return $this; } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php index 5044e1f44f1..9a4c0875095 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php @@ -22,13 +22,12 @@ class Mage_Adminhtml_Block_System_Email_Template_Edit_Form extends Mage_Adminhtm */ protected function _prepareLayout() { - $head = $this->getLayout()->getBlockHead(); + $head = $this->getLayout()->getBlockAdminhtmlHead(); if ($head) { - $head - ->addItem('js', 'prototype/window.js') - ->addItem('js_css', 'prototype/windows/themes/default.css') - ->addCss('lib/prototype/windows/themes/magento.css') - ->addItem('js', 'mage/adminhtml/variables.js'); + $head->addItem('js', 'prototype/window.js'); + $head->addItem('js_css', 'prototype/windows/themes/default.css'); + $head->addCss('lib/prototype/windows/themes/magento.css'); + $head->addItem('js', 'mage/adminhtml/variables.js'); } return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget.php b/app/code/core/Mage/Adminhtml/Block/Widget.php index b0690baa4a6..b70d5bc48b2 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget.php @@ -55,9 +55,7 @@ public function getCurrentUrl($params = []) protected function _addBreadcrumb($label, $title = null, $link = null) { $block = $this->getLayout()->getBlockAdminhtmlBreadcrumbs(); - if ($block) { - $block->addLink($label, $title, $link); - } + $block?->addLink($label, $title, $link); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php index 9192554123e..172e931350d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php @@ -23,9 +23,7 @@ class Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Date extends Mage_Adminhtml protected function _prepareLayout() { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadCalendarJs(true); - } + $head?->setCanLoadCalendarJs(true); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Adminhtml/Controller/Action.php b/app/code/core/Mage/Adminhtml/Controller/Action.php index 66a33f37407..1691ef80b82 100644 --- a/app/code/core/Mage/Adminhtml/Controller/Action.php +++ b/app/code/core/Mage/Adminhtml/Controller/Action.php @@ -101,9 +101,7 @@ protected function _getHelper() protected function _setActiveMenu(string $menuPath) { $block = $this->getLayout()->getBlockAdminhtmlMenu(); - if ($block) { - $block->setActive($menuPath); - } + $block?->setActive($menuPath); return $this; } @@ -114,9 +112,7 @@ protected function _setActiveMenu(string $menuPath) protected function _addBreadcrumb($label, $title, $link = null) { $block = $this->getLayout()->getBlockAdminhtmlBreadcrumbs(); - if ($block) { - $block->addLink($label, $title, $link); - } + $block?->addLink($label, $title, $link); return $this; } diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php index f1b2ca0cef4..9391a979f13 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/RoleController.php @@ -84,9 +84,7 @@ public function editRoleAction() $this->_addBreadcrumb($breadCrumb, $breadCrumbTitle); $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $this->_addLeft( $this->getLayout()->createBlock('adminhtml/api_editroles'), diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php index ca5743d7d75..6e875fd3d03 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php @@ -106,9 +106,7 @@ public function newAction() $this->_setActiveMenu('catalog/reviews_ratings/reviews/all'); $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $this->_addContent($this->getLayout()->createBlock('adminhtml/review_add')); $this->_addContent($this->getLayout()->createBlock('adminhtml/review_product_grid')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php index 28ba09872f7..2739d937091 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/SetController.php @@ -66,9 +66,7 @@ public function editAction() $this->_setActiveMenu('catalog/attributes/sets'); $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $this->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog')); $this->_addBreadcrumb( diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php index 17595ddf1ab..91e728bf5bd 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php @@ -216,9 +216,7 @@ public function newAction() } $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { @@ -272,9 +270,7 @@ public function editAction() } $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $block = $this->getLayout()->getBlock('catalog.wysiwyg.js'); if ($block) { diff --git a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php index addc27da7c6..cc50b553c75 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Catalog/SearchController.php @@ -71,9 +71,7 @@ public function editAction() $this->_title($id ? $model->getQueryText() : $this->__('New Search')); $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadRulesJs(true); - } + $head?->setCanLoadRulesJs(true); $this->getLayout()->getBlock('catalog_search_edit') ->setData('action', $this->getUrl('*/catalog_search/save')); diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php index 895315adf32..bc93e760d8f 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php @@ -110,9 +110,7 @@ public function editRoleAction() $this->_addBreadcrumb($breadCrumb, $breadCrumbTitle); $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $this->_addContent( $this->getLayout()->createBlock('adminhtml/permissions_buttons') diff --git a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php index de73d7f9b71..32c3ac8918b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php @@ -86,9 +86,7 @@ public function editAction() $this->_setActiveMenu('system/config'); $block = $this->getLayout()->getBlockAdminhtmlMenu(); - if ($block) { - $block->setAdditionalCacheKeyInfo([$current]); - } + $block?->setAdditionalCacheKeyInfo([$current]); $this->_addBreadcrumb( Mage::helper('adminhtml')->__('System'), diff --git a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php index f71a7213b03..4179dcac1be 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/DesignController.php @@ -57,9 +57,7 @@ public function editAction() $this->_setActiveMenu('system/design'); $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $id = (int) $this->getRequest()->getParam('id'); $design = Mage::getModel('core/design'); diff --git a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php index 3dacb75914d..a7c35a6e562 100644 --- a/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php +++ b/app/code/core/Mage/Adminhtml/controllers/UrlrewriteController.php @@ -78,9 +78,7 @@ public function editAction() $this->_addContent($this->getLayout()->createBlock('adminhtml/urlrewrite_edit')); $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->setCanLoadExtJs(true); - } + $head?->setCanLoadExtJs(true); $this->renderLayout(); } diff --git a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php index 85b8ea49968..8921d4658ca 100644 --- a/app/code/core/Mage/Catalog/Block/Breadcrumbs.php +++ b/app/code/core/Mage/Catalog/Block/Breadcrumbs.php @@ -50,9 +50,7 @@ protected function _prepareLayout() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(implode($this->getTitleSeparator(), array_reverse($title))); - } + $head?->setTitle(implode($this->getTitleSeparator(), array_reverse($title))); } return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php index 1e12c8b77ee..44d1d2ea8d2 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php +++ b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php @@ -68,9 +68,7 @@ public function getAddToWishlistUrl($product) protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Catalog/Block/Product/Gallery.php b/app/code/core/Mage/Catalog/Block/Product/Gallery.php index d2096dfedbf..df9b50dbdea 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Gallery.php +++ b/app/code/core/Mage/Catalog/Block/Product/Gallery.php @@ -20,9 +20,7 @@ class Mage_Catalog_Block_Product_Gallery extends Mage_Core_Block_Template protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->getProduct()->getMetaTitle()); - } + $head?->setTitle($this->getProduct()->getMetaTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php b/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php index 7aa629b1744..65609683dc3 100644 --- a/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php +++ b/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Date.php @@ -29,9 +29,7 @@ class Mage_Catalog_Block_Product_View_Options_Type_Date extends Mage_Catalog_Blo protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setCanLoadCalendarJs(true); - } + $head?->setCanLoadCalendarJs(true); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Catalog/controllers/CategoryController.php b/app/code/core/Mage/Catalog/controllers/CategoryController.php index d76ab8e6dcb..af02f54e550 100644 --- a/app/code/core/Mage/Catalog/controllers/CategoryController.php +++ b/app/code/core/Mage/Catalog/controllers/CategoryController.php @@ -151,8 +151,8 @@ public function viewAction() $root = $this->getLayout()->getBlockRoot(); if ($root) { - $root->addBodyClass('categorypath-' . $category->getUrlPath()) - ->addBodyClass('category-' . $category->getUrlKey()); + $root->addBodyClass('categorypath-' . $category->getUrlPath()); + $root->addBodyClass('category-' . $category->getUrlKey()); } $this->_initLayoutMessages('catalog/session'); diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php index b9002620cea..1fc582e9b3f 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php @@ -24,8 +24,9 @@ public function _prepareLayout() $breadcrumbs->addCrumb('home', [ 'label' => Mage::helper('catalogsearch')->__('Home'), 'title' => Mage::helper('catalogsearch')->__('Go to Home Page'), - 'link' => Mage::getBaseUrl(), - ])->addCrumb('search', [ + 'link' => Mage::getBaseUrl(), + ]); + $breadcrumbs->addCrumb('search', [ 'label' => Mage::helper('catalogsearch')->__('Catalog Advanced Search'), ]); } diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php index 153e37ade5a..d16f9280209 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php @@ -26,11 +26,13 @@ protected function _prepareLayout() $breadcrumbs->addCrumb('home', [ 'label' => Mage::helper('catalogsearch')->__('Home'), 'title' => Mage::helper('catalogsearch')->__('Go to Home Page'), - 'link' => Mage::getBaseUrl(), - ])->addCrumb('search', [ + 'link' => Mage::getBaseUrl(), + ]); + $breadcrumbs->addCrumb('search', [ 'label' => Mage::helper('catalogsearch')->__('Catalog Advanced Search'), - 'link' => $this->getUrl('*/*/'), - ])->addCrumb('search_result', [ + 'link' => $this->getUrl('*/*/'), + ]); + $breadcrumbs->addCrumb('search_result', [ 'label' => Mage::helper('catalogsearch')->__('Results'), ]); } diff --git a/app/code/core/Mage/CatalogSearch/Block/Result.php b/app/code/core/Mage/CatalogSearch/Block/Result.php index 5258ce0c51d..c130169ea8d 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Result.php @@ -54,7 +54,8 @@ protected function _prepareLayout() 'label' => $this->__('Home'), 'title' => $this->__('Go to Home Page'), 'link' => Mage::getBaseUrl(), - ])->addCrumb('search', [ + ]); + $breadcrumbs->addCrumb('search', [ 'label' => $title, 'title' => $title, ]); @@ -64,9 +65,7 @@ protected function _prepareLayout() $title = $this->__("Search results for: '%s'", $helper->getEscapedQueryText()); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($title); - } + $head?->setTitle($title); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php index 2240baa1324..08926a12b59 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php @@ -20,9 +20,7 @@ class Mage_Checkout_Block_Multishipping_Address_Select extends Mage_Checkout_Blo protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php index 905da6b4983..e55baaa22cf 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php @@ -30,9 +30,7 @@ public function getCheckout() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php index 88001512e88..407adf78951 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php @@ -20,11 +20,9 @@ class Mage_Checkout_Block_Multishipping_Billing extends Mage_Payment_Block_Form_ protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle( - Mage::helper('checkout')->__('Billing Information - %s', $head->getDefaultTitle()), - ); - } + $head?->setTitle( + Mage::helper('checkout')->__('Billing Information - %s', $head->getDefaultTitle()), + ); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php index 11828d45b74..62c0206809f 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php @@ -43,11 +43,9 @@ public function getCheckout() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle( - $this->__('Review Order - %s', $head->getDefaultTitle()), - ); - } + $head?->setTitle( + $this->__('Review Order - %s', $head->getDefaultTitle()), + ); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php index b456ab0a29c..d39aa5902b8 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php @@ -30,9 +30,7 @@ public function getCheckout() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php index 55f84f9efc5..d910432ba55 100644 --- a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php +++ b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php @@ -48,9 +48,7 @@ public function newShippingAction() ->setErrorUrl(Mage::getUrl('*/*/*')); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { $addressForm->setBackUrl(Mage::getUrl('*/multishipping/addresses')); @@ -85,9 +83,7 @@ public function editShippingAction() ->setErrorUrl(Mage::getUrl('*/*/*')); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { $addressForm->setBackUrl(Mage::getUrl('*/multishipping/shipping')); @@ -127,9 +123,7 @@ public function newBillingAction() ->setBackUrl(Mage::getUrl('*/*/selectBilling')); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } $this->renderLayout(); @@ -146,9 +140,7 @@ public function editAddressAction() ->setBackUrl(Mage::getUrl('*/*/selectBilling')); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } $this->renderLayout(); @@ -168,9 +160,7 @@ public function editBillingAction() ->setBackUrl(Mage::getUrl('*/multishipping/overview')); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); - } + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } $this->renderLayout(); diff --git a/app/code/core/Mage/Checkout/controllers/OnepageController.php b/app/code/core/Mage/Checkout/controllers/OnepageController.php index 5c9ff533449..c778d44a2e1 100644 --- a/app/code/core/Mage/Checkout/controllers/OnepageController.php +++ b/app/code/core/Mage/Checkout/controllers/OnepageController.php @@ -209,9 +209,7 @@ public function indexAction() $this->_initLayoutMessages('customer/session'); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Checkout')); - } + $head?->setTitle($this->__('Checkout')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Cms/Block/Page.php b/app/code/core/Mage/Cms/Block/Page.php index 61ef698e93f..5248d27ce10 100644 --- a/app/code/core/Mage/Cms/Block/Page.php +++ b/app/code/core/Mage/Cms/Block/Page.php @@ -83,9 +83,7 @@ protected function _prepareLayout() } $root = $this->getLayout()->getBlockRoot(); - if ($root) { - $root->addBodyClass('cms-' . $page->getIdentifier()); - } + $root?->addBodyClass('cms-' . $page->getIdentifier()); $head = $this->getLayout()->getBlockHead(); if ($head) { diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index a4429b0f150..7f8fe532906 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -541,40 +541,78 @@ public function getAllBlocks() * * @param string $name * @return Mage_Core_Block_Abstract|false + * @deprecated Use getBlockByName() which returns null if block does not exist + * @see getBlockByName() */ public function getBlock($name) { return $this->_blocks[$name] ?? false; } - public function getBlockAdminhtmlBreadcrumbs(): Mage_Adminhtml_Block_Widget_Breadcrumbs|false + /** + * Returns null instead of false if block does not exist + */ + public function getBlockByName(string $name): ?Mage_Core_Block_Abstract + { + $block = $this->getBlock($name); + if (!$block instanceof Mage_Core_Block_Abstract) { + return null; + } + return $block; + } + + public function getBlockAdminhtmlBreadcrumbs(): ?Mage_Adminhtml_Block_Widget_Breadcrumbs { - return $this->getBlock('breadcrumbs'); + $block = $this->getBlock('breadcrumbs'); + if (!$block instanceof Mage_Adminhtml_Block_Widget_Breadcrumbs) { + return null; + } + return $block; } - public function getBlockAdminhtmlHead(): Mage_Adminhtml_Block_Page_Head|false + public function getBlockAdminhtmlHead(): ?Mage_Adminhtml_Block_Page_Head { - return $this->getBlock('head'); + $block = $this->getBlock('head'); + if (!$block instanceof Mage_Adminhtml_Block_Page_Head) { + return null; + } + return $block; } - public function getBlockAdminhtmlMenu(): Mage_Adminhtml_Block_Page_Menu|false + public function getBlockAdminhtmlMenu(): ?Mage_Adminhtml_Block_Page_Menu { - return $this->getBlock('menu'); + $block = $this->getBlock('menu'); + if (!$block instanceof Mage_Adminhtml_Block_Page_Menu) { + return null; + } + return $block; } - public function getBlockBreadcrumbs(): Mage_Page_Block_Html_Breadcrumbs|false + public function getBlockBreadcrumbs(): ?Mage_Page_Block_Html_Breadcrumbs { - return $this->getBlock('breadcrumbs'); + $block = $this->getBlock('breadcrumbs'); + if (!$block instanceof Mage_Page_Block_Html_Breadcrumbs) { + return null; + } + return $block; } - public function getBlockHead(): Mage_Page_Block_Html_Head|false + public function getBlockHead(): ?Mage_Page_Block_Html_Head { - return $this->getBlock('head'); + $block = $this->getBlock('head'); + if (!$block instanceof Mage_Page_Block_Html_Head) { + return null; + } + return $block; } - public function getBlockRoot(): Mage_Page_Block_Html|false + public function getBlockRoot(): ?Mage_Page_Block_Html { - return $this->getBlock('root'); + $block = $this->getBlock('root'); + if (!$block instanceof Mage_Page_Block_Html) { + return null; + } + return $block; } /** diff --git a/app/code/core/Mage/Customer/Block/Address/Book.php b/app/code/core/Mage/Customer/Block/Address/Book.php index 3ec91b00d25..1b9aed65350 100644 --- a/app/code/core/Mage/Customer/Block/Address/Book.php +++ b/app/code/core/Mage/Customer/Block/Address/Book.php @@ -23,9 +23,7 @@ class Mage_Customer_Block_Address_Book extends Mage_Core_Block_Template protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('customer')->__('Address Book')); - } + $head?->setTitle(Mage::helper('customer')->__('Address Book')); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Customer/Block/Address/Edit.php b/app/code/core/Mage/Customer/Block/Address/Edit.php index 7197c11c345..e595163e8a7 100644 --- a/app/code/core/Mage/Customer/Block/Address/Edit.php +++ b/app/code/core/Mage/Customer/Block/Address/Edit.php @@ -50,9 +50,7 @@ protected function _prepareLayout() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->getTitle()); - } + $head?->setTitle($this->getTitle()); if ($postedData = Mage::getSingleton('customer/session')->getAddressFormData(true)) { $this->_address->addData($postedData); diff --git a/app/code/core/Mage/Customer/Block/Form/Register.php b/app/code/core/Mage/Customer/Block/Form/Register.php index 075980abeff..8b5df996bc1 100644 --- a/app/code/core/Mage/Customer/Block/Form/Register.php +++ b/app/code/core/Mage/Customer/Block/Form/Register.php @@ -32,9 +32,7 @@ class Mage_Customer_Block_Form_Register extends Mage_Directory_Block_Data protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('customer')->__('Create New Customer Account')); - } + $head?->setTitle(Mage::helper('customer')->__('Create New Customer Account')); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Customer/controllers/AccountController.php b/app/code/core/Mage/Customer/controllers/AccountController.php index e8c806d232d..2205cb898a9 100644 --- a/app/code/core/Mage/Customer/controllers/AccountController.php +++ b/app/code/core/Mage/Customer/controllers/AccountController.php @@ -104,9 +104,7 @@ public function indexAction() ); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('My Account')); - } + $head?->setTitle($this->__('My Account')); $this->renderLayout(); } @@ -127,9 +125,7 @@ public function loginAction() $this->_initLayoutMessages('catalog/session'); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Customer Login')); - } + $head?->setTitle($this->__('Customer Login')); $this->renderLayout(); } @@ -987,9 +983,7 @@ public function editAction() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Account Information')); - } + $head?->setTitle($this->__('Account Information')); $this->getLayout()->getBlock('messages')->setEscapeMessageFlag(true); $this->renderLayout(); diff --git a/app/code/core/Mage/Downloadable/controllers/CustomerController.php b/app/code/core/Mage/Downloadable/controllers/CustomerController.php index 75202adccaa..135eb4fe22e 100644 --- a/app/code/core/Mage/Downloadable/controllers/CustomerController.php +++ b/app/code/core/Mage/Downloadable/controllers/CustomerController.php @@ -42,9 +42,7 @@ public function productsAction() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('downloadable')->__('My Downloadable Products')); - } + $head?->setTitle(Mage::helper('downloadable')->__('My Downloadable Products')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Newsletter/controllers/ManageController.php b/app/code/core/Mage/Newsletter/controllers/ManageController.php index a87eae11d51..ea90b9b7734 100644 --- a/app/code/core/Mage/Newsletter/controllers/ManageController.php +++ b/app/code/core/Mage/Newsletter/controllers/ManageController.php @@ -40,9 +40,7 @@ public function indexAction() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Newsletter Subscription')); - } + $head?->setTitle($this->__('Newsletter Subscription')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Review/controllers/CustomerController.php b/app/code/core/Mage/Review/controllers/CustomerController.php index 628d35cd4d5..9b79b7cfa91 100644 --- a/app/code/core/Mage/Review/controllers/CustomerController.php +++ b/app/code/core/Mage/Review/controllers/CustomerController.php @@ -65,9 +65,7 @@ public function indexAction() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('My Product Reviews')); - } + $head?->setTitle($this->__('My Product Reviews')); $this->renderLayout(); } @@ -86,9 +84,7 @@ public function viewAction() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Review Details')); - } + $head?->setTitle($this->__('Review Details')); $this->renderLayout(); } diff --git a/app/code/core/Mage/Sales/Block/Order/Creditmemo.php b/app/code/core/Mage/Sales/Block/Order/Creditmemo.php index 7fd5df5a8f1..96aef85f9ec 100644 --- a/app/code/core/Mage/Sales/Block/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Block/Order/Creditmemo.php @@ -26,9 +26,7 @@ protected function _construct() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/Info.php b/app/code/core/Mage/Sales/Block/Order/Info.php index 58a25d5891d..3ec418c8988 100644 --- a/app/code/core/Mage/Sales/Block/Order/Info.php +++ b/app/code/core/Mage/Sales/Block/Order/Info.php @@ -28,9 +28,7 @@ protected function _construct() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/Invoice.php b/app/code/core/Mage/Sales/Block/Order/Invoice.php index b2babe8e279..0c1e4066e37 100644 --- a/app/code/core/Mage/Sales/Block/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Block/Order/Invoice.php @@ -26,9 +26,7 @@ protected function _construct() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/Print.php b/app/code/core/Mage/Sales/Block/Order/Print.php index 9e7da40a620..183ab8c8d8f 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print.php +++ b/app/code/core/Mage/Sales/Block/Order/Print.php @@ -20,9 +20,7 @@ class Mage_Sales_Block_Order_Print extends Mage_Sales_Block_Items_Abstract protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Print Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Print Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php b/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php index a95ae030bea..4e2b9b3fcac 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php +++ b/app/code/core/Mage/Sales/Block/Order/Print/Creditmemo.php @@ -20,9 +20,7 @@ class Mage_Sales_Block_Order_Print_Creditmemo extends Mage_Sales_Block_Items_Abs protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php b/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php index 2b648f1d317..e4743baf580 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php +++ b/app/code/core/Mage/Sales/Block/Order/Print/Invoice.php @@ -20,9 +20,7 @@ class Mage_Sales_Block_Order_Print_Invoice extends Mage_Sales_Block_Items_Abstra protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php b/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php index d6c55789415..75c5298dbb2 100644 --- a/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php +++ b/app/code/core/Mage/Sales/Block/Order/Print/Shipment.php @@ -58,9 +58,7 @@ protected function _beforeToHtml() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/Shipment.php b/app/code/core/Mage/Sales/Block/Order/Shipment.php index 3c3aae85b34..92c4a190f1a 100644 --- a/app/code/core/Mage/Sales/Block/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Block/Order/Shipment.php @@ -26,9 +26,7 @@ protected function _construct() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/Block/Order/View.php b/app/code/core/Mage/Sales/Block/Order/View.php index 98a02ebffd8..976a6b985a6 100644 --- a/app/code/core/Mage/Sales/Block/Order/View.php +++ b/app/code/core/Mage/Sales/Block/Order/View.php @@ -26,9 +26,7 @@ protected function _construct() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); - } + $head?->setTitle($this->__('Order # %s', $this->getOrder()->getRealOrderId())); /** @var Mage_Payment_Helper_Data $helper */ $helper = $this->helper('payment'); diff --git a/app/code/core/Mage/Sales/controllers/OrderController.php b/app/code/core/Mage/Sales/controllers/OrderController.php index e4f38b98b6c..f0c1d5296ca 100644 --- a/app/code/core/Mage/Sales/controllers/OrderController.php +++ b/app/code/core/Mage/Sales/controllers/OrderController.php @@ -41,9 +41,7 @@ public function historyAction() $this->_initLayoutMessages('catalog/session'); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('My Orders')); - } + $head?->setTitle($this->__('My Orders')); if ($block = $this->getLayout()->getBlock('customer.account.link.back')) { $block->setRefererUrl($this->_getRefererUrl()); diff --git a/app/code/core/Mage/Tag/Block/Product/Result.php b/app/code/core/Mage/Tag/Block/Product/Result.php index 9a3dde5390b..dda24c1df72 100644 --- a/app/code/core/Mage/Tag/Block/Product/Result.php +++ b/app/code/core/Mage/Tag/Block/Product/Result.php @@ -37,14 +37,10 @@ protected function _prepareLayout() $title = $this->getHeaderText(); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($title); - } + $head?->setTitle($title); $root = $this->getLayout()->getBlockRoot(); - if ($root) { - $root->setHeaderTitle($title); - } + $root?->setHeaderTitle($title); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Tag/controllers/CustomerController.php b/app/code/core/Mage/Tag/controllers/CustomerController.php index ba419adbba5..a54c948a77c 100644 --- a/app/code/core/Mage/Tag/controllers/CustomerController.php +++ b/app/code/core/Mage/Tag/controllers/CustomerController.php @@ -54,9 +54,7 @@ public function indexAction() } $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('tag')->__('My Tags')); - } + $head?->setTitle(Mage::helper('tag')->__('My Tags')); $this->renderLayout(); } @@ -81,9 +79,7 @@ public function viewAction() $this->_initLayoutMessages('checkout/session'); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle(Mage::helper('tag')->__('My Tags')); - } + $head?->setTitle(Mage::helper('tag')->__('My Tags')); $this->renderLayout(); } else { $this->_forward('noRoute'); diff --git a/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php b/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php index be3218646dd..a54a8ca5aa0 100644 --- a/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php +++ b/app/code/core/Mage/Wishlist/Block/Customer/Sharing.php @@ -29,9 +29,7 @@ class Mage_Wishlist_Block_Customer_Sharing extends Mage_Core_Block_Template protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('Wishlist Sharing')); - } + $head?->setTitle($this->__('Wishlist Sharing')); return $this; } diff --git a/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php b/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php index 1530ee64054..52734907675 100644 --- a/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php +++ b/app/code/core/Mage/Wishlist/Block/Customer/Wishlist.php @@ -41,9 +41,7 @@ protected function _prepareLayout() parent::_prepareLayout(); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->__('My Wishlist')); - } + $head?->setTitle($this->__('My Wishlist')); return $this; } diff --git a/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php b/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php index f6fcc8a5afb..bb0c0df7942 100644 --- a/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php +++ b/app/code/core/Mage/Wishlist/Block/Share/Wishlist.php @@ -32,9 +32,7 @@ protected function _prepareLayout() parent::_prepareLayout(); $head = $this->getLayout()->getBlockHead(); - if ($head) { - $head->setTitle($this->getHeader()); - } + $head?->setTitle($this->getHeader()); return $this; } From 30f624a7ff93c83a868cab3cf409ab52f42ef970 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 20 Oct 2025 10:25:54 +0200 Subject: [PATCH 06/13] updated rector config (prepare for next PR) --- .rector.php | 5 +++++ app/code/core/Mage/Core/Model/Layout.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.rector.php b/.rector.php index fe2dd2477cf..56df7d2871e 100644 --- a/.rector.php +++ b/.rector.php @@ -22,6 +22,7 @@ use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; use Rector\Privatization\Rector as Privatization; use Rector\Renaming\Rector as Renaming; +use Rector\Renaming\ValueObject\MethodCallRename as RenamingMethodCallRename; use Rector\Strict\Rector as Strict; use Rector\Transform\Rector as Transform; use Rector\TypeDeclaration\Rector as TypeDeclaration; @@ -40,6 +41,10 @@ __DIR__, ]) ->withSkipPath(__DIR__ . '/vendor') + # Rename method calls + #->withConfiguredRule(Renaming\MethodCall\RenameMethodRector::class, [ + # new RenamingMethodCallRename('Mage_Core_Model_Layout', 'getBlock', 'getBlockByName'), + #]) ->withRules([ Php85\ArrayDimFetch\ArrayFirstLastRector::class, ]) diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 7f8fe532906..26a92450c99 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -550,11 +550,11 @@ public function getBlock($name) } /** - * Returns null instead of false if block does not exist + * Returns null instead of false if block does not exist */ public function getBlockByName(string $name): ?Mage_Core_Block_Abstract { - $block = $this->getBlock($name); + $block = $this->_blocks[$name] ?? null; if (!$block instanceof Mage_Core_Block_Abstract) { return null; } From 27e08ec88302cea9da4b4bfb72ef513541579266 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 20 Oct 2025 10:29:13 +0200 Subject: [PATCH 07/13] phpcs-fixer --- app/code/core/Mage/Core/Model/Layout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 26a92450c99..729f947e1d3 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -550,7 +550,7 @@ public function getBlock($name) } /** - * Returns null instead of false if block does not exist + * Returns null instead of false if block does not exist */ public function getBlockByName(string $name): ?Mage_Core_Block_Abstract { From 42ac84417b2acba7efc05a93e98b0a23fa312164 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 20 Oct 2025 10:43:13 +0200 Subject: [PATCH 08/13] rector --- app/code/core/Mage/Core/Model/Layout.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 729f947e1d3..9f5f31efdf4 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -558,6 +558,7 @@ public function getBlockByName(string $name): ?Mage_Core_Block_Abstract if (!$block instanceof Mage_Core_Block_Abstract) { return null; } + return $block; } @@ -567,6 +568,7 @@ public function getBlockAdminhtmlBreadcrumbs(): ?Mage_Adminhtml_Block_Widget_Bre if (!$block instanceof Mage_Adminhtml_Block_Widget_Breadcrumbs) { return null; } + return $block; } @@ -576,6 +578,7 @@ public function getBlockAdminhtmlHead(): ?Mage_Adminhtml_Block_Page_Head if (!$block instanceof Mage_Adminhtml_Block_Page_Head) { return null; } + return $block; } @@ -585,6 +588,7 @@ public function getBlockAdminhtmlMenu(): ?Mage_Adminhtml_Block_Page_Menu if (!$block instanceof Mage_Adminhtml_Block_Page_Menu) { return null; } + return $block; } @@ -594,6 +598,7 @@ public function getBlockBreadcrumbs(): ?Mage_Page_Block_Html_Breadcrumbs if (!$block instanceof Mage_Page_Block_Html_Breadcrumbs) { return null; } + return $block; } @@ -603,6 +608,7 @@ public function getBlockHead(): ?Mage_Page_Block_Html_Head if (!$block instanceof Mage_Page_Block_Html_Head) { return null; } + return $block; } @@ -612,6 +618,7 @@ public function getBlockRoot(): ?Mage_Page_Block_Html if (!$block instanceof Mage_Page_Block_Html) { return null; } + return $block; } From a1d8a4abd9f83c5cbf361c3e6c862f2d291a9ae1 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 20 Oct 2025 10:45:08 +0200 Subject: [PATCH 09/13] fixed calls --- app/code/core/Mage/Core/Model/Layout.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 9f5f31efdf4..03c397b57df 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -564,7 +564,7 @@ public function getBlockByName(string $name): ?Mage_Core_Block_Abstract public function getBlockAdminhtmlBreadcrumbs(): ?Mage_Adminhtml_Block_Widget_Breadcrumbs { - $block = $this->getBlock('breadcrumbs'); + $block = $this->getBlockByName('breadcrumbs'); if (!$block instanceof Mage_Adminhtml_Block_Widget_Breadcrumbs) { return null; } @@ -574,7 +574,7 @@ public function getBlockAdminhtmlBreadcrumbs(): ?Mage_Adminhtml_Block_Widget_Bre public function getBlockAdminhtmlHead(): ?Mage_Adminhtml_Block_Page_Head { - $block = $this->getBlock('head'); + $block = $this->getBlockByName('head'); if (!$block instanceof Mage_Adminhtml_Block_Page_Head) { return null; } @@ -584,7 +584,7 @@ public function getBlockAdminhtmlHead(): ?Mage_Adminhtml_Block_Page_Head public function getBlockAdminhtmlMenu(): ?Mage_Adminhtml_Block_Page_Menu { - $block = $this->getBlock('menu'); + $block = $this->getBlockByName('menu'); if (!$block instanceof Mage_Adminhtml_Block_Page_Menu) { return null; } @@ -594,7 +594,7 @@ public function getBlockAdminhtmlMenu(): ?Mage_Adminhtml_Block_Page_Menu public function getBlockBreadcrumbs(): ?Mage_Page_Block_Html_Breadcrumbs { - $block = $this->getBlock('breadcrumbs'); + $block = $this->getBlockByName('breadcrumbs'); if (!$block instanceof Mage_Page_Block_Html_Breadcrumbs) { return null; } @@ -604,7 +604,7 @@ public function getBlockBreadcrumbs(): ?Mage_Page_Block_Html_Breadcrumbs public function getBlockHead(): ?Mage_Page_Block_Html_Head { - $block = $this->getBlock('head'); + $block = $this->getBlockByName('head'); if (!$block instanceof Mage_Page_Block_Html_Head) { return null; } @@ -614,7 +614,7 @@ public function getBlockHead(): ?Mage_Page_Block_Html_Head public function getBlockRoot(): ?Mage_Page_Block_Html { - $block = $this->getBlock('root'); + $block = $this->getBlockByName('root'); if (!$block instanceof Mage_Page_Block_Html) { return null; } From bd6a27bc24848b3eba42c9945db0d6d75864f052 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Mon, 20 Oct 2025 11:38:16 +0200 Subject: [PATCH 10/13] copilot suggestions --- .../Block/System/Email/Template/Edit/Form.php | 11 +++++------ .../controllers/CategoryController.php | 6 ++---- .../CatalogSearch/Block/Advanced/Form.php | 9 ++++----- .../CatalogSearch/Block/Advanced/Result.php | 13 ++++++------- .../core/Mage/CatalogSearch/Block/Result.php | 19 ++++++++++--------- .../Review/controllers/ProductController.php | 17 ++++++++--------- 6 files changed, 35 insertions(+), 40 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php index 9a4c0875095..c9ee6ee48ef 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php @@ -23,12 +23,11 @@ class Mage_Adminhtml_Block_System_Email_Template_Edit_Form extends Mage_Adminhtm protected function _prepareLayout() { $head = $this->getLayout()->getBlockAdminhtmlHead(); - if ($head) { - $head->addItem('js', 'prototype/window.js'); - $head->addItem('js_css', 'prototype/windows/themes/default.css'); - $head->addCss('lib/prototype/windows/themes/magento.css'); - $head->addItem('js', 'mage/adminhtml/variables.js'); - } + $head + ?->addItem('js', 'prototype/window.js') + ->addItem('js_css', 'prototype/windows/themes/default.css') + ->addCss('lib/prototype/windows/themes/magento.css') + ->addItem('js', 'mage/adminhtml/variables.js'); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Catalog/controllers/CategoryController.php b/app/code/core/Mage/Catalog/controllers/CategoryController.php index af02f54e550..20e8a483808 100644 --- a/app/code/core/Mage/Catalog/controllers/CategoryController.php +++ b/app/code/core/Mage/Catalog/controllers/CategoryController.php @@ -150,10 +150,8 @@ public function viewAction() } $root = $this->getLayout()->getBlockRoot(); - if ($root) { - $root->addBodyClass('categorypath-' . $category->getUrlPath()); - $root->addBodyClass('category-' . $category->getUrlKey()); - } + $root?->addBodyClass('categorypath-' . $category->getUrlPath()) + ->addBodyClass('category-' . $category->getUrlKey()); $this->_initLayoutMessages('catalog/session'); $this->_initLayoutMessages('checkout/session'); diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php index 1fc582e9b3f..f724579acbd 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php @@ -20,16 +20,15 @@ class Mage_CatalogSearch_Block_Advanced_Form extends Mage_Core_Block_Template public function _prepareLayout() { $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); - if ($breadcrumbs) { - $breadcrumbs->addCrumb('home', [ + $breadcrumbs + ?->addCrumb('home', [ 'label' => Mage::helper('catalogsearch')->__('Home'), 'title' => Mage::helper('catalogsearch')->__('Go to Home Page'), 'link' => Mage::getBaseUrl(), - ]); - $breadcrumbs->addCrumb('search', [ + ]) + ->addCrumb('search', [ 'label' => Mage::helper('catalogsearch')->__('Catalog Advanced Search'), ]); - } return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php index d16f9280209..c8e8003ba6b 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Advanced/Result.php @@ -22,20 +22,19 @@ class Mage_CatalogSearch_Block_Advanced_Result extends Mage_Core_Block_Template protected function _prepareLayout() { $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); - if ($breadcrumbs) { - $breadcrumbs->addCrumb('home', [ + $breadcrumbs + ?->addCrumb('home', [ 'label' => Mage::helper('catalogsearch')->__('Home'), 'title' => Mage::helper('catalogsearch')->__('Go to Home Page'), 'link' => Mage::getBaseUrl(), - ]); - $breadcrumbs->addCrumb('search', [ + ]) + ->addCrumb('search', [ 'label' => Mage::helper('catalogsearch')->__('Catalog Advanced Search'), 'link' => $this->getUrl('*/*/'), - ]); - $breadcrumbs->addCrumb('search_result', [ + ]) + ->addCrumb('search_result', [ 'label' => Mage::helper('catalogsearch')->__('Results'), ]); - } return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/CatalogSearch/Block/Result.php b/app/code/core/Mage/CatalogSearch/Block/Result.php index c130169ea8d..e6929abc873 100644 --- a/app/code/core/Mage/CatalogSearch/Block/Result.php +++ b/app/code/core/Mage/CatalogSearch/Block/Result.php @@ -50,15 +50,16 @@ protected function _prepareLayout() if ($breadcrumbs) { $title = $this->__("Search results for: '%s'", $helper->getQueryText()); - $breadcrumbs->addCrumb('home', [ - 'label' => $this->__('Home'), - 'title' => $this->__('Go to Home Page'), - 'link' => Mage::getBaseUrl(), - ]); - $breadcrumbs->addCrumb('search', [ - 'label' => $title, - 'title' => $title, - ]); + $breadcrumbs + ->addCrumb('home', [ + 'label' => $this->__('Home'), + 'title' => $this->__('Go to Home Page'), + 'link' => Mage::getBaseUrl(), + ]) + ->addCrumb('search', [ + 'label' => $title, + 'title' => $title, + ]); } // modify page title diff --git a/app/code/core/Mage/Review/controllers/ProductController.php b/app/code/core/Mage/Review/controllers/ProductController.php index d1234ba7933..7d5605c440e 100644 --- a/app/code/core/Mage/Review/controllers/ProductController.php +++ b/app/code/core/Mage/Review/controllers/ProductController.php @@ -224,16 +224,15 @@ public function listAction() $this->_initProductLayout($product); $breadcrumbs = $this->getLayout()->getBlockBreadcrumbs(); - if ($breadcrumbs) { - $breadcrumbs->addCrumb('product', [ - 'label' => $product->getName(), - 'link' => $product->getProductUrl(), - 'readonly' => true, + $breadcrumbs + ?->addCrumb('product', [ + 'label' => $product->getName(), + 'link' => $product->getProductUrl(), + 'readonly' => true, + ]) + ->addCrumb('reviews', [ + 'label' => Mage::helper('review')->__('Product Reviews'), ]); - $breadcrumbs->addCrumb('reviews', [ - 'label' => Mage::helper('review')->__('Product Reviews'), - ]); - } $this->renderLayout(); } elseif (!$this->getResponse()->isRedirect()) { From ea085bee99d2e1100d7d5ebee2886e835a7e3054 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 22 Oct 2025 16:54:53 +0200 Subject: [PATCH 11/13] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../core/Mage/Catalog/Block/Product/Compare/List.php | 2 +- .../Checkout/Block/Multishipping/Address/Select.php | 2 +- .../Mage/Checkout/Block/Multishipping/Addresses.php | 2 +- .../core/Mage/Checkout/Block/Multishipping/Billing.php | 2 +- .../Mage/Checkout/Block/Multishipping/Overview.php | 2 +- .../Mage/Checkout/Block/Multishipping/Shipping.php | 2 +- .../controllers/Multishipping/AddressController.php | 10 +++++----- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php index 44d1d2ea8d2..e503705ea3f 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php +++ b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php @@ -68,7 +68,7 @@ public function getAddToWishlistUrl($product) protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head->getDefaultTitle()); + $head?->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head?->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php index 08926a12b59..e27e3a22eae 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php @@ -20,7 +20,7 @@ class Mage_Checkout_Block_Multishipping_Address_Select extends Mage_Checkout_Blo protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $head->getDefaultTitle()); + $head?->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $head?->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php index e55baaa22cf..68c5fc0ea75 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php @@ -30,7 +30,7 @@ public function getCheckout() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $head->getDefaultTitle()); + $head?->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $head?->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php index 407adf78951..8e5725ea99b 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php @@ -21,7 +21,7 @@ protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); $head?->setTitle( - Mage::helper('checkout')->__('Billing Information - %s', $head->getDefaultTitle()), + Mage::helper('checkout')->__('Billing Information - %s', $head?->getDefaultTitle()), ); return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php index 62c0206809f..4315c76da21 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php @@ -44,7 +44,7 @@ protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); $head?->setTitle( - $this->__('Review Order - %s', $head->getDefaultTitle()), + $this->__('Review Order - %s', $head?->getDefaultTitle()), ); return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php index d39aa5902b8..ce29ffa1a97 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php @@ -30,7 +30,7 @@ public function getCheckout() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $head->getDefaultTitle()); + $head?->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $head?->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php index d910432ba55..2bb56027102 100644 --- a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php +++ b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php @@ -48,7 +48,7 @@ public function newShippingAction() ->setErrorUrl(Mage::getUrl('*/*/*')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { $addressForm->setBackUrl(Mage::getUrl('*/multishipping/addresses')); @@ -83,7 +83,7 @@ public function editShippingAction() ->setErrorUrl(Mage::getUrl('*/*/*')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { $addressForm->setBackUrl(Mage::getUrl('*/multishipping/shipping')); @@ -123,7 +123,7 @@ public function newBillingAction() ->setBackUrl(Mage::getUrl('*/*/selectBilling')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); } $this->renderLayout(); @@ -140,7 +140,7 @@ public function editAddressAction() ->setBackUrl(Mage::getUrl('*/*/selectBilling')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); } $this->renderLayout(); @@ -160,7 +160,7 @@ public function editBillingAction() ->setBackUrl(Mage::getUrl('*/multishipping/overview')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); } $this->renderLayout(); From 8b9b6f67b874dd9cc6ec45ec61fa77385c8ea19a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 22 Oct 2025 17:05:42 +0200 Subject: [PATCH 12/13] Revert "Apply suggestions from code review" This reverts commit ea085bee99d2e1100d7d5ebee2886e835a7e3054. --- .../core/Mage/Catalog/Block/Product/Compare/List.php | 2 +- .../Checkout/Block/Multishipping/Address/Select.php | 2 +- .../Mage/Checkout/Block/Multishipping/Addresses.php | 2 +- .../core/Mage/Checkout/Block/Multishipping/Billing.php | 2 +- .../Mage/Checkout/Block/Multishipping/Overview.php | 2 +- .../Mage/Checkout/Block/Multishipping/Shipping.php | 2 +- .../controllers/Multishipping/AddressController.php | 10 +++++----- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php index e503705ea3f..44d1d2ea8d2 100644 --- a/app/code/core/Mage/Catalog/Block/Product/Compare/List.php +++ b/app/code/core/Mage/Catalog/Block/Product/Compare/List.php @@ -68,7 +68,7 @@ public function getAddToWishlistUrl($product) protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle(Mage::helper('catalog')->__('Products Comparison List') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php index e27e3a22eae..08926a12b59 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Address/Select.php @@ -20,7 +20,7 @@ class Mage_Checkout_Block_Multishipping_Address_Select extends Mage_Checkout_Blo protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle(Mage::helper('checkout')->__('Change Billing Address') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php index 68c5fc0ea75..e55baaa22cf 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Addresses.php @@ -30,7 +30,7 @@ public function getCheckout() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle(Mage::helper('checkout')->__('Ship to Multiple Addresses') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php index 8e5725ea99b..407adf78951 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Billing.php @@ -21,7 +21,7 @@ protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); $head?->setTitle( - Mage::helper('checkout')->__('Billing Information - %s', $head?->getDefaultTitle()), + Mage::helper('checkout')->__('Billing Information - %s', $head->getDefaultTitle()), ); return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php index 4315c76da21..62c0206809f 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Overview.php @@ -44,7 +44,7 @@ protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); $head?->setTitle( - $this->__('Review Order - %s', $head?->getDefaultTitle()), + $this->__('Review Order - %s', $head->getDefaultTitle()), ); return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php index ce29ffa1a97..d39aa5902b8 100644 --- a/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php +++ b/app/code/core/Mage/Checkout/Block/Multishipping/Shipping.php @@ -30,7 +30,7 @@ public function getCheckout() protected function _prepareLayout() { $head = $this->getLayout()->getBlockHead(); - $head?->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle(Mage::helper('checkout')->__('Shipping Methods') . ' - ' . $head->getDefaultTitle()); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php index 2bb56027102..d910432ba55 100644 --- a/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php +++ b/app/code/core/Mage/Checkout/controllers/Multishipping/AddressController.php @@ -48,7 +48,7 @@ public function newShippingAction() ->setErrorUrl(Mage::getUrl('*/*/*')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { $addressForm->setBackUrl(Mage::getUrl('*/multishipping/addresses')); @@ -83,7 +83,7 @@ public function editShippingAction() ->setErrorUrl(Mage::getUrl('*/*/*')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { $addressForm->setBackUrl(Mage::getUrl('*/multishipping/shipping')); @@ -123,7 +123,7 @@ public function newBillingAction() ->setBackUrl(Mage::getUrl('*/*/selectBilling')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } $this->renderLayout(); @@ -140,7 +140,7 @@ public function editAddressAction() ->setBackUrl(Mage::getUrl('*/*/selectBilling')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } $this->renderLayout(); @@ -160,7 +160,7 @@ public function editBillingAction() ->setBackUrl(Mage::getUrl('*/multishipping/overview')); $head = $this->getLayout()->getBlockHead(); - $head?->setTitle($addressForm->getTitle() . ' - ' . $head?->getDefaultTitle()); + $head?->setTitle($addressForm->getTitle() . ' - ' . $head->getDefaultTitle()); } $this->renderLayout(); From 89f11ad2a72d0349f3a54379332671f0c2eee4d1 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 5 Nov 2025 21:50:47 +0100 Subject: [PATCH 13/13] use traits --- app/code/core/Mage/Core/Model/Layout.php | 63 +------------------ .../Core/Model/Layout/Traits/Adminhtml.php | 48 ++++++++++++++ .../Core/Model/Layout/Traits/Frontend.php | 48 ++++++++++++++ 3 files changed, 99 insertions(+), 60 deletions(-) create mode 100644 app/code/core/Mage/Core/Model/Layout/Traits/Adminhtml.php create mode 100644 app/code/core/Mage/Core/Model/Layout/Traits/Frontend.php diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index ea589e61ac7..83ea9931fff 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -14,6 +14,9 @@ */ class Mage_Core_Model_Layout extends Varien_Simplexml_Config { + use Mage_Core_Model_Layout_Traits_Adminhtml; + use Mage_Core_Model_Layout_Traits_Frontend; + /** * Layout Update module * @@ -562,66 +565,6 @@ public function getBlockByName(string $name): ?Mage_Core_Block_Abstract return $block; } - public function getBlockAdminhtmlBreadcrumbs(): ?Mage_Adminhtml_Block_Widget_Breadcrumbs - { - $block = $this->getBlockByName('breadcrumbs'); - if (!$block instanceof Mage_Adminhtml_Block_Widget_Breadcrumbs) { - return null; - } - - return $block; - } - - public function getBlockAdminhtmlHead(): ?Mage_Adminhtml_Block_Page_Head - { - $block = $this->getBlockByName('head'); - if (!$block instanceof Mage_Adminhtml_Block_Page_Head) { - return null; - } - - return $block; - } - - public function getBlockAdminhtmlMenu(): ?Mage_Adminhtml_Block_Page_Menu - { - $block = $this->getBlockByName('menu'); - if (!$block instanceof Mage_Adminhtml_Block_Page_Menu) { - return null; - } - - return $block; - } - - public function getBlockBreadcrumbs(): ?Mage_Page_Block_Html_Breadcrumbs - { - $block = $this->getBlockByName('breadcrumbs'); - if (!$block instanceof Mage_Page_Block_Html_Breadcrumbs) { - return null; - } - - return $block; - } - - public function getBlockHead(): ?Mage_Page_Block_Html_Head - { - $block = $this->getBlockByName('head'); - if (!$block instanceof Mage_Page_Block_Html_Head) { - return null; - } - - return $block; - } - - public function getBlockRoot(): ?Mage_Page_Block_Html - { - $block = $this->getBlockByName('root'); - if (!$block instanceof Mage_Page_Block_Html) { - return null; - } - - return $block; - } - /** * Add a block to output * diff --git a/app/code/core/Mage/Core/Model/Layout/Traits/Adminhtml.php b/app/code/core/Mage/Core/Model/Layout/Traits/Adminhtml.php new file mode 100644 index 00000000000..0a602b60831 --- /dev/null +++ b/app/code/core/Mage/Core/Model/Layout/Traits/Adminhtml.php @@ -0,0 +1,48 @@ +getBlockByName('breadcrumbs'); + if (!$block instanceof Mage_Adminhtml_Block_Widget_Breadcrumbs) { + return null; + } + + return $block; + } + + public function getBlockAdminhtmlHead(): ?Mage_Adminhtml_Block_Page_Head + { + $block = $this->getBlockByName('head'); + if (!$block instanceof Mage_Adminhtml_Block_Page_Head) { + return null; + } + + return $block; + } + + public function getBlockAdminhtmlMenu(): ?Mage_Adminhtml_Block_Page_Menu + { + $block = $this->getBlockByName('menu'); + if (!$block instanceof Mage_Adminhtml_Block_Page_Menu) { + return null; + } + + return $block; + } +} diff --git a/app/code/core/Mage/Core/Model/Layout/Traits/Frontend.php b/app/code/core/Mage/Core/Model/Layout/Traits/Frontend.php new file mode 100644 index 00000000000..c4ff68a0bfe --- /dev/null +++ b/app/code/core/Mage/Core/Model/Layout/Traits/Frontend.php @@ -0,0 +1,48 @@ +getBlockByName('breadcrumbs'); + if (!$block instanceof Mage_Page_Block_Html_Breadcrumbs) { + return null; + } + + return $block; + } + + public function getBlockHead(): ?Mage_Page_Block_Html_Head + { + $block = $this->getBlockByName('head'); + if (!$block instanceof Mage_Page_Block_Html_Head) { + return null; + } + + return $block; + } + + public function getBlockRoot(): ?Mage_Page_Block_Html + { + $block = $this->getBlockByName('root'); + if (!$block instanceof Mage_Page_Block_Html) { + return null; + } + + return $block; + } +}