3

In our development setup I get the following error if, after a long while, I refresh (or directly go to) the /checkout/cart/ or /checkout/onepage/ url, e.g. when the items in my cart have been removed due to a timeout or there is nothing in the cart at all.

Notice: Undefined variable: freePackageValue  in /var/www/dev/htdocs/app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php on line 130

#0 /var/www/dev/htdocs/app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php(130): mageCoreErrorHandler(8, 'Undefined varia...', '/var/www/dev/ht...', 130, Array)
#1 /var/www/dev/htdocs/app/code/core/Mage/Shipping/Model/Shipping.php(209): Mage_Shipping_Model_Carrier_Tablerate->collectRates(Object(Mage_Shipping_Model_Rate_Request))
#2 /var/www/dev/htdocs/app/code/core/Mage/Shipping/Model/Shipping.php(129): Mage_Shipping_Model_Shipping->collectCarrierRates('tablerate', Object(Mage_Shipping_Model_Rate_Request))
#3 /var/www/dev/htdocs/app/code/core/Mage/Sales/Model/Quote/Address.php(944): Mage_Shipping_Model_Shipping->collectRates(Object(Mage_Shipping_Model_Rate_Request))
#4 /var/www/dev/htdocs/app/code/core/Mage/Sales/Model/Quote/Address.php(875): Mage_Sales_Model_Quote_Address->requestShippingRates()
#5 /var/www/dev/.modman/integer-net_autoshipping/app/code/community/IntegerNet/Autoshipping/Model/Observer.php(46): Mage_Sales_Model_Quote_Address->collectShippingRates()
#6 /var/www/dev/htdocs/app/code/core/Mage/Core/Model/App.php(1338): IntegerNet_Autoshipping_Model_Observer->addShipping(Object(Varien_Event_Observer))
#7 /var/www/dev/htdocs/app/code/core/Mage/Core/Model/App.php(1317): Mage_Core_Model_App->_callObserverMethod(Object(IntegerNet_Autoshipping_Model_Observer), 'addShipping', Object(Varien_Event_Observer))
#8 /var/www/dev/htdocs/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#9 /var/www/dev/htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(531): Mage::dispatchEvent('controller_acti...', Array)
#10 /var/www/dev/htdocs/app/code/core/Mage/Core/Controller/Front/Action.php(64): Mage_Core_Controller_Varien_Action->preDispatch()
#11 /var/www/dev/htdocs/app/code/core/Mage/Checkout/controllers/CartController.php(126): Mage_Core_Controller_Front_Action->preDispatch()
#12 /var/www/dev/htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(407): Mage_Checkout_CartController->preDispatch()
#13 /var/www/dev/htdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#14 /var/www/dev/htdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#15 /var/www/dev/htdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#16 /var/www/dev/htdocs/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#17 /var/www/dev/htdocs/index.php(87): Mage::run('my_storeview', 'store')
#18 {main}

Now in our live setup this is no issue at all, as the "your cart is empty" message is correctly shown, but I do wonder why in our dev setup (where all the magento and php error output is set to on) this is happening.

Anybody got a clue?

  • You found a core bug. to fix it, copy line 107 to line 105, so the definition of $freePackageValue outside the if. You can copy the file to local, but I recommend to not do this and hope, that the bug is fixed exactly this way in the next version – Fabian Blechschmidt Mar 13 '15 at 19:01
  • @FabianBlechschmidt You're right. It's indeed a corebug. I have reported it and hope they'll fix it. Now if only they accepted PR's for 1.9.x .... :) – Ottonet Mar 14 '15 at 9:34
7

As @FabianBlechschmidt correctly pointed out it is indeed a corebug in (at least) Magento 1.9.0.1.

Original (lines 104 to 108) app/code/core/Mage/Shipping/Model/Carrier/Tablerate.php:

   // Free shipping by qty
    $freeQty = 0;
    if ($request->getAllItems()) {
        $freePackageValue = 0;
        foreach ($request->getAllItems() as $item) {

fixed lines 104 to 108 in /app/code/local/Mage/Shipping/Model/Carrier/Tablerate.php

    // Free shipping by qty
    $freeQty = 0;
    $freePackageValue = 0;
    if ($request->getAllItems()) {
        foreach ($request->getAllItems() as $item) {

I have filed a bug report...

2

Because when using developer mode, undefined variables are fatal errors. It is done to signal you to not introduce subtle bugs.

In theory, every extension is developer mode proof.

What you'll also notice is that some translations fall back to English. This is because in developer mode, translations are not looked up I the global scope if it cannot be found in the module scope. This is done so that every module takes responsibility for its own translations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.