Skip to content

Commit

Permalink
Merge branch 'master' into 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 30, 2016
2 parents 9bbb63b + 7091d4d commit ba30f67
Show file tree
Hide file tree
Showing 37 changed files with 319 additions and 86 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Expand Up @@ -29,7 +29,7 @@ matrix:

include:
- php: 7.0
env: COVERALLS=1 DEFAULT=0
env: CODECOVERAGE=1 DEFAULT=0

- php: 7.0
env: PHPCS=1 DEFAULT=0
Expand All @@ -41,7 +41,7 @@ matrix:
env: HHVM=1 DB=mysql db_dsn='mysql://travis@0.0.0.0/cakephp_test'

allow_failures:
- env: COVERALLS=1 DEFAULT=0
- env: CODECOVERAGE=1 DEFAULT=0

- php: hhvm

Expand All @@ -59,9 +59,6 @@ before_script:
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test2;' -U postgres -d cakephp_test; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'CREATE SCHEMA test3;' -U postgres -d cakephp_test; fi"

- sh -c "if [ '$COVERALLS' = '1' ]; then composer require --dev satooshi/php-coveralls:dev-master; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"

- sh -c "if [ '$HHVM' != '1' ]; then echo 'extension = memcached.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
- sh -c "if [ '$HHVM' != '1' ]; then echo 'extension = redis.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
- sh -c "if [ '$HHVM' != '1' ]; then echo 'extension = apc.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi"
Expand All @@ -75,8 +72,9 @@ script:

- sh -c "if [ '$PHPCS' = '1' ]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi"

- sh -c "if [ '$COVERALLS' = '1' ]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover build/logs/clover.xml || true; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then vendor/bin/coveralls -v; fi"
- sh -c "if [ '$CODECOVERAGE' = '1' ]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=clover.xml || true; fi"
- sh -c "if [ '$CODECOVERAGE' = '1' ]; then wget -O codecov.sh https://codecov.io/bash; fi"
- sh -c "if [ '$CODECOVERAGE' = '1' ]; then bash codecov.sh; fi"

notifications:
email: false
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)
[![Build Status](https://img.shields.io/travis/cakephp/cakephp/master.svg?style=flat-square)](https://travis-ci.org/cakephp/cakephp)
[![Coverage Status](https://img.shields.io/coveralls/cakephp/cakephp/master.svg?style=flat-square)](https://coveralls.io/r/cakephp/cakephp?branch=master)
[![Coverage Status](https://img.shields.io/codecov/c/github/cakephp/cakephp.svg?style=flat-square)](https://codecov.io/github/cakephp/cakephp)
[![Code Consistency](https://squizlabs.github.io/PHP_CodeSniffer/analysis/cakephp/cakephp/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/cakephp/cakephp/)
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/cakephp.svg?style=flat-square)](https://packagist.org/packages/cakephp/cakephp)
[![Latest Stable Version](https://img.shields.io/packagist/v/cakephp/cakephp.svg?style=flat-square&label=stable)](https://packagist.org/packages/cakephp/cakephp)
Expand Down
3 changes: 1 addition & 2 deletions src/Cache/composer.json
Expand Up @@ -15,6 +15,5 @@
},
"require": {
"cakephp/core": "~3.0"
},
"minimum-stability": "beta"
}
}
3 changes: 1 addition & 2 deletions src/Collection/composer.json
Expand Up @@ -13,6 +13,5 @@
"Cake\\Collection\\": "."
},
"files": ["functions.php"]
},
"minimum-stability": "beta"
}
}
2 changes: 1 addition & 1 deletion src/Controller/Controller.php
Expand Up @@ -237,7 +237,7 @@ public function __construct(Request $request = null, Response $response = null,
}

if ($this->name === null && isset($request->params['controller'])) {
$this->name = Inflector::camelize($request->params['controller']);
$this->name = $request->params['controller'];
}

if ($this->name === null) {
Expand Down
3 changes: 1 addition & 2 deletions src/Core/composer.json
Expand Up @@ -16,6 +16,5 @@
"Cake\\Core\\": "."
},
"files": ["functions.php"]
},
"minimum-stability": "dev"
}
}
4 changes: 2 additions & 2 deletions src/Database/Query.php
Expand Up @@ -405,8 +405,8 @@ public function modifier($modifiers, $overwrite = false)
* ```
* $query->from(['p' => 'posts']); // Produces FROM posts p
* $query->from('authors'); // Appends authors: FROM posts p, authors
* $query->select(['products'], true); // Resets the list: FROM products
* $query->select(['sub' => $countQuery]); // FROM (SELECT ...) sub
* $query->from(['products'], true); // Resets the list: FROM products
* $query->from(['sub' => $countQuery]); // FROM (SELECT ...) sub
* ```
*
* @param array|ExpressionInterface|string $tables tables to be added to the list
Expand Down
3 changes: 1 addition & 2 deletions src/Database/composer.json
Expand Up @@ -20,6 +20,5 @@
"psr-4": {
"Cake\\Database\\": "."
}
},
"minimum-stability": "beta"
}
}
3 changes: 1 addition & 2 deletions src/Datasource/composer.json
Expand Up @@ -19,6 +19,5 @@
"psr-4": {
"Cake\\Datasource\\": "."
}
},
"minimum-stability": "beta"
}
}
13 changes: 9 additions & 4 deletions src/Error/BaseErrorHandler.php
Expand Up @@ -329,12 +329,17 @@ protected function _getMessage(Exception $exception)
$message .= "\nException Attributes: " . var_export($exception->getAttributes(), true);
}
}
if ((PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg')) {
$request = Router::getRequest();
if ($request) {
$message .= "\nRequest URL: " . $request->here();

$request = Router::getRequest();
if ($request) {
$message .= "\nRequest URL: " . $request->here();

$referer = $request->env('HTTP_REFERER');
if ($referer) {
$message .= "\nReferer URL: " . $referer;
}
}

if (!empty($config['trace'])) {
$message .= "\nStack Trace:\n" . $exception->getTraceAsString() . "\n\n";
}
Expand Down
3 changes: 1 addition & 2 deletions src/Event/composer.json
Expand Up @@ -12,6 +12,5 @@
"psr-4": {
"Cake\\Event\\": "."
}
},
"minimum-stability": "beta"
}
}
3 changes: 1 addition & 2 deletions src/I18n/composer.json
Expand Up @@ -22,6 +22,5 @@
},
"suggest": {
"cakephp/cache": "Require this if you want automatic caching of translators"
},
"minimum-stability": "dev"
}
}
3 changes: 1 addition & 2 deletions src/Log/composer.json
Expand Up @@ -16,6 +16,5 @@
"require": {
"cakephp/core": "~3.0",
"psr/log": "1.0"
},
"minimum-stability": "beta"
}
}
6 changes: 5 additions & 1 deletion src/ORM/Association/BelongsToMany.php
Expand Up @@ -1204,11 +1204,15 @@ protected function _buildQuery($options)
}

$query = $this->_appendJunctionJoin($query, []);

if ($query->autoFields() === null) {
$query->autoFields($query->clause('select') === []);
}

// Ensure that association conditions are applied
// and that the required keys are in the selected columns.
$query
->where($this->junctionConditions())
->autoFields($query->clause('select') === [])
->select($query->aliasFields((array)$assoc->foreignKey(), $name));

$assoc->attachTo($query);
Expand Down
7 changes: 4 additions & 3 deletions src/ORM/Marshaller.php
Expand Up @@ -322,9 +322,7 @@ protected function _belongsToMany(Association $assoc, array $data, $options = []
$query->andWhere(function ($exp) use ($conditions) {
return $exp->or_($conditions);
});
}

if (isset($query)) {
$keyFields = array_keys($primaryKey);

$existing = [];
Expand All @@ -341,8 +339,10 @@ protected function _belongsToMany(Association $assoc, array $data, $options = []
}
}
$key = implode(';', $key);

// Update existing record and child associations
if (isset($existing[$key])) {
$records[$i] = $existing[$key];
$records[$i] = $this->merge($existing[$key], $data[$i], $options);
}
}
}
Expand All @@ -355,6 +355,7 @@ protected function _belongsToMany(Association $assoc, array $data, $options = []
}

foreach ($records as $i => $record) {
// Update junction table data in _joinData.
if (isset($data[$i]['_joinData'])) {
$joinData = $jointMarshaller->one($data[$i]['_joinData'], $nested);
$record->set('_joinData', $joinData);
Expand Down
3 changes: 1 addition & 2 deletions src/ORM/composer.json
Expand Up @@ -24,6 +24,5 @@
},
"suggest": {
"cakephp/i18n": "~3.0"
},
"minimum-stability": "dev"
}
}
12 changes: 6 additions & 6 deletions src/Routing/Filter/ControllerFactoryFilter.php
Expand Up @@ -68,13 +68,13 @@ protected function _getController($request, $response)
$controller = $request->params['controller'];
}
if (!empty($request->params['prefix'])) {
$prefixes = array_map(
'Cake\Utility\Inflector::camelize',
explode('/', $request->params['prefix'])
);
$namespace .= '/' . implode('/', $prefixes);
$namespace .= '/' . $request->params['prefix'];
}
if (strpos($controller, '\\') !== false || strpos($controller, '.') !== false) {
$firstChar = substr($controller, 0, 1);
if (strpos($controller, '\\') !== false ||
strpos($controller, '.') !== false ||
$firstChar === strtolower($firstChar)
) {
return false;
}
$className = false;
Expand Down
7 changes: 6 additions & 1 deletion src/Routing/Route/InflectedRoute.php
Expand Up @@ -50,7 +50,12 @@ public function parse($url)
$params['controller'] = Inflector::camelize($params['controller']);
}
if (!empty($params['plugin'])) {
$params['plugin'] = Inflector::camelize($params['plugin']);
if (strpos($params['plugin'], '/') === false) {
$params['plugin'] = Inflector::camelize($params['plugin']);
} else {
list($vendor, $plugin) = explode('/', $params['plugin'], 2);
$params['plugin'] = Inflector::camelize($vendor) . '/' . Inflector::camelize($plugin);
}
}
return $params;
}
Expand Down
24 changes: 12 additions & 12 deletions src/Shell/PluginShell.php
Expand Up @@ -41,19 +41,19 @@ class PluginShell extends Shell
public function getOptionParser()
{
$parser = parent::getOptionParser();

$parser->description('Plugin Shell perform various tasks related to plugin.')
->addSubcommand('assets', [
'help' => 'Symlink / copy plugin assets to app\'s webroot',
'parser' => $this->Assets->getOptionParser()
])->addSubcommand('load', [
'help' => 'Loads a plugin',
'parser' => $this->Load->getOptionParser(),
])
->addSubcommand('unload', [
'help' => 'Unloads a plugin',
'parser' => $this->Unload->getOptionParser(),
]);
->addSubcommand('assets', [
'help' => 'Symlink / copy plugin assets to app\'s webroot',
'parser' => $this->Assets->getOptionParser()
])->addSubcommand('load', [
'help' => 'Loads a plugin',
'parser' => $this->Load->getOptionParser(),
])
->addSubcommand('unload', [
'help' => 'Unloads a plugin',
'parser' => $this->Unload->getOptionParser(),
]);

return $parser;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Utility/composer.json
Expand Up @@ -13,6 +13,5 @@
"Cake\\Utility\\": "."
},
"files": ["bootstrap.php"]
},
"minimum-stability": "beta"
}
}
3 changes: 1 addition & 2 deletions src/Validation/composer.json
Expand Up @@ -15,6 +15,5 @@
},
"require": {
"cakephp/utility": "~3.0"
},
"minimum-stability": "dev"
}
}
2 changes: 1 addition & 1 deletion src/View/Form/FormContext.php
Expand Up @@ -135,6 +135,6 @@ public function hasError($field)
*/
public function error($field)
{
return array_values(Hash::get($this->_form->errors(), $field, []));
return array_values((array)Hash::get($this->_form->errors(), $field, []));
}
}
8 changes: 6 additions & 2 deletions src/View/Helper/FormHelper.php
Expand Up @@ -1612,8 +1612,12 @@ public function postButton($title, $url, array $options = [])
* Creates an HTML link, but access the URL using the method you specify
* (defaults to POST). Requires javascript to be enabled in browser.
*
* This method creates a `<form>` element. So do not use this method inside an
* existing form. Instead you should add a submit button using FormHelper::submit()
* This method creates a `<form>` element. If you want to use this method inside of an
* existing form, you must use the `block` option so that the new form is being set to
* a view block that can be rendered outside of the main form.
*
* If all you are looking for is a button to submit your form, then you should use
* `FormHelper::button()` or `FormHelper::submit()` instead.
*
* ### Options:
*
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper/HtmlHelper.php
Expand Up @@ -74,7 +74,7 @@ class HtmlHelper extends Helper
'parastart' => '<p{{attrs}}>',
'css' => '<link rel="{{rel}}" href="{{url}}"{{attrs}}/>',
'style' => '<style{{attrs}}>{{content}}</style>',
'charset' => '<meta http-equiv="Content-Type" content="text/html; charset={{charset}}"/>',
'charset' => '<meta charset="{{charset}}"/>',
'ul' => '<ul{{attrs}}>{{content}}</ul>',
'ol' => '<ol{{attrs}}>{{content}}</ol>',
'li' => '<li{{attrs}}>{{content}}</li>',
Expand Down
6 changes: 0 additions & 6 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -359,12 +359,6 @@ public function testConstructSetModelClass()
$this->assertEquals('Posts', $controller->modelClass);
$this->assertInstanceOf('Cake\ORM\Table', $controller->Posts);

