Bugfix - Magento 1: PHP Parse error: syntax error, unexpected T_NAMESPACE, expecting T_STRING in app/code/community/EcomDev/ProductPageShipping/Model/Session.php on line 26 Print

  • 76

The following error was encountered recently whilst migrating a customer site to our Magento Optimised Managed VPS, which has PHP 5.3 installed:

PHP Parse error:  syntax error, unexpected T_NAMESPACE, expecting T_STRING in app/code/community/EcomDev/ProductPageShipping/Model/Session.php on line 26

Looking at the code in that file, we see the following:

 
class EcomDev_ProductPageShipping_Model_Session extends Mage_Core_Model_Session_Abstract
{
 const NAMESPACE = 'productpageshipping';
public function __construct()
 {
 $this->init(self::NAMESPACE);
 }
}

What's happening here is that NAMESPACE is a reserved word in PHP 5.3 - Doh! It's an easy fix however, simply replace NAMESPACE with something else, such as the following:

class EcomDev_ProductPageShipping_Model_Session extends Mage_Core_Model_Session_Abstract
{
 const PRODUCTPAGESHIPPING_NAMESPACE = 'productpageshipping';
public function __construct()
 {
 $this->init(self::PRODUCTPAGESHIPPING_NAMESPACE);
 }
}

The above applies to any extension using NAMESPACE, not just the EcomDev extension as in the example.

If you are a Create Hosting customer on the Magento Hosting Plan, feel free to submit a support ticket and we can take care of this issue for you.


Was this answer helpful?

« Back