Merge remote branch 'origin/2.0' into 2.0-phpunit

This commit is contained in:
José Lorenzo Rodríguez Urdaneta 2010-07-07 22:22:12 -04:30
commit 3f2df10cc2
2 changed files with 19 additions and 33 deletions

View file

@ -134,8 +134,9 @@ class FileEngine extends CacheEngine {
$success = $this->_File->ftruncate(0) && $this->_File->fwrite($contents);
if ($this->settings['lock']) {
$this->_File->flock(LOCK_EX);
$this->_File->flock(LOCK_UN);
}
$this->_File = null;
return $success;
}
@ -171,7 +172,7 @@ class FileEngine extends CacheEngine {
}
if ($this->settings['lock']) {
$this->_File->flock(LOCK_SH);
$this->_File->flock(LOCK_UN);
}
$data = trim($data);
@ -195,7 +196,9 @@ class FileEngine extends CacheEngine {
if ($this->_setKey($key) === false || !$this->_init) {
return false;
}
return unlink($this->_File->getRealPath());
$path = $this->_File->getRealPath();
$this->_File = null;
return unlink($path);
}
/**
@ -234,7 +237,9 @@ class FileEngine extends CacheEngine {
continue;
}
}
unlink($this->_File->getRealPath());
$path = $this->_File->getRealPath();
$this->_File = null;
unlink($path);
}
$dir->close();
return true;

View file

@ -28,7 +28,7 @@ include_once CONFIGS . 'database.php';
* @package cake
* @subpackage cake.cake.libs.model
*/
class ConnectionManager extends Object {
class ConnectionManager {
/**
* Holds a loaded instance of the Connections object
@ -69,10 +69,8 @@ class ConnectionManager extends Object {
* Gets a reference to the ConnectionManger object instance
*
* @return object Instance
* @access public
* @static
*/
function &getInstance() {
public static function &getInstance() {
static $instance = array();
if (!$instance) {
@ -87,10 +85,8 @@ class ConnectionManager extends Object {
*
* @param string $name The name of the DataSource, as defined in app/config/database.php
* @return object Instance
* @access public
* @static
*/
function &getDataSource($name) {
public static function &getDataSource($name) {
$_this =& ConnectionManager::getInstance();
if (!empty($_this->_dataSources[$name])) {
@ -122,10 +118,8 @@ class ConnectionManager extends Object {
* Gets the list of available DataSource connections
*
* @return array List of available connections
* @access public
* @static
*/
function sourceList() {
public static function sourceList() {
$_this =& ConnectionManager::getInstance();
return array_keys($_this->_dataSources);
}
@ -138,10 +132,8 @@ class ConnectionManager extends Object {
* @param object $source DataSource object
* @return string Datasource name, or null if source is not present
* in the ConnectionManager.
* @access public
* @static
*/
function getSourceName(&$source) {
public static function getSourceName(&$source) {
$_this =& ConnectionManager::getInstance();
foreach ($_this->_dataSources as $name => $ds) {
if ($ds == $source) {
@ -158,10 +150,8 @@ class ConnectionManager extends Object {
* or an array containing the filename (without extension) and class name of the object,
* to be found in app/models/datasources/ or cake/libs/model/datasources/.
* @return boolean True on success, null on failure or false if the class is already loaded
* @access public
* @static
*/
function loadDataSource($connName) {
public static function loadDataSource($connName) {
$_this =& ConnectionManager::getInstance();
if (is_array($connName)) {
@ -193,12 +183,9 @@ class ConnectionManager extends Object {
*
* @return array An associative array of elements where the key is the connection name
* (as defined in Connections), and the value is an array with keys 'filename' and 'classname'.
* @access public
* @static
*/
function enumConnectionObjects() {
public static function enumConnectionObjects() {
$_this =& ConnectionManager::getInstance();
return $_this->_connectionsEnum;
}
@ -208,10 +195,8 @@ class ConnectionManager extends Object {
* @param string $name The DataSource name
* @param array $config The DataSource configuration settings
* @return object A reference to the DataSource object, or null if creation failed
* @access public
* @static
*/
function &create($name = '', $config = array()) {
public static function &create($name = '', $config = array()) {
$_this =& ConnectionManager::getInstance();
if (empty($name) || empty($config) || array_key_exists($name, $_this->_connectionsEnum)) {
@ -228,10 +213,8 @@ class ConnectionManager extends Object {
* Gets a list of class and file names associated with the user-defined DataSource connections
*
* @return void
* @access protected
* @static
*/
function _getConnectionObjects() {
protected function _getConnectionObjects() {
$connections = get_object_vars($this->config);
if ($connections != null) {
@ -247,9 +230,8 @@ class ConnectionManager extends Object {
* Returns the file, class name, and parent for the given driver.
*
* @return array An indexed array with: filename, classname, plugin and parent
* @access private
*/
function __connectionData($config) {
private function __connectionData($config) {
if (!isset($config['datasource'])) {
$config['datasource'] = 'dbo';
}
@ -285,7 +267,6 @@ class ConnectionManager extends Object {
/**
* Destructor.
*
* @access private
*/
function __destruct() {
if (Configure::read('Session.save') == 'database' && function_exists('session_write_close')) {