mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Changing return types
read now returns empty string instead of false when read method returns an empty value. write, destroy and gc will return boolean type
This commit is contained in:
parent
776c128fe0
commit
dd11c63069
2 changed files with 16 additions and 10 deletions
|
@ -52,7 +52,11 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
* @return mixed The value of the key or false if it does not exist
|
||||
*/
|
||||
public function read($id) {
|
||||
return Cache::read($id, Configure::read('Session.handler.config'));
|
||||
$data = Cache::read($id, Configure::read('Session.handler.config'));
|
||||
if(empty($data)){
|
||||
return '';
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +67,7 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
* @return bool True for successful write, false otherwise.
|
||||
*/
|
||||
public function write($id, $data) {
|
||||
return Cache::write($id, $data, Configure::read('Session.handler.config'));
|
||||
return (bool)Cache::write($id, $data, Configure::read('Session.handler.config'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +77,7 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
* @return bool True for successful delete, false otherwise.
|
||||
*/
|
||||
public function destroy($id) {
|
||||
return Cache::delete($id, Configure::read('Session.handler.config'));
|
||||
return (bool)Cache::delete($id, Configure::read('Session.handler.config'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,7 +87,7 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
* @return bool Success
|
||||
*/
|
||||
public function gc($expires = null) {
|
||||
return Cache::gc(Configure::read('Session.handler.config'), $expires);
|
||||
return (bool)Cache::gc(Configure::read('Session.handler.config'), $expires);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -93,10 +93,10 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
));
|
||||
|
||||
if (empty($row[$this->_model->alias]['data'])) {
|
||||
return false;
|
||||
return '';
|
||||
}
|
||||
|
||||
return $row[$this->_model->alias]['data'];
|
||||
return (string)$row[$this->_model->alias]['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,9 +123,9 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
'counterCache' => false
|
||||
);
|
||||
try {
|
||||
return $this->_model->save($record, $options);
|
||||
return (bool)$this->_model->save($record, $options);
|
||||
} catch (PDOException $e) {
|
||||
return $this->_model->save($record, $options);
|
||||
return (bool)$this->_model->save($record, $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,8 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
* @return bool True for successful delete, false otherwise.
|
||||
*/
|
||||
public function destroy($id) {
|
||||
return $this->_model->delete($id);
|
||||
return true;
|
||||
return (bool)$this->_model->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,7 +152,8 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
} else {
|
||||
$expires = time() - $expires;
|
||||
}
|
||||
return $this->_model->deleteAll(array($this->_model->alias . ".expires <" => $expires), false, false);
|
||||
$this->_model->deleteAll(array($this->_model->alias . ".expires <" => $expires), false, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue