Skip to content

Commit

Permalink
Merge branch '2.0-phpunit' of github.com:cakephp/cakephp into 2.0-php…
Browse files Browse the repository at this point in the history
…unit
  • Loading branch information
lorenzo committed Jun 1, 2010
2 parents a737b77 + 02a04ab commit 3586626
Show file tree
Hide file tree
Showing 276 changed files with 1,125 additions and 821 deletions.
9 changes: 7 additions & 2 deletions app/config/core.php
Expand Up @@ -157,6 +157,11 @@

/**
* The name of CakePHP's session cookie.
*
* Note the guidelines for Session names states: "The session name references
* the session id in cookies and URLs. It should contain only alphanumeric
* characters."
* @link http://php.net/session_name
*/
Configure::write('Session.cookie', 'CAKEPHP');

Expand All @@ -183,8 +188,8 @@
* Valid values:
*
* 'high' Session timeout in 'Session.timeout' x 10
* 'medium' Session timeout in 'Session.timeout' x 100
* 'low' Session timeout in 'Session.timeout' x 300
* 'medium' Session timeout in 'Session.timeout' x 5040
* 'low' Session timeout in 'Session.timeout' x 2628000
*
* CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high'.
Expand Down
6 changes: 3 additions & 3 deletions app/webroot/test.php
Expand Up @@ -4,16 +4,16 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing
* @package cake
* @subpackage cake.cake.tests.libs
* @subpackage cake.app.webroot
* @since CakePHP(tm) v 1.2.0.4433
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
Expand Down
2 changes: 1 addition & 1 deletion cake/console/cake.php
Expand Up @@ -432,7 +432,7 @@ public function getInput($prompt, $options = null, $default = null) {
$printOptions = '(' . implode('/', $options) . ')';
}

if ($default == null) {
if ($default === null) {
$this->stdout($prompt . " $printOptions \n" . '> ', false);
} else {
$this->stdout($prompt . " $printOptions \n" . "[$default] > ", false);
Expand Down
6 changes: 3 additions & 3 deletions cake/console/libs/shell.php
Expand Up @@ -551,13 +551,13 @@ protected function _modelName($name) {
}

/**
* Creates the proper singular model key for associations
* Creates the proper underscored model key for associations
*
* @param string $name Controller class name
* @param string $name Model class name
* @return string Singular model key
*/
protected function _modelKey($name) {
return Inflector::underscore(Inflector::singularize($name)) . '_id';
return Inflector::underscore($name) . '_id';
}

/**
Expand Down
8 changes: 5 additions & 3 deletions cake/console/libs/tasks/controller.php
Expand Up @@ -57,7 +57,7 @@ public function initialize() {
*/
public function execute() {
if (empty($this->args)) {
$this->_interactive();
return $this->_interactive();
}

if (isset($this->args[0])) {
Expand Down Expand Up @@ -175,7 +175,7 @@ protected function _interactive() {
);
}
} else {
list($wannaBakeCrud, $wannaBakeCrud) = $this->_askAboutMethods();
list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods();
}

if (strtolower($wannaBakeCrud) == 'y') {
Expand All @@ -186,6 +186,7 @@ protected function _interactive() {
$actions .= $this->bakeActions($controllerName, $admin, strtolower($wannaUseSession) == 'y');
}

$baked = false;
if ($this->interactive === true) {
$this->confirmController($controllerName, $useDynamicScaffold, $helpers, $components);
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
Expand All @@ -202,6 +203,7 @@ protected function _interactive() {
$this->bakeTest($controllerName);
}
}
return $baked;
}

/**
Expand Down Expand Up @@ -282,7 +284,7 @@ public function bakeActions($controllerName, $admin = null, $wannaUseSession = t
$controllerPath = $this->_controllerPath($controllerName);
$pluralName = $this->_pluralName($currentModelName);
$singularName = Inflector::variable($currentModelName);
$singularHumanName = $this->_singularHumanName($currentModelName);
$singularHumanName = $this->_singularHumanName($controllerName);
$pluralHumanName = $this->_pluralName($controllerName);

$this->Template->set(compact('admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName',
Expand Down
2 changes: 1 addition & 1 deletion cake/console/libs/tasks/template.php
Expand Up @@ -54,7 +54,7 @@ public function initialize() {
protected function _findThemes() {
$paths = App::path('shells');
$core = array_pop($paths);
$core = str_replace('libs' . DS, '', $core);
$core = preg_replace('#libs' . DS . '$#', '', $core);
$paths[] = $core;
$Folder =& new Folder($core . 'templates' . DS . 'default');
$contents = $Folder->read();
Expand Down
6 changes: 2 additions & 4 deletions cake/console/libs/tasks/test.php
Expand Up @@ -94,14 +94,12 @@ protected function _interactive($type = null) {
$this->out(sprintf(__('Path: %s'), $this->path));
$this->hr();

$selection = null;
if ($type) {
$type = Inflector::camelize($type);
if (!in_array($type, $this->classTypes)) {
unset($type);
$this->error(sprintf('Incorrect type provided. Please choose one of %s', implode(', ', $this->classTypes)));
}
}
if (!$type) {
} else {
$type = $this->getObjectType();
}
$className = $this->getClassName($type);
Expand Down
3 changes: 2 additions & 1 deletion cake/console/libs/tasks/view.php
Expand Up @@ -195,6 +195,7 @@ public function all() {
$actions = $this->_methodsToBake();
}
$this->bakeActions($actions, $vars);
$actions = null;
}
}
}
Expand Down Expand Up @@ -290,7 +291,7 @@ private function __loadController() {
$primaryKey = $modelObj->primaryKey;
$displayField = $modelObj->displayField;
$singularVar = Inflector::variable($modelClass);
$singularHumanName = $this->_singularHumanName($modelClass);
$singularHumanName = $this->_singularHumanName($this->controllerName);
$schema = $modelObj->schema(true);
$fields = array_keys($schema);
$associations = $this->__associations($modelObj);
Expand Down
4 changes: 2 additions & 2 deletions cake/console/libs/testsuite.php
Expand Up @@ -6,14 +6,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.console.libs
* @since CakePHP(tm) v 1.2.0.4433
Expand Down
4 changes: 2 additions & 2 deletions cake/console/templates/skel/webroot/test.php
Expand Up @@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.libs
* @since CakePHP(tm) v 1.2.0.4433
Expand Down
37 changes: 15 additions & 22 deletions cake/libs/cake_session.php
Expand Up @@ -130,6 +130,14 @@ class CakeSession extends Object {
*/
public $host = null;

/**
* Session timeout multiplier factor
*
* @var ineteger
* @access public
*/
var $timeout = null;

/**
* Constructor.
*
Expand Down Expand Up @@ -455,20 +463,20 @@ function __initSession() {

switch ($this->security) {
case 'high':
$this->cookieLifeTime = 0;
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
case 'medium':
$this->cookieLifeTime = 7 * 86400;
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
case 'low':
default:
$this->cookieLifeTime = 788940000;
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
break;
}

Expand Down Expand Up @@ -591,15 +599,14 @@ protected function _checkValid() {
if ((Configure::read('Session.checkAgent') === false || $this->_userAgent == $this->read('Config.userAgent')) && $this->time <= $this->read('Config.time')) {
$time = $this->read('Config.time');
$this->write('Config.time', $this->sessionTime);

if (Configure::read('Security.level') === 'high') {
$check = $this->read('Config.timeout');
$check = $check - 1;
$check -= 1;
$this->write('Config.timeout', $check);

if (time() > ($time - (Security::inactiveMins() * Configure::read('Session.timeout')) + 2) || $check < 1) {
$this->renew();
$this->write('Config.timeout', 10);
$this->write('Config.timeout', Security::inactiveMins());
}
}
$this->valid = true;
Expand All @@ -611,7 +618,7 @@ protected function _checkValid() {
} else {
$this->write('Config.userAgent', $this->_userAgent);
$this->write('Config.time', $this->sessionTime);
$this->write('Config.timeout', 10);
$this->write('Config.timeout', Security::inactiveMins());
$this->valid = true;
$this->__setError(1, 'Session is valid');
}
Expand Down Expand Up @@ -738,21 +745,7 @@ function __read($id) {
* @access private
*/
function __write($id, $data) {
switch (Configure::read('Security.level')) {
case 'medium':
$factor = 100;
break;
case 'low':
$factor = 300;
break;
case 'high':
default:
$factor = 10;
break;
}

$expires = time() + Configure::read('Session.timeout') * $factor;

$expires = time() + Configure::read('Session.timeout') * Security::inactiveMins();
$model =& ClassRegistry::getObject('Session');
$return = $model->save(compact('id', 'data', 'expires'));
return $return;
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/component.php
Expand Up @@ -22,7 +22,7 @@
*
* @package cake
* @subpackage cake.cake.libs.controller
* @link http://book.cakephp.org/view/62/Components
* @link http://book.cakephp.org/view/993/Components
*/
class Component extends Object {

Expand Down
9 changes: 8 additions & 1 deletion cake/libs/controller/components/request_handler.php
Expand Up @@ -258,8 +258,9 @@ public function startup(&$controller) {
*
* @param object $controller A reference to the controller
* @param mixed $url A string or array containing the redirect location
* @param mixed HTTP Status for redirect
*/
public function beforeRedirect(&$controller, $url) {
public function beforeRedirect(&$controller, $url, $status = null) {
if (!$this->isAjax()) {
return;
}
Expand All @@ -269,6 +270,12 @@ public function beforeRedirect(&$controller, $url) {
if (is_array($url)) {
$url = Router::url($url + array('base' => false));
}
if (!empty($status)) {
$statusCode = $controller->httpCodes($status);
$code = key($statusCode);
$msg = $statusCode[$code];
$controller->header("HTTP/1.1 {$code} {$msg}");
}
echo $this->requestAction($url, array('return'));
$this->_stop();
}
Expand Down
1 change: 0 additions & 1 deletion cake/libs/controller/components/security.php
Expand Up @@ -109,7 +109,6 @@ class SecurityComponent extends Object {

/**
* An associative array of usernames/passwords used for HTTP-authenticated logins.
* If using digest authentication, passwords should be MD5-hashed.
*
* @var array
* @access public
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/scaffold.php
Expand Up @@ -390,7 +390,7 @@ function __scaffoldDelete($params = array()) {

if ($this->ScaffoldModel->delete($id)) {
$message = __(
sprintf('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id),
sprintf('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id)
);
if ($this->_validSession) {
$this->controller->Session->setFlash($message);
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/file.php
Expand Up @@ -186,7 +186,7 @@ public function read($bytes = false, $mode = 'rb', $force = false) {
if ($bytes === false) {
$this->close();
}
return $data;
return trim($data);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions cake/libs/folder.php
Expand Up @@ -66,7 +66,7 @@ class Folder {
* @var array
* @access private
*/
private $__errors = false;
private $__errors = array();

/**
* Holds array of complete directory paths.
Expand Down Expand Up @@ -678,11 +678,14 @@ public function move($options) {
$to = $options;
$options = (array)$options;
}
$options = array_merge(array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array()), $options);
$options = array_merge(
array('to' => $to, 'from' => $this->path, 'mode' => $this->mode, 'skip' => array()),
$options
);

if ($this->copy($options)) {
if ($this->delete($options['from'])) {
return $this->cd($options['to']);
return (bool)$this->cd($options['to']);
}
}
return false;
Expand Down
2 changes: 2 additions & 0 deletions cake/libs/l10n.php
Expand Up @@ -172,6 +172,7 @@ class L10n {
/* Urdu */ 'urd' => 'ur',
/* Venda */ 'ven' => 've',
/* Vietnamese */ 'vie' => 'vi',
/* Welsh */ 'cym' => 'cy',
/* Xhosa */ 'xho' => 'xh',
/* Yiddish */ 'yid' => 'yi',
/* Zulu */ 'zul' => 'zu');
Expand Down Expand Up @@ -315,6 +316,7 @@ class L10n {
'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl'),
've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr'),
'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr'),
'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', 'direction' => 'ltr'),
'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr'),
'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr'),
'zh' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'),
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -726,8 +726,8 @@ function resultSet(&$results) {
$j = 0;

while ($j < $numFields) {
$column = mysql_fetch_field($results,$j);
if (!empty($column->table)) {
$column = mysql_fetch_field($results, $j);
if (!empty($column->table) && strpos($column->name, '__') === false) {
$this->map[$index++] = array($column->table, $column->name);
} else {
$this->map[$index++] = array(0, $column->name);
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/model.php
Expand Up @@ -1263,7 +1263,7 @@ function save($data = null, $validate = true, $fieldList = array()) {
}
}

if (isset($this->data[$this->alias][$this->primaryKey]) && empty($this->data[$this->alias][$this->primaryKey])) {
if (empty($this->data[$this->alias][$this->primaryKey])) {
unset($this->data[$this->alias][$this->primaryKey]);
}
$fields = $values = array();
Expand Down

0 comments on commit 3586626

Please sign in to comment.