Skip to content

Commit

Permalink
Fixed bug empty template file interrupts forwarding chain
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Oct 9, 2012
1 parent 66f6f17 commit 0fd6c86
Showing 3 changed files with 67 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package2.xml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
<email>[email protected]</email>
<active>yes</active>
</lead>
<date>2012-10-08</date>
<date>2012-?-?</date>
<time>10:21:46</time>
<version>
<release>2.2.4</release>
@@ -22,9 +22,7 @@
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
- Improving warning info while failed opening template script
- Fixed bug that $this is not Yaf_View_Simple in render method which was introduced in 2.2.3
- Fixed memleak in Yaf_View_Simple::display()
- Fixed bug empty template file interrupts forwarding chain
</notes>
<contents>
<dir name="/">
@@ -69,6 +67,7 @@
<file name="simple.c" role="src" />
</dir>
<file name="config.w32" role="src" />
<file name="LICENSE" role="src" />
<file name="CREDITS" role="src" />
<file name="EXPERIMENTAL" role="src" />
<file name="php_yaf.h" role="src" />
@@ -154,6 +153,7 @@
<file name="058.phpt" role="test" />
<file name="059.phpt" role="test" />
<file name="060.phpt" role="test" />
<file name="061.phpt" role="test" />
<file name="build.inc" role="test" />
<file name="bug61493.phpt" role="test" />
<file name="simple.ini" role="test" />
52 changes: 52 additions & 0 deletions tests/061.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--TEST--
Bug empty template file interrupts forward chain
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
--FILE--
<?php
require "build.inc";
startup();

$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);

file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
\$this->forward("dummy");
}
public function dummyAction() {
}
}
PHP
);

file_put_contents(APPLICATION_PATH . "/controllers/Dummy.php", <<<PHP
<?php
class DummyController extends Yaf_Controller_Abstract {
public function indexAction() {
}
}
PHP
);

file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "");
file_put_contents(APPLICATION_PATH . "/views/index/dummy.phtml", "Dummy");

$app = new Yaf_Application($config);
$response = $app->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
Dummy
18 changes: 11 additions & 7 deletions yaf_dispatcher.c
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_dispatcher.c 327708 2012-09-20 10:32:28Z laruence $ */
/* $Id: yaf_dispatcher.c 327959 2012-10-09 02:45:32Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -756,14 +756,20 @@ int yaf_dispatcher_handle(yaf_dispatcher_t *dispatcher, yaf_request_t *request,
zend_call_method_with_1_params(&executor, ce, NULL, "render", &ret, action);
zval_ptr_dtor(&executor);

if (ret && Z_TYPE_P(ret) == IS_STRING && Z_STRLEN_P(ret)) {
yaf_response_alter_body(response, NULL, 0, Z_STRVAL_P(ret), Z_STRLEN_P(ret), YAF_RESPONSE_APPEND TSRMLS_CC);
zval_ptr_dtor(&ret);
} else if (ret) {
if (!ret) {
zval_ptr_dtor(&action);
return 0;
} else if (IS_BOOL == Z_TYPE_P(ret) && !Z_BVAL_P(ret)) {
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
return 0;
}

if (Z_TYPE_P(ret) == IS_STRING && Z_STRLEN_P(ret)) {
yaf_response_alter_body(response, NULL, 0, Z_STRVAL_P(ret), Z_STRLEN_P(ret), YAF_RESPONSE_APPEND TSRMLS_CC);
}

zval_ptr_dtor(&ret);
} else {
zend_call_method_with_1_params(&executor, ce, NULL, "display", &ret, action);
zval_ptr_dtor(&executor);
@@ -779,8 +785,6 @@ int yaf_dispatcher_handle(yaf_dispatcher_t *dispatcher, yaf_request_t *request,
return 0;
} else {
zval_ptr_dtor(&ret);
zval_ptr_dtor(&action);
return 1;
}
}
} else {

0 comments on commit 0fd6c86

Please sign in to comment.