From cf3ee203a2427b250b03a90a78880f10273771f2 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 10 May 2013 12:08:06 -0500 Subject: [PATCH] Adjusted backtrace call to reduce memory usage --- lib/Twig/Error.php | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/lib/Twig/Error.php b/lib/Twig/Error.php index e77ec98..72d91a9 100644 --- a/lib/Twig/Error.php +++ b/lib/Twig/Error.php @@ -186,7 +186,14 @@ class Twig_Error extends Exception protected function guessTemplateInfo() { $template = null; - foreach (debug_backtrace() as $trace) { + + if (version_compare(phpversion(), '5.3.6', '>=')) { + $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT); + } else { + $backtrace = debug_backtrace(); + } + + foreach ($backtrace as $trace) { if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) { if (null === $this->filename || $this->filename == $trace['object']->getTemplateName()) { $template = $trace['object']; -- 1.7.2.5