mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-03 06:33:38 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -1,20 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Cache Session save handler. Allows saving session information into Cache.
|
||||
*
|
||||
* PHP 5
|
||||
* Cache Session save handler. Allows saving session information into Cache.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Model.Datasource.Session
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Cache', 'Cache');
|
||||
|
@ -31,7 +30,7 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
/**
|
||||
* Method called on open of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function open() {
|
||||
return true;
|
||||
|
@ -40,7 +39,7 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
/**
|
||||
* Method called on close of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function close() {
|
||||
return true;
|
||||
|
@ -53,38 +52,43 @@ 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 (!is_numeric($data) && empty($data)) {
|
||||
return '';
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function called on write for database sessions.
|
||||
*
|
||||
* @param integer $id ID that uniquely identifies session in database
|
||||
* @param int $id ID that uniquely identifies session in database
|
||||
* @param mixed $data The value of the data to be saved.
|
||||
* @return boolean True for successful write, false otherwise.
|
||||
* @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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called on the destruction of a database session.
|
||||
*
|
||||
* @param integer $id ID that uniquely identifies session in cache
|
||||
* @return boolean True for successful delete, false otherwise.
|
||||
* @param int $id ID that uniquely identifies session in cache
|
||||
* @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'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function called on gc for cache sessions.
|
||||
*
|
||||
* @param integer $expires Timestamp (defaults to current time)
|
||||
* @return boolean Success
|
||||
* @param int $expires Timestamp (defaults to current time)
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Model.Datasource
|
||||
* @since CakePHP(tm) v 2.1
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for Session handlers. Custom session handler classes should implement
|
||||
* Interface for Session handlers. Custom session handler classes should implement
|
||||
* this interface as it allows CakeSession know how to map methods to session_set_save_handler()
|
||||
*
|
||||
* @package Cake.Model.Datasource.Session
|
||||
|
@ -24,14 +25,14 @@ interface CakeSessionHandlerInterface {
|
|||
/**
|
||||
* Method called on open of a session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function open();
|
||||
|
||||
/**
|
||||
* Method called on close of a session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function close();
|
||||
|
||||
|
@ -46,26 +47,26 @@ interface CakeSessionHandlerInterface {
|
|||
/**
|
||||
* Helper function called on write for sessions.
|
||||
*
|
||||
* @param integer $id ID that uniquely identifies session in database
|
||||
* @param int $id ID that uniquely identifies session in database
|
||||
* @param mixed $data The value of the data to be saved.
|
||||
* @return boolean True for successful write, false otherwise.
|
||||
* @return bool True for successful write, false otherwise.
|
||||
*/
|
||||
public function write($id, $data);
|
||||
|
||||
/**
|
||||
* Method called on the destruction of a session.
|
||||
*
|
||||
* @param integer $id ID that uniquely identifies session in database
|
||||
* @return boolean True for successful delete, false otherwise.
|
||||
* @param int $id ID that uniquely identifies session in database
|
||||
* @return bool True for successful delete, false otherwise.
|
||||
*/
|
||||
public function destroy($id);
|
||||
|
||||
/**
|
||||
* Run the Garbage collection on the session storage. This method should vacuum all
|
||||
* Run the Garbage collection on the session storage. This method should vacuum all
|
||||
* expired or dead sessions.
|
||||
*
|
||||
* @param integer $expires Timestamp (defaults to current time)
|
||||
* @return boolean Success
|
||||
* @param int $expires Timestamp (defaults to current time)
|
||||
* @return bool Success
|
||||
*/
|
||||
public function gc($expires = null);
|
||||
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Database Session save handler. Allows saving session information into a model.
|
||||
*
|
||||
* PHP 5
|
||||
* Database Session save handler. Allows saving session information into a model.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Model.Datasource.Session
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeSessionHandlerInterface', 'Model/Datasource/Session');
|
||||
|
@ -42,9 +41,8 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
protected $_timeout;
|
||||
|
||||
/**
|
||||
* Constructor. Looks at Session configuration information and
|
||||
* Constructor. Looks at Session configuration information and
|
||||
* sets up the session model.
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
$modelName = Configure::read('Session.handler.model');
|
||||
|
@ -68,7 +66,7 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
/**
|
||||
* Method called on open of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function open() {
|
||||
return true;
|
||||
|
@ -77,7 +75,7 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
/**
|
||||
* Method called on close of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function close() {
|
||||
return true;
|
||||
|
@ -86,27 +84,34 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
/**
|
||||
* Method used to read from a database session.
|
||||
*
|
||||
* @param integer|string $id The key of the value to read
|
||||
* @param int|string $id The key of the value to read
|
||||
* @return mixed The value of the key or false if it does not exist
|
||||
*/
|
||||
public function read($id) {
|
||||
$row = $this->_model->find('first', array(
|
||||
'conditions' => array($this->_model->primaryKey => $id)
|
||||
'conditions' => array($this->_model->alias . '.' . $this->_model->primaryKey => $id)
|
||||
));
|
||||
|
||||
if (empty($row[$this->_model->alias]['data'])) {
|
||||
return false;
|
||||
if (empty($row[$this->_model->alias])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $row[$this->_model->alias]['data'];
|
||||
if (!is_numeric($row[$this->_model->alias]['data']) && empty($row[$this->_model->alias]['data'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string)$row[$this->_model->alias]['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function called on write for database sessions.
|
||||
*
|
||||
* @param integer $id ID that uniquely identifies session in database
|
||||
* Will retry, once, if the save triggers a PDOException which
|
||||
* can happen if a race condition is encountered
|
||||
*
|
||||
* @param int $id ID that uniquely identifies session in database
|
||||
* @param mixed $data The value of the data to be saved.
|
||||
* @return boolean True for successful write, false otherwise.
|
||||
* @return bool True for successful write, false otherwise.
|
||||
*/
|
||||
public function write($id, $data) {
|
||||
if (!$id) {
|
||||
|
@ -115,24 +120,34 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
$expires = time() + $this->_timeout;
|
||||
$record = compact('id', 'data', 'expires');
|
||||
$record[$this->_model->primaryKey] = $id;
|
||||
return $this->_model->save($record);
|
||||
|
||||
$options = array(
|
||||
'validate' => false,
|
||||
'callbacks' => false,
|
||||
'counterCache' => false
|
||||
);
|
||||
try {
|
||||
return (bool)$this->_model->save($record, $options);
|
||||
} catch (PDOException $e) {
|
||||
return (bool)$this->_model->save($record, $options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called on the destruction of a database session.
|
||||
*
|
||||
* @param integer $id ID that uniquely identifies session in database
|
||||
* @return boolean True for successful delete, false otherwise.
|
||||
* @param int $id ID that uniquely identifies session in database
|
||||
* @return bool True for successful delete, false otherwise.
|
||||
*/
|
||||
public function destroy($id) {
|
||||
return $this->_model->delete($id);
|
||||
return (bool)$this->_model->delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function called on gc for database sessions.
|
||||
*
|
||||
* @param integer $expires Timestamp (defaults to current time)
|
||||
* @return boolean Success
|
||||
* @param int $expires Timestamp (defaults to current time)
|
||||
* @return bool Success
|
||||
*/
|
||||
public function gc($expires = null) {
|
||||
if (!$expires) {
|
||||
|
@ -140,7 +155,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
Add a link
Reference in a new issue