diff --git a/ext/cache/backend/apc.c b/ext/cache/backend/apc.c index d3008e879b2..5536f6bbe22 100644 --- a/ext/cache/backend/apc.c +++ b/ext/cache/backend/apc.c @@ -80,19 +80,19 @@ static const zend_function_entry phalcon_cache_backend_apc_method_entry[] = { PHP_FE_END }; -static int phalcon_cache_backend_is_apcu = -1; +static int phalcon_cache_backend_is_old_apcu = -1; /** * Phalcon\Cache\Backend\Apc initializer */ PHALCON_INIT_CLASS(Phalcon_Cache_Backend_Apc){ - if (-1 == phalcon_cache_backend_is_apcu) { - phalcon_cache_backend_is_apcu = zend_hash_exists(&module_registry, SS("apcu")); - if (phalcon_cache_backend_is_apcu) { + if (-1 == phalcon_cache_backend_is_old_apcu) { + phalcon_cache_backend_is_old_apcu = zend_hash_exists(&module_registry, SS("apcu")); + if (phalcon_cache_backend_is_old_apcu) { zend_constant *c; if (zend_hash_find(EG(zend_constants), SS("APCU_APC_FULL_BC"), (void**)&c) == SUCCESS) { - phalcon_cache_backend_is_apcu = !zend_is_true(&c->value); + phalcon_cache_backend_is_old_apcu = !zend_is_true(&c->value); } } } @@ -390,7 +390,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Apc, queryKeys){ PHALCON_INIT_VAR(iterator); object_init_ex(iterator, apciterator_ce); assert(phalcon_has_constructor(iterator TSRMLS_CC)); - if (!phalcon_cache_backend_is_apcu) { + if (!phalcon_cache_backend_is_old_apcu) { PHALCON_ALLOC_GHOST_ZVAL(type); ZVAL_STRING(type, "user", 1); phalcon_call_method_p2_noret(iterator, "__construct", type, prefix_pattern); @@ -512,7 +512,7 @@ PHP_METHOD(Phalcon_Cache_Backend_Apc, flush){ PHALCON_INIT_VAR(iterator); object_init_ex(iterator, apciterator_ce); assert(phalcon_has_constructor(iterator TSRMLS_CC)); - if (!phalcon_cache_backend_is_apcu) { + if (!phalcon_cache_backend_is_old_apcu) { PHALCON_ALLOC_GHOST_ZVAL(type); ZVAL_STRING(type, "user", 1); phalcon_call_method_p2_noret(iterator, "__construct", type, prefix_pattern); diff --git a/ext/kernel/file.c b/ext/kernel/file.c index dafb11a0eda..799d5a55f8c 100644 --- a/ext/kernel/file.c +++ b/ext/kernel/file.c @@ -17,7 +17,13 @@ +------------------------------------------------------------------------+ */ -#include "php_phalcon.h" +#include "kernel/file.h" +#include "kernel/main.h" +#include "kernel/memory.h" +#include "kernel/concat.h" +#include "kernel/operators.h" + +#include #include
#include @@ -27,12 +33,6 @@ #include #include -#include "kernel/main.h" -#include "kernel/memory.h" -#include "kernel/concat.h" -#include "kernel/operators.h" -#include "kernel/file.h" - /** * Checks if a file exist * @@ -140,7 +140,7 @@ void phalcon_prepare_virtual_path(zval *return_value, zval *path, zval *virtual_ if (ch == '\0') { break; } - if (ch == '/' || ch == '\\' || ch == ':') { + if (ch == '/' || ch == '\\' || ch == ':' || !isprint(ch)) { smart_str_appendl(&virtual_str, Z_STRVAL_P(virtual_separator), Z_STRLEN_P(virtual_separator)); } else { @@ -157,6 +157,28 @@ void phalcon_prepare_virtual_path(zval *return_value, zval *path, zval *virtual_ } } +/** + * Faster version of phalcon_prepare_virtual_path() + */ +void phalcon_prepare_virtual_path_ex(zval *return_value, const char *path, size_t path_len, char virtual_separator TSRMLS_DC) +{ + char *copy = ecalloc(path_len+1, 1); + size_t i; + + for (i=0; i #include +#include #include "kernel/main.h" #include "kernel/memory.h" @@ -52,6 +53,7 @@ zend_class_entry *phalcon_mvc_model_metadata_files_ce; PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, __construct); PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, read); PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, write); +PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, reset); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_model_metadata_files___construct, 0, 0, 0) ZEND_ARG_INFO(0, options) @@ -61,6 +63,7 @@ static const zend_function_entry phalcon_mvc_model_metadata_files_method_entry[] PHP_ME(Phalcon_Mvc_Model_MetaData_Files, __construct, arginfo_phalcon_mvc_model_metadata_files___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Phalcon_Mvc_Model_MetaData_Files, read, arginfo_phalcon_mvc_model_metadatainterface_read, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Mvc_Model_MetaData_Files, write, arginfo_phalcon_mvc_model_metadatainterface_write, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Mvc_Model_MetaData_Files, reset, arginfo_phalcon_mvc_model_metadatainterface_reset, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -87,25 +90,17 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, __construct){ zval *options = NULL, *meta_data_dir, *empty_array; - PHALCON_MM_GROW(); + phalcon_fetch_params(0, 0, 1, &options); - phalcon_fetch_params(1, 0, 1, &options); - - if (!options) { - options = PHALCON_GLOBAL(z_null); - } - - if (Z_TYPE_P(options) == IS_ARRAY) { + if (options && Z_TYPE_P(options) == IS_ARRAY) { if (phalcon_array_isset_string_fetch(&meta_data_dir, options, SS("metaDataDir"))) { phalcon_update_property_this(this_ptr, SL("_metaDataDir"), meta_data_dir TSRMLS_CC); } } - PHALCON_INIT_VAR(empty_array); + PHALCON_ALLOC_GHOST_ZVAL(empty_array); array_init(empty_array); phalcon_update_property_this(this_ptr, SL("_metaData"), empty_array TSRMLS_CC); - - PHALCON_MM_RESTORE(); } /** @@ -116,19 +111,18 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, __construct){ */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, read){ - zval *key, separator = zval_used_for_init, *meta_data_dir, *virtual_key; + zval **key, *meta_data_dir, *virtual_key; zval *path, *data = NULL; + phalcon_fetch_params_ex(1, 0, &key); + PHALCON_ENSURE_IS_STRING(key); + PHALCON_MM_GROW(); - phalcon_fetch_params(1, 1, 0, &key); - - ZVAL_STRINGL(&separator, "_", 1, 0); - meta_data_dir = phalcon_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY_CC); PHALCON_INIT_VAR(virtual_key); - phalcon_prepare_virtual_path(virtual_key, key, &separator TSRMLS_CC); + phalcon_prepare_virtual_path_ex(virtual_key, Z_STRVAL_PP(key), Z_STRLEN_PP(key), '_' TSRMLS_CC); PHALCON_INIT_VAR(path); PHALCON_CONCAT_VVS(path, meta_data_dir, virtual_key, ".php"); @@ -149,28 +143,24 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, read){ */ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Files, write){ - zval *key, *data, *separator, *meta_data_dir, *virtual_key; + zval **key, **data, *meta_data_dir, *virtual_key; zval *path, *php_export, *status; smart_str exp = { NULL, 0, 0 }; + phalcon_fetch_params_ex(2, 0, &key, &data); + PHALCON_MM_GROW(); - phalcon_fetch_params(1, 2, 0, &key, &data); - - PHALCON_INIT_VAR(separator); - ZVAL_STRING(separator, "_", 1); - - PHALCON_OBS_VAR(meta_data_dir); - phalcon_read_property_this(&meta_data_dir, this_ptr, SL("_metaDataDir"), PH_NOISY_CC); + meta_data_dir = phalcon_fetch_nproperty_this(this_ptr, SL("_metaDataDir"), PH_NOISY_CC); PHALCON_INIT_VAR(virtual_key); - phalcon_prepare_virtual_path(virtual_key, key, separator TSRMLS_CC); + phalcon_prepare_virtual_path_ex(virtual_key, Z_STRVAL_PP(key), Z_STRLEN_PP(key), '_' TSRMLS_CC); PHALCON_INIT_VAR(path); PHALCON_CONCAT_VVS(path, meta_data_dir, virtual_key, ".php"); smart_str_appends(&exp, "get_iterator(spl_ce_GlobIterator, iterator, 0 TSRMLS_CC); + it->funcs->rewind(it TSRMLS_CC); + while (SUCCESS == it->funcs->valid(it TSRMLS_CC) && !EG(exception)) { + zval dummy; +#if PHP_VERSION_ID < 50500 + char *str_key; + uint str_key_len; + ulong int_key; + + int key_type = it->funcs->get_current_key(it, &str_key, &str_key_len, &int_key TSRMLS_CC); + if (likely(key_type == HASH_KEY_IS_STRING)) { + PHALCON_INIT_NVAR(itkey); + /* Note that str_key_len includes the trailing zero */ + ZVAL_STRINGL(itkey, str_key, str_key_len-1, 1); + phalcon_unlink(&dummy, itkey TSRMLS_CC); + } +#else + PHALCON_INIT_NVAR(itkey); + it->funcs->get_current_key(it, itkey TSRMLS_CC); + phalcon_unlink(&dummy, itkey TSRMLS_CC); +#endif + + it->funcs->move_forward(it TSRMLS_CC); + } + + it->funcs->dtor(it TSRMLS_CC); + + if (!EG(exception)) { + PHALCON_CALL_PARENT_NORET(phalcon_mvc_model_metadata_files_ce, getThis(), "reset"); + } + + PHALCON_MM_RESTORE(); +} diff --git a/ext/mvc/model/metadata/session.c b/ext/mvc/model/metadata/session.c index cea59ff9f2f..c6d994471af 100644 --- a/ext/mvc/model/metadata/session.c +++ b/ext/mvc/model/metadata/session.c @@ -26,6 +26,7 @@ #include "kernel/array.h" #include "kernel/object.h" #include "kernel/concat.h" +#include "kernel/fcall.h" /** * Phalcon\Mvc\Model\MetaData\Session @@ -46,6 +47,7 @@ zend_class_entry *phalcon_mvc_model_metadata_session_ce; PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, __construct); PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, read); PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, write); +PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, reset); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_model_metadata_session___construct, 0, 0, 0) ZEND_ARG_INFO(0, options) @@ -55,6 +57,7 @@ static const zend_function_entry phalcon_mvc_model_metadata_session_method_entry PHP_ME(Phalcon_Mvc_Model_MetaData_Session, __construct, arginfo_phalcon_mvc_model_metadata_session___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Phalcon_Mvc_Model_MetaData_Session, read, arginfo_phalcon_mvc_model_metadatainterface_read, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Mvc_Model_MetaData_Session, write, arginfo_phalcon_mvc_model_metadatainterface_write, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Mvc_Model_MetaData_Session, reset, arginfo_phalcon_mvc_model_metadatainterface_reset, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -81,27 +84,17 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, __construct){ zval *options = NULL, *prefix, *empty_array; - PHALCON_MM_GROW(); - - phalcon_fetch_params(1, 0, 1, &options); + phalcon_fetch_params(0, 0, 1, &options); - if (!options) { - options = PHALCON_GLOBAL(z_null); - } - - if (Z_TYPE_P(options) == IS_ARRAY) { - if (phalcon_array_isset_string(options, SS("prefix"))) { - PHALCON_OBS_VAR(prefix); - phalcon_array_fetch_string(&prefix, options, SL("prefix"), PH_NOISY); + if (options && Z_TYPE_P(options) == IS_ARRAY) { + if (phalcon_array_isset_string_fetch(&prefix, options, SS("prefix"))) { phalcon_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } } - PHALCON_INIT_VAR(empty_array); + PHALCON_ALLOC_GHOST_ZVAL(empty_array); array_init(empty_array); phalcon_update_property_this(this_ptr, SL("_metaData"), empty_array TSRMLS_CC); - - PHALCON_MM_RESTORE(); } /** @@ -118,12 +111,11 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, read){ PHALCON_MM_GROW(); - phalcon_fetch_params(1, 1, 0, &key); + phalcon_fetch_params(0, 1, 0, &key); session = phalcon_get_global(SS("_SESSION") TSRMLS_CC); - PHALCON_OBS_VAR(prefix); - phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); + prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(prefix_key); PHALCON_CONCAT_SV(prefix_key, "$PMM$", prefix); @@ -155,8 +147,7 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, write){ phalcon_fetch_params(1, 2, 0, &key, &data); - PHALCON_OBS_VAR(prefix); - phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); + prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(prefix_key); PHALCON_CONCAT_SV(prefix_key, "$PMM$", prefix); @@ -166,3 +157,15 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, write){ PHALCON_MM_RESTORE(); } +PHP_METHOD(Phalcon_Mvc_Model_MetaData_Session, reset) +{ + zval prefix_key = zval_used_for_init, *pprefix = &prefix_key, *_SESSION; + zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); + + phalcon_concat_sv(&pprefix, SL("$PMM$"), prefix, 0 TSRMLS_CC); + _SESSION = phalcon_get_global(SS("_SESSION") TSRMLS_CC); + phalcon_array_unset(&_SESSION, &prefix_key, 0); + zval_dtor(&prefix_key); + + PHALCON_CALL_PARENTW(NULL, phalcon_mvc_model_metadata_session_ce, getThis(), "reset"); +} diff --git a/ext/mvc/model/metadata/xcache.c b/ext/mvc/model/metadata/xcache.c index 99dbf067edf..9c72d7132ba 100644 --- a/ext/mvc/model/metadata/xcache.c +++ b/ext/mvc/model/metadata/xcache.c @@ -28,6 +28,7 @@ #include "kernel/object.h" #include "kernel/concat.h" #include "kernel/fcall.h" +#include "kernel/hash.h" /** * Phalcon\Mvc\Model\MetaData\Xcache @@ -50,6 +51,7 @@ zend_class_entry *phalcon_mvc_model_metadata_xcache_ce; PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, __construct); PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, read); PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, write); +PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, reset); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_model_metadata_xcache___construct, 0, 0, 0) ZEND_ARG_INFO(0, options) @@ -59,6 +61,7 @@ static const zend_function_entry phalcon_mvc_model_metadata_xcache_method_entry[ PHP_ME(Phalcon_Mvc_Model_MetaData_Xcache, __construct, arginfo_phalcon_mvc_model_metadata_xcache___construct, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR) PHP_ME(Phalcon_Mvc_Model_MetaData_Xcache, read, arginfo_phalcon_mvc_model_metadatainterface_read, ZEND_ACC_PUBLIC) PHP_ME(Phalcon_Mvc_Model_MetaData_Xcache, write, arginfo_phalcon_mvc_model_metadatainterface_write, ZEND_ACC_PUBLIC) + PHP_ME(Phalcon_Mvc_Model_MetaData_Xcache, reset, arginfo_phalcon_mvc_model_metadatainterface_reset, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -86,32 +89,21 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, __construct){ zval *options = NULL, *prefix, *ttl, *empty_array; - PHALCON_MM_GROW(); - - phalcon_fetch_params(1, 0, 1, &options); + phalcon_fetch_params(0, 0, 1, &options); - if (!options) { - options = PHALCON_GLOBAL(z_null); - } - - if (Z_TYPE_P(options) == IS_ARRAY) { - if (phalcon_array_isset_string(options, SS("prefix"))) { - PHALCON_OBS_VAR(prefix); - phalcon_array_fetch_string(&prefix, options, SL("prefix"), PH_NOISY); + if (options && Z_TYPE_P(options) == IS_ARRAY) { + if (phalcon_array_isset_string_fetch(&prefix, options, SS("prefix"))) { phalcon_update_property_this(this_ptr, SL("_prefix"), prefix TSRMLS_CC); } - if (phalcon_array_isset_string(options, SS("lifetime"))) { - PHALCON_OBS_VAR(ttl); - phalcon_array_fetch_string(&ttl, options, SL("lifetime"), PH_NOISY); + + if (phalcon_array_isset_string_fetch(&ttl, options, SS("lifetime"))) { phalcon_update_property_this(this_ptr, SL("_ttl"), ttl TSRMLS_CC); } } - PHALCON_INIT_VAR(empty_array); + PHALCON_ALLOC_GHOST_ZVAL(empty_array); array_init(empty_array); phalcon_update_property_this(this_ptr, SL("_metaData"), empty_array TSRMLS_CC); - - PHALCON_MM_RESTORE(); } /** @@ -128,8 +120,7 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, read){ phalcon_fetch_params(1, 1, 0, &key); - PHALCON_OBS_VAR(prefix); - phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); + prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(xc_key); PHALCON_CONCAT_SVV(xc_key, "$PMM$", prefix, key); @@ -157,8 +148,7 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, write){ phalcon_fetch_params(1, 2, 0, &key, &data); - PHALCON_OBS_VAR(prefix); - phalcon_read_property_this(&prefix, this_ptr, SL("_prefix"), PH_NOISY_CC); + prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); PHALCON_INIT_VAR(xc_key); PHALCON_CONCAT_SVV(xc_key, "$PMM$", prefix, key); @@ -169,3 +159,39 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, write){ PHALCON_MM_RESTORE(); } + +PHP_METHOD(Phalcon_Mvc_Model_MetaData_Xcache, reset) +{ + zval *meta = phalcon_fetch_nproperty_this(this_ptr, SL("_metaData"), PH_NOISY TSRMLS_CC); + zval *real_key = NULL; + + PHALCON_MM_GROW(); + + if (SUCCESS == phalcon_function_exists_ex(SL("xcache_unset_by_prefix") TSRMLS_CC)) { + zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); + + PHALCON_INIT_VAR(real_key); + phalcon_concat_svs(&real_key, SL("$PMM$"), prefix, SL("meta-"), 0 TSRMLS_CC); + PHALCON_CALL_FUNCTION_NORET("xcache_unset_by_prefix", real_key); + } + else if (Z_TYPE_P(meta) == IS_ARRAY) { + HashTable *ht = Z_ARRVAL_P(meta); + HashPosition hp; + zval *prefix = phalcon_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY TSRMLS_CC); + + for ( + zend_hash_internal_pointer_reset_ex(ht, &hp); + zend_hash_get_current_key_type_ex(ht, &hp) != HASH_KEY_NON_EXISTENT; + zend_hash_move_forward_ex(ht, &hp) + ) { + zval key = phalcon_get_current_key_w(ht, &hp); + + PHALCON_INIT_NVAR(real_key); + phalcon_concat_svsv(&real_key, SL("$PMM$"), prefix, SL("meta-"), &key, 0 TSRMLS_CC); + PHALCON_CALL_FUNCTION_NORET("xcache_unset", real_key); + } + } + + PHALCON_CALL_PARENT_NORET(phalcon_mvc_model_metadata_xcache_ce, getThis(), "reset"); + PHALCON_MM_RESTORE(); +} diff --git a/ext/mvc/model/metadatainterface.c b/ext/mvc/model/metadatainterface.c index 23f6282f48b..93178cc93fb 100644 --- a/ext/mvc/model/metadatainterface.c +++ b/ext/mvc/model/metadatainterface.c @@ -45,8 +45,8 @@ static const zend_function_entry phalcon_mvc_model_metadatainterface_method_entr PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, getColumnMap, arginfo_phalcon_mvc_model_metadatainterface_getcolumnmap) PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, getReverseColumnMap, arginfo_phalcon_mvc_model_metadatainterface_getreversecolumnmap) PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, hasAttribute, arginfo_phalcon_mvc_model_metadatainterface_hasattribute) - PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, isEmpty, NULL) - PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, reset, NULL) + PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, isEmpty, arginfo_phalcon_mvc_model_metadatainterface_isempty) + PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, reset, arginfo_phalcon_mvc_model_metadatainterface_reset) PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, read, arginfo_phalcon_mvc_model_metadatainterface_read) PHP_ABSTRACT_ME(Phalcon_Mvc_Model_MetaDataInterface, write, arginfo_phalcon_mvc_model_metadatainterface_write) PHP_FE_END diff --git a/ext/mvc/model/metadatainterface.h b/ext/mvc/model/metadatainterface.h index 19f16d98669..4948a12ea91 100644 --- a/ext/mvc/model/metadatainterface.h +++ b/ext/mvc/model/metadatainterface.h @@ -129,4 +129,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_model_metadatainterface_write, 0, 0, ZEND_ARG_INFO(0, data) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_model_metadatainterface_reset, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_mvc_model_metadatainterface_isempty, 0, 0, 0) +ZEND_END_ARG_INFO() + #endif /* PHALCON_MVC_MODEL_METADADTAINTERFACE_H */ diff --git a/unit-tests/ModelsMetadataAdaptersTest.php b/unit-tests/ModelsMetadataAdaptersTest.php index 4294811c5a7..4228d4fc24f 100644 --- a/unit-tests/ModelsMetadataAdaptersTest.php +++ b/unit-tests/ModelsMetadataAdaptersTest.php @@ -131,8 +131,10 @@ public function testMetadataMemory() $this->assertFalse($metaData->isEmpty()); - Robots::findFirst(); + $metaData->reset(); + $this->assertTrue($metaData->isEmpty()); + Robots::findFirst(); } public function testMetadataSession() @@ -169,8 +171,10 @@ public function testMetadataSession() $this->assertFalse($metaData->isEmpty()); - Robots::findFirst(); + $metaData->reset(); + $this->assertTrue($metaData->isEmpty()); + Robots::findFirst(); } public function testMetadataApc() @@ -210,8 +214,10 @@ public function testMetadataApc() $this->assertFalse($metaData->isEmpty()); - Robots::findFirst(); + $metaData->reset(); + $this->assertTrue($metaData->isEmpty()); + Robots::findFirst(); } public function testMetadataXcache() @@ -251,8 +257,10 @@ public function testMetadataXcache() $this->assertFalse($metaData->isEmpty()); - Robots::findFirst(); + $metaData->reset(); + $this->assertTrue($metaData->isEmpty()); + Robots::findFirst(); } public function testMetadataFiles() @@ -271,9 +279,6 @@ public function testMetadataFiles() )); }); - @unlink('unit-tests/cache/meta-robots-robots.php'); - @unlink('unit-tests/cache/map-robots.php'); - $metaData = $di->getShared('modelsMetadata'); $metaData->reset(); @@ -287,6 +292,9 @@ public function testMetadataFiles() $this->assertFalse($metaData->isEmpty()); + $metaData->reset(); + $this->assertTrue($metaData->isEmpty()); + Robots::findFirst(); }