diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index b6ef75f70..e1b83c609 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -125,10 +125,9 @@ class CakeSession { * Constructor. * * @param string $base The base path for the Session - * @param boolean $start Should session be started right now * @return void */ - public static function init($base = null, $start = true) { + public static function init($base = null) { self::$time = time(); $checkAgent = Configure::read('Session.checkAgent'); @@ -181,6 +180,7 @@ class CakeSession { if (self::started()) { return true; } + CakeSession::init(); $id = self::id(); session_write_close(); self::_configureSession(); @@ -342,6 +342,9 @@ class CakeSession { if ($userAgent) { self::$_userAgent = $userAgent; } + if (empty(self::$_userAgent)) { + CakeSession::init(self::$path); + } return self::$_userAgent; } @@ -680,65 +683,4 @@ class CakeSession { self::$error[$errorNumber] = $errorMessage; self::$lastError = $errorNumber; } -} - - -/** - * 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 - */ -interface CakeSessionHandlerInterface { -/** - * Method called on open of a session. - * - * @return boolean Success - */ - public function open(); - -/** - * Method called on close of a session. - * - * @return boolean Success - */ - public function close(); - -/** - * Method used to read from a session. - * - * @param mixed $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); - -/** - * Helper function called on write for sessions. - * - * @param integer $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. - */ - 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. - */ - public function destroy($id); - -/** - * 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 - */ - public function gc($expires = null); -} - - -// Initialize the session -CakeSession::init(); +} \ No newline at end of file diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 7b38ff5ce..568e06c82 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -196,7 +196,7 @@ class Mysql extends DboSource { } else { $tables = array(); - while ($line = $result->fetch()) { + while ($line = $result->fetch(PDO::FETCH_NUM)) { $tables[] = $line[0]; } @@ -280,7 +280,7 @@ class Mysql extends DboSource { public function getCharsetName($name) { if ((bool)version_compare($this->getVersion(), "5", ">=")) { $r = $this->_execute('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', array($name)); - $cols = $r->fetch(); + $cols = $r->fetch(PDO::FETCH_ASSOC); if (isset($cols['CHARACTER_SET_NAME'])) { return $cols['CHARACTER_SET_NAME']; @@ -309,7 +309,7 @@ class Mysql extends DboSource { throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table)); } - foreach ($cols as $column) { + while ($column = $cols->fetch(PDO::FETCH_OBJ)) { $fields[$column->Field] = array( 'type' => $this->column($column->Type), 'null' => ($column->Null === 'YES' ? true : false), @@ -442,7 +442,7 @@ class Mysql extends DboSource { $old = version_compare($this->getVersion(), '4.1', '<='); if ($table) { $indices = $this->_execute('SHOW INDEX FROM ' . $table); - while ($idx = $indices->fetch()) { + while ($idx = $indices->fetch(PDO::FETCH_OBJ)) { if ($old) { $idx = (object) current((array)$idx); } diff --git a/lib/Cake/Model/Datasource/Session/CacheSession.php b/lib/Cake/Model/Datasource/Session/CacheSession.php index 665f4e30c..fc758d838 100644 --- a/lib/Cake/Model/Datasource/Session/CacheSession.php +++ b/lib/Cake/Model/Datasource/Session/CacheSession.php @@ -18,6 +18,7 @@ */ App::uses('Cache', 'Cache'); +App::uses('CakeSessionHandlerInterface', 'Model/Datasource/Session'); /** * CacheSession provides method for saving sessions into a Cache engine. Used with CakeSession diff --git a/lib/Cake/Model/Datasource/Session/CakeSessionHandlerInterface.php b/lib/Cake/Model/Datasource/Session/CakeSessionHandlerInterface.php new file mode 100644 index 000000000..5e62e1053 --- /dev/null +++ b/lib/Cake/Model/Datasource/Session/CakeSessionHandlerInterface.php @@ -0,0 +1,70 @@ + $ruleParams[0]); $valid = $this->Behaviors->dispatchMethod($this, $rule, $ruleParams); - } elseif (method_exists('Validation', $rule)) { + } elseif (class_exists('Validation') && method_exists('Validation', $rule)) { $valid = call_user_func_array(array('Validation', $rule), $ruleParams); } elseif (!is_array($validator['rule'])) { $valid = preg_match($rule, $data[$fieldName]); diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index 8f71b6e06..44b427629 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -402,7 +402,7 @@ class Debugger { if (!isset($data[$i])) { continue; } - $string = str_replace(array("\r\n", "\n"), "", highlight_string($data[$i], true)); + $string = str_replace(array("\r\n", "\n"), "", self::_highlight($data[$i])); if ($i == $line) { $lines[] = '' . $string . ''; } else { @@ -412,6 +412,23 @@ class Debugger { return $lines; } +/** + * Wraps the highlight_string funciton in case the server API does not + * implement the function as it is the case of the HipHop interpreter + * + * @param string $str the string to convert + * @return string + */ + protected static function _highlight($str) { + static $supportHighlight = null; + if (!$supportHighlight && function_exists('hphp_log')) { + $supportHighlight = false; + return htmlentities($str); + } + $supportHighlight = true; + return highlight_string($str, true); + } + /** * Converts a variable to a string for debug output. * diff --git a/lib/Cake/Utility/String.php b/lib/Cake/Utility/String.php index 4b2a524b3..61b22681c 100644 --- a/lib/Cake/Utility/String.php +++ b/lib/Cake/Utility/String.php @@ -79,7 +79,9 @@ class String { $node = crc32(Configure::read('Security.salt')); } - if (function_exists('zend_thread_id')) { + if (function_exists('hphp_get_thread_id')) { + $pid = hphp_get_thread_id(); + } else if (function_exists('zend_thread_id')) { $pid = zend_thread_id(); } else { $pid = getmypid(); diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 7d654faf9..8812901a2 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -93,7 +93,7 @@ class PaginatorHelper extends AppHelper { $this->_ajaxHelperClass = $ajaxProvider; App::uses($ajaxProvider . 'Helper', 'View/Helper'); $classname = $ajaxProvider . 'Helper'; - if (!method_exists($classname, 'link')) { + if (!class_exists($classname) || !method_exists($classname, 'link')) { throw new CakeException(sprintf( __d('cake_dev', '%s does not implement a link() method, it is incompatible with PaginatorHelper'), $classname ));