Merge branch 'master' into 2.4

Conflicts:
	lib/Cake/Console/ShellDispatcher.php
	lib/Cake/Utility/CakeNumber.php
	lib/Cake/View/Elements/sql_dump.ctp
This commit is contained in:
Jose Lorenzo Rodriguez 2013-08-11 23:31:10 +02:00
commit 9d07fc4330
39 changed files with 208 additions and 115 deletions

View file

@ -111,7 +111,7 @@ before_script:
}" > app/Config/database.php }" > app/Config/database.php
script: script:
- sh -c "if [ '$PHPCS' != '1' ]; then ./lib/Cake/Console/cake test core AllTests --stderr; else phpcs -p --extensions=php --standard=CakePHP ./lib/Cake; fi" - sh -c "if [ '$PHPCS' = '1' ]; then phpcs -p --extensions=php --standard=CakePHP ./lib/Cake; elif [ '$DB' = 'mysql' ]; then ./lib/Cake/Console/cake test core AllTests --stderr; else ./lib/Cake/Console/cake test core AllDbRelated --stderr; fi"
notifications: notifications:
email: false email: false

View file

@ -223,6 +223,8 @@ class FileEngine extends CacheEngine {
if (!$this->_init) { if (!$this->_init) {
return false; return false;
} }
$this->_File = null;
$threshold = $now = false; $threshold = $now = false;
if ($check) { if ($check) {
$now = time(); $now = time();
@ -233,11 +235,17 @@ class FileEngine extends CacheEngine {
$directory = new RecursiveDirectoryIterator($this->settings['path']); $directory = new RecursiveDirectoryIterator($this->settings['path']);
$contents = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST); $contents = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST);
$cleared = array();
foreach ($contents as $path) { foreach ($contents as $path) {
if ($path->isFile()) { if ($path->isFile()) {
continue; continue;
} }
$this->_clearDirectory($path->getRealPath() . DS, $now, $threshold);
$path = $path->getRealPath() . DS;
if (!in_array($path, $cleared)) {
$this->_clearDirectory($path, $now, $threshold);
$cleared[] = $path;
}
} }
return true; return true;
} }
@ -263,7 +271,7 @@ class FileEngine extends CacheEngine {
continue; continue;
} }
$filePath = $path . $entry; $filePath = $path . $entry;
if (is_dir($filePath)) { if (!file_exists($filePath) || is_dir($filePath)) {
continue; continue;
} }
$file = new SplFileObject($path . $entry, 'r'); $file = new SplFileObject($path . $entry, 'r');
@ -281,7 +289,9 @@ class FileEngine extends CacheEngine {
} }
} }
if ($file->isFile()) { if ($file->isFile()) {
unlink($file->getRealPath()); $_path = $file->getRealPath();
$file = null;
unlink($_path);
} }
} }
} }
@ -394,6 +404,7 @@ class FileEngine extends CacheEngine {
* @return boolean success * @return boolean success
*/ */
public function clearGroup($group) { public function clearGroup($group) {
$this->_File = null;
$directoryIterator = new RecursiveDirectoryIterator($this->settings['path']); $directoryIterator = new RecursiveDirectoryIterator($this->settings['path']);
$contents = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::CHILD_FIRST); $contents = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($contents as $object) { foreach ($contents as $object) {
@ -403,7 +414,6 @@ class FileEngine extends CacheEngine {
unlink($object->getPathName()); unlink($object->getPathName());
} }
} }
$this->_File = null;
return true; return true;
} }
} }

View file

