Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_GiftMessage shouldn't be required for Mage_Adminhtml #4263

Open
Hanmac opened this issue Oct 9, 2024 · 2 comments · May be fixed by #4266
Open

Mage_GiftMessage shouldn't be required for Mage_Adminhtml #4263

Hanmac opened this issue Oct 9, 2024 · 2 comments · May be fixed by #4266

Comments

@Hanmac
Copy link
Contributor

Hanmac commented Oct 9, 2024

Preconditions (*)

  1. should be all versions

Steps to reproduce (*)

  1. have Mage_Giftmessage be disabled via etc/modules
  2. Open an existing Sales/Order

Expected result (*)

  1. Sales/Order does open

Actual result (*)

  1. Exception
Error: Class "Mage_Giftmessage_Helper_Message" not found in /var/www/app/Mage.php:612
Stack trace:
#0 /var/www//app/code/core/Mage/Core/Model/Layout.php(625): Mage::helper()
#1 /var/www/app/code/core/Mage/Core/Block/Abstract.php(1108): Mage_Core_Model_Layout->helper()
#2 /var/www/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Items/Renderer/Default.php(208): Mage_Core_Block_Abstract->helper()
#3 /var/www/app/design/adminhtml/default/default/template/sales/order/view/items/renderer/default.phtml(29): Mage_Adminhtml_Block_Sales_Order_View_Items_Renderer_Default->canDisplayGiftmessage()
#4 /var/www/app/code/core/Mage/Core/Block/Template.php(273): include('...')
#5 /var/www/app/code/core/Mage/Core/Block/Template.php(310): Mage_Core_Block_Template->fetchView()

Possible Solution

Currently in the Route adminhtml_sales_order_view, the gift_options Block is added there:

<block type="adminhtml/template" name="gift_options" template="sales/order/giftoptions.phtml">
<block type="adminhtml/sales_order_view_giftmessage" name="order_giftmessage" template="sales/order/view/giftmessage.phtml"></block>
</block>

That in itself isn't the problem, because the Template itself checks again:


which calls this function
public function canDisplayGiftmessage()
{
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable('order', $this->getEntity(), $this->getEntity()->getStoreId());
}

or a different function for the different Item Renderer

public function canDisplayGiftmessage()
{
/** @var Mage_GiftMessage_Helper_Message $helper */
$helper = $this->helper('giftmessage/message');
return $helper->getIsMessagesAvailable(
'order_item',
$this->getItem(),
$this->getItem()->getOrder()->getStoreId()
);
}

The problem there is the direct call to the Helper Mage_GiftMessage_Helper_Message, without checking first if the Module Mage_GiftMessage is enabled.

Probably both these functions should have this?

if (!Mage::helper('core')->isModuleEnabled('Mage_GiftMessage')) {
  return false;
}

I haven't checked all Routes yet if they need to be protected like this

@sreichel
Copy link
Contributor

sreichel commented Oct 9, 2024

@Hanmac
Copy link
Contributor Author

Hanmac commented Oct 10, 2024

I added a Draft PR, it doesn't address the product attribute, but the templates all have better protection functions now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants