Merge branch 'master' into 2.7

This commit is contained in:
mark_story 2015-02-10 23:00:43 -05:00
commit eb85a875c0
13 changed files with 125 additions and 18 deletions

3
.gitattributes vendored
View file

@ -33,3 +33,6 @@
*.ico binary *.ico binary
*.mo binary *.mo binary
*.pdf binary *.pdf binary
*.woff binary
*.ttf binary
*.eot binary

View file

@ -1,7 +1,6 @@
language: php language: php
php: php:
- 5.2
- 5.3 - 5.3
- 5.4 - 5.4
- 5.5 - 5.5
@ -27,8 +26,8 @@ matrix:
before_script: before_script:
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then composer global require 'phpunit/phpunit=3.7.33'; fi" - sh -c "composer global require 'phpunit/phpunit=3.7.33'"
- sh -c "if [ '$TRAVIS_PHP_VERSION' != '5.2' ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit; fi" - sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit"
- sudo locale-gen de_DE - 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_test;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi"

View file

@ -60,7 +60,7 @@ To run the sniffs for CakePHP coding standards:
phpcs -p --extensions=php --standard=CakePHP ./lib/Cake phpcs -p --extensions=php --standard=CakePHP ./lib/Cake
Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer) Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.mdown) contains installation info repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.md) contains installation info
for the sniff and phpcs. for the sniff and phpcs.
# Additional Resources # Additional Resources

View file

@ -123,7 +123,7 @@ class PluginTask extends AppShell {
'Test' . DS . 'Fixture', 'Test' . DS . 'Fixture',
'View' . DS . 'Elements', 'View' . DS . 'Elements',
'View' . DS . 'Helper', 'View' . DS . 'Helper',
'View' . DS . 'Layout', 'View' . DS . 'Layouts',
'webroot' . DS . 'css', 'webroot' . DS . 'css',
'webroot' . DS . 'js', 'webroot' . DS . 'js',
'webroot' . DS . 'img', 'webroot' . DS . 'img',

View file

@ -22,7 +22,6 @@ App::uses('ConsoleInputSubcommand', 'Console');
App::uses('ConsoleOptionParser', 'Console'); App::uses('ConsoleOptionParser', 'Console');
App::uses('ClassRegistry', 'Utility'); App::uses('ClassRegistry', 'Utility');
App::uses('File', 'Utility'); App::uses('File', 'Utility');
App::uses('ClassRegistry', 'Utility');
/** /**
* Base class for command-line utilities for automating programmer chores. * Base class for command-line utilities for automating programmer chores.

View file

@ -95,6 +95,14 @@ App::uses('Router', 'Routing');
*/ */
class ErrorHandler { class ErrorHandler {
/**
* Whether to give up rendering an exception, if the renderer itself is
* throwing exceptions.
*
* @var bool
*/
protected static $_bailExceptionRendering = false;
/** /**
* Set as the default exception handler by the CakePHP bootstrap process. * Set as the default exception handler by the CakePHP bootstrap process.
* *
@ -125,6 +133,8 @@ class ErrorHandler {
$e->getMessage(), $e->getMessage(),
$e->getTraceAsString() $e->getTraceAsString()
); );
self::$_bailExceptionRendering = true;
trigger_error($message, E_USER_ERROR); trigger_error($message, E_USER_ERROR);
} }
} }
@ -234,6 +244,8 @@ class ErrorHandler {
* @param string $file File on which error occurred * @param string $file File on which error occurred
* @param int $line Line that triggered the error * @param int $line Line that triggered the error
* @return bool * @return bool
* @throws FatalErrorException If the Exception renderer threw an exception during rendering, and debug > 0.
* @throws InternalErrorException If the Exception renderer threw an exception during rendering, and debug is 0.
*/ */
public static function handleFatalError($code, $description, $file, $line) { public static function handleFatalError($code, $description, $file, $line) {
$logMessage = 'Fatal Error (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; $logMessage = 'Fatal Error (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
@ -249,10 +261,18 @@ class ErrorHandler {
} }
if (Configure::read('debug')) { if (Configure::read('debug')) {
call_user_func($exceptionHandler, new FatalErrorException($description, 500, $file, $line)); $exception = new FatalErrorException($description, 500, $file, $line);
} else { } else {
call_user_func($exceptionHandler, new InternalErrorException()); $exception = new InternalErrorException();
} }
if (self::$_bailExceptionRendering) {
self::$_bailExceptionRendering = false;
throw $exception;
}
call_user_func($exceptionHandler, $exception);
return false; return false;
} }

View file

@ -1138,7 +1138,7 @@ class CakeResponse {
/** /**
* Checks whether a response has not been modified according to the 'If-None-Match' * Checks whether a response has not been modified according to the 'If-None-Match'
* (Etags) and 'If-Modified-Since' (last modification date) request * (Etags) and 'If-Modified-Since' (last modification date) request
* headers headers. If the response is detected to be not modified, it * headers. If the response is detected to be not modified, it
* is marked as so accordingly so the client can be informed of that. * is marked as so accordingly so the client can be informed of that.
* *
* In order to mark a response as not modified, you need to set at least * In order to mark a response as not modified, you need to set at least

View file

@ -115,7 +115,7 @@ class PluginTaskTest extends CakeTestCase {
'Test' . DS . 'Fixture', 'Test' . DS . 'Fixture',
'View' . DS . 'Elements', 'View' . DS . 'Elements',
'View' . DS . 'Helper', 'View' . DS . 'Helper',
'View' . DS . 'Layout', 'View' . DS . 'Layouts',
'webroot' . DS . 'css', 'webroot' . DS . 'css',
'webroot' . DS . 'js', 'webroot' . DS . 'js',
'webroot' . DS . 'img', 'webroot' . DS . 'img',

View file

@ -254,7 +254,11 @@ class BasicAuthenticateTest extends CakeTestCase {
*/ */
public function testAuthenticateUserFieldsRelatedModelsSuccess() { public function testAuthenticateUserFieldsRelatedModelsSuccess() {
$User = ClassRegistry::init('User'); $User = ClassRegistry::init('User');
$User->bindModel(array('hasOne' => array('Article'))); $User->bindModel(array('hasOne' => array(
'Article' => array(
'order' => 'Article.id ASC'
)
)));
$this->auth->settings['recursive'] = 0; $this->auth->settings['recursive'] = 0;
$this->auth->settings['userFields'] = array('Article.id', 'Article.title'); $this->auth->settings['userFields'] = array('Article.id', 'Article.title');
$request = new CakeRequest('posts/index', false); $request = new CakeRequest('posts/index', false);

View file

@ -20,6 +20,23 @@ App::uses('ErrorHandler', 'Error');
App::uses('Controller', 'Controller'); App::uses('Controller', 'Controller');
App::uses('Router', 'Routing'); App::uses('Router', 'Routing');
/**
* A faulty ExceptionRenderer to test nesting.
*/
class FaultyExceptionRenderer extends ExceptionRenderer {
/**
* Dummy rendering implementation.
*
* @return void
* @throws Exception
*/
public function render() {
throw new Exception('Error from renderer.');
}
}
/** /**
* ErrorHandlerTest class * ErrorHandlerTest class
* *
@ -320,4 +337,48 @@ class ErrorHandlerTest extends CakeTestCase {
$this->assertContains('[FatalErrorException] Something wrong', $log[1], 'message missing.'); $this->assertContains('[FatalErrorException] Something wrong', $log[1], 'message missing.');
} }
/**
* testExceptionRendererNestingDebug method
*
* @return void
*/
public function testExceptionRendererNestingDebug() {
Configure::write('debug', 2);
Configure::write('Exception.renderer', 'FaultyExceptionRenderer');
$result = false;
try {
ob_start();
ob_start();
ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__);
} catch (Exception $e) {
$result = $e instanceof FatalErrorException;
}
restore_error_handler();
$this->assertTrue($result);
}
/**
* testExceptionRendererNestingProduction method
*
* @return void
*/
public function testExceptionRendererNestingProduction() {
Configure::write('debug', 0);
Configure::write('Exception.renderer', 'FaultyExceptionRenderer');
$result = false;
try {
ob_start();
ob_start();
ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__);
} catch (Exception $e) {
$result = $e instanceof InternalErrorException;
}
restore_error_handler();
$this->assertTrue($result);
}
} }

View file

@ -763,6 +763,32 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/**
* Tests correct generation of decimal fields as text inputs
*
* @return void
*/
public function testTextFieldGenerationForDecimalAsText() {
$this->Form->create('ValidateUser');
$result = $this->Form->input('cost_decimal', array(
'type' => 'text'
));
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ValidateUserCostDecimal'),
'Cost Decimal',
'/label',
array('input' => array(
'type' => 'text',
'name' => 'data[ValidateUser][cost_decimal]',
'id' => 'ValidateUserCostDecimal',
'maxlength' => 6,
)),
'/div'
);
$this->assertTags($result, $expected);
}
/** /**
* Tests correct generation of number fields for integer fields * Tests correct generation of number fields for integer fields
* *

View file

@ -20,12 +20,7 @@
<div id="content"> <div id="content">
<h2>PHPUnit is not installed!</h2> <h2>PHPUnit is not installed!</h2>
<p>You must install PHPUnit to use the CakePHP(tm) Test Suite.</p> <p>You must install PHPUnit to use the CakePHP(tm) Test Suite.</p>
<p>PHPUnit can be installed with pear, using the pear installer.</p> <p>PHPUnit can be installed with Composer, or downloaded as a phar archive.</p>
<p>To install with the PEAR installer run the following commands:</p>
<ul>
<li><code>pear config-set auto_discover 1</code></li>
<li><code>pear install pear.phpunit.de/PHPUnit</code></li>
</ul>
<p>Once PHPUnit is installed make sure its located on PHP's <code>include_path</code> by checking your php.ini</p> <p>Once PHPUnit is installed make sure its located on PHP's <code>include_path</code> by checking your php.ini</p>
<p>For full instructions on how to <a href="http://www.phpunit.de/manual/current/en/installation.html" target="_blank">install PHPUnit, see the PHPUnit installation guide</a>.</p> <p>For full instructions on how to <a href="http://www.phpunit.de/manual/current/en/installation.html" target="_blank">install PHPUnit, see the PHPUnit installation guide</a>.</p>
<p><a href="https://github.com/sebastianbergmann/phpunit" target="_blank">Download PHPUnit</a></p> <p><a href="https://github.com/sebastianbergmann/phpunit" target="_blank">Download PHPUnit</a></p>

View file

@ -1292,7 +1292,7 @@ class FormHelper extends AppHelper {
if ($autoLength && if ($autoLength &&
in_array($options['type'], array('text', 'textarea', 'email', 'tel', 'url', 'search')) in_array($options['type'], array('text', 'textarea', 'email', 'tel', 'url', 'search'))
) { ) {
$options['maxlength'] = $fieldDef['length']; $options['maxlength'] = (int)$fieldDef['length'];
} }
return $options; return $options;
} }