2

I'm using magento C.E. 1.9.1.0 and PHP 7.1 and I get the following error when I visit a category page:

PHP Fatal error:  Uncaught Error: Cannot re-assign $this in /var/www/magento/app/code/core/Mage/Core/Block/Template.php Line 215

This error happens here (Line 215):

extract ($this->_viewVars, EXTR_SKIP);

This is due to dynamic calls being forbidden in PHP 7.1

Does anyone knows of a fix for this?

2
  1. copy app/code/core/Mage/Core/Block/Template.php to app/code/local/Mage/Core/Block/Template.php

  2. in app/code/local/Mage/Core/Block/Template.php comment out line 215 and add line 216 as shown below:

    215         #extract ($this->_viewVars, EXTR_SKIP);                                                                                                                               
    216         foreach($this->_viewVars as $k => $v) if(!isset(${$k}) && $k != 'this') ${$k} = $v;
    
| improve this answer | |
  • Unfortunately this has the same effect as extract, now I get the same error message but at this line: ${$k} = $v; – lloiacono Dec 19 '16 at 14:15
  • try adding $k != 'this' as shown above and report back. – Konstantin Gerasimov Dec 19 '16 at 14:24
  • Adding $k != 'this' fix the problem. I will accept the answer after a few days as I would like to test thoroughly and get different ideas for this. – lloiacono Dec 19 '16 at 14:28

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.