From ccee505f47ba3a5a70ca42084c38a2f17759bf30 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 26 Jun 2024 13:45:36 +0800 Subject: [PATCH] fixed issue #584 (yaf_view_simple __isset missed) --- tests/029.phpt | 8 ++++++++ views/yaf_view_simple.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/tests/029.phpt b/tests/029.phpt index 705d7147..e9a8c24b 100644 --- a/tests/029.phpt +++ b/tests/029.phpt @@ -14,8 +14,12 @@ print_r($view->get("a")); print_r($view->get()); $view->clear("b"); print_r($view->get()); +var_dump(empty($view->a)); +var_dump(isset($view->a)); $view->clear(); print_r($view->get()); +var_dump(empty($view->a)); +var_dump(isset($view->a)); ?> --EXPECTF-- bArray @@ -27,6 +31,10 @@ Array ( [a] => b ) +bool(false) +bool(true) Array ( ) +bool(true) +bool(false) diff --git a/views/yaf_view_simple.c b/views/yaf_view_simple.c index 7402fed7..add71001 100755 --- a/views/yaf_view_simple.c +++ b/views/yaf_view_simple.c @@ -551,6 +551,20 @@ PHP_METHOD(yaf_view_simple, get) { } /* }}} */ +/** {{{ proto public Yaf_View_Simple::__isset($name) +*/ +PHP_METHOD(yaf_view_simple, __isset) { + zend_string *name = NULL; + yaf_view_object *view = Z_YAFVIEWOBJ_P(getThis()); + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name) == FAILURE) { + return; + } + + RETURN_BOOL(zend_hash_exists(&view->tpl_vars, name)); +} +/* }}} */ + /** {{{ proto public Yaf_View_Simple::render(string $tpl, array $vars = NULL) */ PHP_METHOD(yaf_view_simple, render) { @@ -638,6 +652,7 @@ zend_function_entry yaf_view_simple_methods[] = { PHP_ME(yaf_view_simple, clear, arginfo_class_Yaf_View_Simple_clear, ZEND_ACC_PUBLIC) PHP_ME(yaf_view_simple, setScriptPath, arginfo_class_Yaf_View_Simple_setScriptPath, ZEND_ACC_PUBLIC) PHP_ME(yaf_view_simple, getScriptPath, arginfo_class_Yaf_View_Simple_getScriptPath, ZEND_ACC_PUBLIC) + PHP_ME(yaf_view_simple, __isset, arginfo_class_Yaf_View_Simple___isset, ZEND_ACC_PUBLIC) PHP_MALIAS(yaf_view_simple, __get, get, arginfo_class_Yaf_View_Simple___get, ZEND_ACC_PUBLIC) PHP_MALIAS(yaf_view_simple, __set, assign, arginfo_class_Yaf_View_Simple___set, ZEND_ACC_PUBLIC) {NULL, NULL, NULL}