Skip to content

Instantly share code, notes, and snippets.

@harlesc
Last active April 9, 2017 20:31
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save harlesc/66449504110fbbd96214 to your computer and use it in GitHub Desktop.
Save harlesc/66449504110fbbd96214 to your computer and use it in GitHub Desktop.
Patch to get Magento 1.9 working with >= PHP 7.0.0 RC 6

Patch using method below or if you don't want to patch a core file, see this Magento extension that does the same thing but correctly overrides the core file:
https://github.com/MageMechanic/PhpSeven

# run in magento root directory

# one-liner to apply patch using wget
wget -qO- 'https://gist.githubusercontent.com/MageMechanic/66449504110fbbd96214/raw/php7_magento_1_9_core.patch' | patch -p0

# one-liner to apply patch using curl
curl -s 'https://gist.githubusercontent.com/MageMechanic/66449504110fbbd96214/raw/php7_magento_1_9_core.patch' | patch -p0

# ...easier to read
PATCH_URL='https://gist.githubusercontent.com/MageMechanic/66449504110fbbd96214/raw/php7_magento_1_9_core.patch'

# to apply with wget
wget -qO- $PATCH_URL | patch -p0

# ...or with curl
curl -s $PATCH_URL | patch -p0

# to revert using wget  
wget -qO- $PATCH_URL | patch -p0 -R

# ...or revert using curl  
curl -s $PATCH_URL | patch -p0 -R

References

http://afilina.com/magento-1-9-on-php7/
http://www.bubblecode.net/en/2015/07/24/magento-php-7/
http://magento.stackexchange.com/questions/74008/is-magento-ready-for-php-7#answer-80912
http://www.code007.ro/making-work-magento-with-php-7-rc1/

--- app/code/core/Mage/Core/Model/Layout.php
+++ app/code/core/Mage/Core/Model/Layout.php
@@ -552,7 +552,7 @@
$out = '';
if (!empty($this->_output)) {
foreach ($this->_output as $callback) {
- $out .= $this->getBlock($callback[0])->$callback[1]();
+ $out .= $this->getBlock($callback[0])->{$callback[1]}();
}
}
@navarr
Copy link

navarr commented Nov 16, 2015

Is there a Magento2 PR for this fix yet?

@franciskim
Copy link

Very cool. And I suppose it works with PHP 7.0.6.

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