mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Allowing returning numeric 0 from read
This commit is contained in:
parent
a02fb9e771
commit
a966e46545
4 changed files with 8 additions and 2 deletions
|
@ -53,7 +53,8 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
*/
|
||||
public function read($id) {
|
||||
$data = Cache::read($id, Configure::read('Session.handler.config'));
|
||||
if (empty($data)) {
|
||||
|
||||
if (!is_numeric($data) && empty($data)) {
|
||||
return '';
|
||||
}
|
||||
return $data;
|
||||
|
|
|
@ -92,7 +92,7 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
'conditions' => array($this->_model->alias . '.' . $this->_model->primaryKey => $id)
|
||||
));
|
||||
|
||||
if (empty($row[$this->_model->alias]['data'])) {
|
||||
if (!is_numeric($row[$this->_model->alias]['data']) && empty($row[$this->_model->alias]['data'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,8 @@ class CacheSessionTest extends CakeTestCase {
|
|||
public function testRead() {
|
||||
$this->storage->write('test_one', 'Some other value');
|
||||
$this->assertEquals('Some other value', $this->storage->read('test_one'), 'Incorrect value.');
|
||||
$this->storage->write('test_two', 0);
|
||||
$this->assertEquals(0, $this->storage->read('test_two'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -144,7 +144,10 @@ class DatabaseSessionTest extends CakeTestCase {
|
|||
public function testRead() {
|
||||
$this->storage->write('foo', 'Some value');
|
||||
$this->assertEquals($this->storage->read('foo'), 'Some value');
|
||||
$this->storage->write('bar', 0);
|
||||
$this->assertEquals(0, $this->storage->read('bar'));
|
||||
$this->assertSame('', $this->storage->read('made up value'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue