From 298fa34630e148431d3cb2f88ef1b6e1e350a8ed Mon Sep 17 00:00:00 2001 From: phalcon Date: Tue, 5 Feb 2013 07:13:29 -0500 Subject: [PATCH 1/3] Fixing bug with partials in Mvc\View --- build/32bits/phalcon.c | 7 ++----- build/safe/phalcon.c | 7 ++----- ext/mvc/view.c | 8 ++------ 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/build/32bits/phalcon.c b/build/32bits/phalcon.c index a22bdb30fca..fa4331764b3 100644 --- a/build/32bits/phalcon.c +++ b/build/32bits/phalcon.c @@ -58630,7 +58630,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){ PHP_METHOD(Phalcon_Mvc_View, partial){ zval *partial_path, *zfalse, *partials_dir, *real_path; - zval *engines, *content; + zval *engines; PHALCON_MM_GROW(); @@ -58646,15 +58646,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){ PHALCON_INIT_VAR(real_path); PHALCON_CONCAT_VV(real_path, partials_dir, partial_path); - phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC); PHALCON_INIT_VAR(engines); PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines"); PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse); - PHALCON_OBS_VAR(content); - phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC); - RETURN_CCTOR(content); + PHALCON_MM_RESTORE(); } PHP_METHOD(Phalcon_Mvc_View, getRender){ diff --git a/build/safe/phalcon.c b/build/safe/phalcon.c index 4eac3acce74..01878bc7d12 100644 --- a/build/safe/phalcon.c +++ b/build/safe/phalcon.c @@ -58630,7 +58630,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){ PHP_METHOD(Phalcon_Mvc_View, partial){ zval *partial_path, *zfalse, *partials_dir, *real_path; - zval *engines, *content; + zval *engines; PHALCON_MM_GROW(); @@ -58646,15 +58646,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){ PHALCON_INIT_VAR(real_path); PHALCON_CONCAT_VV(real_path, partials_dir, partial_path); - phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC); PHALCON_INIT_VAR(engines); PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines"); PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse); - PHALCON_OBS_VAR(content); - phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC); - RETURN_CCTOR(content); + PHALCON_MM_RESTORE(); } PHP_METHOD(Phalcon_Mvc_View, getRender){ diff --git a/ext/mvc/view.c b/ext/mvc/view.c index 1248d6de49e..6f46a0aeba6 100755 --- a/ext/mvc/view.c +++ b/ext/mvc/view.c @@ -1324,12 +1324,11 @@ PHP_METHOD(Phalcon_Mvc_View, pick){ * * * @param string $partialPath - * @return string */ PHP_METHOD(Phalcon_Mvc_View, partial){ zval *partial_path, *zfalse, *partials_dir, *real_path; - zval *engines, *content; + zval *engines; PHALCON_MM_GROW(); @@ -1345,15 +1344,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){ PHALCON_INIT_VAR(real_path); PHALCON_CONCAT_VV(real_path, partials_dir, partial_path); - phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC); PHALCON_INIT_VAR(engines); PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines"); PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse); - PHALCON_OBS_VAR(content); - phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC); - RETURN_CCTOR(content); + PHALCON_MM_RESTORE(); } /** From b029722f79f63252b8a68ca1e00d33c2a28fc4d5 Mon Sep 17 00:00:00 2001 From: phalcon Date: Tue, 5 Feb 2013 07:16:46 -0500 Subject: [PATCH 2/3] Fixing bug with partials in Mvc\View --- unit-tests/ViewEnginesTest.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/unit-tests/ViewEnginesTest.php b/unit-tests/ViewEnginesTest.php index 8ad09e5bd74..6f08d2a0866 100644 --- a/unit-tests/ViewEnginesTest.php +++ b/unit-tests/ViewEnginesTest.php @@ -34,14 +34,18 @@ public function __construct(Phalcon\Mvc\View $view, Phalcon\DI $di) parent::__construct($view, $di); } - public function render($path, $params) + public function render($path, $params, $mustClean=false) { if (!isset($params['content'])) { $params['content'] = $this->_view->getContent(); } - $mustache = clone $this->_mustache; - $content = $mustache->render(file_get_contents($path), $params); - $this->_view->setContent($content); + + $content = $this->_mustache->render(file_get_contents($path), $params); + if ($mustClean) { + $this->_view->setContent($content); + } else { + echo $content; + } } } @@ -61,7 +65,7 @@ public function __construct(Phalcon\Mvc\View $view, Phalcon\DI $di) parent::__construct($view, $di); } - public function render($path, $params) + public function render($path, $params, $mustClean=false) { $view = $this->_view; if (!isset($params['content'])) { @@ -73,7 +77,12 @@ public function render($path, $params) } $relativePath = str_replace($view->getViewsDir(), '', $path); - $this->_view->setContent($this->_twig->render($relativePath, $params)); + $content = $this->_twig->render($relativePath, $params); + if ($mustClean) { + $this->_view->setContent($content); + } else { + echo $content; + } } } From f65b3d3b8787fc9b0c88322af953078daeddb78a Mon Sep 17 00:00:00 2001 From: phalcon Date: Tue, 5 Feb 2013 07:24:28 -0500 Subject: [PATCH 3/3] Regenerating build for 64bits [ci skip] --- build/64bits/phalcon.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build/64bits/phalcon.c b/build/64bits/phalcon.c index 2022c20183c..420b8b013e8 100644 --- a/build/64bits/phalcon.c +++ b/build/64bits/phalcon.c @@ -73532,7 +73532,7 @@ PHP_METHOD(Phalcon_Mvc_View, pick){ PHP_METHOD(Phalcon_Mvc_View, partial){ zval *partial_path, *zfalse, *partials_dir, *real_path; - zval *engines, *content; + zval *engines; PHALCON_MM_GROW(); @@ -73548,15 +73548,12 @@ PHP_METHOD(Phalcon_Mvc_View, partial){ PHALCON_INIT_VAR(real_path); PHALCON_CONCAT_VV(real_path, partials_dir, partial_path); - phalcon_update_property_null(this_ptr, SL("_content") TSRMLS_CC); PHALCON_INIT_VAR(engines); PHALCON_CALL_METHOD(engines, this_ptr, "_loadtemplateengines"); PHALCON_CALL_METHOD_PARAMS_5_NORETURN(this_ptr, "_enginerender", engines, real_path, zfalse, zfalse, zfalse); - PHALCON_OBS_VAR(content); - phalcon_read_property(&content, this_ptr, SL("_content"), PH_NOISY_CC); - RETURN_CCTOR(content); + PHALCON_MM_RESTORE(); } PHP_METHOD(Phalcon_Mvc_View, getRender){