From ee2762bf580166dab1f710b528a62e7f36c88f88 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Fri, 22 Nov 2013 08:10:23 +0200 Subject: [PATCH 1/3] Test case for #1575 --- ext/tests/issue-1575.phpt | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 ext/tests/issue-1575.phpt diff --git a/ext/tests/issue-1575.phpt b/ext/tests/issue-1575.phpt new file mode 100644 index 00000000000..22b1e0d7ba1 --- /dev/null +++ b/ext/tests/issue-1575.phpt @@ -0,0 +1,43 @@ +--TEST-- +flashSession->getMessages(type, BOOLEAN remove) removed all messages - https://github.com/phalcon/cphalcon/issues/1575 +--GET-- +dummy=1 +--SKIPIF-- + +--FILE-- + 'issue-1575')); +var_dump($s->start()); +$fs = $di->getShared('flashSession'); +$fs->success('Success'); +$fs->warning('Warning'); +var_dump($fs->getMessages(null, false)); +$fs->getMessages('success', true); +var_dump($fs->getMessages(null, false)); +$fs->getMessages(null, true); +var_dump($fs->getMessages(null, false)); +?> +--EXPECT-- +bool(true) +array(2) { + ["success"]=> + array(1) { + [0]=> + string(7) "Success" + } + ["warning"]=> + array(1) { + [0]=> + string(7) "Warning" + } +} +array(1) { + ["warning"]=> + array(1) { + [0]=> + string(7) "Warning" + } +} +array(0) { +} From 6c5a14fdc3855445455949f46e99d97ade1dcd2c Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Fri, 22 Nov 2013 08:00:17 +0200 Subject: [PATCH 2/3] Implement #1575 Conflicts: ext/flash/session.c --- ext/flash/session.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/ext/flash/session.c b/ext/flash/session.c index 7b24e4d6d52..43d6a9743e5 100644 --- a/ext/flash/session.c +++ b/ext/flash/session.c @@ -208,6 +208,7 @@ PHP_METHOD(Phalcon_Flash_Session, message){ PHP_METHOD(Phalcon_Flash_Session, getMessages){ zval *type = NULL, *remove = NULL, *messages, *return_messages; + zval *do_remove; PHALCON_MM_GROW(); @@ -221,15 +222,30 @@ PHP_METHOD(Phalcon_Flash_Session, getMessages){ PHALCON_INIT_VAR(remove); ZVAL_BOOL(remove, 1); } - + + if (Z_TYPE_P(type) != IS_NULL) { + PHALCON_INIT_VAR(do_remove); + ZVAL_FALSE(do_remove); + } + else { + do_remove = remove; + } + PHALCON_INIT_VAR(messages); - phalcon_call_method_p1(messages, this_ptr, "_getsessionmessages", remove); - if (Z_TYPE_P(messages) == IS_ARRAY) { - if (likely(Z_TYPE_P(type) == IS_STRING)) { + phalcon_call_method_p1(messages, this_ptr, "_getsessionmessages", do_remove); + if (Z_TYPE_P(messages) == IS_ARRAY) { + if (likely(Z_TYPE_P(type) != IS_NULL)) { if (phalcon_array_isset(messages, type)) { PHALCON_OBS_VAR(return_messages); phalcon_array_fetch(&return_messages, messages, type, PH_NOISY); - RETURN_CCTOR(return_messages); + RETVAL_ZVAL(return_messages, 1, 0); + if (zend_is_true(remove)) { + phalcon_array_unset(&messages, type, 0); + phalcon_call_method_p1_noret(this_ptr, "_setsessionmessages", messages); + } + + PHALCON_MM_RESTORE(); + return; } RETURN_MM_EMPTY_ARRAY(); From 1a1abe1e1d342eab1c602dd1b86140097c554566 Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Thu, 28 Nov 2013 19:27:03 +0200 Subject: [PATCH 3/3] Skip test for #1340 when openssl is not available --- ext/tests/issue-1340-valgrind.phpt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/tests/issue-1340-valgrind.phpt b/ext/tests/issue-1340-valgrind.phpt index d1a693cc09b..9edec88dd02 100644 --- a/ext/tests/issue-1340-valgrind.phpt +++ b/ext/tests/issue-1340-valgrind.phpt @@ -1,7 +1,12 @@ --TEST-- Memory corruption in zim_Phalcon_Security_hash() - https://github.com/phalcon/cphalcon/issues/1340 - run under Valgrind! --SKIPIF-- - + --FILE--