-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phalcon\Flash\Session getMessages bug #11283
Comments
This is a bug? Obviously if you have received messages from the session, you do not want to receive their again. In any case you can use |
This is not a bug? Obviously if I'm trying to remove ONE particular type, not ALL other types should be removed. |
Can you please try |
The bug is at least from 2.0.9; 2.0.9 is the version that I am using and when I incidentally realize the bug. The version information is on my first comment too. When I was using 1.3.4 it works fine. |
We don't add changes directly to stable branches. Currently development branch is |
I just installed 2.0.x, the result is the same; the bug is still there. I would like to confirm the version; it is the "2001040" when executing \Phalcon\Version::getId(), correct? |
I'm not sure. Latest build in 2.0.x: Line L4431 |
$ php --ri phalcon
phalcon
Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 2.0.10
Build Date => Dec 19 2015 14:06:30
Powered by Zephir => Version 0.9.1a-dev
Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off $ php -r 'echo \Phalcon\Version::getId(), PHP_EOL;'
2001040
$ git status
On branch 2.0.x
Your branch is up-to-date with 'phalcon/2.0.x'.
nothing to commit, working directory clean $ git show
commit fe827a440bb5b4c4f4fe749dae5391dfbaefe1a5
Merge: 42ea223 b18140f
Author: Andy Gutierrez <gutierrezandresfelipe@gmail.com>
Date: Thu Jan 7 11:13:44 2016 -0500
Merge pull request #11278 from ifsnow/2.0.x
Fixed for building on windows. $ php codecept.phar run tests/unit/Phalcon/Flash/Session/FlashSessionDefaultTest.php
Codeception PHP Testing Framework v2.0.7
Powered by PHPUnit 4.3.1 by Sebastian Bergmann.
Unit Tests (4) --------------------------------------------------------------------------------------------------------------------------------------------------------
Trying to test get messages type remove messages (Phalcon\Tests\unit\Phalcon\Flash\Session\FlashSessionDefaultTest::testGetMessagesTypeRemoveMessages) Ok
Trying to test clear (Phalcon\Tests\unit\Phalcon\Flash\Session\FlashSessionDefaultTest::testClear) Ok
Trying to test string with data set "error" (Phalcon\Tests\unit\Phalcon\Flash\Session\FlashSessionDefaultTest::testString) Ok
Trying to test string with data set "success" (Phalcon\Tests\unit\Phalcon\Flash\Session\FlashSessionDefaultTest::testString) Ok
Trying to test string with data set "notice" (Phalcon\Tests\unit\Phalcon\Flash\Session\FlashSessionDefaultTest::testString) Ok
Trying to test string data provider (Phalcon\Tests\unit\Phalcon\Flash\Session\FlashSessionDefaultTest::testStringDataProvider) Ok
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 78 ms, Memory: 9.25Mb
OK (6 tests, 7 assertions)
|
I did the practical test: $this->flash_session->success('test success');
$this->flash_session->error('test error');
$this->flash_session->notice('test notice');
echo "<pre>"; var_dump($this->flash_session->getMessages(NULL, FALSE)); echo "</pre>"; // all three types are there
echo "<pre>"; var_dump($this->flash_session->getMessages('error', TRUE)); echo "</pre>"; // output only the error type
echo "<pre>"; var_dump($this->flash_session->getMessages(NULL, FALSE)); echo "</pre>"; // nothing left |
<?php
use Phalcon\Di;
use Phalcon\Flash\Session;
use Phalcon\Session\Adapter\Files;
$flash = new Session;
$di = new Di;
$di->setShared('session', function () {
$session = new Files;
$session->start();
return $session;
});
$flash->setDI($di);
$flash->success('sample success');
$flash->error('sample error');
$flash->notice('sample notice');
$expectedMessages = [
'success' => ['sample success'],
'error' => ['sample error'],
'notice' => ['sample notice'],
];
assert($flash->getMessages(null, false) === $expectedMessages);
assert($flash->getMessages('success') === ['sample success']);
assert($flash->getMessages('error') === ['sample error']);
assert(['notice' => ['sample notice']] === $flash->getMessages());
assert(null === $flash->getMessages()); |
assert($flash->getMessages(null, false) === $expectedMessages); // I get TRUE
assert($flash->getMessages('success') === ['sample success']); // I get TRUE
assert($flash->getMessages('error') === ['sample error']); // I get NULL
assert(['notice' => ['sample notice']] === $flash->getMessages()); // I get NULL |
Can you please provide OS name/version and |
|
Cannot reproduce this. # php --ri phalcon
phalcon
Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 2.0.10
Build Date => Jan 8 2016 03:02:54
Powered by Zephir => Version 0.9.1a-dev
Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off $ php session_test.php # all ok, all assertions described above passes |
First of all I am sorry for my attitude earlier and I am sorry for bothering you so much. |
|
"Did you used the test provided by me above exactly and unchanged?" "Did you run the test in console mode?" "Did you restart PHP-FPM after compiling new Phalcon (if you are used PHP-FPM)?" my version of PHP is 5.4.16, my OS is CentOS 7 "Try to use not safe build" |
Bug: if with a TRUE for the 2nd parameter or without it, ALL types are removed.
Special thank to Lajos Bencz, he found out the line https://github.com/phalcon/cphalcon/blob/phalcon-v2.0.9/phalcon/flash/session.zep#L70
The text was updated successfully, but these errors were encountered: