mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '1.2' into 1.3-merger
Conflicts: cake/console/libs/acl.php cake/console/libs/tasks/controller.php cake/console/libs/tasks/db_config.php cake/console/libs/tasks/model.php cake/console/libs/templates/skel/views/layouts/xml/default.ctp cake/libs/model/datasources/dbo/dbo_mysql.php cake/libs/model/datasources/dbo/dbo_mysqli.php cake/libs/validation.php cake/libs/view/helpers/form.php cake/tests/cases/basics.test.php cake/tests/cases/console/libs/tasks/model.test.php cake/tests/cases/libs/cake_test_case.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php cake/tests/cases/libs/view/helpers/javascript.test.php cake/tests/cases/libs/view/helpers/session.test.php cake/tests/groups/controller.group.php cake/tests/groups/lib.group.php cake/tests/groups/no_database.group.php
This commit is contained in:
commit
a3bb77c4f3
43 changed files with 591 additions and 490 deletions
|
@ -0,0 +1,2 @@
|
|||
<?php echo $xml->header(); ?>
|
||||
<?php echo $content_for_layout; ?>
|
|
@ -641,15 +641,15 @@ class CakeSession extends Object {
|
|||
function __regenerateId() {
|
||||
$oldSessionId = session_id();
|
||||
if ($oldSessionId) {
|
||||
$sessionpath = session_save_path();
|
||||
if (empty($sessionpath)) {
|
||||
$sessionpath = "/tmp";
|
||||
}
|
||||
if (session_id() != "" || isset($_COOKIE[session_name()])) {
|
||||
if (session_id() != ''|| isset($_COOKIE[session_name()])) {
|
||||
setcookie(Configure::read('Session.cookie'), '', time() - 42000, $this->path);
|
||||
}
|
||||
session_regenerate_id(true);
|
||||
if (PHP_VERSION < 5.1) {
|
||||
$sessionPath = session_save_path();
|
||||
if (empty($sessionPath)) {
|
||||
$sessionPath = '/tmp';
|
||||
}
|
||||
$newSessid = session_id();
|
||||
|
||||
if (function_exists('session_write_close')) {
|
||||
|
@ -659,7 +659,7 @@ class CakeSession extends Object {
|
|||
session_id($oldSessionId);
|
||||
session_start();
|
||||
session_destroy();
|
||||
$file = $sessionpath . DS . "sess_$oldSessionId";
|
||||
$file = $sessionPath . DS . 'sess_' . $oldSessionId;
|
||||
@unlink($file);
|
||||
$this->__initSession();
|
||||
session_id($newSessid);
|
||||
|
|
|
@ -450,10 +450,10 @@ class AuthComponent extends Object {
|
|||
return false;
|
||||
}
|
||||
$defaults = array(
|
||||
'loginAction' => Router::normalize(array(
|
||||
'controller'=> Inflector::underscore(Inflector::pluralize($this->userModel)),
|
||||
'loginAction' => array(
|
||||
'controller' => Inflector::underscore(Inflector::pluralize($this->userModel)),
|
||||
'action' => 'login'
|
||||
)),
|
||||
),
|
||||
'sessionKey' => 'Auth.' . $this->userModel,
|
||||
'logoutRedirect' => $this->loginAction,
|
||||
'loginError' => __('Login failed. Invalid username or password.', true),
|
||||
|
|
|
@ -74,6 +74,9 @@ class Controller extends Object {
|
|||
*
|
||||
* Example: var $uses = array('Product', 'Post', 'Comment');
|
||||
*
|
||||
* Can be set to array() to use no models. Can be set to false to
|
||||
* use no models and prevent the merging of $uses with AppController
|
||||
*
|
||||
* @var mixed A single name as a string or a list of names as an array.
|
||||
* @access protected
|
||||
* @link http://book.cakephp.org/view/53/components-helpers-and-uses
|
||||
|
|
|
@ -229,16 +229,8 @@ class Debugger extends Object {
|
|||
*/
|
||||
function log($var, $level = LOG_DEBUG) {
|
||||
$_this = Debugger::getInstance();
|
||||
$trace = $_this->trace(array('start' => 1, 'depth' => 2, 'format' => 'array'));
|
||||
$source = null;
|
||||
|
||||
if (is_object($trace[0]['object']) && isset($trace[0]['object']->_reporter->_test_stack)) {
|
||||
$stack = $trace[0]['object']->_reporter->_test_stack;
|
||||
$source = sprintf('[%1$s, %3$s::%2$s()]' . "\n",
|
||||
array_shift($stack), array_pop($stack), array_pop($stack));
|
||||
}
|
||||
|
||||
CakeLog::write($level, $source . $_this->exportVar($var));
|
||||
$source = $_this->trace(array('start' => 1)) . "\n";
|
||||
CakeLog::write($level, "\n" . $source . $_this->exportVar($var));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -326,7 +326,7 @@ class Folder extends Object {
|
|||
* @static
|
||||
*/
|
||||
function addPathElement($path, $element) {
|
||||
return Folder::slashTerm($path) . $element;
|
||||
return rtrim($path, DS) . DS . $element;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -693,7 +693,7 @@ class HttpSocket extends CakeSocket {
|
|||
|
||||
foreach ($items as $item) {
|
||||
if (strpos($item, '=') !== false) {
|
||||
list($key, $value) = explode('=', $item);
|
||||
list($key, $value) = explode('=', $item, 2);
|
||||
} else {
|
||||
$key = $item;
|
||||
$value = null;
|
||||
|
|
|
@ -474,7 +474,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
'fields' => array($Model->primaryKey, $left, $right), 'recursive' => $recursive)
|
||||
);
|
||||
if ($nextNode) {
|
||||
list($nextNode)= array_values($nextNode);
|
||||
list($nextNode) = array_values($nextNode);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -657,6 +657,8 @@ class TreeBehavior extends ModelBehavior {
|
|||
$sort = $field . ' ' . $order;
|
||||
$nodes = $this->children($Model, $id, true, $fields, $sort, null, null, $recursive);
|
||||
|
||||
$cacheQueries = $Model->cacheQueries;
|
||||
$Model->cacheQueries = false;
|
||||
if ($nodes) {
|
||||
foreach ($nodes as $node) {
|
||||
$id = $node[$Model->alias][$Model->primaryKey];
|
||||
|
@ -666,6 +668,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
}
|
||||
}
|
||||
}
|
||||
$Model->cacheQueries = $cacheQueries;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -320,45 +320,53 @@ class DataSource extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Used to create new records. The "C" CRUD.
|
||||
*
|
||||
* To-be-overridden in subclasses.
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @param unknown_type $fields
|
||||
* @param unknown_type $values
|
||||
* @return unknown
|
||||
* @param Model $model The Model to be created.
|
||||
* @param array $fields An Array of fields to be saved.
|
||||
* @param array $values An Array of values to save.
|
||||
* @return boolean success
|
||||
*/
|
||||
function create(&$model, $fields = null, $values = null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to read records from the Datasource. The "R" in CRUD
|
||||
*
|
||||
* To-be-overridden in subclasses.
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @param unknown_type $queryData
|
||||
* @return unknown
|
||||
* @param Model $model The model being read.
|
||||
* @param array $queryData An array of query data used to find the data you want
|
||||
* @return mixed
|
||||
*/
|
||||
function read(&$model, $queryData = array()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a record(s) in the datasource.
|
||||
*
|
||||
* To-be-overridden in subclasses.
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @param unknown_type $fields
|
||||
* @param unknown_type $values
|
||||
* @return unknown
|
||||
* @param Model $model Instance of the model class being updated
|
||||
* @param array $fields Array of fields to be updated
|
||||
* @param array $values Array of values to be update $fields to.
|
||||
* @return boolean Success
|
||||
*/
|
||||
function update(&$model, $fields = null, $values = null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a record(s) in the datasource.
|
||||
*
|
||||
* To-be-overridden in subclasses.
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @param unknown_type $id
|
||||
* @param Model $model The model class having record(s) deleted
|
||||
* @param mixed $id Primary key of the model
|
||||
*/
|
||||
function delete(&$model, $id = null) {
|
||||
if ($id == null) {
|
||||
|
@ -396,6 +404,16 @@ class DataSource extends Object {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the conditions for the Datasource being available
|
||||
* are satisfied. Often used from connect() to check for support
|
||||
* before establishing a connection.
|
||||
*
|
||||
* @return boolean Whether or not the Datasources conditions for use are met.
|
||||
**/
|
||||
function enabled() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Returns true if the DataSource supports the given interface (method)
|
||||
*
|
||||
|
|
|
@ -110,7 +110,9 @@ class DboAdodb extends DboSource {
|
|||
$adodb_driver = substr($config['connect'], 0, $persistent);
|
||||
$connect = 'PConnect';
|
||||
}
|
||||
|
||||
if (!$this->enabled()) {
|
||||
return false;
|
||||
}
|
||||
$this->_adodb = NewADOConnection($adodb_driver);
|
||||
|
||||
$this->_adodbDataDict = NewDataDictionary($this->_adodb, $adodb_driver);
|
||||
|
@ -123,6 +125,14 @@ class DboAdodb extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that AdoDB is available.
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return function_exists('NewADOConnection');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -146,6 +146,14 @@ class DboDb2 extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the DB2 extension is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('ibm_db2');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -140,10 +140,19 @@ class DboFirebird extends DboSource {
|
|||
$connect = $config['connect'];
|
||||
|
||||
$this->connected = false;
|
||||
|
||||
$this->connection = $connect($config['host'] . ':' . $config['database'], $config['login'], $config['password']);
|
||||
$this->connected = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the interbase extension is loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('interbase');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -164,6 +164,14 @@ class DboMssql extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that MsSQL is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('mssql');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -118,6 +118,40 @@ class DboMysqlBase extends DboSource {
|
|||
'boolean' => array('name' => 'tinyint', 'limit' => '1')
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns an array of the fields in given table name.
|
||||
*
|
||||
* @param string $tableName Name of database table to inspect
|
||||
* @return array Fields in table. Keys are name and type
|
||||
*/
|
||||
function describe(&$model) {
|
||||
$cache = parent::describe($model);
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
}
|
||||
$fields = false;
|
||||
$cols = $this->query('DESCRIBE ' . $this->fullTableName($model));
|
||||
|
||||
foreach ($cols as $column) {
|
||||
$colKey = array_keys($column);
|
||||
if (isset($column[$colKey[0]]) && !isset($column[0])) {
|
||||
$column[0] = $column[$colKey[0]];
|
||||
}
|
||||
if (isset($column[0])) {
|
||||
$fields[$column[0]['Field']] = array(
|
||||
'type' => $this->column($column[0]['Type']),
|
||||
'null' => ($column[0]['Null'] == 'YES' ? true : false),
|
||||
'default' => $column[0]['Default'],
|
||||
'length' => $this->length($column[0]['Type']),
|
||||
);
|
||||
if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
|
||||
$fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->__cacheDescription($this->fullTableName($model, false), $fields);
|
||||
return $fields;
|
||||
}
|
||||
/**
|
||||
* Generates and executes an SQL UPDATE statement for given model, fields, and values.
|
||||
*
|
||||
|
@ -498,6 +532,14 @@ class DboMysql extends DboMysqlBase {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the MySQL extension is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('mysql');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
@ -547,52 +589,6 @@ class DboMysql extends DboMysqlBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the fields in given table name.
|
||||
*
|
||||
* @param string $tableName Name of database table to inspect
|
||||
* @return array Fields in table. Keys are name and type
|
||||
*/
|
||||
function describe(&$model) {
|
||||
$cache = parent::describe($model);
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
}
|
||||
$fields = false;
|
||||
$cols = $this->query('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model));
|
||||
|
||||
foreach ($cols as $column) {
|
||||
$colKey = array_keys($column);
|
||||
if (isset($column[$colKey[0]]) && !isset($column[0])) {
|
||||
$column[0] = $column[$colKey[0]];
|
||||
}
|
||||
if (isset($column[0])) {
|
||||
$fields[$column[0]['Field']] = array(
|
||||
'type' => $this->column($column[0]['Type']),
|
||||
'null' => ($column[0]['Null'] == 'YES' ? true : false),
|
||||
'default' => $column[0]['Default'],
|
||||
'length' => $this->length($column[0]['Type']),
|
||||
);
|
||||
if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
|
||||
$fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']];
|
||||
}
|
||||
foreach ($this->fieldParameters as $name => $value) {
|
||||
if (!empty($column[0][$value['column']])) {
|
||||
$fields[$column[0]['Field']][$name] = $column[0][$value['column']];
|
||||
}
|
||||
}
|
||||
if (isset($fields[$column[0]['Field']]['collate'])) {
|
||||
$charset = $this->getCharsetName($fields[$column[0]['Field']]['collate']);
|
||||
if ($charset) {
|
||||
$fields[$column[0]['Field']]['charset'] = $charset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->__cacheDescription($this->fullTableName($model, false), $fields);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
||||
*
|
||||
|
|
|
@ -89,6 +89,14 @@ class DboMysqli extends DboMysqlBase {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that MySQLi is installed/enabled
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('mysqli');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
@ -159,44 +167,6 @@ class DboMysqli extends DboMysqlBase {
|
|||
return $tables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the fields in given table name.
|
||||
*
|
||||
* @param string $tableName Name of database table to inspect
|
||||
* @return array Fields in table. Keys are name and type
|
||||
*/
|
||||
function describe(&$model) {
|
||||
|
||||
$cache = parent::describe($model);
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$fields = false;
|
||||
$cols = $this->query('DESCRIBE ' . $this->fullTableName($model));
|
||||
|
||||
foreach ($cols as $column) {
|
||||
$colKey = array_keys($column);
|
||||
if (isset($column[$colKey[0]]) && !isset($column[0])) {
|
||||
$column[0] = $column[$colKey[0]];
|
||||
}
|
||||
if (isset($column[0])) {
|
||||
$fields[$column[0]['Field']] = array(
|
||||
'type' => $this->column($column[0]['Type']),
|
||||
'null' => ($column[0]['Null'] == 'YES' ? true : false),
|
||||
'default' => $column[0]['Default'],
|
||||
'length' => $this->length($column[0]['Type'])
|
||||
);
|
||||
if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
|
||||
$fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->__cacheDescription($this->fullTableName($model, false), $fields);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
||||
*
|
||||
|
@ -344,26 +314,6 @@ class DboMysqli extends DboMysqlBase {
|
|||
return 'text';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of a database-native column description, or null if no length
|
||||
*
|
||||
* @param string $real Real database-layer column type (i.e. "varchar(255)")
|
||||
* @return integer An integer representing the length of the column
|
||||
*/
|
||||
function length($real) {
|
||||
$col = str_replace(array(')', 'unsigned'), '', $real);
|
||||
$limit = null;
|
||||
|
||||
if (strpos($col, '(') !== false) {
|
||||
list($col, $limit) = explode('(', $col);
|
||||
}
|
||||
|
||||
if ($limit != null) {
|
||||
return intval($limit);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
|
|
@ -112,6 +112,14 @@ class DboOdbc extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the ODBC extension is installed/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('odbc');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -129,6 +129,14 @@ class DboPostgres extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if PostgreSQL is enabled/loaded
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('pgsql');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
@ -289,6 +297,7 @@ class DboPostgres extends DboSource {
|
|||
case 'date':
|
||||
case 'datetime':
|
||||
case 'timestamp':
|
||||
case 'time':
|
||||
if ($data === '') {
|
||||
return $read ? 'NULL' : 'DEFAULT';
|
||||
}
|
||||
|
|
|
@ -143,6 +143,14 @@ class DboSqlite extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that SQLite is enabled/installed
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('sqlite');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -111,6 +111,14 @@ class DboSybase extends DboSource {
|
|||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that one of the sybase extensions is installed
|
||||
*
|
||||
* @return boolean
|
||||
**/
|
||||
function enabled() {
|
||||
return extension_loaded('sybase') || extension_loaded('sybase_ct');
|
||||
}
|
||||
/**
|
||||
* Disconnects from database.
|
||||
*
|
||||
|
|
|
@ -116,7 +116,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
parent::__construct($config);
|
||||
$this->fullDebug = Configure::read() > 1;
|
||||
|
||||
if (!$this->enabled()) {
|
||||
return false;
|
||||
}
|
||||
if ($autoConnect) {
|
||||
return $this->connect();
|
||||
} else {
|
||||
|
|
|
@ -81,15 +81,15 @@ class CacheHelper extends AppHelper {
|
|||
$cacheTime = 0;
|
||||
$useCallbacks = false;
|
||||
if (is_array($this->cacheAction)) {
|
||||
$contoller = Inflector::underscore($this->controllerName);
|
||||
$controller = Inflector::underscore($this->controllerName);
|
||||
$check = str_replace('/', '_', $this->here);
|
||||
$replace = str_replace('/', '_', $this->base);
|
||||
$match = str_replace($this->base, '', $this->here);
|
||||
$match = str_replace('//', '/', $match);
|
||||
$match = str_replace('/' . $contoller . '/', '', $match);
|
||||
$match = str_replace('/' . $controller . '/', '', $match);
|
||||
$match = str_replace('/' . $this->controllerName . '/', '', $match);
|
||||
$check = str_replace($replace, '', $check);
|
||||
$check = str_replace('_' . $contoller . '_', '', $check);
|
||||
$check = str_replace('_' . $controller . '_', '', $check);
|
||||
$check = str_replace('_' . $this->controllerName . '_', '', $check);
|
||||
$check = Inflector::slug($check);
|
||||
$check = preg_replace('/^_+/', '', $check);
|
||||
|
@ -179,7 +179,6 @@ class CacheHelper extends AppHelper {
|
|||
$outputResult = array_values($outputResult);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($fileResult)) {
|
||||
$i = 0;
|
||||
foreach ($fileResult as $cacheBlock) {
|
||||
|
@ -202,24 +201,23 @@ class CacheHelper extends AppHelper {
|
|||
function __parseOutput($cache) {
|
||||
$count = 0;
|
||||
if (!empty($this->__match)) {
|
||||
|
||||
foreach ($this->__match as $found) {
|
||||
$original = $cache;
|
||||
$length = strlen($found);
|
||||
$position = 0;
|
||||
|
||||
for ($i = 1; $i <= 1; $i++) {
|
||||
$position = strpos($cache, $found, $position);
|
||||
for ($i = 1; $i <= 1; $i++) {
|
||||
$position = strpos($cache, $found, $position);
|
||||
|
||||
if ($position !== false) {
|
||||
$cache = substr($original, 0, $position);
|
||||
$cache .= $this->__replace[$count];
|
||||
$cache .= substr($original, $position + $length);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if ($position !== false) {
|
||||
$cache = substr($original, 0, $position);
|
||||
$cache .= $this->__replace[$count];
|
||||
$cache .= substr($original, $position + $length);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
return $cache;
|
||||
}
|
||||
|
@ -301,5 +299,4 @@ class CacheHelper extends AppHelper {
|
|||
return cache('views' . DS . $cache, $file, $timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -772,9 +772,13 @@ class FormHelper extends AppHelper {
|
|||
|
||||
if ($label !== false) {
|
||||
$labelAttributes = $this->domId(array(), 'for');
|
||||
if (in_array($options['type'], array('date', 'datetime'))) {
|
||||
$labelAttributes['for'] .= 'Month';
|
||||
} else if ($options['type'] === 'time') {
|
||||
if ($options['type'] === 'date' || $options['type'] === 'datetime') {
|
||||
if (isset($options['dateFormat']) && $options['dateFormat'] === 'NONE') {
|
||||
$labelAttributes['for'] .= 'Hour';
|
||||
} else {
|
||||
$labelAttributes['for'] .= 'Month';
|
||||
}
|
||||
} elseif ($options['type'] === 'time') {
|
||||
$labelAttributes['for'] .= 'Hour';
|
||||
}
|
||||
|
||||
|
@ -1816,7 +1820,7 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if ($name !== null) {
|
||||
if ((!$selectedIsEmpty && $selected == $name) || ($selectedIsArray && in_array($name, $selected))) {
|
||||
if ((!$selectedIsEmpty && (string)$selected == (string)$name) || ($selectedIsArray && in_array($name, $selected))) {
|
||||
if ($attributes['style'] === 'checkbox') {
|
||||
$htmlOptions['checked'] = true;
|
||||
} else {
|
||||
|
|
|
@ -250,11 +250,13 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates a sorting link
|
||||
* Generates a sorting link. Sets named parameters for the sort and direction. Handles
|
||||
* direction switching automatically.
|
||||
*
|
||||
* @param string $title Title for the link.
|
||||
* @param string $key The name of the key that the recordset should be sorted.
|
||||
* @param array $options Options for sorting link. See #options for list of keys.
|
||||
* @param string $title Title for the link.
|
||||
* @param string $key The name of the key that the recordset should be sorted. If $key is null
|
||||
* $title will be used for the key, and a title will be generated by inflection.
|
||||
* @param array $options Options for sorting link. See #options for list of keys.
|
||||
* @return string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified
|
||||
* key the returned link will sort by 'desc'.
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* TestTaskTest file
|
||||
* ModelTaskTest file
|
||||
*
|
||||
* Test Case for test generation shell task
|
||||
*
|
||||
|
@ -17,10 +18,10 @@
|
|||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.console.libs.tasks
|
||||
* @since CakePHP v 1.3
|
||||
* @since CakePHP v 1.2.6
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
App::import('Shell', 'Shell', false);
|
||||
App::import('Core', 'Shell');
|
||||
|
||||
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
||||
define('DISABLE_AUTO_DISPATCH', true);
|
||||
|
@ -33,16 +34,14 @@ if (!class_exists('ShellDispatcher')) {
|
|||
ob_end_clean();
|
||||
}
|
||||
|
||||
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';
|
||||
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'fixture.php';
|
||||
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
|
||||
|
||||
if (!class_exists('TestTask')) {
|
||||
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';
|
||||
}
|
||||
|
||||
Mock::generatePartial(
|
||||
'ShellDispatcher', 'TestModelTaskMockShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
||||
);
|
||||
|
||||
Mock::generatePartial(
|
||||
'ModelTask', 'MockModelTask',
|
||||
array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest')
|
||||
|
|
|
@ -84,6 +84,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
$this->_debug = Configure::read('debug');
|
||||
$this->Case =& new SubjectCakeTestCase();
|
||||
$reporter =& new MockCakeHtmlReporter();
|
||||
$this->Case->setReporter($reporter);
|
||||
|
@ -97,6 +98,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
Configure::write('debug', $this->_debug);
|
||||
unset($this->Case);
|
||||
unset($this->Reporter);
|
||||
}
|
||||
|
|
|
@ -389,6 +389,7 @@ class ComponentTest extends CakeTestCase {
|
|||
function testNestedComponentLoading() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('Apple');
|
||||
$Controller->uses = false;
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
|
||||
|
@ -409,6 +410,7 @@ class ComponentTest extends CakeTestCase {
|
|||
function testComponentStartup() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('Apple');
|
||||
$Controller->uses = false;
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
$Controller->beforeFilter();
|
||||
|
@ -429,6 +431,7 @@ class ComponentTest extends CakeTestCase {
|
|||
*/
|
||||
function testMultipleComponentInitialize() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->uses = false;
|
||||
$Controller->components = array('Orange', 'Banana');
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
|
@ -450,7 +453,7 @@ class ComponentTest extends CakeTestCase {
|
|||
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('ParamTest' => array('test' => 'value', 'flag'), 'Apple');
|
||||
|
||||
$Controller->uses = false;
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
|
||||
|
@ -482,8 +485,12 @@ class ComponentTest extends CakeTestCase {
|
|||
* @return void
|
||||
**/
|
||||
function testComponentParamsNoDuplication() {
|
||||
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
||||
return;
|
||||
}
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('Orange' => array('setting' => array('itemx')));
|
||||
$Controller->uses = false;
|
||||
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
|
@ -499,6 +506,7 @@ class ComponentTest extends CakeTestCase {
|
|||
function testMutuallyReferencingComponents() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('MutuallyReferencingOne');
|
||||
$Controller->uses = false;
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
|
||||
|
@ -524,6 +532,7 @@ class ComponentTest extends CakeTestCase {
|
|||
function testSomethingReferencingEmailComponent() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('SomethingWithEmail');
|
||||
$Controller->uses = false;
|
||||
$Controller->constructClasses();
|
||||
$Controller->Component->initialize($Controller);
|
||||
$Controller->beforeFilter();
|
||||
|
@ -550,14 +559,17 @@ class ComponentTest extends CakeTestCase {
|
|||
* @access public
|
||||
*/
|
||||
function testDoubleLoadingOfSessionComponent() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController');
|
||||
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->uses = array();
|
||||
$Controller->uses = false;
|
||||
$Controller->components = array('Session');
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->components, array('Session' => '', 'Orange' => array('colour' => 'blood orange')));
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -222,6 +222,7 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testRequireSecureFail() {
|
||||
$_SERVER['HTTPS'] = 'off';
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$this->Controller->action = 'posted';
|
||||
$this->Controller->Security->requireSecure('posted');
|
||||
|
|
|
@ -131,7 +131,14 @@ class MergePostsController extends MergeVarPluginAppController {
|
|||
* @package cake.tests.cases.libs.controller
|
||||
**/
|
||||
class ControllerMergeVarsTestCase extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* Skips the case if APP_CONTROLLER_EXISTS is defined
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function skip() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'APP_CONTROLLER_EXISTS cannot run. %s');
|
||||
}
|
||||
/**
|
||||
* end test
|
||||
*
|
||||
|
|
|
@ -286,6 +286,7 @@ class DebuggerTest extends CakeTestCase {
|
|||
Debugger::log(array('whatever', 'here'));
|
||||
$result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
|
||||
$this->assertPattern('/DebuggerTest\:\:testLog/', $result);
|
||||
$this->assertPattern('/\[main\]/', $result);
|
||||
$this->assertPattern('/array/', $result);
|
||||
$this->assertPattern('/"whatever",/', $result);
|
||||
$this->assertPattern('/"here"/', $result);
|
||||
|
|
|
@ -219,6 +219,18 @@ class FolderTest extends CakeTestCase {
|
|||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test Adding path elements to a path
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testAddPathElement() {
|
||||
$result = Folder::addPathElement(DS . 'some' . DS . 'dir', 'another_path');
|
||||
$this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path');
|
||||
|
||||
$result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path');
|
||||
$this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path');
|
||||
}
|
||||
/**
|
||||
* testFolderRead method
|
||||
*
|
||||
|
|
|
@ -1026,6 +1026,28 @@ class HttpSocketTest extends CakeTestCase {
|
|||
'host' => 'www.google.com',
|
||||
'port' => 8080,
|
||||
));
|
||||
|
||||
$uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2%3Dvalue3');
|
||||
$this->assertIdentical($uri, array(
|
||||
'scheme' => 'http',
|
||||
'host' => 'www.cakephp.org',
|
||||
'path' => '/',
|
||||
'query' => array(
|
||||
'param1' => 'value1',
|
||||
'param2' => 'value2=value3'
|
||||
)
|
||||
));
|
||||
|
||||
$uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2=value3');
|
||||
$this->assertIdentical($uri, array(
|
||||
'scheme' => 'http',
|
||||
'host' => 'www.cakephp.org',
|
||||
'path' => '/',
|
||||
'query' => array(
|
||||
'param1' => 'value1',
|
||||
'param2' => 'value2=value3'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2603,7 +2603,7 @@ class I18nTest extends CakeTestCase {
|
|||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __domainCategorySingular($domain = 'test_plugin', $category = LC_MONETARY) {
|
||||
function __domainCategorySingular($domain = 'test_plugin', $category = 3) {
|
||||
$singular = __dc($domain, 'Plural Rule 1', $category, true);
|
||||
return $singular;
|
||||
}
|
||||
|
@ -2614,7 +2614,7 @@ class I18nTest extends CakeTestCase {
|
|||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __domainCategoryPlural($domain = 'test_plugin', $category = LC_MONETARY) {
|
||||
function __domainCategoryPlural($domain = 'test_plugin', $category = 3) {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category, true), (float)$number);
|
||||
|
@ -2653,7 +2653,7 @@ class I18nTest extends CakeTestCase {
|
|||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __category($category = LC_MONETARY) {
|
||||
function __category($category = 3) {
|
||||
$singular = __c('Plural Rule 1', $category, true);
|
||||
return $singular;
|
||||
}
|
||||
|
|
|
@ -1220,6 +1220,25 @@ class NumberTreeTest extends CakeTestCase {
|
|||
$this->assertIdentical($nodes, $sortedNodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* test reordering large-ish trees with cacheQueries = true.
|
||||
* This caused infinite loops when moving down elements as stale data is returned
|
||||
* from the memory cache
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testReorderBigTreeWithQueryCaching() {
|
||||
extract($this->settings);
|
||||
$this->Tree =& new $modelClass();
|
||||
$this->Tree->initialize(2, 10);
|
||||
|
||||
$original = $this->Tree->cacheQueries;
|
||||
$this->Tree->cacheQueries = true;
|
||||
$this->Tree->reorder(array('field' => 'name', 'direction' => 'DESC'));
|
||||
$this->assertTrue($this->Tree->cacheQueries, 'cacheQueries was not restored after reorder(). %s');
|
||||
$this->Tree->cacheQueries = $original;
|
||||
}
|
||||
/**
|
||||
* testGenerateTreeListWithSelfJoin method
|
||||
*
|
||||
|
|
|
@ -161,7 +161,7 @@ class MysqlTestModel extends Model {
|
|||
* @subpackage cake.tests.cases.libs.model.datasources.dbo
|
||||
*/
|
||||
class DboMysqlTest extends CakeTestCase {
|
||||
|
||||
var $fixtures = array('core.binary_test');
|
||||
/**
|
||||
* The Dbo instance to be tested
|
||||
*
|
||||
|
@ -187,7 +187,6 @@ class DboMysqlTest extends CakeTestCase {
|
|||
*/
|
||||
function startTest() {
|
||||
$db = ConnectionManager::getDataSource('test_suite');
|
||||
$this->db = new DboMysqlTestDb($db->config);
|
||||
$this->model = new MysqlTestModel();
|
||||
}
|
||||
|
||||
|
@ -196,8 +195,9 @@ class DboMysqlTest extends CakeTestCase {
|
|||
*
|
||||
* @access public
|
||||
*/
|
||||
function endTest() {
|
||||
unset($this->db);
|
||||
function tearDown() {
|
||||
unset($this->model);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -285,11 +285,11 @@ class DboMysqlTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testTinyintCasting() {
|
||||
$this->db->cacheSources = $this->db->testing = false;
|
||||
$this->db->cacheSources = false;
|
||||
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
|
||||
|
||||
$this->model = new CakeTestModel(array(
|
||||
'name' => 'Tinyint', 'table' => $this->db->fullTableName('tinyint', false)
|
||||
'name' => 'Tinyint', 'table' => 'tinyint', 'ds' => 'test_suite'
|
||||
));
|
||||
|
||||
$result = $this->model->schema();
|
||||
|
@ -324,12 +324,12 @@ class DboMysqlTest extends CakeTestCase {
|
|||
* @access public
|
||||
*/
|
||||
function testIndexDetection() {
|
||||
$this->db->cacheSources = $this->db->testing = false;
|
||||
$this->db->cacheSources = false;
|
||||
|
||||
$name = $this->db->fullTableName('simple');
|
||||
$this->db->query('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
|
||||
$expected = array('PRIMARY' => array('column' => 'id', 'unique' => 1));
|
||||
$result = $this->db->index($name, false);
|
||||
$result = $this->db->index('simple', false);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->db->query('DROP TABLE ' . $name);
|
||||
|
||||
|
@ -339,7 +339,7 @@ class DboMysqlTest extends CakeTestCase {
|
|||
'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
||||
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
|
||||
);
|
||||
$result = $this->db->index($name, false);
|
||||
$result = $this->db->index('with_a_key', false);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->db->query('DROP TABLE ' . $name);
|
||||
|
||||
|
@ -350,7 +350,7 @@ class DboMysqlTest extends CakeTestCase {
|
|||
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
|
||||
'pointless_small_int' => array('column' => 'small_int', 'unique' => 0),
|
||||
);
|
||||
$result = $this->db->index($name, false);
|
||||
$result = $this->db->index('with_two_keys', false);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->db->query('DROP TABLE ' . $name);
|
||||
|
||||
|
@ -362,7 +362,7 @@ class DboMysqlTest extends CakeTestCase {
|
|||
'pointless_small_int' => array('column' => 'small_int', 'unique' => 0),
|
||||
'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0),
|
||||
);
|
||||
$result = $this->db->index($name, false);
|
||||
$result = $this->db->index('with_compound_keys', false);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->db->query('DROP TABLE ' . $name);
|
||||
|
||||
|
@ -375,7 +375,7 @@ class DboMysqlTest extends CakeTestCase {
|
|||
'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0),
|
||||
'other_way' => array('column' => array('small_int', 'bool'), 'unique' => 0),
|
||||
);
|
||||
$result = $this->db->index($name, false);
|
||||
$result = $this->db->index('with_multiple_compound_keys', false);
|
||||
$this->assertEqual($expected, $result);
|
||||
$this->db->query('DROP TABLE ' . $name);
|
||||
}
|
||||
|
@ -628,6 +628,24 @@ class DboMysqlTest extends CakeTestCase {
|
|||
|
||||
$this->db->query($this->db->dropSchema($schema1));
|
||||
}
|
||||
/**
|
||||
* test saving and retrieval of blobs
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testBlobSaving() {
|
||||
$this->db->cacheSources = false;
|
||||
$data = "GIF87ab |