Skip to content
Permalink
Browse files

Allowing returning numeric 0 from read

  • Loading branch information...
phpnut committed Dec 29, 2015
1 parent a02fb9e commit a966e465459c33db66196ca913620552ec609d65
@@ -53,7 +53,8 @@ public function close() {
*/
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 @@ public function read($id) {
'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 @@ public function testWrite() {
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 @@ public function testWriteEmptySessionId() {
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'));
}
/**

0 comments on commit a966e46

Please sign in to comment.
You can’t perform that action at this time.