From 66c75319d9349093786a90c2542e8e2fbc10bd9f Mon Sep 17 00:00:00 2001 From: jere_jones Date: Fri, 29 Jun 2012 23:38:18 -0400 Subject: [PATCH 01/13] Add exists() and destroy() to Phalcon_Session --- dev/phalcon.h | 8 ++++ dev/session.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/dev/phalcon.h b/dev/phalcon.h index 846545653a0..876396fc3b3 100755 --- a/dev/phalcon.h +++ b/dev/phalcon.h @@ -1118,12 +1118,14 @@ PHP_METHOD(Phalcon_Controller_Front, getInstance); PHP_METHOD(Phalcon_Controller_Front, reset); PHP_METHOD(Phalcon_Session, start); +PHP_METHOD(Phalcon_Session, destroy); PHP_METHOD(Phalcon_Session, setOptions); PHP_METHOD(Phalcon_Session, get); PHP_METHOD(Phalcon_Session, set); PHP_METHOD(Phalcon_Session, has); PHP_METHOD(Phalcon_Session, remove); PHP_METHOD(Phalcon_Session, getId); +PHP_METHOD(Phalcon_Session, exists); PHP_METHOD(Phalcon_Flash, _showMessage); PHP_METHOD(Phalcon_Flash, error); @@ -3156,6 +3158,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_start, 0, 0, 0) ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_destroy, 0, 0, 0) + ZEND_ARG_INFO(0, delete_cookie) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_setoptions, 0, 0, 1) ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() @@ -4520,12 +4526,14 @@ PHALCON_INIT_FUNCS(phalcon_controller_front_functions){ PHALCON_INIT_FUNCS(phalcon_session_functions){ PHP_ME(Phalcon_Session, start, arginfo_phalcon_session_start, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Session, destroy, arginfo_phalcon_session_destroy, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, setOptions, arginfo_phalcon_session_setoptions, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, get, arginfo_phalcon_session_get, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, set, arginfo_phalcon_session_set, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, has, arginfo_phalcon_session_has, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, remove, arginfo_phalcon_session_remove, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, getId, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Session, exists, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_FE_END }; diff --git a/dev/session.c b/dev/session.c index ca4baa24874..dd321ff49b8 100644 --- a/dev/session.c +++ b/dev/session.c @@ -77,6 +77,89 @@ PHP_METHOD(Phalcon_Session, start){ PHALCON_MM_RESTORE(); } +/** + * Destroys a session, optionally also deleting the session cookie. Calling this function before calling Phalcon_Session::start() is an error. + * + * @param array $delete_cookie + */ +PHP_METHOD(Phalcon_Session, destroy){ + + zval *session_cookie_name = NULL, + *session_cookie_value = NULL, + *session_cookie_expiration = NULL, + *session_cookie_params = NULL, + *session_cookie_path_key = NULL, + *session_cookie_path = NULL, + *session_cookie_domain_key = NULL, + *session_cookie_domain = NULL, + *session_cookie_secure_key = NULL, + *session_cookie_secure = NULL, + *session_cookie_httponly_key = NULL, + *session_cookie_httponly = NULL, + *cookies = NULL, + *set_cookie_return = NULL, + *session_destroy_return = NULL; + zval* set_cookie_params[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + + zend_bool delete_cookie = FALSE; + + PHALCON_MM_GROW(); + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &delete_cookie) == FAILURE) { + PHALCON_MM_RESTORE(); + RETURN_NULL(); + } + + if (delete_cookie) { + PHALCON_ALLOC_ZVAL_MM(session_cookie_params); + PHALCON_CALL_FUNC(session_cookie_params, "session_get_cookie_params"); + + PHALCON_ALLOC_ZVAL_MM(session_cookie_name); + PHALCON_CALL_FUNC(session_cookie_name, "session_name"); + set_cookie_params[0] = session_cookie_name; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_value); + ZVAL_STRING(session_cookie_value, "", 1); + set_cookie_params[1] = session_cookie_value; + + PHALCON_INIT_VAR(session_cookie_expiration); + ZVAL_LONG(session_cookie_expiration, 1); + set_cookie_params[2] = session_cookie_expiration; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_path_key); + ZVAL_STRING(session_cookie_path_key, "path", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_path); + phalcon_array_fetch(&session_cookie_path, session_cookie_params, session_cookie_path_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[3] = session_cookie_path; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_domain_key); + ZVAL_STRING(session_cookie_domain_key, "domain", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_domain); + phalcon_array_fetch(&session_cookie_domain, session_cookie_params, session_cookie_domain_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[4] = session_cookie_domain; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_secure_key); + ZVAL_STRING(session_cookie_secure_key, "secure", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_secure); + phalcon_array_fetch(&session_cookie_secure, session_cookie_params, session_cookie_secure_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[5] = session_cookie_secure; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_httponly_key); + ZVAL_STRING(session_cookie_httponly_key, "httponly", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_httponly); + phalcon_array_fetch(&session_cookie_httponly, session_cookie_params, session_cookie_httponly_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[6] = session_cookie_httponly; + + PHALCON_ALLOC_ZVAL_MM(set_cookie_return); + PHALCON_CALL_FUNC_PARAMS(set_cookie_return, "setcookie", 7, set_cookie_params); + } + + PHALCON_ALLOC_ZVAL_MM(session_destroy_return); + PHALCON_CALL_FUNC(session_destroy_return, "session_destroy"); + + RETURN_DZVAL(session_destroy_return); +} + /** * Sets session options * @@ -258,3 +341,29 @@ PHP_METHOD(Phalcon_Session, getId){ RETURN_DZVAL(r0); } +/** + * Checks if session cookie exists + * + * @return string + */ +PHP_METHOD(Phalcon_Session, exists){ + zval *session_cookie_name = NULL, + *cookies = NULL; + int eval_int; + + PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(session_cookie_name); + PHALCON_CALL_FUNC(session_cookie_name, "session_name"); + + phalcon_get_global(&cookies, SL("_COOKIE")+1 TSRMLS_CC); + eval_int = phalcon_array_isset(cookies, session_cookie_name); + + PHALCON_MM_RESTORE(); + + if (eval_int) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} + From a7d9a948051aefdc89104f42a4a39661e5628bc1 Mon Sep 17 00:00:00 2001 From: jere_jones Date: Fri, 29 Jun 2012 23:41:37 -0400 Subject: [PATCH 02/13] Correct Phalcon_Session::destroy param type --- dev/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/session.c b/dev/session.c index dd321ff49b8..07830ec6fe9 100644 --- a/dev/session.c +++ b/dev/session.c @@ -80,7 +80,7 @@ PHP_METHOD(Phalcon_Session, start){ /** * Destroys a session, optionally also deleting the session cookie. Calling this function before calling Phalcon_Session::start() is an error. * - * @param array $delete_cookie + * @param bool $delete_cookie */ PHP_METHOD(Phalcon_Session, destroy){ From 9e9d8c52375faac458316ce657fd27e85a8edf00 Mon Sep 17 00:00:00 2001 From: jere_jones Date: Sat, 30 Jun 2012 14:28:33 -0400 Subject: [PATCH 03/13] Efficency modifications to Phalcon_Session Phalcon_Session::start only calls session_start() once. Phalcon_Session::destory ensures Phalcon_Session::exists returns false and Phalcon_Session::start can be called again. --- dev/phalcon.c | 3 +++ dev/session.c | 54 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/dev/phalcon.c b/dev/phalcon.c index ddc52983b86..39bd8f637ea 100755 --- a/dev/phalcon.c +++ b/dev/phalcon.c @@ -684,6 +684,9 @@ PHP_MINIT_FUNCTION(phalcon){ phalcon_session_ce = zend_register_internal_class(&ce_session TSRMLS_CC); zend_declare_property_null(phalcon_session_ce, SL("_uniqueId"), ZEND_ACC_STATIC|ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_ce, SL("_options"), ZEND_ACC_STATIC|ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(phalcon_session_ce, SL("_started"), 0, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC); + // _exists is not a bool so that it can be NULL meaning it hasn't been set yet. + zend_declare_property_null(phalcon_session_ce, SL("_exists"), ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC); INIT_CLASS_ENTRY(ce_flash, "Phalcon_Flash", phalcon_flash_functions); phalcon_flash_ce = zend_register_internal_class(&ce_flash TSRMLS_CC); diff --git a/dev/session.c b/dev/session.c index 07830ec6fe9..4f19254c883 100644 --- a/dev/session.c +++ b/dev/session.c @@ -57,6 +57,8 @@ PHP_METHOD(Phalcon_Session, start){ zval *options = NULL; zval *a0 = NULL; zval *r0 = NULL; + zval *started = NULL; + zval *ztrue = NULL; PHALCON_MM_GROW(); @@ -71,9 +73,21 @@ PHP_METHOD(Phalcon_Session, start){ PHALCON_CPY_WRT(options, a0); } - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_FUNC(r0, "session_start"); - + PHALCON_OBSERVE_VAR(started); + phalcon_read_static_property(&started, SL("Phalcon_Session"), SL("_started") TSRMLS_CC); + + if (!zend_is_true(started)) { + PHALCON_ALLOC_ZVAL_MM(r0); + PHALCON_CALL_FUNC(r0, "session_start"); + + PHALCON_INIT_VAR(ztrue); + ZVAL_BOOL(ztrue, TRUE); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_started"), ztrue TSRMLS_CC); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), ztrue TSRMLS_CC); + } else { + + } + PHALCON_MM_RESTORE(); } @@ -98,7 +112,8 @@ PHP_METHOD(Phalcon_Session, destroy){ *session_cookie_httponly = NULL, *cookies = NULL, *set_cookie_return = NULL, - *session_destroy_return = NULL; + *session_destroy_return = NULL, + *zfalse = NULL; zval* set_cookie_params[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; zend_bool delete_cookie = FALSE; @@ -157,6 +172,11 @@ PHP_METHOD(Phalcon_Session, destroy){ PHALCON_ALLOC_ZVAL_MM(session_destroy_return); PHALCON_CALL_FUNC(session_destroy_return, "session_destroy"); + PHALCON_INIT_VAR(zfalse); + ZVAL_BOOL(zfalse, FALSE); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_started"), zfalse TSRMLS_CC); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), zfalse TSRMLS_CC); + RETURN_DZVAL(session_destroy_return); } @@ -347,17 +367,31 @@ PHP_METHOD(Phalcon_Session, getId){ * @return string */ PHP_METHOD(Phalcon_Session, exists){ - zval *session_cookie_name = NULL, - *cookies = NULL; + zval *static_exists = NULL; + zval *cookie_exists = NULL; + zval *session_cookie_name = NULL; + zval *cookies = NULL; int eval_int; PHALCON_MM_GROW(); - PHALCON_ALLOC_ZVAL_MM(session_cookie_name); - PHALCON_CALL_FUNC(session_cookie_name, "session_name"); - phalcon_get_global(&cookies, SL("_COOKIE")+1 TSRMLS_CC); - eval_int = phalcon_array_isset(cookies, session_cookie_name); + PHALCON_OBSERVE_VAR(static_exists); + phalcon_read_static_property(&static_exists, SL("Phalcon_Session"), SL("_exists") TSRMLS_CC); + + if (Z_TYPE_P(static_exists) == IS_NULL) { + PHALCON_ALLOC_ZVAL_MM(session_cookie_name); + PHALCON_CALL_FUNC(session_cookie_name, "session_name"); + + phalcon_get_global(&cookies, SL("_COOKIE")+1 TSRMLS_CC); + eval_int = phalcon_array_isset(cookies, session_cookie_name); + PHALCON_INIT_VAR(cookie_exists); + ZVAL_BOOL(cookie_exists, eval_int); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), cookie_exists TSRMLS_CC); + phalcon_read_static_property(&static_exists, SL("Phalcon_Session"), SL("_exists") TSRMLS_CC); + } + + eval_int = zend_is_true(static_exists); PHALCON_MM_RESTORE(); if (eval_int) { From 1937b7ea42b08c81c1212184c303ee52ff583039 Mon Sep 17 00:00:00 2001 From: jere_jones Date: Sat, 30 Jun 2012 19:06:33 -0400 Subject: [PATCH 04/13] Update vcproj for file existence changes in phalcon/cphalcon --- win32/cphalcon.vcproj | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/win32/cphalcon.vcproj b/win32/cphalcon.vcproj index 8ef5a02fa00..36706959ab4 100644 --- a/win32/cphalcon.vcproj +++ b/win32/cphalcon.vcproj @@ -46,7 +46,7 @@ StringPooling="true" MinimalRebuild="true" BasicRuntimeChecks="3" - RuntimeLibrary="1" + RuntimeLibrary="3" UsePrecompiledHeader="0" ObjectFile="$(IntDir)\" WarningLevel="3" @@ -2779,42 +2779,6 @@ /> - - - - - - - - - - - - - - From 13f1a887cf1dc7f14e4bb215019d93ed1ec40a1a Mon Sep 17 00:00:00 2001 From: jere_jones Date: Wed, 4 Jul 2012 12:29:34 -0400 Subject: [PATCH 05/13] Update VS2008 project to include registry.c --- win32/cphalcon.vcproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/win32/cphalcon.vcproj b/win32/cphalcon.vcproj index 36706959ab4..a89e4913a15 100644 --- a/win32/cphalcon.vcproj +++ b/win32/cphalcon.vcproj @@ -4012,6 +4012,10 @@ RelativePath="..\dev\php_phalcon.h" > + + From 669e9d0480e2911095e56bac11883c3c0df63101 Mon Sep 17 00:00:00 2001 From: jere_jones Date: Wed, 4 Jul 2012 12:31:36 -0400 Subject: [PATCH 06/13] Add Phalcon_Session::started(). Make get/set/has more efficient and cache-friendly --- dev/phalcon.h | 2 + dev/session.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/dev/phalcon.h b/dev/phalcon.h index 749205a872a..100981fd520 100755 --- a/dev/phalcon.h +++ b/dev/phalcon.h @@ -1133,6 +1133,7 @@ PHP_METHOD(Phalcon_Session, set); PHP_METHOD(Phalcon_Session, has); PHP_METHOD(Phalcon_Session, remove); PHP_METHOD(Phalcon_Session, getId); +PHP_METHOD(Phalcon_Session, started); PHP_METHOD(Phalcon_Session, exists); PHP_METHOD(Phalcon_Flash, _showMessage); @@ -4566,6 +4567,7 @@ PHALCON_INIT_FUNCS(phalcon_session_functions){ PHP_ME(Phalcon_Session, has, arginfo_phalcon_session_has, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, remove, arginfo_phalcon_session_remove, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, getId, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Session, started, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, exists, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_FE_END }; diff --git a/dev/session.c b/dev/session.c index 4f19254c883..d1268aa6b0f 100644 --- a/dev/session.c +++ b/dev/session.c @@ -73,8 +73,8 @@ PHP_METHOD(Phalcon_Session, start){ PHALCON_CPY_WRT(options, a0); } - PHALCON_OBSERVE_VAR(started); - phalcon_read_static_property(&started, SL("Phalcon_Session"), SL("_started") TSRMLS_CC); + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); if (!zend_is_true(started)) { PHALCON_ALLOC_ZVAL_MM(r0); @@ -84,8 +84,6 @@ PHP_METHOD(Phalcon_Session, start){ ZVAL_BOOL(ztrue, TRUE); phalcon_update_static_property(SL("Phalcon_Session"), SL("_started"), ztrue TSRMLS_CC); phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), ztrue TSRMLS_CC); - } else { - } PHALCON_MM_RESTORE(); @@ -114,11 +112,25 @@ PHP_METHOD(Phalcon_Session, destroy){ *set_cookie_return = NULL, *session_destroy_return = NULL, *zfalse = NULL; + zval *exists = NULL, *started = NULL; zval* set_cookie_params[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; zend_bool delete_cookie = FALSE; PHALCON_MM_GROW(); + + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_FALSE; + } + + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &delete_cookie) == FAILURE) { PHALCON_MM_RESTORE(); @@ -219,10 +231,25 @@ PHP_METHOD(Phalcon_Session, get){ zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; zval *g0 = NULL; + zval *exists = NULL, *started = NULL; + int eval_int; PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_NULL(); + } + + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); @@ -257,6 +284,7 @@ PHP_METHOD(Phalcon_Session, get){ PHP_METHOD(Phalcon_Session, set){ zval *index = NULL, *value = NULL; + zval *started = NULL; zval *g0 = NULL; zval *r0 = NULL; zval *t0 = NULL; @@ -268,6 +296,12 @@ PHP_METHOD(Phalcon_Session, set){ RETURN_NULL(); } + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + phalcon_get_global(&g0, SL("_SESSION")+1 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_OBSERVE_VAR(t0); @@ -289,15 +323,29 @@ PHP_METHOD(Phalcon_Session, has){ zval *r0 = NULL; zval *t0 = NULL; zval *g0 = NULL; + zval *exists = NULL, *started = NULL; int eval_int; PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_FALSE; + } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Session"), SL("_uniqueId") TSRMLS_CC); @@ -305,6 +353,7 @@ PHP_METHOD(Phalcon_Session, has){ PHALCON_CPY_WRT(key, r0); phalcon_get_global(&g0, SL("_SESSION")+1 TSRMLS_CC); eval_int = phalcon_array_isset(g0, key); + if (eval_int) { PHALCON_MM_RESTORE(); RETURN_TRUE; @@ -312,8 +361,6 @@ PHP_METHOD(Phalcon_Session, has){ PHALCON_MM_RESTORE(); RETURN_FALSE; } - - PHALCON_MM_RESTORE(); } /** @@ -324,17 +371,31 @@ PHP_METHOD(Phalcon_Session, has){ PHP_METHOD(Phalcon_Session, remove){ zval *index = NULL, *key = NULL; + zval *exists = NULL, *started = NULL; zval *r0 = NULL; zval *t0 = NULL; zval *g0 = NULL; PHALCON_MM_GROW(); - + + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_FALSE; + } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Session"), SL("_uniqueId") TSRMLS_CC); @@ -361,10 +422,34 @@ PHP_METHOD(Phalcon_Session, getId){ RETURN_DZVAL(r0); } +/** + * Checks if session has been started + * + * @return boolean + */ +PHP_METHOD(Phalcon_Session, started){ + zval *static_started = NULL; + int eval_int; + + PHALCON_MM_GROW(); + + PHALCON_OBSERVE_VAR(static_started); + phalcon_read_static_property(&static_started, SL("Phalcon_Session"), SL("_started") TSRMLS_CC); + + eval_int = zend_is_true(static_started); + PHALCON_MM_RESTORE(); + + if (eval_int) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} + /** * Checks if session cookie exists * - * @return string + * @return boolean */ PHP_METHOD(Phalcon_Session, exists){ zval *static_exists = NULL; From 5a13685e3ab03a2de5acff37a2811fa3d4810e06 Mon Sep 17 00:00:00 2001 From: jere_jones Date: Wed, 4 Jul 2012 20:14:26 -0400 Subject: [PATCH 07/13] Partial views work now. Only external change is that partials must be echoed. They don't output themselves. --- dev/view.c | 57 ++++++++++++++++++----- dev/view/engine.c | 7 ++- dev/view/engine/mustache.c | 6 +-- dev/view/engine/php.c | 9 ++-- dev/view/engine/twig.c | 6 +-- unit-tests/ViewTest.php | 21 +++++---- unit-tests/views/partials/_partial2.phtml | 1 + unit-tests/views/test5/index.phtml | 2 +- unit-tests/views/test9/index.phtml | 5 ++ 9 files changed, 82 insertions(+), 32 deletions(-) create mode 100644 unit-tests/views/partials/_partial2.phtml create mode 100644 unit-tests/views/test9/index.phtml diff --git a/dev/view.c b/dev/view.c index 72695ee9fc5..1443702b368 100755 --- a/dev/view.c +++ b/dev/view.c @@ -572,6 +572,7 @@ PHP_METHOD(Phalcon_View, _engineRender){ zval *t7 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *i0 = NULL; + zval *rendered = NULL; HashTable *ah0; HashPosition hp0; zval **hd; @@ -588,6 +589,8 @@ PHP_METHOD(Phalcon_View, _engineRender){ RETURN_NULL(); } + PHALCON_INIT_VAR(rendered); + ZVAL_NULL(rendered); PHALCON_INIT_VAR(not_exists); ZVAL_BOOL(not_exists, 1); @@ -680,7 +683,7 @@ PHP_METHOD(Phalcon_View, _engineRender){ PHALCON_CONCAT_VV(r5, views_dir_path, extension); PHALCON_CPY_WRT(view_engine_path, r5); if (phalcon_file_exists(view_engine_path TSRMLS_CC) == SUCCESS) { - PHALCON_CALL_METHOD_PARAMS_2_NORETURN(engine, "render", view_engine_path, view_params, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_2(rendered, engine, "render", view_engine_path, view_params, PHALCON_NO_CHECK); PHALCON_INIT_VAR(not_exists); ZVAL_BOOL(not_exists, 0); @@ -705,7 +708,7 @@ PHP_METHOD(Phalcon_View, _engineRender){ } } - PHALCON_MM_RESTORE(); + RETURN_DZVAL(rendered); } /** @@ -757,6 +760,7 @@ PHP_METHOD(Phalcon_View, render){ zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL; + zval *render_buffer = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; @@ -843,7 +847,11 @@ PHP_METHOD(Phalcon_View, render){ PHALCON_INIT_VAR(r6); is_smaller_or_equal_function(r6, t4, render_level TSRMLS_CC); if (zend_is_true(r6)) { - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, render_view, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, render_view, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } PHALCON_INIT_VAR(t5); @@ -870,7 +878,11 @@ PHP_METHOD(Phalcon_View, render){ ZVAL_ZVAL(template_before, *hd, 1, 0); PHALCON_INIT_VAR(r8); PHALCON_CONCAT_VV(r8, layouts_dir, template_before); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r8, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r8, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } zend_hash_move_forward_ex(ah0, &hp0); goto fes_b0d8_2; fee_b0d8_2: @@ -881,7 +893,11 @@ PHP_METHOD(Phalcon_View, render){ } else { PHALCON_ALLOC_ZVAL_MM(r9); PHALCON_CONCAT_VV(r9, layouts_dir, template_before); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r9, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r9, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } PHALCON_INIT_VAR(silence); @@ -897,7 +913,12 @@ PHP_METHOD(Phalcon_View, render){ if (zend_is_true(r10)) { PHALCON_ALLOC_ZVAL_MM(r11); PHALCON_CONCAT_VV(r11, layouts_dir, render_controller); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r11, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r11, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } + } PHALCON_INIT_VAR(t8); @@ -924,7 +945,11 @@ PHP_METHOD(Phalcon_View, render){ ZVAL_ZVAL(template_after, *hd, 1, 0); PHALCON_INIT_VAR(r13); PHALCON_CONCAT_VV(r13, layouts_dir, template_after); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r13, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r13, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } zend_hash_move_forward_ex(ah1, &hp1); goto fes_b0d8_3; fee_b0d8_3: @@ -935,7 +960,11 @@ PHP_METHOD(Phalcon_View, render){ } else { PHALCON_ALLOC_ZVAL_MM(r14); PHALCON_CONCAT_VV(r14, layouts_dir, templates_after); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r14, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r14, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } PHALCON_INIT_VAR(silence); @@ -951,7 +980,11 @@ PHP_METHOD(Phalcon_View, render){ if (zend_is_true(r15)) { PHALCON_ALLOC_ZVAL_MM(t11); phalcon_read_property(&t11, this_ptr, SL("_mainView"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, t11, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, t11, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } if (zend_is_true(cache)) { @@ -1035,6 +1068,7 @@ PHP_METHOD(Phalcon_View, pick){ PHP_METHOD(Phalcon_View, partial){ zval *partial_path = NULL, *vfalse = NULL; + zval *render_buffer = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); @@ -1047,11 +1081,12 @@ PHP_METHOD(Phalcon_View, partial){ PHALCON_INIT_VAR(vfalse); ZVAL_BOOL(vfalse, 0); + PHALCON_INIT_VAR(render_buffer); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD(r0, this_ptr, "_loadtemplateengines", PHALCON_NO_CHECK); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", r0, partial_path, vfalse, vfalse, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", r0, partial_path, vfalse, vfalse, PHALCON_NO_CHECK); - PHALCON_MM_RESTORE(); + RETURN_DZVAL(render_buffer); } /** diff --git a/dev/view/engine.c b/dev/view/engine.c index ed73d67a717..160540c394d 100644 --- a/dev/view/engine.c +++ b/dev/view/engine.c @@ -210,10 +210,12 @@ PHP_METHOD(Phalcon_View_Engine, path){ * Renders a partial inside another view * * @param string $partialPath + * @return string */ PHP_METHOD(Phalcon_View_Engine, partial){ zval *partial_path = NULL; + zval *render_buffer = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); @@ -225,8 +227,9 @@ PHP_METHOD(Phalcon_View_Engine, partial){ PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_view"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t0, "partial", partial_path, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_1(render_buffer, t0, "partial", partial_path, PHALCON_NO_CHECK); - PHALCON_MM_RESTORE(); + RETURN_DZVAL(render_buffer); } diff --git a/dev/view/engine/mustache.c b/dev/view/engine/mustache.c index 7ec1fece493..df3acbfc4f6 100644 --- a/dev/view/engine/mustache.c +++ b/dev/view/engine/mustache.c @@ -95,6 +95,7 @@ PHP_METHOD(Phalcon_View_Engine_Mustache, __construct){ * * @param string $path * @param array $params + * @return string */ PHP_METHOD(Phalcon_View_Engine_Mustache, render){ @@ -122,9 +123,8 @@ PHP_METHOD(Phalcon_View_Engine_Mustache, render){ PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_FUNC_PARAMS_1(r1, "file_get_contents", path); PHALCON_CALL_METHOD_PARAMS_2(r0, t1, "render", r1, this_ptr, PHALCON_NO_CHECK); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t0, "setcontent", r0, PHALCON_NO_CHECK); - - PHALCON_MM_RESTORE(); + + RETURN_DZVAL(r0); } PHP_METHOD(Phalcon_View_Engine_Mustache, __isset){ diff --git a/dev/view/engine/php.c b/dev/view/engine/php.c index cc62c3a1ca1..fa3c5430bbd 100644 --- a/dev/view/engine/php.c +++ b/dev/view/engine/php.c @@ -69,6 +69,7 @@ PHP_METHOD(Phalcon_View_Engine_Php, __construct){ * * @param string $path * @param array $params + * @return string */ PHP_METHOD(Phalcon_View_Engine_Php, render){ @@ -90,7 +91,7 @@ PHP_METHOD(Phalcon_View_Engine_Php, render){ RETURN_NULL(); } - PHALCON_CALL_FUNC_NORETURN("ob_clean"); + PHALCON_CALL_FUNC_NORETURN("ob_start"); if (phalcon_valid_foreach(params TSRMLS_CC)) { ah0 = Z_ARRVAL_P(params); zend_hash_internal_pointer_reset_ex(ah0, &hp0); @@ -122,8 +123,8 @@ PHP_METHOD(Phalcon_View_Engine_Php, render){ PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_FUNC(r0, "ob_get_contents"); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t0, "setcontent", r0, PHALCON_NO_CHECK); - - PHALCON_MM_RESTORE(); + PHALCON_CALL_FUNC_NORETURN("ob_end_clean"); + + RETURN_DZVAL(r0); } diff --git a/dev/view/engine/twig.c b/dev/view/engine/twig.c index 16bba8944ec..e5addfbc7a6 100644 --- a/dev/view/engine/twig.c +++ b/dev/view/engine/twig.c @@ -111,6 +111,7 @@ PHP_METHOD(Phalcon_View_Engine_Twig, __construct){ * * @param string $path * @param array $params + * @return string */ PHP_METHOD(Phalcon_View_Engine_Twig, render){ @@ -161,8 +162,7 @@ PHP_METHOD(Phalcon_View_Engine_Twig, render){ PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, SL("_twig"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_2(r3, t2, "render", relative_path, twig_params, PHALCON_NO_CHECK); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t1, "setcontent", r3, PHALCON_NO_CHECK); - - PHALCON_MM_RESTORE(); + + RETURN_DZVAL(r3); } diff --git a/unit-tests/ViewTest.php b/unit-tests/ViewTest.php index 493f9d79ee7..5f36cb59740 100644 --- a/unit-tests/ViewTest.php +++ b/unit-tests/ViewTest.php @@ -21,7 +21,6 @@ class ViewTest extends PHPUnit_Framework_TestCase { public function testStandardRender(){ - $view = new Phalcon_View(); $view->setBasePath(__DIR__.'/../'); @@ -32,12 +31,12 @@ public function testStandardRender(){ $view->start(); $view->render('test2', 'index'); $view->finish(); - $this->assertEquals($view->getContent(), 'here'."\n"); + $this->assertEquals($view->getContent(), 'here'.PHP_EOL); $view->start(); $view->render('test3', 'other'); $view->finish(); - $this->assertEquals($view->getContent(), 'lolhere'."\n"); + $this->assertEquals($view->getContent(), 'lolhere'.PHP_EOL); //Variables $view->setParamToView('a_cool_var', 'le-this'); @@ -46,7 +45,7 @@ public function testStandardRender(){ $view->render('test3', 'another'); $view->finish(); - $this->assertEquals($view->getContent(), 'lol

le-this

'."\n"); + $this->assertEquals($view->getContent(), 'lol

le-this

'.PHP_EOL); //Templates $view->setTemplateAfter('test'); @@ -55,7 +54,7 @@ public function testStandardRender(){ $view->render('test3', 'other'); $view->finish(); - $this->assertEquals($view->getContent(), 'zuplolhere'."\n"); + $this->assertEquals($view->getContent(), 'zuplolhere'.PHP_EOL); $view->cleanTemplateAfter(); @@ -65,7 +64,7 @@ public function testStandardRender(){ $view->start(); $view->render('test3', 'other'); $view->finish(); - $this->assertEquals($view->getContent(), 'lolhere'."\n"); + $this->assertEquals($view->getContent(), 'lolhere'.PHP_EOL); $view->setRenderLevel(Phalcon_View::LEVEL_LAYOUT); @@ -87,7 +86,7 @@ public function testStandardRender(){ $view->pick('test3/yup'); $view->render('test3', 'other'); $view->finish(); - $this->assertEquals($view->getContent(), 'lolyup'."\n"); + $this->assertEquals($view->getContent(), 'lolyup'.PHP_EOL); } @@ -105,7 +104,13 @@ public function testPartials(){ $view->render('test5', 'index'); $view->finish(); - $this->assertEquals($view->getContent(), 'Hey, this is a partial, also le-this'."\n"); + $this->assertEquals($view->getContent(), 'Hey, this is a partial, also le-this'.PHP_EOL); + + $view->start(); + $view->render('test9', 'index'); + $view->finish(); + + $this->assertEquals($view->getContent(), 'Hey, this is a partial, also le-this
Hey, this is a second partial, also le-this'.PHP_EOL); } diff --git a/unit-tests/views/partials/_partial2.phtml b/unit-tests/views/partials/_partial2.phtml new file mode 100644 index 00000000000..86d1ef0be49 --- /dev/null +++ b/unit-tests/views/partials/_partial2.phtml @@ -0,0 +1 @@ +Hey, this is a second partial, also \ No newline at end of file diff --git a/unit-tests/views/test5/index.phtml b/unit-tests/views/test5/index.phtml index 0a3a0dbf84c..9dd4d02c36a 100644 --- a/unit-tests/views/test5/index.phtml +++ b/unit-tests/views/test5/index.phtml @@ -1 +1 @@ -partial("partials/_partial1") ?> \ No newline at end of file +partial("partials/_partial1") ?> \ No newline at end of file diff --git a/unit-tests/views/test9/index.phtml b/unit-tests/views/test9/index.phtml new file mode 100644 index 00000000000..88a3c27506c --- /dev/null +++ b/unit-tests/views/test9/index.phtml @@ -0,0 +1,5 @@ +partial("partials/_partial1"); +echo '
'; +echo $this->partial("partials/_partial2"); +?> \ No newline at end of file From d860f23b226214e5e7505307b033eda79b13ceac Mon Sep 17 00:00:00 2001 From: Phalcon Date: Wed, 4 Jul 2012 19:23:15 -0500 Subject: [PATCH 08/13] Replacing boolean constants by values --- dev/session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/session.c b/dev/session.c index d1268aa6b0f..07319bd1f17 100644 --- a/dev/session.c +++ b/dev/session.c @@ -81,7 +81,7 @@ PHP_METHOD(Phalcon_Session, start){ PHALCON_CALL_FUNC(r0, "session_start"); PHALCON_INIT_VAR(ztrue); - ZVAL_BOOL(ztrue, TRUE); + ZVAL_BOOL(ztrue, 1); phalcon_update_static_property(SL("Phalcon_Session"), SL("_started"), ztrue TSRMLS_CC); phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), ztrue TSRMLS_CC); } @@ -115,7 +115,7 @@ PHP_METHOD(Phalcon_Session, destroy){ zval *exists = NULL, *started = NULL; zval* set_cookie_params[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; - zend_bool delete_cookie = FALSE; + zend_bool delete_cookie = 0; PHALCON_MM_GROW(); @@ -185,7 +185,7 @@ PHP_METHOD(Phalcon_Session, destroy){ PHALCON_CALL_FUNC(session_destroy_return, "session_destroy"); PHALCON_INIT_VAR(zfalse); - ZVAL_BOOL(zfalse, FALSE); + ZVAL_BOOL(zfalse, 0); phalcon_update_static_property(SL("Phalcon_Session"), SL("_started"), zfalse TSRMLS_CC); phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), zfalse TSRMLS_CC); From 01f515f72d4ee392cab635f37c748dfc63e9b2b0 Mon Sep 17 00:00:00 2001 From: Phalcon Date: Sat, 7 Jul 2012 16:50:55 -0500 Subject: [PATCH 09/13] Running tests with release --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a0fc1516c2c..be293f97da3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_script: - git clone https://github.com/bobthecow/mustache.php.git - git clone git://github.com/fabpot/Twig.git - cd ../.. - - cd dev/ + - cd release/ - export CFLAGS="-g -O2 -fno-delete-null-pointer-checks" - sh -c "phpize && ./configure --enable-phalcon && make && sudo make install" - echo "extension=phalcon.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` From 2602bf6d6cdcf8ed84f4a3a0c4b9f8adc26e9ec3 Mon Sep 17 00:00:00 2001 From: Phalcon Date: Sat, 7 Jul 2012 18:44:26 -0500 Subject: [PATCH 10/13] Removing partials test --- unit-tests/ViewTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unit-tests/ViewTest.php b/unit-tests/ViewTest.php index 5f36cb59740..8208e676ca1 100644 --- a/unit-tests/ViewTest.php +++ b/unit-tests/ViewTest.php @@ -90,7 +90,7 @@ public function testStandardRender(){ } - public function testPartials(){ + /*public function testPartials(){ $view = new Phalcon_View(); $view->setBasePath(__DIR__.'/../'); @@ -112,6 +112,6 @@ public function testPartials(){ $this->assertEquals($view->getContent(), 'Hey, this is a partial, also le-this
Hey, this is a second partial, also le-this'.PHP_EOL); - } + }*/ -} \ No newline at end of file +} From 038b5c28b846d17b8bf1989dfed75036123a2f40 Mon Sep 17 00:00:00 2001 From: Andres Gutierrez Date: Mon, 9 Jul 2012 00:42:29 -0500 Subject: [PATCH 11/13] Restoring dev build --- .travis.yml | 2 +- unit-tests/ViewTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index be293f97da3..a0fc1516c2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_script: - git clone https://github.com/bobthecow/mustache.php.git - git clone git://github.com/fabpot/Twig.git - cd ../.. - - cd release/ + - cd dev/ - export CFLAGS="-g -O2 -fno-delete-null-pointer-checks" - sh -c "phpize && ./configure --enable-phalcon && make && sudo make install" - echo "extension=phalcon.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` diff --git a/unit-tests/ViewTest.php b/unit-tests/ViewTest.php index 8208e676ca1..f8eab5439f5 100644 --- a/unit-tests/ViewTest.php +++ b/unit-tests/ViewTest.php @@ -90,7 +90,7 @@ public function testStandardRender(){ } - /*public function testPartials(){ + public function testPartials(){ $view = new Phalcon_View(); $view->setBasePath(__DIR__.'/../'); @@ -112,6 +112,6 @@ public function testStandardRender(){ $this->assertEquals($view->getContent(), 'Hey, this is a partial, also le-this
Hey, this is a second partial, also le-this'.PHP_EOL); - }*/ + } } From 5f3434fe7ef8835b11dfce124d970074688edfa2 Mon Sep 17 00:00:00 2001 From: jere_jones Date: Mon, 9 Jul 2012 12:20:56 -0400 Subject: [PATCH 12/13] Fix partialView and viewCache tests --- dev/view.c | 7 ++++++- unit-tests/views/test5/index.phtml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dev/view.c b/dev/view.c index 1443702b368..c9765d82130 100755 --- a/dev/view.c +++ b/dev/view.c @@ -761,6 +761,7 @@ PHP_METHOD(Phalcon_View, render){ zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL; zval *render_buffer = NULL; + zval *z_null = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; @@ -994,7 +995,11 @@ PHP_METHOD(Phalcon_View, render){ PHALCON_ALLOC_ZVAL_MM(r17); PHALCON_CALL_METHOD(r17, cache, "isfresh", PHALCON_NO_CHECK); if (zend_is_true(r17)) { - PHALCON_CALL_METHOD_NORETURN(cache, "save", PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD(render_buffer, this_ptr, "getcontent", PHALCON_NO_CHECK); + PHALCON_INIT_VAR(z_null); + ZVAL_NULL(z_null); + PHALCON_CALL_METHOD_PARAMS_2_NORETURN(cache, "save", z_null, render_buffer, PHALCON_NO_CHECK); } } } diff --git a/unit-tests/views/test5/index.phtml b/unit-tests/views/test5/index.phtml index 9dd4d02c36a..1e5e8700533 100644 --- a/unit-tests/views/test5/index.phtml +++ b/unit-tests/views/test5/index.phtml @@ -1 +1 @@ -partial("partials/_partial1") ?> \ No newline at end of file +partial("partials/_partial1"); ?> \ No newline at end of file From 938ede80679aa6dc85ae9381922e56ee176be1b9 Mon Sep 17 00:00:00 2001 From: jere_jones Date: Mon, 9 Jul 2012 12:23:49 -0400 Subject: [PATCH 13/13] Update /release files Auto generate /release files via script Add /release files to VS2008 project Make VS2008 build /dev or /release depending on target config. --- release/phalcon.c | 468 +- release/phalcon.h | 10 + release/php_phalcon.h | 37 +- win32/README.md | 8 +- win32/cphalcon.vcproj | 5922 +++++++++++--------- win32/scripts/create_release_src_files.bat | 7 + win32/scripts/create_release_src_files.js | 296 + win32/scripts/update-project.js | 71 +- 8 files changed, 4034 insertions(+), 2785 deletions(-) create mode 100644 win32/scripts/create_release_src_files.bat create mode 100644 win32/scripts/create_release_src_files.js diff --git a/release/phalcon.c b/release/phalcon.c index 8a8b9d323e9..faa8b0c28ea 100644 --- a/release/phalcon.c +++ b/release/phalcon.c @@ -84,7 +84,7 @@ extern PHPAPI zend_class_entry *spl_ce_SeekableIterator; #endif /** Startup functions */ -extern void php_phalcon_init_globals(zend_phalcon_globals *phalcon_globals TSRMLS_DC); +void php_phalcon_init_globals(zend_phalcon_globals *phalcon_globals TSRMLS_DC); /** Globals functions */ int phalcon_init_global(char *global, int global_length TSRMLS_DC); @@ -92,23 +92,23 @@ int phalcon_get_global(zval **arr, char *global, int global_length TSRMLS_DC); int phalcon_get_global_by_index(char *global, char *index, zval *result TSRMLS_DC); /** Exception Functions */ -extern void phalcon_throw_exception(zval *object TSRMLS_DC); -extern void phalcon_throw_exception_string(zend_class_entry *ce, char *message, zend_uint message_len TSRMLS_DC); +void phalcon_throw_exception(zval *object TSRMLS_DC); +void phalcon_throw_exception_string(zend_class_entry *ce, char *message, zend_uint message_len TSRMLS_DC); int phalcon_file_exists(zval *filename TSRMLS_DC); /** Function replacement **/ -extern void phalcon_fast_count(zval *result, zval *array TSRMLS_DC); -extern void phalcon_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC); -extern void phalcon_fast_explode(zval *result, zval *delimiter, zval *str TSRMLS_DC); -extern void phalcon_fast_strpos(zval *return_value, zval *haystack, zval *needle TSRMLS_DC); -extern void phalcon_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject TSRMLS_DC); +void phalcon_fast_count(zval *result, zval *array TSRMLS_DC); +void phalcon_fast_join(zval *result, zval *glue, zval *pieces TSRMLS_DC); +void phalcon_fast_explode(zval *result, zval *delimiter, zval *str TSRMLS_DC); +void phalcon_fast_strpos(zval *return_value, zval *haystack, zval *needle TSRMLS_DC); +void phalcon_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject TSRMLS_DC); /** Low level filters */ int phalcon_filter_alphanum(zval *result, zval *param); /* Utils functions */ -extern void phalcon_inherit_not_found(char *class_name, char *inherit_name); +void phalcon_inherit_not_found(char *class_name, char *inherit_name); int phalcon_valid_foreach(zval *arr TSRMLS_DC); /** Export symbols to active symbol table */ @@ -194,7 +194,6 @@ int phalcon_set_symbol(zval *key_name, zval *value TSRMLS_DC); }\ } - #define PHALCON_CALL_FUNC(return_value, func_name) if(phalcon_call_func(return_value, func_name, strlen(func_name), 1 TSRMLS_CC)==FAILURE) return; #define PHALCON_CALL_FUNC_NORETURN(func_name) if(phalcon_call_func(NULL, func_name, strlen(func_name), 0 TSRMLS_CC)==FAILURE) return; #define PHALCON_CALL_FUNC_PARAMS(return_value, func_name, param_count, params) if(phalcon_call_func_params(return_value, func_name, strlen(func_name), param_count, params, 1 TSRMLS_CC)==FAILURE) return; @@ -361,13 +360,12 @@ int phalcon_debug_param(zval *param TSRMLS_DC); int phalcon_error_space(); int phalcon_debug_space(); -extern FILE *phalcon_log; +FILE *phalcon_log; int phalcon_debug_trace; -extern phalcon_debug_entry *start; -extern phalcon_debug_entry *active; +phalcon_debug_entry *start; +phalcon_debug_entry *active; #endif - #ifndef PHALCON_RELEASE int phalcon_assert_class(zval *object, char *class_name TSRMLS_DC); @@ -380,9 +378,9 @@ int phalcon_assert_class(zval *object, char *class_name TSRMLS_DC); /** Class Constants */ #define PHALCON_GET_CLASS_CONSTANT(var, class_entry, name) PHALCON_VAR_INIT(var); phalcon_get_class_constant(var, class_entry, name, strlen(name) TSRMLS_CC) -extern void phalcon_get_class(zval *result, zval *object TSRMLS_DC); +void phalcon_get_class(zval *result, zval *object TSRMLS_DC); -extern zend_class_entry *phalcon_fetch_class(zval *class_name TSRMLS_DC); +zend_class_entry *phalcon_fetch_class(zval *class_name TSRMLS_DC); int phalcon_get_class_constant(zval *return_value, zend_class_entry *ce, char *constant_name, int constant_length TSRMLS_DC); @@ -409,7 +407,6 @@ int phalcon_update_property_zval_zval(zval *obj, zval *property, zval *value TSR /** Static properties **/ int phalcon_read_static_property(zval **result, char *class_name, int class_length, char *property_name, int property_length TSRMLS_DC); int phalcon_update_static_property(char *class_name, int class_length, char *name, int name_length, zval *value TSRMLS_DC); - /** Check for index existence */ int phalcon_array_isset(const zval *arr, zval *index); int phalcon_array_isset_long(const zval *arr, ulong index); @@ -429,17 +426,16 @@ int phalcon_array_update_string(zval **arr, char *index, uint index_length, zval int phalcon_array_update_long(zval **arr, ulong index, zval **value, int separate, int copy, int ctor TSRMLS_DC); /** Update/Append multidimensional arrays */ -extern void phalcon_array_update_multi_2(zval **config, zval *index1, zval *index2, zval **value, int separate TSRMLS_DC); -extern void phalcon_array_update_multi_long_long_2(zval **arr, long index1, long index2, zval **value, int separate TSRMLS_DC); -extern void phalcon_array_update_multi_long_str_2(zval **arr, long index1, char *index2, int index2_length, zval **value, int separate TSRMLS_DC); -extern void phalcon_array_update_multi_append_2(zval **arr, zval *index1, zval *value, int separate TSRMLS_DC); +void phalcon_array_update_multi_2(zval **config, zval *index1, zval *index2, zval **value, int separate TSRMLS_DC); +void phalcon_array_update_multi_long_long_2(zval **arr, long index1, long index2, zval **value, int separate TSRMLS_DC); +void phalcon_array_update_multi_long_str_2(zval **arr, long index1, char *index2, int index2_length, zval **value, int separate TSRMLS_DC); +void phalcon_array_update_multi_append_2(zval **arr, zval *index1, zval *value, int separate TSRMLS_DC); /** Fetch items from arrays */ int phalcon_array_fetch(zval **return_value, zval *arr, zval *index, int silent TSRMLS_DC); int phalcon_array_fetch_string(zval **return_value, zval *arr, char *index, uint index_length, int silent TSRMLS_DC); int phalcon_array_fetch_long(zval **return_value, zval *arr, ulong index, int silent TSRMLS_DC); - /** Operators */ #define PHALCON_COMPARE_STRING(op1, op2) phalcon_compare_strict_string(op1, op2, strlen(op2)) @@ -447,17 +443,17 @@ int phalcon_array_fetch_long(zval **return_value, zval *arr, ulong index, int si int phalcon_add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC); int phalcon_and_function(zval *result, zval *left, zval *right); -extern void phalcon_concat_self(zval **left, zval *right TSRMLS_DC); +void phalcon_concat_self(zval **left, zval *right TSRMLS_DC); int phalcon_compare_strict_string(zval *op1, char *op2, int op2_length); int phalcon_is_smaller_strict_long(zval *op1, long op2 TSRMLS_DC); int phalcon_is_smaller_or_equal_strict_long(zval *op1, long op2 TSRMLS_DC); -extern void phalcon_increment_function(zval **var, int separate TSRMLS_DC); -extern void phalcon_decrement_function(zval **var, int separate TSRMLS_DC); +void phalcon_increment_function(zval **var, int separate TSRMLS_DC); +void phalcon_decrement_function(zval **var, int separate TSRMLS_DC); -extern void phalcon_cast(zval *result, zval *var, zend_uint type); +void phalcon_cast(zval *result, zval *var, zend_uint type); #define PHALCON_CONCAT_SV(result, op1, op2) \ phalcon_concat_sv(result, op1, strlen(op1), op2 TSRMLS_CC); #define PHALCON_CONCAT_SVS(result, op1, op2, op3) \ @@ -489,24 +485,23 @@ extern void phalcon_cast(zval *result, zval *var, zend_uint type); #define PHALCON_CONCAT_VVVS(result, op1, op2, op3, op4) \ phalcon_concat_vvvs(result, op1, op2, op3, op4, strlen(op4) TSRMLS_CC); -extern void phalcon_concat_sv(zval *result, char *op1, zend_uint op1_len, zval *op2 TSRMLS_DC); -extern void phalcon_concat_svs(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len TSRMLS_DC); -extern void phalcon_concat_svsv(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4 TSRMLS_DC); -extern void phalcon_concat_svsvs(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, char *op5, zend_uint op5_len TSRMLS_DC); -extern void phalcon_concat_svsvsv(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, char *op5, zend_uint op5_len, zval *op6 TSRMLS_DC); -extern void phalcon_concat_svsvsvs(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, char *op5, zend_uint op5_len, zval *op6, char *op7, zend_uint op7_len TSRMLS_DC); -extern void phalcon_concat_svsvv(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, zval *op5 TSRMLS_DC); -extern void phalcon_concat_svv(zval *result, char *op1, zend_uint op1_len, zval *op2, zval *op3 TSRMLS_DC); -extern void phalcon_concat_vs(zval *result, zval *op1, char *op2, zend_uint op2_len TSRMLS_DC); -extern void phalcon_concat_vsv(zval *result, zval *op1, char *op2, zend_uint op2_len, zval *op3 TSRMLS_DC); -extern void phalcon_concat_vsvs(zval *result, zval *op1, char *op2, zend_uint op2_len, zval *op3, char *op4, zend_uint op4_len TSRMLS_DC); -extern void phalcon_concat_vv(zval *result, zval *op1, zval *op2 TSRMLS_DC); -extern void phalcon_concat_vvs(zval *result, zval *op1, zval *op2, char *op3, zend_uint op3_len TSRMLS_DC); -extern void phalcon_concat_vvv(zval *result, zval *op1, zval *op2, zval *op3 TSRMLS_DC); -extern void phalcon_concat_vvvs(zval *result, zval *op1, zval *op2, zval *op3, char *op4, zend_uint op4_len TSRMLS_DC); - -extern void phalcon_init_var(zval **var TSRMLS_DC); -extern void phalcon_cpy_wrt(zval **dest, zval *var TSRMLS_DC); +void phalcon_concat_sv(zval *result, char *op1, zend_uint op1_len, zval *op2 TSRMLS_DC); +void phalcon_concat_svs(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len TSRMLS_DC); +void phalcon_concat_svsv(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4 TSRMLS_DC); +void phalcon_concat_svsvs(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, char *op5, zend_uint op5_len TSRMLS_DC); +void phalcon_concat_svsvsv(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, char *op5, zend_uint op5_len, zval *op6 TSRMLS_DC); +void phalcon_concat_svsvsvs(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, char *op5, zend_uint op5_len, zval *op6, char *op7, zend_uint op7_len TSRMLS_DC); +void phalcon_concat_svsvv(zval *result, char *op1, zend_uint op1_len, zval *op2, char *op3, zend_uint op3_len, zval *op4, zval *op5 TSRMLS_DC); +void phalcon_concat_svv(zval *result, char *op1, zend_uint op1_len, zval *op2, zval *op3 TSRMLS_DC); +void phalcon_concat_vs(zval *result, zval *op1, char *op2, zend_uint op2_len TSRMLS_DC); +void phalcon_concat_vsv(zval *result, zval *op1, char *op2, zend_uint op2_len, zval *op3 TSRMLS_DC); +void phalcon_concat_vsvs(zval *result, zval *op1, char *op2, zend_uint op2_len, zval *op3, char *op4, zend_uint op4_len TSRMLS_DC); +void phalcon_concat_vv(zval *result, zval *op1, zval *op2 TSRMLS_DC); +void phalcon_concat_vvs(zval *result, zval *op1, zval *op2, char *op3, zend_uint op3_len TSRMLS_DC); +void phalcon_concat_vvv(zval *result, zval *op1, zval *op2, zval *op3 TSRMLS_DC); +void phalcon_concat_vvvs(zval *result, zval *op1, zval *op2, zval *op3, char *op4, zend_uint op4_len TSRMLS_DC); +void phalcon_init_var(zval **var TSRMLS_DC); +void phalcon_cpy_wrt(zval **dest, zval *var TSRMLS_DC); int phalcon_memory_grow_stack(TSRMLS_D); int phalcon_memory_restore_stack(TSRMLS_D); @@ -632,11 +627,6 @@ int phalcon_clean_restore_stack(TSRMLS_D); zval_ptr_dtor(&var);\ } - -#ifdef HAVE_CONFIG_H -#endif - - /** * Initialize globals on each request or each thread started */ @@ -991,10 +981,6 @@ int phalcon_valid_foreach(zval *arr TSRMLS_DC){ void phalcon_inherit_not_found(char *class_name, char *inherit_name){ fprintf(stderr, "Phalcon Error: Extended class '%s' not found when registering class '%s'", class_name, inherit_name); } -#ifdef HAVE_CONFIG_H -#endif - - /** * Initializes fcall cache */ @@ -2257,10 +2243,6 @@ int phalcon_call_internal_method(char *method_name, int method_len, zend_fcall_i } #endif -#ifdef HAVE_CONFIG_H -#endif - - /** * Do an internal require to a plain php file * @@ -2363,11 +2345,6 @@ int phalcon_require(zval *require_path TSRMLS_DC){ return status; } - -#ifdef HAVE_CONFIG_H -#endif - - /** * Applies sprintf function to a variable list */ @@ -2712,11 +2689,6 @@ int phalcon_step_out_entry(){ } #endif - -#ifdef HAVE_CONFIG_H -#endif - - #ifndef PHALCON_RELEASE int phalcon_assert_class(zval *object, char *class_name TSRMLS_DC){ @@ -2737,9 +2709,6 @@ int phalcon_assert_class(zval *object, char *class_name TSRMLS_DC){ } #endif -#ifdef HAVE_CONFIG_H -#endif - #ifdef PHP_WIN32 #endif @@ -3131,11 +3100,6 @@ int phalcon_update_static_property(char *class_name, int class_length, char *nam return FAILURE; } } - -#ifdef HAVE_CONFIG_H -#endif - - /** * Check if index exists on an array zval */ @@ -3660,12 +3624,6 @@ void phalcon_array_update_multi_append_2(zval **arr, zval *index1, zval *value, zval_ptr_dtor(&temp); } - -#ifdef HAVE_CONFIG_H -#endif - - - /** * Performs logical AND function operator */ @@ -3826,11 +3784,6 @@ void phalcon_cast(zval *result, zval *var, zend_uint type){ } -#ifdef HAVE_CONFIG_H -#endif - - - void phalcon_concat_sv(zval *result, char *op1, zend_uint op1_len, zval *op2 TSRMLS_DC){ zval op2_copy; @@ -4419,11 +4372,6 @@ void phalcon_concat_vvvs(zval *result, zval *op1, zval *op2, zval *op3, char *op } - -#ifdef HAVE_CONFIG_H -#endif - - /** * Initializes/Reinitializes a variable */ @@ -4586,7 +4534,8 @@ int phalcon_clean_restore_stack(TSRMLS_D){ phalcon_memory_restore_stack(TSRMLS_C); } return SUCCESS; -}/** +} +/** * Phalcon_Session_Namespace * * This component helps to separate session data into namespaces. Working by this way @@ -11041,6 +10990,7 @@ PHP_METHOD(Phalcon_View, _engineRender){ zval *t7 = NULL; zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *i0 = NULL; + zval *rendered = NULL; HashTable *ah0; HashPosition hp0; zval **hd; @@ -11057,6 +11007,8 @@ PHP_METHOD(Phalcon_View, _engineRender){ RETURN_NULL(); } + PHALCON_INIT_VAR(rendered); + ZVAL_NULL(rendered); PHALCON_INIT_VAR(not_exists); ZVAL_BOOL(not_exists, 1); @@ -11149,7 +11101,7 @@ PHP_METHOD(Phalcon_View, _engineRender){ PHALCON_CONCAT_VV(r5, views_dir_path, extension); PHALCON_CPY_WRT(view_engine_path, r5); if (phalcon_file_exists(view_engine_path TSRMLS_CC) == SUCCESS) { - PHALCON_CALL_METHOD_PARAMS_2_NORETURN(engine, "render", view_engine_path, view_params, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_2(rendered, engine, "render", view_engine_path, view_params, PHALCON_NO_CHECK); PHALCON_INIT_VAR(not_exists); ZVAL_BOOL(not_exists, 0); @@ -11174,7 +11126,7 @@ PHP_METHOD(Phalcon_View, _engineRender){ } } - PHALCON_MM_RESTORE(); + RETURN_DZVAL(rendered); } /** @@ -11226,6 +11178,8 @@ PHP_METHOD(Phalcon_View, render){ zval *r0 = NULL, *r1 = NULL, *r2 = NULL, *r3 = NULL, *r4 = NULL, *r5 = NULL, *r6 = NULL; zval *r7 = NULL, *r8 = NULL, *r9 = NULL, *r10 = NULL, *r11 = NULL, *r12 = NULL, *r13 = NULL; zval *r14 = NULL, *r15 = NULL, *r16 = NULL, *r17 = NULL; + zval *render_buffer = NULL; + zval *z_null = NULL; HashTable *ah0, *ah1; HashPosition hp0, hp1; zval **hd; @@ -11312,7 +11266,11 @@ PHP_METHOD(Phalcon_View, render){ PHALCON_INIT_VAR(r6); is_smaller_or_equal_function(r6, t4, render_level TSRMLS_CC); if (zend_is_true(r6)) { - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, render_view, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, render_view, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } PHALCON_INIT_VAR(t5); @@ -11339,7 +11297,11 @@ PHP_METHOD(Phalcon_View, render){ ZVAL_ZVAL(template_before, *hd, 1, 0); PHALCON_INIT_VAR(r8); PHALCON_CONCAT_VV(r8, layouts_dir, template_before); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r8, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r8, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } zend_hash_move_forward_ex(ah0, &hp0); goto fes_b0d8_2; fee_b0d8_2: @@ -11350,7 +11312,11 @@ PHP_METHOD(Phalcon_View, render){ } else { PHALCON_ALLOC_ZVAL_MM(r9); PHALCON_CONCAT_VV(r9, layouts_dir, template_before); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r9, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r9, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } PHALCON_INIT_VAR(silence); @@ -11366,7 +11332,12 @@ PHP_METHOD(Phalcon_View, render){ if (zend_is_true(r10)) { PHALCON_ALLOC_ZVAL_MM(r11); PHALCON_CONCAT_VV(r11, layouts_dir, render_controller); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r11, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r11, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } + } PHALCON_INIT_VAR(t8); @@ -11393,7 +11364,11 @@ PHP_METHOD(Phalcon_View, render){ ZVAL_ZVAL(template_after, *hd, 1, 0); PHALCON_INIT_VAR(r13); PHALCON_CONCAT_VV(r13, layouts_dir, template_after); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r13, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r13, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } zend_hash_move_forward_ex(ah1, &hp1); goto fes_b0d8_3; fee_b0d8_3: @@ -11404,7 +11379,11 @@ PHP_METHOD(Phalcon_View, render){ } else { PHALCON_ALLOC_ZVAL_MM(r14); PHALCON_CONCAT_VV(r14, layouts_dir, templates_after); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, r14, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, r14, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } PHALCON_INIT_VAR(silence); @@ -11420,7 +11399,11 @@ PHP_METHOD(Phalcon_View, render){ if (zend_is_true(r15)) { PHALCON_ALLOC_ZVAL_MM(t11); phalcon_read_property(&t11, this_ptr, SL("_mainView"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", engines, t11, silence, cache, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", engines, t11, silence, cache, PHALCON_NO_CHECK); + if (zend_is_true(render_buffer)) { + PHALCON_CALL_METHOD_PARAMS_1_NORETURN(this_ptr, "setcontent", render_buffer, PHALCON_NO_CHECK); + } } if (zend_is_true(cache)) { @@ -11430,7 +11413,11 @@ PHP_METHOD(Phalcon_View, render){ PHALCON_ALLOC_ZVAL_MM(r17); PHALCON_CALL_METHOD(r17, cache, "isfresh", PHALCON_NO_CHECK); if (zend_is_true(r17)) { - PHALCON_CALL_METHOD_NORETURN(cache, "save", PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD(render_buffer, this_ptr, "getcontent", PHALCON_NO_CHECK); + PHALCON_INIT_VAR(z_null); + ZVAL_NULL(z_null); + PHALCON_CALL_METHOD_PARAMS_2_NORETURN(cache, "save", z_null, render_buffer, PHALCON_NO_CHECK); } } } @@ -11504,6 +11491,7 @@ PHP_METHOD(Phalcon_View, pick){ PHP_METHOD(Phalcon_View, partial){ zval *partial_path = NULL, *vfalse = NULL; + zval *render_buffer = NULL; zval *r0 = NULL; PHALCON_MM_GROW(); @@ -11516,11 +11504,12 @@ PHP_METHOD(Phalcon_View, partial){ PHALCON_INIT_VAR(vfalse); ZVAL_BOOL(vfalse, 0); + PHALCON_INIT_VAR(render_buffer); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_METHOD(r0, this_ptr, "_loadtemplateengines", PHALCON_NO_CHECK); - PHALCON_CALL_METHOD_PARAMS_4_NORETURN(this_ptr, "_enginerender", r0, partial_path, vfalse, vfalse, PHALCON_NO_CHECK); + PHALCON_CALL_METHOD_PARAMS_4(render_buffer, this_ptr, "_enginerender", r0, partial_path, vfalse, vfalse, PHALCON_NO_CHECK); - PHALCON_MM_RESTORE(); + RETURN_DZVAL(render_buffer); } /** @@ -11966,10 +11955,12 @@ PHP_METHOD(Phalcon_View_Engine, path){ * Renders a partial inside another view * * @param string $partialPath + * @return string */ PHP_METHOD(Phalcon_View_Engine, partial){ zval *partial_path = NULL; + zval *render_buffer = NULL; zval *t0 = NULL; PHALCON_MM_GROW(); @@ -11981,9 +11972,10 @@ PHP_METHOD(Phalcon_View_Engine, partial){ PHALCON_ALLOC_ZVAL_MM(t0); phalcon_read_property(&t0, this_ptr, SL("_view"), PHALCON_NOISY TSRMLS_CC); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t0, "partial", partial_path, PHALCON_NO_CHECK); + PHALCON_INIT_VAR(render_buffer); + PHALCON_CALL_METHOD_PARAMS_1(render_buffer, t0, "partial", partial_path, PHALCON_NO_CHECK); - PHALCON_MM_RESTORE(); + RETURN_DZVAL(render_buffer); } /** @@ -12026,6 +12018,7 @@ PHP_METHOD(Phalcon_View_Engine_Php, __construct){ * * @param string $path * @param array $params + * @return string */ PHP_METHOD(Phalcon_View_Engine_Php, render){ @@ -12047,7 +12040,7 @@ PHP_METHOD(Phalcon_View_Engine_Php, render){ RETURN_NULL(); } - PHALCON_CALL_FUNC_NORETURN("ob_clean"); + PHALCON_CALL_FUNC_NORETURN("ob_start"); if (phalcon_valid_foreach(params TSRMLS_CC)) { ah0 = Z_ARRVAL_P(params); zend_hash_internal_pointer_reset_ex(ah0, &hp0); @@ -12079,9 +12072,9 @@ PHP_METHOD(Phalcon_View_Engine_Php, render){ PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_CALL_FUNC(r0, "ob_get_contents"); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t0, "setcontent", r0, PHALCON_NO_CHECK); - - PHALCON_MM_RESTORE(); + PHALCON_CALL_FUNC_NORETURN("ob_end_clean"); + + RETURN_DZVAL(r0); } /** @@ -12160,6 +12153,7 @@ PHP_METHOD(Phalcon_View_Engine_Twig, __construct){ * * @param string $path * @param array $params + * @return string */ PHP_METHOD(Phalcon_View_Engine_Twig, render){ @@ -12210,9 +12204,8 @@ PHP_METHOD(Phalcon_View_Engine_Twig, render){ PHALCON_ALLOC_ZVAL_MM(t2); phalcon_read_property(&t2, this_ptr, SL("_twig"), PHALCON_NOISY TSRMLS_CC); PHALCON_CALL_METHOD_PARAMS_2(r3, t2, "render", relative_path, twig_params, PHALCON_NO_CHECK); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t1, "setcontent", r3, PHALCON_NO_CHECK); - - PHALCON_MM_RESTORE(); + + RETURN_DZVAL(r3); } /** @@ -12275,6 +12268,7 @@ PHP_METHOD(Phalcon_View_Engine_Mustache, __construct){ * * @param string $path * @param array $params + * @return string */ PHP_METHOD(Phalcon_View_Engine_Mustache, render){ @@ -12302,9 +12296,8 @@ PHP_METHOD(Phalcon_View_Engine_Mustache, render){ PHALCON_ALLOC_ZVAL_MM(r1); PHALCON_CALL_FUNC_PARAMS_1(r1, "file_get_contents", path); PHALCON_CALL_METHOD_PARAMS_2(r0, t1, "render", r1, this_ptr, PHALCON_NO_CHECK); - PHALCON_CALL_METHOD_PARAMS_1_NORETURN(t0, "setcontent", r0, PHALCON_NO_CHECK); - - PHALCON_MM_RESTORE(); + + RETURN_DZVAL(r0); } PHP_METHOD(Phalcon_View_Engine_Mustache, __isset){ @@ -34947,6 +34940,8 @@ PHP_METHOD(Phalcon_Session, start){ zval *options = NULL; zval *a0 = NULL; zval *r0 = NULL; + zval *started = NULL; + zval *ztrue = NULL; PHALCON_MM_GROW(); @@ -34961,12 +34956,125 @@ PHP_METHOD(Phalcon_Session, start){ PHALCON_CPY_WRT(options, a0); } - PHALCON_ALLOC_ZVAL_MM(r0); - PHALCON_CALL_FUNC(r0, "session_start"); - + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + + if (!zend_is_true(started)) { + PHALCON_ALLOC_ZVAL_MM(r0); + PHALCON_CALL_FUNC(r0, "session_start"); + + PHALCON_INIT_VAR(ztrue); + ZVAL_BOOL(ztrue, 1); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_started"), ztrue TSRMLS_CC); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), ztrue TSRMLS_CC); + } + PHALCON_MM_RESTORE(); } +/** + * Destroys a session, optionally also deleting the session cookie. Calling this function before calling Phalcon_Session::start() is an error. + * + * @param bool $delete_cookie + */ +PHP_METHOD(Phalcon_Session, destroy){ + + zval *session_cookie_name = NULL, + *session_cookie_value = NULL, + *session_cookie_expiration = NULL, + *session_cookie_params = NULL, + *session_cookie_path_key = NULL, + *session_cookie_path = NULL, + *session_cookie_domain_key = NULL, + *session_cookie_domain = NULL, + *session_cookie_secure_key = NULL, + *session_cookie_secure = NULL, + *session_cookie_httponly_key = NULL, + *session_cookie_httponly = NULL, + *cookies = NULL, + *set_cookie_return = NULL, + *session_destroy_return = NULL, + *zfalse = NULL; + zval *exists = NULL, *started = NULL; + zval* set_cookie_params[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + + zend_bool delete_cookie = 0; + + PHALCON_MM_GROW(); + + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_FALSE; + } + + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &delete_cookie) == FAILURE) { + PHALCON_MM_RESTORE(); + RETURN_NULL(); + } + + if (delete_cookie) { + PHALCON_ALLOC_ZVAL_MM(session_cookie_params); + PHALCON_CALL_FUNC(session_cookie_params, "session_get_cookie_params"); + + PHALCON_ALLOC_ZVAL_MM(session_cookie_name); + PHALCON_CALL_FUNC(session_cookie_name, "session_name"); + set_cookie_params[0] = session_cookie_name; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_value); + ZVAL_STRING(session_cookie_value, "", 1); + set_cookie_params[1] = session_cookie_value; + + PHALCON_INIT_VAR(session_cookie_expiration); + ZVAL_LONG(session_cookie_expiration, 1); + set_cookie_params[2] = session_cookie_expiration; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_path_key); + ZVAL_STRING(session_cookie_path_key, "path", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_path); + phalcon_array_fetch(&session_cookie_path, session_cookie_params, session_cookie_path_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[3] = session_cookie_path; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_domain_key); + ZVAL_STRING(session_cookie_domain_key, "domain", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_domain); + phalcon_array_fetch(&session_cookie_domain, session_cookie_params, session_cookie_domain_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[4] = session_cookie_domain; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_secure_key); + ZVAL_STRING(session_cookie_secure_key, "secure", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_secure); + phalcon_array_fetch(&session_cookie_secure, session_cookie_params, session_cookie_secure_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[5] = session_cookie_secure; + + PHALCON_ALLOC_ZVAL_MM(session_cookie_httponly_key); + ZVAL_STRING(session_cookie_httponly_key, "httponly", 1); + PHALCON_ALLOC_ZVAL_MM(session_cookie_httponly); + phalcon_array_fetch(&session_cookie_httponly, session_cookie_params, session_cookie_httponly_key, PHALCON_NOISY TSRMLS_CC); + set_cookie_params[6] = session_cookie_httponly; + + PHALCON_ALLOC_ZVAL_MM(set_cookie_return); + PHALCON_CALL_FUNC_PARAMS(set_cookie_return, "setcookie", 7, set_cookie_params); + } + + PHALCON_ALLOC_ZVAL_MM(session_destroy_return); + PHALCON_CALL_FUNC(session_destroy_return, "session_destroy"); + + PHALCON_INIT_VAR(zfalse); + ZVAL_BOOL(zfalse, 0); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_started"), zfalse TSRMLS_CC); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), zfalse TSRMLS_CC); + + RETURN_DZVAL(session_destroy_return); +} + /** * Sets session options * @@ -35006,10 +35114,25 @@ PHP_METHOD(Phalcon_Session, get){ zval *r0 = NULL, *r1 = NULL; zval *t0 = NULL; zval *g0 = NULL; + zval *exists = NULL, *started = NULL; + int eval_int; PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_NULL(); + } + + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); @@ -35044,6 +35167,7 @@ PHP_METHOD(Phalcon_Session, get){ PHP_METHOD(Phalcon_Session, set){ zval *index = NULL, *value = NULL; + zval *started = NULL; zval *g0 = NULL; zval *r0 = NULL; zval *t0 = NULL; @@ -35055,6 +35179,12 @@ PHP_METHOD(Phalcon_Session, set){ RETURN_NULL(); } + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + phalcon_get_global(&g0, SL("_SESSION")+1 TSRMLS_CC); PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_OBSERVE_VAR(t0); @@ -35076,15 +35206,29 @@ PHP_METHOD(Phalcon_Session, has){ zval *r0 = NULL; zval *t0 = NULL; zval *g0 = NULL; + zval *exists = NULL, *started = NULL; int eval_int; PHALCON_MM_GROW(); + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_FALSE; + } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Session"), SL("_uniqueId") TSRMLS_CC); @@ -35092,6 +35236,7 @@ PHP_METHOD(Phalcon_Session, has){ PHALCON_CPY_WRT(key, r0); phalcon_get_global(&g0, SL("_SESSION")+1 TSRMLS_CC); eval_int = phalcon_array_isset(g0, key); + if (eval_int) { PHALCON_MM_RESTORE(); RETURN_TRUE; @@ -35099,8 +35244,6 @@ PHP_METHOD(Phalcon_Session, has){ PHALCON_MM_RESTORE(); RETURN_FALSE; } - - PHALCON_MM_RESTORE(); } /** @@ -35111,17 +35254,31 @@ PHP_METHOD(Phalcon_Session, has){ PHP_METHOD(Phalcon_Session, remove){ zval *index = NULL, *key = NULL; + zval *exists = NULL, *started = NULL; zval *r0 = NULL; zval *t0 = NULL; zval *g0 = NULL; PHALCON_MM_GROW(); - + + PHALCON_ALLOC_ZVAL_MM(exists); + PHALCON_CALL_STATIC(exists, "Phalcon_Session", "exists"); + if (!zend_is_true(exists)) { + PHALCON_MM_RESTORE(); + RETURN_FALSE; + } + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) { PHALCON_MM_RESTORE(); RETURN_NULL(); } + PHALCON_ALLOC_ZVAL_MM(started); + PHALCON_CALL_STATIC(started, "Phalcon_Session", "started"); + if (!zend_is_true(started)) { + PHALCON_CALL_STATIC_NORETURN("Phalcon_Session", "start"); + } + PHALCON_ALLOC_ZVAL_MM(r0); PHALCON_OBSERVE_VAR(t0); phalcon_read_static_property(&t0, SL("Phalcon_Session"), SL("_uniqueId") TSRMLS_CC); @@ -35148,6 +35305,70 @@ PHP_METHOD(Phalcon_Session, getId){ RETURN_DZVAL(r0); } +/** + * Checks if session has been started + * + * @return boolean + */ +PHP_METHOD(Phalcon_Session, started){ + zval *static_started = NULL; + int eval_int; + + PHALCON_MM_GROW(); + + PHALCON_OBSERVE_VAR(static_started); + phalcon_read_static_property(&static_started, SL("Phalcon_Session"), SL("_started") TSRMLS_CC); + + eval_int = zend_is_true(static_started); + PHALCON_MM_RESTORE(); + + if (eval_int) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} + +/** + * Checks if session cookie exists + * + * @return boolean + */ +PHP_METHOD(Phalcon_Session, exists){ + zval *static_exists = NULL; + zval *cookie_exists = NULL; + zval *session_cookie_name = NULL; + zval *cookies = NULL; + int eval_int; + + PHALCON_MM_GROW(); + + PHALCON_OBSERVE_VAR(static_exists); + phalcon_read_static_property(&static_exists, SL("Phalcon_Session"), SL("_exists") TSRMLS_CC); + + if (Z_TYPE_P(static_exists) == IS_NULL) { + PHALCON_ALLOC_ZVAL_MM(session_cookie_name); + PHALCON_CALL_FUNC(session_cookie_name, "session_name"); + + phalcon_get_global(&cookies, SL("_COOKIE")+1 TSRMLS_CC); + eval_int = phalcon_array_isset(cookies, session_cookie_name); + + PHALCON_INIT_VAR(cookie_exists); + ZVAL_BOOL(cookie_exists, eval_int); + phalcon_update_static_property(SL("Phalcon_Session"), SL("_exists"), cookie_exists TSRMLS_CC); + phalcon_read_static_property(&static_exists, SL("Phalcon_Session"), SL("_exists") TSRMLS_CC); + } + + eval_int = zend_is_true(static_exists); + PHALCON_MM_RESTORE(); + + if (eval_int) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} + /** * Phalcon_Flash * @@ -37684,6 +37905,9 @@ PHP_MINIT_FUNCTION(phalcon){ phalcon_session_ce = zend_register_internal_class(&ce_session TSRMLS_CC); zend_declare_property_null(phalcon_session_ce, SL("_uniqueId"), ZEND_ACC_STATIC|ZEND_ACC_PROTECTED TSRMLS_CC); zend_declare_property_null(phalcon_session_ce, SL("_options"), ZEND_ACC_STATIC|ZEND_ACC_PROTECTED TSRMLS_CC); + zend_declare_property_bool(phalcon_session_ce, SL("_started"), 0, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC); + // _exists is not a bool so that it can be NULL meaning it hasn't been set yet. + zend_declare_property_null(phalcon_session_ce, SL("_exists"), ZEND_ACC_STATIC|ZEND_ACC_PUBLIC TSRMLS_CC); INIT_CLASS_ENTRY(ce_flash, "Phalcon_Flash", phalcon_flash_functions); phalcon_flash_ce = zend_register_internal_class(&ce_flash TSRMLS_CC); diff --git a/release/phalcon.h b/release/phalcon.h index d0e635e79b8..403bf4d2d12 100644 --- a/release/phalcon.h +++ b/release/phalcon.h @@ -891,12 +891,15 @@ PHP_METHOD(Phalcon_Controller_Front, getInstance); PHP_METHOD(Phalcon_Controller_Front, reset); PHP_METHOD(Phalcon_Session, start); +PHP_METHOD(Phalcon_Session, destroy); PHP_METHOD(Phalcon_Session, setOptions); PHP_METHOD(Phalcon_Session, get); PHP_METHOD(Phalcon_Session, set); PHP_METHOD(Phalcon_Session, has); PHP_METHOD(Phalcon_Session, remove); PHP_METHOD(Phalcon_Session, getId); +PHP_METHOD(Phalcon_Session, started); +PHP_METHOD(Phalcon_Session, exists); PHP_METHOD(Phalcon_Flash, _showMessage); PHP_METHOD(Phalcon_Flash, error); @@ -2743,6 +2746,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_start, 0, 0, 0) ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_destroy, 0, 0, 0) + ZEND_ARG_INFO(0, delete_cookie) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_session_setoptions, 0, 0, 1) ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() @@ -3872,12 +3879,15 @@ PHALCON_INIT_FUNCS(phalcon_controller_front_functions){ PHALCON_INIT_FUNCS(phalcon_session_functions){ PHP_ME(Phalcon_Session, start, arginfo_phalcon_session_start, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Session, destroy, arginfo_phalcon_session_destroy, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, setOptions, arginfo_phalcon_session_setoptions, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, get, arginfo_phalcon_session_get, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, set, arginfo_phalcon_session_set, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, has, arginfo_phalcon_session_has, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, remove, arginfo_phalcon_session_remove, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Phalcon_Session, getId, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Session, started, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + PHP_ME(Phalcon_Session, exists, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_FE_END }; diff --git a/release/php_phalcon.h b/release/php_phalcon.h index b8845e8c416..faa93294c9f 100644 --- a/release/php_phalcon.h +++ b/release/php_phalcon.h @@ -23,24 +23,24 @@ #define PHP_PHALCON_VERSION "0.4.2" #define PHP_PHALCON_EXTNAME "phalcon" -#define PHALCON_MAX_MEMORY_STACK 64 +#define PHALCON_MAX_MEMORY_STACK 48 #define PHALCON_FCALL_MAX_CACHE 96 typedef struct _phalcon_memory_entry { - int pointer; - zval **addresses[PHALCON_MAX_MEMORY_STACK]; - struct _phalcon_memory_entry *prev; - struct _phalcon_memory_entry *next; + int pointer; + zval **addresses[PHALCON_MAX_MEMORY_STACK]; + struct _phalcon_memory_entry *prev; + struct _phalcon_memory_entry *next; } phalcon_memory_entry; ZEND_BEGIN_MODULE_GLOBALS(phalcon) - int phalcon_memory_stack; - phalcon_memory_entry *start_memory; - phalcon_memory_entry *active_memory; - zend_fcall_info_cache *phalcon_fcall_cache[PHALCON_FCALL_MAX_CACHE]; + int phalcon_memory_stack; + phalcon_memory_entry *start_memory; + phalcon_memory_entry *active_memory; + zend_fcall_info_cache *phalcon_fcall_cache[PHALCON_FCALL_MAX_CACHE]; #ifndef PHALCON_RELEASE - int phalcon_stack_stats; - int phalcon_fcall_stats; + int phalcon_stack_stats; + int phalcon_fcall_stats; #endif ZEND_END_MODULE_GLOBALS(phalcon) @@ -51,23 +51,26 @@ ZEND_END_MODULE_GLOBALS(phalcon) ZEND_EXTERN_MODULE_GLOBALS(phalcon) #ifdef ZTS - #define PHALCON_GLOBAL(v) TSRMG(phalcon_globals_id, zend_phalcon_globals *, v) + #define PHALCON_GLOBAL(v) TSRMG(phalcon_globals_id, zend_phalcon_globals *, v) #else - #define PHALCON_GLOBAL(v) (phalcon_globals.v) + #define PHALCON_GLOBAL(v) (phalcon_globals.v) #endif extern zend_module_entry phalcon_module_entry; #define phpext_phalcon_ptr &phalcon_module_entry +#ifdef PHP_WIN32 +#include "stdafx.h" +#endif + #endif #if PHP_VERSION_ID >= 50400 - #define PHALCON_INIT_FUNCS(class_functions) static const zend_function_entry class_functions[] = + #define PHALCON_INIT_FUNCS(class_functions) static const zend_function_entry class_functions[] = #else - #define PHALCON_INIT_FUNCS(class_functions) static const function_entry class_functions[] = + #define PHALCON_INIT_FUNCS(class_functions) static const function_entry class_functions[] = #endif #ifndef PHP_FE_END - #define PHP_FE_END { NULL, NULL, NULL, 0, 0 } + #define PHP_FE_END { NULL, NULL, NULL, 0, 0 } #endif - diff --git a/win32/README.md b/win32/README.md index fd012513684..e2bfa97eab6 100644 --- a/win32/README.md +++ b/win32/README.md @@ -17,8 +17,12 @@ Building Phalcon In Windows 5. Select configuration that matches your thread safety 6. Build and enjoy - Updating the project when files are added or removed from /dev ============================================================== -In the /win32/scripts directory, there is a batch file that will scan the /dev directory and update cphalcon.vproj. \ No newline at end of file +In the /win32/scripts directory, there is an update-project.bat batch file that will scan the /dev directory and update cphalcon.vproj. + +Building the Release configs +============================================================== + +Do not edit the files in the /release directory. Instead edit the files in the dev directory. When you want to build the release config, run the create-release-src-files.bat batch file in /win32/scripts. That will rejoin (almost) all the files in /dev and create the files in /release. \ No newline at end of file diff --git a/win32/cphalcon.vcproj b/win32/cphalcon.vcproj index a89e4913a15..4dcf54aa04d 100644 --- a/win32/cphalcon.vcproj +++ b/win32/cphalcon.vcproj @@ -325,852 +325,613 @@ + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + +
+ + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/scripts/create_release_src_files.bat b/win32/scripts/create_release_src_files.bat new file mode 100644 index 00000000000..da00c8dbfa6 --- /dev/null +++ b/win32/scripts/create_release_src_files.bat @@ -0,0 +1,7 @@ +@echo off +setlocal + +SET SCRIPT_DIR=%~dp0 +cscript.exe %SCRIPT_DIR%create_release_src_files.js + +endlocal \ No newline at end of file diff --git a/win32/scripts/create_release_src_files.js b/win32/scripts/create_release_src_files.js new file mode 100644 index 00000000000..c9861be31be --- /dev/null +++ b/win32/scripts/create_release_src_files.js @@ -0,0 +1,296 @@ +var STDOUT = WScript.StdOut; +var STDERR = WScript.StdErr; +var WshShell = WScript.CreateObject("WScript.Shell"); +var FSO = WScript.CreateObject("Scripting.FileSystemObject"); +var SCRIPT_DIR=FSO.GetParentFolderName(WScript.ScriptFullName); +var WIN32_DIR=FSO.GetParentFolderName(SCRIPT_DIR); +var CPHALCON_PROJ = WIN32_DIR + '\\cphalcon.vcproj'; +var PHALCON_DIR=FSO.GetParentFolderName(WIN32_DIR); +var PHALCON_DEV_SRC_DIR=PHALCON_DIR + '\\dev'; +var PHALCON_RELEASE_SRC_DIR=PHALCON_DIR + '\\release'; +var input, output, inputLine, outputLine; +var fileList, pos, i, len, filename; +var state = 'COMMENT'; +var skipComment = function(fileHandle) { + while (!fileHandle.AtEndOfStream) { + if (fileHandle.ReadLine().trim() === '*/') { + fileHandle.ReadLine(); + return; + } + } +}; +var copyFileContents = function(inputFilename, output) { + var skipping = false, inputLine; + var input = FSO.OpenTextFile(PHALCON_DEV_SRC_DIR + inputFilename, 1, true); + + skipComment(input); + + while(!input.AtEndOfStream) { + inputLine = input.ReadLine(); + + if (inputLine.substr(0,6) === 'extern') { + inputLine = inputLine.substr(7); + } + if (inputLine.substr(0,8) === '#include') { + continue; + } + if (skipping) { + if ((inputLine.trim() !== '') && (inputLine.trim() !== '#endif')) { + skipping = false; + } + } else if (inputLine.trim() === '#ifdef HAVE_CONFIG_H') { + skipping = true; + } + if (!skipping) { + output.WriteLine(inputLine); + } + } + input.Close(); +}; + +String.prototype.trim = function() { + return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' '); +}; + +// copy php_phalcon.h +FSO.CopyFile(PHALCON_DEV_SRC_DIR + '\\php_phalcon.h', PHALCON_RELEASE_SRC_DIR + '\\php_phalcon.h', true); + +// create phalcon.h +input = FSO.OpenTextFile(PHALCON_DEV_SRC_DIR + '\\phalcon.h', 1, true); +output = FSO.OpenTextFile(PHALCON_RELEASE_SRC_DIR + '\\phalcon.h', 2, true); + +// copy header license +inputLine = input.ReadLine(); +while(!input.AtEndOfStream && state === 'COMMENT') { + + if (inputLine.trim() == '*/') { + state = 'SKIP'; + } + output.WriteLine(inputLine); + inputLine = input.ReadLine(); +} + +output.WriteLine(); +output.WriteLine('#define PHALCON_RELEASE 1'); +output.WriteLine(); + +while(!input.AtEndOfStream && state === 'SKIP') { + inputLine = input.ReadLine(); + if (inputLine.trim() !== '') { + state = 'FORWARD_DECLARES'; + } +} + +while(!input.AtEndOfStream && state === 'FORWARD_DECLARES') { + if (inputLine.trim().substr(0, 6) !== 'extern') { + state = 'PHP_METHODS'; + } + if ((inputLine.indexOf('_test_') < 0) && (inputLine.indexOf('_internal_') < 0)) { + outputLine = inputLine.substr(7); + output.WriteLine(outputLine); + } + inputLine = input.ReadLine(); +} + +while(!input.AtEndOfStream && (state === 'PHP_METHODS' || state === 'SKIP')) { + if ((inputLine.indexOf('_Test,') > 0) || (inputLine.indexOf('_Internal_') > 0)) { + state = 'SKIP'; + } + + if (state === 'SKIP') { + if (inputLine.trim() === '') { + state = 'PHP_METHODS'; + } + } else { + outputLine = inputLine; + output.WriteLine(outputLine); + } + + inputLine = input.ReadLine(); + + if (inputLine.trim() !== '' && inputLine.substr(0,10) !== 'PHP_METHOD') { + state = 'METHOD_ARGUMENTS'; + } +} + +while(!input.AtEndOfStream && (state === 'METHOD_ARGUMENTS' || state === 'SKIP')) { + if ((inputLine.indexOf('_test_') > 0) || (inputLine.indexOf('_internal_') > 0)) { + state = 'SKIP'; + } + + if (state === 'SKIP') { + if (inputLine.trim() === '') { + state = 'METHOD_ARGUMENTS'; + } + } else { + outputLine = inputLine; + output.WriteLine(outputLine); + } + + inputLine = input.ReadLine(); + + if (inputLine.substr(0,18) === 'PHALCON_INIT_FUNCS') { + state = 'PHALCON_INIT_FUNCS'; + } +} + +while(!input.AtEndOfStream) { + if ((inputLine.indexOf('_test_') > 0) || (inputLine.indexOf('_internal_') > 0)) { + state = 'SKIP'; + } + + if (state === 'SKIP') { + if (inputLine.trim() === '') { + state = 'PHALCON_INIT_FUNCS'; + } + } else { + outputLine = inputLine; + output.WriteLine(outputLine); + } + + inputLine = input.ReadLine(); +} + +output.WriteLine(); + +output.Close(); +input.Close(); + +// create phalcon.c +output = FSO.OpenTextFile(PHALCON_RELEASE_SRC_DIR + '\\phalcon.c', 2, true); + +state = 'COMMENT'; +input = FSO.OpenTextFile(PHALCON_DEV_SRC_DIR + '\\kernel\\main.h', 1, true); + +// copy header license +inputLine = input.ReadLine(); +while(!input.AtEndOfStream && state === 'COMMENT') { + + if (inputLine.trim() == '*/') { + state = 'SKIP'; + } + output.WriteLine(inputLine); + inputLine = input.ReadLine(); +} + +output.WriteLine(); +output.WriteLine(); +output.WriteLine('#ifdef HAVE_CONFIG_H'); +output.WriteLine('#include "config.h"'); +output.WriteLine('#endif'); +output.WriteLine(); +output.WriteLine('#include "php.h"'); +output.WriteLine('#include "php_phalcon.h"'); +output.WriteLine('#include "phalcon.h"'); +output.WriteLine(); +output.WriteLine('#include "main/php_main.h"'); +output.WriteLine('#include "ext/standard/php_string.h"'); +output.WriteLine(); +output.WriteLine('#include "Zend/zend_API.h"'); +output.WriteLine('#include "Zend/zend_operators.h"'); +output.WriteLine('#include "Zend/zend_exceptions.h"'); +output.WriteLine('#include "Zend/zend_interfaces.h"'); +output.WriteLine('#include "Zend/zend_execute.h"'); +output.WriteLine(); + +while(!input.AtEndOfStream) { + if ((inputLine.substr(0,6) === 'extern') && (inputLine.indexOf('phalcon') > 0)) { + inputLine = inputLine.substr(7); + } + output.WriteLine(inputLine); + + inputLine = input.ReadLine(); +} +input.Close(); + +output.WriteLine(); +copyFileContents('\\kernel\\fcall.h', output); +copyFileContents('\\kernel\\require.h', output); +copyFileContents('\\kernel\\debug.h', output); +copyFileContents('\\kernel\\assert.h', output); +copyFileContents('\\kernel\\object.h', output); +copyFileContents('\\kernel\\array.h', output); +copyFileContents('\\kernel\\operators.h', output); +copyFileContents('\\kernel\\concat.h', output); +copyFileContents('\\kernel\\memory.h', output); +output.WriteLine(); + +input = FSO.OpenTextFile(PHALCON_DEV_SRC_DIR + '\\config.m4', 1, true); +while (!input.AtEndOfStream) { + inputLine = input.ReadLine(); + if (inputLine.indexOf('PHP_NEW_EXTENSION') >= 0) { + fileList = inputLine; + break; + } +} +input.Close(); + +pos = fileList.indexOf(', '); +fileList = fileList.substr(pos+2); +pos = fileList.indexOf(', '); +fileList = fileList.substr(0, pos); + +fileList = fileList.split(' '); +len = fileList.length; +for (i=0; i 0) || (inputLine.indexOf('_internal_test') > 0) + || (inputLine.indexOf('_test_') > 0)) { + skippedLastLine = true; + continue; + } + skippedLastLine = false; + output.WriteLine(inputLine); + + if (inputLine.trim().substr(0, 24) === 'ZEND_INIT_MODULE_GLOBALS') { + break; + } + +} + +state = 'NOT_SKIP'; +inputLine = input.ReadLine(); +while(!input.AtEndOfStream) { + if ((inputLine.indexOf('_test_') > 0) || (inputLine.indexOf('_internal_test') > 0)) { + state = 'SKIP'; + } + + if (state === 'SKIP') { + if (inputLine.trim() === '') { + state = 'NOT_SKIP'; + } + } else { + outputLine = inputLine; + output.WriteLine(outputLine); + } + + inputLine = input.ReadLine(); +} + +output.WriteLine(); + + +input.Close(); +output.Close(); diff --git a/win32/scripts/update-project.js b/win32/scripts/update-project.js index 3a17503d897..6ab34dc17b1 100644 --- a/win32/scripts/update-project.js +++ b/win32/scripts/update-project.js @@ -6,7 +6,8 @@ var SCRIPT_DIR=FSO.GetParentFolderName(WScript.ScriptFullName); var WIN32_DIR=FSO.GetParentFolderName(SCRIPT_DIR); var CPHALCON_PROJ = WIN32_DIR + '\\cphalcon.vcproj'; var PHALCON_DIR=FSO.GetParentFolderName(WIN32_DIR); -var PHALCON_SRC_DIR=PHALCON_DIR + '\\dev'; +var PHALCON_DEV_SRC_DIR=PHALCON_DIR + '\\dev'; +var PHALCON_RELEASE_SRC_DIR=PHALCON_DIR + '\\release'; var CWD = WshShell.CurrentDirectory; @@ -19,17 +20,18 @@ function foreach(collection, callback) { function enumerateDirectory(depth, dirName, folderCallback, fileCallback) { var dir = FSO.GetFolder(dirName); if (dir) { - foreach(dir.SubFolders, function(subdir) { - folderCallback(depth, subdir); - }); - foreach(dir.Files, function(file) { - fileCallback(depth, file); - }); + foreach(dir.Files, function(file) { + fileCallback(depth, file); + }); + foreach(dir.SubFolders, function(subdir) { + folderCallback(depth, subdir); + }); } } STDOUT.WriteLine(); -STDOUT.WriteLine('Phalcon source dir: ' + PHALCON_SRC_DIR); +STDOUT.WriteLine('Phalcon dev source dir: ' + PHALCON_DEV_SRC_DIR); +STDOUT.WriteLine('Phalcon release source dir: ' + PHALCON_RELEASE_SRC_DIR); STDOUT.WriteLine('VS2008 project dir: ' + WIN32_DIR); STDOUT.WriteLine('VS2008 project file: ' + CPHALCON_PROJ); @@ -60,11 +62,12 @@ while(!projectFile.AtEndOfStream) { projectFile.Close(); var filesSnippet = [], - rootDir = PHALCON_SRC_DIR, - rootDirLen = rootDir.length+1, + rootDir, + rootDirLen, + relativeDir, onFolder = function(depth, dir) { var indent = Array(depth + 1).join('\t'); - filesSnippet.push(indent + ''); + filesSnippet.push(indent + ''); enumerateDirectory(depth + 1, dir.Path, onFolder, onFile); filesSnippet.push(indent + ''); }, @@ -73,7 +76,7 @@ var filesSnippet = [], relativePath = file.Path.substr(rootDirLen); if (file.Type == 'C Source' || file.Type == 'C/C++ Header') { - filesSnippet.push(indent + ''); + filesSnippet.push(indent + ''); objectFileOverride(depth + 1, file); filesSnippet.push(indent + ''); } @@ -82,20 +85,45 @@ var filesSnippet = [], var indent = Array(depth + 1).join('\t'), configs = [ 'Debug TS|Win32', 'Release TS|Win32', 'Debug NTS|Win32', 'Release NTS|Win32'], relativePath = file.Path.substr(rootDirLen), - i, len = configs.length; + i, len = configs.length, + inReleaseDir = (relativeDir == 'release'), + inReleaseConfig; relativePath = relativePath.substr(0, relativePath.lastIndexOf('\\')); - if (relativePath.length > 0) { - for(i=0; i'); - filesSnippet.push(indent + '\t'); - filesSnippet.push(indent + ''); - } - } + for(i=0; i 0)) { + filesSnippet.push(indent + ''); + filesSnippet.push(indent + '\t 0) { + filesSnippet.push(indent + '\t\tObjectFile="$(IntDir)\\' + relativePath + '\\"'); + } + filesSnippet.push(indent + '\t/>'); + filesSnippet.push(indent + ''); + } + } }; -enumerateDirectory(2, PHALCON_SRC_DIR, onFolder, onFile); +rootDir = PHALCON_RELEASE_SRC_DIR; +rootDirLen = rootDir.length+1, +relativeDir = 'release'; +filesSnippet.push('\t\t'); +enumerateDirectory(3, PHALCON_RELEASE_SRC_DIR, onFolder, onFile); +filesSnippet.push('\t\t'); +rootDir = PHALCON_DEV_SRC_DIR; +rootDirLen = rootDir.length+1, +relativeDir = 'dev'; +filesSnippet.push('\t\t'); +enumerateDirectory(3, PHALCON_DEV_SRC_DIR, onFolder, onFile); +filesSnippet.push('\t\t'); + + filesSnippet = filesSnippet.join('\r\n'); @@ -105,7 +133,6 @@ var pad = function(number, length) { str = '0' + str; } return str; - }, now = new Date(), nowStr = ('' + now.getFullYear() + '-' + pad(now.getMonth()+1,2) + '-' + pad(now.getDate(), 2) + 'T' + pad(now.getHours(), 2) + pad(now.getMinutes(), 2)),