@ -66,6 +66,9 @@ class BakeShell extends AppShell {
$this->{$task}->connection = $this->params['connection']; $this->{$task}->connection = $this->params['connection'];
} }
} }
if (isset($this->params['connection'])) {
$this->connection = $this->params['connection'];
}
} }
/** /**

View file

@ -129,8 +129,8 @@ class ServerShell extends AppShell {
$command = sprintf("php -S %s:%d -t %s %s", $command = sprintf("php -S %s:%d -t %s %s",
$this->_host, $this->_host,
$this->_port, $this->_port,
$this->_documentRoot, escapeshellarg($this->_documentRoot),
$this->_documentRoot . '/index.php' escapeshellarg($this->_documentRoot . '/index.php')
); );
$port = ($this->_port == self::DEFAULT_PORT) ? '' : ':' . $this->_port; $port = ($this->_port == self::DEFAULT_PORT) ? '' : ':' . $this->_port;

View file

@ -122,8 +122,10 @@ class ShellDispatcher {
define('ROOT', $this->params['root']); define('ROOT', $this->params['root']);
define('APP_DIR', $this->params['app']); define('APP_DIR', $this->params['app']);
define('APP', $this->params['working'] . DS); define('APP', $this->params['working'] . DS);
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', APP . $this->params['webroot'] . DS); define('WWW_ROOT', APP . $this->params['webroot'] . DS);
if (!is_dir(ROOT . DS . APP_DIR . DS . 'tmp') && !defined('TMP')) { }
if (!defined('TMP') && !is_dir(APP . 'tmp')) {
define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'tmp' . DS); define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'tmp' . DS);
} }
$boot = file_exists(ROOT . DS . APP_DIR . DS . 'Config' . DS . 'bootstrap.php'); $boot = file_exists(ROOT . DS . APP_DIR . DS . 'Config' . DS . 'bootstrap.php');

View file

@ -198,7 +198,7 @@ You can also add some CSS styles for your pages at: APP/webroot/css.');
<ul> <ul>
<li><a href="http://cakefoundation.org/"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a> <li><a href="http://cakefoundation.org/"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li> <ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
<li><a href="http://www.cakephp.org"><?php echo __d('cake_dev', 'CakePHP'); ?> </a> <li><a href="http://www.cakephp.org">CakePHP</a>
<ul><li><?php echo __d('cake_dev', 'The Rapid Development Framework'); ?></li></ul></li> <ul><li><?php echo __d('cake_dev', 'The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a> <li><a href="http://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Your Rapid Development Cookbook'); ?></li></ul></li> <ul><li><?php echo __d('cake_dev', 'Your Rapid Development Cookbook'); ?></li></ul></li>

View file

@ -421,7 +421,7 @@ class CookieComponent extends Component {
'httpOnly' => $this->httpOnly 'httpOnly' => $this->httpOnly
)); ));
if (!is_null($this->_reset)) { if (!empty($this->_reset)) {
$this->_expires = $this->_reset; $this->_expires = $this->_reset;
$this->_reset = null; $this->_reset = null;
} }

View file

@ -85,7 +85,7 @@ class AclNode extends Model {
'joins' => array(array( 'joins' => array(array(
'table' => $table, 'table' => $table,
'alias' => "{$type}0", 'alias' => "{$type}0",
'type' => 'LEFT', 'type' => 'INNER',
'conditions' => array("{$type}0.alias" => $start) 'conditions' => array("{$type}0.alias" => $start)
)), )),
'order' => $db->name("{$type}.lft") . ' DESC' 'order' => $db->name("{$type}.lft") . ' DESC'
@ -97,7 +97,7 @@ class AclNode extends Model {
$queryData['joins'][] = array( $queryData['joins'][] = array(
'table' => $table, 'table' => $table,
'alias' => "{$type}{$i}", 'alias' => "{$type}{$i}",
'type' => 'LEFT', 'type' => 'INNER',
'conditions' => array( 'conditions' => array(
$db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft"), $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft"),
$db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght"), $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght"),

View file

@ -0,0 +1,51 @@
<?php
/**
* AllDbRelatedTest file
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Test.Case
* @since CakePHP(tm) v 2.3
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* AllDbRelatedTest class
*
* This test group will run db related tests.
*
* @package Cake.Test.Case
*/
class AllDbRelatedTest extends PHPUnit_Framework_TestSuite {
/**
* Suite define the tests for this suite
*
* @return void
*/
public static function suite() {
$suite = new PHPUnit_Framework_TestSuite('All Db Related Tests');
$path = CORE_TEST_CASES . DS;
$suite->addTestFile($path . 'AllBehaviorsTest.php');
$suite->addTestFile($path . 'Controller' . DS . 'Component' . DS . 'PaginatorComponentTest.php');
$suite->addTestFile($path . 'AllDatabaseTest.php');
$suite->addTestFile($path . 'Model' . DS . 'ModelTest.php');
$suite->addTestFile($path . 'View' . DS . 'ViewTest.php');
$suite->addTestFile($path . 'View' . DS . 'ScaffoldViewTest.php');
$suite->addTestFile($path . 'View' . DS . 'HelperTest.php');
$suite->addTestFile($path . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php');
$suite->addTestFile($path . 'View' . DS . 'Helper' . DS . 'PaginatorHelperTest.php');
return $suite;
}
}

View file

@ -203,6 +203,24 @@ class CookieComponentTest extends CakeTestCase {
$this->assertEquals('value', $result); $this->assertEquals('value', $result);
} }
/**
* test that two write() calls use the expiry.
*
* @return void
*/
public function testWriteMultipleShareExpiry() {
$this->Cookie->write('key1', 'value1', false);
$this->Cookie->write('key2', 'value2', false);
$name = $this->Cookie->name . '[key1]';
$result = $this->Controller->response->cookie($name);
$this->assertWithinMargin(time() + 10, $result['expire'], 2, 'Expiry time is wrong');
$name = $this->Cookie->name . '[key2]';
$result = $this->Controller->response->cookie($name);
$this->assertWithinMargin(time() + 10, $result['expire'], 2, 'Expiry time is wrong');
}
/** /**
* test write with distant future cookies * test write with distant future cookies
* *

View file

@ -600,7 +600,7 @@ class ObjectTest extends CakeTestCase {
$this->assertEquals(null, $result['plugin']); $this->assertEquals(null, $result['plugin']);
$result = $this->object->requestAction('/request_action/params_pass/sort:desc/limit:5'); $result = $this->object->requestAction('/request_action/params_pass/sort:desc/limit:5');
$expected = array('sort' => 'desc', 'limit' => 5,); $expected = array('sort' => 'desc', 'limit' => 5);
$this->assertEquals($expected, $result['named']); $this->assertEquals($expected, $result['named']);
$result = $this->object->requestAction( $result = $this->object->requestAction(

View file

@ -1547,8 +1547,8 @@ class HttpSocketTest extends CakeTestCase {
'name' => 'jim', 'name' => 'jim',
'items' => array( 'items' => array(
'personal' => array( 'personal' => array(
'book' 'book',
, 'pen' 'pen'
), ),
'ball' 'ball'
) )

View file

@ -408,6 +408,11 @@ TEXT;
false false
TEXT; TEXT;
$this->assertTextEquals($expected, $result); $this->assertTextEquals($expected, $result);
$file = fopen('php://output', 'w');
fclose($file);
$result = Debugger::exportVar($file);
$this->assertTextEquals('unknown', $result);
} }
/** /**

View file

@ -2470,8 +2470,8 @@ class SetTest extends CakeTestCase {
array( array(
'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), 'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'),
'Author' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'), 'Author' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'),
) ),
, array( array(
'Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'), 'Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'),
'Author' => array('id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', 'test' => 'working'), 'Author' => array('id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', 'test' => 'working'),
) )

View file

@ -330,14 +330,12 @@ TEXT;
$this->assertTextEquals($expected, $result, 'Text not wrapped.'); $this->assertTextEquals($expected, $result, 'Text not wrapped.');
$result = String::wrap($text, array('width' => 20, 'wordWrap' => false)); $result = String::wrap($text, array('width' => 20, 'wordWrap' => false));
$expected = <<<TEXT $expected = 'This is the song th' . "\n" .
This is the song th 'at never ends. This' . "\n" .
at never ends. This ' is the song that n' . "\n" .
is the song that n 'ever ends. This is ' . "\n" .
ever ends. This is 'the song that never' . "\n" .
the song that never ' ends.';
ends.
TEXT;
$this->assertTextEquals($expected, $result, 'Text not wrapped.'); $this->assertTextEquals($expected, $result, 'Text not wrapped.');
} }

View file

@ -290,7 +290,7 @@ class PaginatorHelperTest extends CakeTestCase {
Router::setRequestInfo(array( Router::setRequestInfo(array(
array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(),
'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true')), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true')),
array('base' => '/', 'here' => '/accounts/', 'webroot' => '/',) array('base' => '/', 'here' => '/accounts/', 'webroot' => '/')
)); ));
$this->Paginator->options(array('url' => array('param'))); $this->Paginator->options(array('url' => array('param')));

View file

@ -500,6 +500,8 @@ class Debugger {
return strtolower(gettype($var)); return strtolower(gettype($var));
case 'null': case 'null':
return 'null'; return 'null';
case 'unknown':
return 'unknown';
default: default:
return self::_object($var, $depth - 1, $indent + 1); return self::_object($var, $depth - 1, $indent + 1);
} }
@ -591,24 +593,20 @@ class Debugger {
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$ref = new ReflectionObject($var); $ref = new ReflectionObject($var);
$reflectionProperties = $ref->getProperties(ReflectionProperty::IS_PROTECTED); $filters = array(
ReflectionProperty::IS_PROTECTED => 'protected',
ReflectionProperty::IS_PRIVATE => 'private',
);
foreach ($filters as $filter => $visibility) {
$reflectionProperties = $ref->getProperties($filter);
foreach ($reflectionProperties as $reflectionProperty) { foreach ($reflectionProperties as $reflectionProperty) {
$reflectionProperty->setAccessible(true); $reflectionProperty->setAccessible(true);
$property = $reflectionProperty->getValue($var); $property = $reflectionProperty->getValue($var);
$value = self::_export($property, $depth - 1, $indent); $value = self::_export($property, $depth - 1, $indent);
$key = $reflectionProperty->name; $key = $reflectionProperty->name;
$props[] = "[protected] $key => " . $value; $props[] = sprintf('[%s] %s => %s', $visibility, $key, $value);
} }
$reflectionProperties = $ref->getProperties(ReflectionProperty::IS_PRIVATE);
foreach ($reflectionProperties as $reflectionProperty) {
$reflectionProperty->setAccessible(true);
$property = $reflectionProperty->getValue($var);
$value = self::_export($property, $depth - 1, $indent);
$key = $reflectionProperty->name;
$props[] = "[private] $key => " . $value;
} }
} }

View file

@ -65,12 +65,20 @@ if ($noLogs || isset($_forced_from_dbo_)):
} }
$i['query'] .= " , params[ " . rtrim($bindParam, ', ') . " ]"; $i['query'] .= " , params[ " . rtrim($bindParam, ', ') . " ]";
} }
echo "<tr><td>" . ($k + 1) . "</td><td>" . h($i['query']) . "</td><td>{$i['error']}</td><td style = \"text-align: right\">{$i['affected']}</td><td style = \"text-align: right\">{$i['numRows']}</td><td style = \"text-align: right\">{$i['took']}</td></tr>\n"; printf('<tr><td>%d</td><td>%s</td><td>%s</td><td style="text-align: right">%d</td><td style="text-align: right">%d</td><td style="text-align: right">%d</td></tr>%s',
$k + 1,
h($i['query']),
$i['error'],
$i['affected'],
$i['numRows'],
$i['took'],
"\n"
);
endforeach; endforeach;
?> ?>
</tbody></table> </tbody></table>
<?php <?php
endforeach; endforeach;
else: else:
echo '<p>Encountered unexpected $sqlLogs cannot generate SQL log</p>'; printf('<p>%s</p>', __d('cake_dev', 'Encountered unexpected %s. Cannot generate SQL log.', '$sqlLogs'));
endif; endif;