Skip to content

Instantly share code, notes, and snippets.

@dimkalinux dimkalinux/latte.patch Secret
Last active Dec 22, 2015

Embed
What would you like to do?
Lower memory usage on Latte template with big variables
diff -ur nette/Nette/Latte/Macros/UIMacros.php nette.patched/Nette/Latte/Macros/UIMacros.php
--- nette/Nette/Latte/Macros/UIMacros.php 2013-08-08 02:14:19.000000000 +0300
+++ nette.patched/Nette/Latte/Macros/UIMacros.php 2013-08-30 19:13:24.000000000 +0300
@@ -98,7 +98,7 @@
$prolog[] = "//\n// block $name\n//\n"
. "if (!function_exists(\$_l->blocks[" . var_export($name, TRUE) . "][] = '$func')) { "
. "function $func(\$_l, \$_args) { "
- . (PHP_VERSION_ID > 50208 ? 'extract($_args)' : 'foreach ($_args as $__k => $__v) $$__k = $__v') // PHP bug #46873
+ . 'foreach ($_args as $__k => $__v) $$__k = $__v' // PHP bug #46873
. ($snippet ? '; $_control->validateControl(' . var_export(substr($name, 1), TRUE) . ')' : '')
. "\n?>$code<?php\n}}";
}
@@ -250,7 +250,7 @@
return "\n\n//\n// block $name\n//\n"
. "if (!function_exists(\$_l->blocks[$fname]['{$this->getCompiler()->getTemplateId()}'] = '$func')) { "
. "function $func(\$_l, \$_args) { "
- . (PHP_VERSION_ID > 50208 ? 'extract($_args)' : 'foreach ($_args as $__k => $__v) $$__k = $__v'); // PHP bug #46873
+ . 'foreach ($_args as $__k => $__v) $$__k = $__v'; // PHP bug #46873
}
}
diff -ur nette/Nette/Utils/LimitedScope.php nette.patched/Nette/Utils/LimitedScope.php
--- nette/Nette/Utils/LimitedScope.php 2013-08-08 02:14:19.000000000 +0300
+++ nette.patched/Nette/Utils/LimitedScope.php 2013-08-30 19:21:16.000000000 +0300
@@ -65,7 +65,7 @@
if (self::$vars === TRUE) {
return require func_get_arg(0);
}
- extract(self::$vars);
+ foreach (self::$vars as $k => $v) { $$k = $v; }
}
return require func_get_arg(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.