Skip to content

Commit

Permalink
Merge branch 'master' into 2.5
Browse files Browse the repository at this point in the history
Conflicts:
	lib/Cake/Model/Datasource/DboSource.php
	lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
	lib/Cake/Utility/Folder.php
	lib/Cake/VERSION.txt
  • Loading branch information
ADmad committed May 4, 2014
2 parents 99a7ddf + 2f0a9be commit d466e00
Show file tree
Hide file tree
Showing 48 changed files with 138 additions and 73 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -21,6 +21,8 @@ matrix:
- PHPCS=1

before_script:
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then composer global require 'phpunit/phpunit=3.7.33'; fi"
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit; fi"
- sudo locale-gen de_DE
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi"
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/ConsoleShell.php
Expand Up @@ -303,7 +303,7 @@ protected function _unbind($command) {
$validCurrentAssociation = false;

foreach ($currentAssociations as $model => $currentAssociation) {
if ($model == $modelB && $association == $currentAssociation) {
if ($model === $modelB && $association === $currentAssociation) {
$validCurrentAssociation = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/ServerShell.php
Expand Up @@ -92,7 +92,7 @@ public function startup() {
}

// for windows
if (substr($this->_documentRoot, -1, 1) == DIRECTORY_SEPARATOR) {
if (substr($this->_documentRoot, -1, 1) === DIRECTORY_SEPARATOR) {
$this->_documentRoot = substr($this->_documentRoot, 0, strlen($this->_documentRoot) - 1);
}
if (preg_match("/^([a-z]:)[\\\]+(.+)$/i", $this->_documentRoot, $m)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/DbConfigTask.php
Expand Up @@ -296,7 +296,7 @@ public function bake($configs) {

foreach ($oldConfigs as $key => $oldConfig) {
foreach ($configs as $config) {
if ($oldConfig['name'] == $config['name']) {
if ($oldConfig['name'] === $config['name']) {
unset($oldConfigs[$key]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -414,7 +414,7 @@ protected function _parse($functionName, $map) {
$mapCount = count($map);
$strings = $this->_getStrings($position, $mapCount);

if ($mapCount == count($strings)) {
if ($mapCount === count($strings)) {
extract(array_combine($map, $strings));
$category = isset($category) ? $category : 6;
$category = intval($category);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -632,13 +632,13 @@ public function findHasOneAndMany(Model $model, $associations) {
}
foreach ($tempFieldNames as $fieldName) {
$assoc = false;
if ($fieldName != $model->primaryKey && $fieldName == $foreignKey) {
if ($fieldName !== $model->primaryKey && $fieldName === $foreignKey) {
$assoc = array(
'alias' => $tempOtherModel->name,
'className' => $tempOtherModel->name,
'foreignKey' => $fieldName
);
} elseif ($otherTable == $model->table && $fieldName === 'parent_id') {
} elseif ($otherTable === $model->table && $fieldName === 'parent_id') {
$assoc = array(
'alias' => 'Child' . $model->name,
'className' => $model->name,
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -302,7 +302,7 @@ public function getRealClassName($type, $class) {

$position = strpos($class, $type);

if ($position !== false && strlen($class) - $position == strlen($type)) {
if ($position !== false && (strlen($class) - $position) === strlen($type)) {
return $class;
}
return $class . $type;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ViewTask.php
Expand Up @@ -151,7 +151,7 @@ protected function _methodsToBake() {
unset($methods[$i]);
}
}
if ($method[0] === '_' || $method == strtolower($this->controllerName . 'Controller')) {
if ($method[0] === '_' || $method === strtolower($this->controllerName . 'Controller')) {
unset($methods[$i]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -609,7 +609,7 @@ protected function _moveViewFiles() {

$new = 'View' . DS . Inflector::camelize($old);
$old = 'View' . DS . $old;
if ($new == $old) {
if ($new === $old) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/ConsoleInput.php
Expand Up @@ -47,7 +47,7 @@ class ConsoleInput {
* @param string $handle The location of the stream to use as input.
*/
public function __construct($handle = 'php://stdin') {
$this->_canReadline = extension_loaded('readline') && $handle == 'php://stdin' ? true : false;
$this->_canReadline = extension_loaded('readline') && $handle === 'php://stdin' ? true : false;
$this->_input = fopen($handle, 'r');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Templates/default/views/form.ctp
Expand Up @@ -23,7 +23,7 @@
<?php
echo "\t<?php\n";
foreach ($fields as $field) {
if (strpos($action, 'add') !== false && $field == $primaryKey) {
if (strpos($action, 'add') !== false && $field === $primaryKey) {
continue;
} elseif (!in_array($field, array('created', 'modified', 'updated'))) {
echo "\t\techo \$this->Form->input('{$field}');\n";
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Templates/skel/View/Layouts/flash.ctp
Expand Up @@ -13,7 +13,7 @@
<?php echo $this->Html->charset(); ?>
<title><?php echo $page_title; ?></title>

<?php if (Configure::read('debug') == 0): ?>
<?php if (!Configure::read('debug')): ?>
<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/>
<?php endif ?>
<style><!--
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Controller/Component/Acl/PhpAcl.php
Expand Up @@ -462,7 +462,7 @@ public function resolve($aro) {
$mapped = '';

if (is_array($aro)) {
if (isset($aro['model']) && isset($aro['foreign_key']) && $aro['model'] == $aroGroup) {
if (isset($aro['model']) && isset($aro['foreign_key']) && $aro['model'] === $aroGroup) {
$mapped = $aroGroup . '/' . $aro['foreign_key'];
} elseif (isset($aro[$model][$field])) {
$mapped = $aroGroup . '/' . $aro[$model][$field];
Expand All @@ -479,7 +479,7 @@ public function resolve($aro) {

$aroModel = Inflector::camelize($aroModel);

if ($aroModel == $model || $aroModel == $aroGroup) {
if ($aroModel === $model || $aroModel === $aroGroup) {
$mapped = $aroGroup . '/' . $aroValue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -723,7 +723,7 @@ public function redirectUrl($url = null) {
$redir = $this->Session->read('Auth.redirect');
$this->Session->delete('Auth.redirect');

if (Router::normalize($redir) == Router::normalize($this->loginAction)) {
if (Router::normalize($redir) === Router::normalize($this->loginAction)) {
$redir = $this->loginRedirect;
}
} elseif ($this->loginRedirect) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/PaginatorComponent.php
Expand Up @@ -392,7 +392,7 @@ public function validateSort(Model $object, array $options, array $whitelist = a
if (strpos($key, '.') !== false) {
list($alias, $field) = explode('.', $key);
}
$correctAlias = ($object->alias == $alias);
$correctAlias = ($object->alias === $alias);

if ($correctAlias && $object->hasField($field)) {
$order[$object->alias . '.' . $field] = $value;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -525,7 +525,7 @@ public function requestedWith($type = null) {
return $this->mapType($contentType);
}
if (is_string($type)) {
return ($type == $this->mapType($contentType));
return ($type === $this->mapType($contentType));
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Controller/Component/SecurityComponent.php
Expand Up @@ -230,7 +230,7 @@ public function startup(Controller $controller) {
$controller->request->params['requested'] != 1
);

if ($this->_action == $this->blackHoleCallback) {
if ($this->_action === $this->blackHoleCallback) {
return $this->blackHole($controller, 'auth');
}

Expand Down Expand Up @@ -362,7 +362,7 @@ protected function _methodsRequired(Controller $controller) {
$property = 'require' . $method;
if (is_array($this->$property) && !empty($this->$property)) {
$require = $this->$property;
if (in_array($this->_action, $require) || $this->$property == array('*')) {
if (in_array($this->_action, $require) || $this->$property === array('*')) {
if (!$this->request->is($method)) {
if (!$this->blackHole($controller, $method)) {
return null;
Expand All @@ -384,7 +384,7 @@ protected function _secureRequired(Controller $controller) {
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
$requireSecure = $this->requireSecure;

if (in_array($this->_action, $requireSecure) || $this->requireSecure == array('*')) {
if (in_array($this->_action, $requireSecure) || $this->requireSecure === array('*')) {
if (!$this->request->is('ssl')) {
if (!$this->blackHole($controller, 'secure')) {
return null;
Expand All @@ -405,7 +405,7 @@ protected function _authRequired(Controller $controller) {
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
$requireAuth = $this->requireAuth;

if (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth == array('*')) {
if (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth === array('*')) {
if (!isset($controller->request->data['_Token'])) {
if (!$this->blackHole($controller, 'auth')) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Core/App.php
Expand Up @@ -668,7 +668,7 @@ protected static function _loadClass($name, $plugin, $type, $originalType, $pare
$type = 'Console';
} elseif (isset(self::$types[$originalType]['suffix'])) {
$suffix = self::$types[$originalType]['suffix'];
$name .= ($suffix == $name) ? '' : $suffix;
$name .= ($suffix === $name) ? '' : $suffix;
}
if ($parent && isset(self::$types[$originalType]['extends'])) {
$extends = self::$types[$originalType]['extends'];
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Error/ExceptionRenderer.php
Expand Up @@ -92,7 +92,8 @@ public function __construct(Exception $exception) {
$this->controller = $this->_getController($exception);

if (method_exists($this->controller, 'appError')) {
return $this->controller->appError($exception);
$this->controller->appError($exception);
return;
}
$method = $template = Inflector::variable(str_replace('Exception', '', get_class($exception)));
$code = $exception->getCode();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Log/Engine/FileLog.php
Expand Up @@ -165,7 +165,7 @@ protected function _getFilename($type) {

if (!empty($this->_file)) {
$filename = $this->_file;
} elseif ($type == 'error' || $type == 'warning') {
} elseif ($type === 'error' || $type === 'warning') {
$filename = 'error.log';
} elseif (in_array($type, $debugTypes)) {
$filename = 'debug.log';
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Behavior/ContainableBehavior.php
Expand Up @@ -188,7 +188,7 @@ public function beforeFind(Model $Model, $query) {
foreach (array('hasOne', 'belongsTo') as $type) {
if (!empty($Model->{$type})) {
foreach ($Model->{$type} as $assoc => $data) {
if ($Model->useDbConfig == $Model->{$assoc}->useDbConfig && !empty($data['fields'])) {
if ($Model->useDbConfig === $Model->{$assoc}->useDbConfig && !empty($data['fields'])) {
foreach ((array)$data['fields'] as $field) {
$query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field;
}
Expand All @@ -203,7 +203,7 @@ public function beforeFind(Model $Model, $query) {
$field = $Model->primaryKey;
} elseif (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
list($modelName, $field) = explode('.', $field);
if ($Model->useDbConfig == $Model->{$modelName}->useDbConfig) {
if ($Model->useDbConfig === $Model->{$modelName}->useDbConfig) {
$field = $modelName . '.' . (
($field === '--primaryKey--') ? $Model->$modelName->primaryKey : $field
);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -121,7 +121,7 @@ public function beforeFind(Model $Model, $query) {
$this->_joinTable = $joinTable;
$this->_runtimeModel = $RuntimeModel;

if (is_string($query['fields']) && "COUNT(*) AS {$db->name('count')}" == $query['fields']) {
if (is_string($query['fields']) && $query['fields'] === "COUNT(*) AS {$db->name('count')}") {
$query['fields'] = "COUNT(DISTINCT({$db->name($Model->escapeField())})) {$db->alias}count";
$query['joins'][] = array(
'type' => 'INNER',
Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Model/Behavior/TreeBehavior.php
Expand Up @@ -228,7 +228,8 @@ public function beforeSave(Model $Model, $options = array()) {

if (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
return false;
} elseif ($node[$Model->primaryKey] == $parentNode[$Model->primaryKey]) {
}
if ($node[$Model->primaryKey] === $parentNode[$Model->primaryKey]) {
return false;
}
}
Expand Down Expand Up @@ -951,7 +952,7 @@ protected function _setParent(Model $Model, $parentId = null, $created = false)
}
$parentNode = $parentNode[0];

if (($Model->id == $parentId)) {
if (($Model->id === $parentId)) {
return false;
} elseif (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/BehaviorCollection.php
Expand Up @@ -190,7 +190,7 @@ public function unload($name) {
parent::unload($name);
}
foreach ($this->_methods as $m => $callback) {
if (is_array($callback) && $callback[0] == $name) {
if (is_array($callback) && $callback[0] === $name) {
unset($this->_methods[$m]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/CakeSchema.php
Expand Up @@ -230,7 +230,7 @@ public function read($options = array()) {
}

if (isset($this->plugin)) {
if ($model == $this->plugin . 'AppModel') {
if ($model === $this->plugin . 'AppModel') {
continue;
}
$importModel = $model;
Expand Down Expand Up @@ -608,7 +608,7 @@ protected function _columns(&$Obj) {

$columns = array();
foreach ($fields as $name => $value) {
if ($Obj->primaryKey == $name) {
if ($Obj->primaryKey === $name) {
$value['key'] = 'primary';
}
if (!isset($db->columns[$value['type']])) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Datasource/Database/Mysql.php
Expand Up @@ -398,7 +398,7 @@ public function update(Model $model, $fields = array(), $values = null, $conditi

if (!empty($conditions)) {
$alias = $this->name($model->alias);
if ($model->name == $model->alias) {
if ($model->name === $model->alias) {
$joins = implode(' ', $this->_getJoins($model));
}
}
Expand Down Expand Up @@ -527,7 +527,7 @@ public function alterSchema($compare, $table = null) {
$colList = array();
foreach ($compare as $curTable => $types) {
$indexes = $tableParameters = $colList = array();
if (!$table || $table == $curTable) {
if (!$table || $table === $curTable) {
$out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n";
foreach ($types as $type => $column) {
if (isset($column['indexes'])) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Datasource/Database/Postgres.php
Expand Up @@ -240,7 +240,7 @@ public function describe($model) {
'length' => $length
);
if ($model instanceof Model) {
if ($c->name == $model->primaryKey) {
if ($c->name === $model->primaryKey) {
$fields[$c->name]['key'] = 'primary';
if ($fields[$c->name]['type'] !== 'string') {
$fields[$c->name]['length'] = 11;
Expand Down Expand Up @@ -509,7 +509,7 @@ public function alterSchema($compare, $table = null) {
$colList = array();
foreach ($compare as $curTable => $types) {
$indexes = $colList = array();
if (!$table || $table == $curTable) {
if (!$table || $table === $curTable) {
$out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n";
foreach ($types as $type => $column) {
if (isset($column['indexes'])) {
Expand Down Expand Up @@ -540,7 +540,7 @@ public function alterSchema($compare, $table = null) {

$default = isset($col['default']) ? $col['default'] : null;
$nullable = isset($col['null']) ? $col['null'] : null;
$boolToInt = $original['type'] == 'boolean' && $col['type'] == 'integer';
$boolToInt = $original['type'] === 'boolean' && $col['type'] === 'integer';
unset($col['default'], $col['null']);
if ($field !== $col['name']) {
$newName = $this->name($col['name']);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Sqlserver.php
Expand Up @@ -688,7 +688,7 @@ public function buildColumn($column) {
} else {
$result = str_replace('DEFAULT NULL', 'NULL', $result);
}
} elseif (array_keys($column) == array('type', 'name')) {
} elseif (array_keys($column) === array('type', 'name')) {
$result .= ' NULL';
} elseif (strpos($result, "DEFAULT N'")) {
$result = str_replace("DEFAULT N'", "DEFAULT '", $result);
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -998,7 +998,7 @@ public function create(Model $Model, $fields = null, $values = null) {
for ($i = 0; $i < $count; $i++) {
$valueInsert[] = $this->value($values[$i], $Model->getColumnType($fields[$i]));
$fieldInsert[] = $this->name($fields[$i]);
if ($fields[$i] == $Model->primaryKey) {
if ($fields[$i] === $Model->primaryKey) {
$id = $values[$i];
}
}
Expand Down Expand Up @@ -3196,7 +3196,7 @@ public function createSchema($schema, $tableName = null) {
$out = '';

foreach ($schema->tables as $curTable => $columns) {
if (!$tableName || $tableName == $curTable) {
if (!$tableName || $tableName === $curTable) {
$cols = $indexes = $tableParameters = array();
$primary = null;
$table = $this->fullTableName($curTable);
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Model.php
Expand Up @@ -1488,7 +1488,7 @@ public function isVirtualField($field) {

if (strpos($field, '.') !== false) {
list($model, $field) = explode('.', $field);
if ($model == $this->alias && isset($this->virtualFields[$field])) {
if ($model === $this->alias && isset($this->virtualFields[$field])) {
return true;
}
}
Expand Down Expand Up @@ -1932,7 +1932,7 @@ protected function _saveMulti($joined, $id, $db) {
}

foreach ((array)$data as $row) {
if ((is_string($row) && (strlen($row) == 36 || strlen($row) == 16)) || is_numeric($row)) {
if ((is_string($row) && (strlen($row) === 36 || strlen($row) === 16)) || is_numeric($row)) {
$newJoins[] = $row;
$values = array($id, $row);

Expand Down Expand Up @@ -3480,7 +3480,7 @@ public function setDataSource($dataSource = null) {
if (!empty($oldConfig) && isset($db->config['prefix'])) {
$oldDb = ConnectionManager::getDataSource($oldConfig);

if (!isset($this->tablePrefix) || (!isset($oldDb->config['prefix']) || $this->tablePrefix == $oldDb->config['prefix'])) {
if (!isset($this->tablePrefix) || (!isset($oldDb->config['prefix']) || $this->tablePrefix === $oldDb->config['prefix'])) {
$this->tablePrefix = $db->config['prefix'];
}
} elseif (isset($db->config['prefix'])) {
Expand Down

0 comments on commit d466e00

Please sign in to comment.