From e2617621fd52f4a1e997c43b56b34d3dbb940993 Mon Sep 17 00:00:00 2001 From: phpnut Date: Sun, 20 May 2007 04:44:18 +0000 Subject: [PATCH] Adding fix for #2607, fixes Fatal error: Call to a member function on a non-object when using php 4 Adding fix for #2590, fixes ps_files_cleanup_dir: failed: Permission denied git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5124 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/controller/components/acl.php | 3 +- cake/libs/session.php | 155 ++++++++++++------------ 2 files changed, 78 insertions(+), 80 deletions(-) diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index 23209b56d..904668f08 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -174,8 +174,9 @@ class AclComponent extends Object { * * @package cake * @subpackage cake.cake.libs.controller.components + * @abstract */ -class AclBase { +class AclBase extends Object { /** * This class should never be instantiated, just subclassed. * diff --git a/cake/libs/session.php b/cake/libs/session.php index ed12a86cf..7b3b8a7fe 100644 --- a/cake/libs/session.php +++ b/cake/libs/session.php @@ -360,34 +360,6 @@ class CakeSession extends Object { $this->__overwrite($_SESSION, Set::insert($_SESSION, $var, $value)); return (Set::extract($_SESSION, $var) == $value); } -/** - * Method called on close of a database - * session - * - * @return boolean - * @access private - */ - function __close() { - $probability = mt_rand(1, 150); - if($probability <= 3) { - CakeSession::__gc(); - } - return true; - } -/** - * Method called on the destruction of a - * database session - * - * @param integer $key - * @return boolean - * @access private - */ - function __destroy($key) { - $db =& ConnectionManager::getDataSource('default'); - $table = $db->fullTableName(CAKE_SESSION_TABLE); - $db->execute("DELETE FROM " . $db->name($table) . " WHERE " . $db->name($table.'.id') . " = " . $db->value($key, 'integer')); - return true; - } /** * Helper method to destroy invalid sessions. * @@ -411,20 +383,6 @@ class CakeSession extends Object { $this->__construct($this->path); $this->renew(); } -/** - * Helper function called on gc for - * database sessions - * - * @param unknown_type $expires - * @return boolean - * @access private - */ - function __gc($expires = null) { - $db =& ConnectionManager::getDataSource('default'); - $table = $db->fullTableName(CAKE_SESSION_TABLE); - $db->execute("DELETE FROM " . $db->name($table) . " WHERE " . $db->name($table.'.expires') . " < ". $db->value(time())); - return true; - } /** * Helper method to initialize a session, based on Cake core settings. * @@ -459,7 +417,6 @@ class CakeSession extends Object { ini_set('session.name', CAKE_SESSION_COOKIE); ini_set('session.cookie_lifetime', $this->cookieLifeTime); ini_set('session.cookie_path', $this->path); - ini_set('session.gc_probability', 1); ini_set('session.auto_start', 0); ini_set('session.save_path', TMP . 'sessions'); } @@ -476,7 +433,6 @@ class CakeSession extends Object { ini_set('session.name', CAKE_SESSION_COOKIE); ini_set('session.cookie_lifetime', $this->cookieLifeTime); ini_set('session.cookie_path', $this->path); - ini_set('session.gc_probability', 1); ini_set('session.auto_start', 0); } } @@ -494,7 +450,6 @@ class CakeSession extends Object { ini_set('session.name', CAKE_SESSION_COOKIE); ini_set('session.cookie_lifetime', $this->cookieLifeTime); ini_set('session.cookie_path', $this->path); - ini_set('session.gc_probability', 1); } } break; @@ -535,40 +490,6 @@ class CakeSession extends Object { $this->__setError(1, "Session is valid"); } } -/** - * Method called on open of a database - * sesson - * - * @return boolean - * @access private - * - */ - function __open() { - return true; - } -/** - * Method used to read from a database - * session - * - * @param mixed $key The key of the value to read - * @return mixed The value of the key or false if it does not exist - * @access private - */ - function __read($key) { - $db =& ConnectionManager::getDataSource('default'); - $table = $db->fullTableName(CAKE_SESSION_TABLE, false); - $row = $db->query("SELECT " . $db->name($table.'.data') . " FROM " . $db->name($table) . " WHERE " . $db->name($table.'.id') . " = " . $db->value($key), false); - - if ($row && !isset($row[0][$table]) && isset($row[0][0])) { - $table = 0; - } - - if ($row && $row[0][$table]['data']) { - return $row[0][$table]['data']; - } else { - return false; - } - } /** * Helper method to restart a session. * @@ -640,6 +561,54 @@ class CakeSession extends Object { $this->error[$errorNumber] = $errorMessage; $this->lastError = $errorNumber; } +/** + * Method called on open of a database + * sesson + * + * @return boolean + * @access private + * + */ + function __open() { + return true; + } +/** + * Method called on close of a database + * session + * + * @return boolean + * @access private + */ + function __close() { + $probability = mt_rand(1, 150); + if($probability <= 3) { + CakeSession::__gc(); + } + return true; + } +/** + * Method used to read from a database + * session + * + * @param mixed $key The key of the value to read + * @return mixed The value of the key or false if it does not exist + * @access private + */ + function __read($key) { + $db =& ConnectionManager::getDataSource('default'); + $table = $db->fullTableName(CAKE_SESSION_TABLE, false); + $row = $db->query("SELECT " . $db->name($table.'.data') . " FROM " . $db->name($table) . " WHERE " . $db->name($table.'.id') . " = " . $db->value($key), false); + + if ($row && !isset($row[0][$table]) && isset($row[0][0])) { + $table = 0; + } + + if ($row && $row[0][$table]['data']) { + return $row[0][$table]['data']; + } else { + return false; + } + } /** * Helper function called on write for database * sessions @@ -685,5 +654,33 @@ class CakeSession extends Object { } return true; } +/** + * Method called on the destruction of a + * database session + * + * @param integer $key + * @return boolean + * @access private + */ + function __destroy($key) { + $db =& ConnectionManager::getDataSource('default'); + $table = $db->fullTableName(CAKE_SESSION_TABLE); + $db->execute("DELETE FROM " . $db->name($table) . " WHERE " . $db->name($table.'.id') . " = " . $db->value($key, 'integer')); + return true; + } +/** + * Helper function called on gc for + * database sessions + * + * @param unknown_type $expires + * @return boolean + * @access private + */ + function __gc($expires = null) { + $db =& ConnectionManager::getDataSource('default'); + $table = $db->fullTableName(CAKE_SESSION_TABLE); + $db->execute("DELETE FROM " . $db->name($table) . " WHERE " . $db->name($table.'.expires') . " < ". $db->value(time())); + return true; + } } ?> \ No newline at end of file