$request->params['controller'] = 'posts';
$controller = new \TestApp\Controller\PostsController($request, $response);
$this->assertEquals('Posts', $controller->modelClass);
$this->assertInstanceOf('Cake\ORM\Table', $controller->Posts);
unset($request->params['controller']);

$controller = new \TestApp\Controller\Admin\PostsController($request, $response);
$this->assertEquals('Posts', $controller->modelClass);
$this->assertInstanceOf('Cake\ORM\Table', $controller->Posts);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/QueryTest.php
Expand Up @@ -261,7 +261,7 @@ public function testSelectWithJoinsConditions()
*/
public function testSelectAliasedJoins()
{
$this->skipIf(version_compare(PHP_VERSION, '5.6.0', '<'), 'This test fails on travis for older PHP.');
$this->markTestSkipped('This test fails on travis for older PHP.');
$query = new Query($this->connection);
$result = $query
->select(['title', 'name'])
Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase/Error/ErrorHandlerTest.php
Expand Up @@ -86,6 +86,8 @@ public function setUp()

$request = new Request();
$request->base = '';
$request->env('HTTP_REFERER', '/referer');

Router::setRequestInfo($request);
Configure::write('debug', true);

Expand Down Expand Up @@ -304,7 +306,9 @@ public function testHandleExceptionLogAttributes()
'[Cake\Routing\Exception\MissingControllerException] ' .
'Controller class Derp could not be found.'
),
$this->stringContains('Exception Attributes:')
$this->stringContains('Exception Attributes:'),
$this->stringContains('Request URL:'),
$this->stringContains('Referer URL:')
));

$this->_logger->expects($this->at(1))
Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase/I18n/TimeTest.php
Expand Up @@ -714,6 +714,10 @@ public function testDebugInfo($class)
*/
public function testParseDateTime($class)
{
$time = $class::parseDateTime('01/01/1970 00:00am');
$this->assertNotNull($time);
$this->assertEquals('1970-01-01 00:00', $time->format('Y-m-d H:i'));

$time = $class::parseDateTime('10/13/2013 12:54am');
$this->assertNotNull($time);
$this->assertEquals('2013-10-13 00:54', $time->format('Y-m-d H:i'));
Expand Down

0 comments on commit ba30f67

Please sign in to comment.