mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '2.1-hiphop' into 2.1
This commit is contained in:
commit
c029316a62
9 changed files with 107 additions and 72 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -681,64 +684,3 @@ class CakeSession {
|
|||
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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2011, 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)
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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);
|
||||
}
|
|
@ -16,6 +16,9 @@
|
|||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
App::uses('CakeSessionHandlerInterface', 'Model/Datasource/Session');
|
||||
|
||||
/**
|
||||
* DatabaseSession provides methods to be used with CakeSession.
|
||||
*
|
||||
|
|
|
@ -3078,7 +3078,7 @@ class Model extends Object implements CakeEventListener {
|
|||
$ruleParams[] = $validator;
|
||||
$ruleParams[0] = array($fieldName => $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]);
|
||||
|
|
|
@ -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[] = '<span class="code-highlight">' . $string . '</span>';
|
||||
} 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.
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue