diff --git a/ext/session/bag.c b/ext/session/bag.c index 82a9b1eb2d9..dc5a59643ab 100644 --- a/ext/session/bag.c +++ b/ext/session/bag.c @@ -62,7 +62,7 @@ PHALCON_INIT_CLASS(Phalcon_Session_Bag){ zend_declare_property_null(phalcon_session_bag_ce, SL("_dependencyInjector"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_bag_ce, SL("_name"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_bag_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC); - zend_declare_property_bool(phalcon_session_bag_ce, SL("_initalized"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(phalcon_session_bag_ce, SL("_initialized"), 0, ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_bag_ce, SL("_session"), ZEND_ACC_PROTECTED TSRMLS_CC); zend_class_implements(phalcon_session_bag_ce TSRMLS_CC, 2, phalcon_di_injectionawareinterface_ce, phalcon_session_baginterface_ce); @@ -77,16 +77,11 @@ PHALCON_INIT_CLASS(Phalcon_Session_Bag){ */ PHP_METHOD(Phalcon_Session_Bag, __construct){ - zval *name; + zval **name; - phalcon_fetch_params(0, 1, 0, &name); - - if (Z_TYPE_P(name) != IS_STRING) { - PHALCON_THROW_EXCEPTION_STRW(phalcon_session_exception_ce, "The name parameter must be a string"); - return; - } - phalcon_update_property_this(this_ptr, SL("_name"), name TSRMLS_CC); - + phalcon_fetch_params_ex(1, 0, &name); + PHALCON_ENSURE_IS_STRING(name); + phalcon_update_property_this(this_ptr, SL("_name"), *name TSRMLS_CC); } /** @@ -161,7 +156,7 @@ PHP_METHOD(Phalcon_Session_Bag, initialize){ } phalcon_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC); - phalcon_update_property_bool(this_ptr, SL("_initalized"), 1 TSRMLS_CC); + phalcon_update_property_bool(this_ptr, SL("_initialized"), 1 TSRMLS_CC); PHALCON_MM_RESTORE(); } @@ -175,13 +170,13 @@ PHP_METHOD(Phalcon_Session_Bag, initialize){ */ PHP_METHOD(Phalcon_Session_Bag, destroy){ - zval *initalized, *name, *session; + zval *initialized, *name, *session; PHALCON_MM_GROW(); - PHALCON_OBS_VAR(initalized); - phalcon_read_property_this(&initalized, this_ptr, SL("_initalized"), PH_NOISY_CC); - if (PHALCON_IS_FALSE(initalized)) { + PHALCON_OBS_VAR(initialized); + phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); + if (PHALCON_IS_FALSE(initialized)) { phalcon_call_method_noret(this_ptr, "initialize"); } @@ -207,16 +202,16 @@ PHP_METHOD(Phalcon_Session_Bag, destroy){ */ PHP_METHOD(Phalcon_Session_Bag, set){ - zval *property, *value, *initalized, *name, *data; + zval *property, *value, *initialized, *name, *data; zval *session; PHALCON_MM_GROW(); phalcon_fetch_params(1, 2, 0, &property, &value); - PHALCON_OBS_VAR(initalized); - phalcon_read_property_this(&initalized, this_ptr, SL("_initalized"), PH_NOISY_CC); - if (PHALCON_IS_FALSE(initalized)) { + PHALCON_OBS_VAR(initialized); + phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); + if (PHALCON_IS_FALSE(initialized)) { phalcon_call_method_noret(this_ptr, "initialize"); } @@ -261,7 +256,7 @@ PHALCON_DOC_METHOD(Phalcon_Session_Bag, __set); */ PHP_METHOD(Phalcon_Session_Bag, get){ - zval *property, *default_value = NULL, *initalized; + zval *property, *default_value = NULL, *initialized; zval *data, *value; PHALCON_MM_GROW(); @@ -275,9 +270,9 @@ PHP_METHOD(Phalcon_Session_Bag, get){ /** * Check first if the bag is initialized */ - PHALCON_OBS_VAR(initalized); - phalcon_read_property_this(&initalized, this_ptr, SL("_initalized"), PH_NOISY_CC); - if (PHALCON_IS_FALSE(initalized)) { + PHALCON_OBS_VAR(initialized); + phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); + if (PHALCON_IS_FALSE(initialized)) { phalcon_call_method_noret(this_ptr, "initialize"); } @@ -323,15 +318,15 @@ PHALCON_DOC_METHOD(Phalcon_Session_Bag, __get); */ PHP_METHOD(Phalcon_Session_Bag, has){ - zval *property, *initalized, *data; + zval *property, *initialized, *data; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &property); - PHALCON_OBS_VAR(initalized); - phalcon_read_property_this(&initalized, this_ptr, SL("_initalized"), PH_NOISY_CC); - if (PHALCON_IS_FALSE(initalized)) { + PHALCON_OBS_VAR(initialized); + phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); + if (PHALCON_IS_FALSE(initialized)) { phalcon_call_method_noret(this_ptr, "initialize"); } @@ -370,11 +365,18 @@ PHALCON_DOC_METHOD(Phalcon_Session_Bag, __isset); PHP_METHOD(Phalcon_Session_Bag, remove){ zval *property, *data = NULL, *name, *session; + zval *initialized; PHALCON_MM_GROW(); phalcon_fetch_params(1, 1, 0, &property); - + + PHALCON_OBS_VAR(initialized); + phalcon_read_property_this(&initialized, this_ptr, SL("_initialized"), PH_NOISY_CC); + if (PHALCON_IS_FALSE(initialized)) { + phalcon_call_method_noret(this_ptr, "initialize"); + } + PHALCON_OBS_VAR(data); phalcon_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); if (phalcon_array_isset(data, property)) {