Skip to content

Commit

Permalink
Merge remote-tracking branch 'cakephp/2.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
psaintjust committed Jul 9, 2016
2 parents 0934d02 + 0a0ded1 commit ae42deb
Show file tree
Hide file tree
Showing 36 changed files with 482 additions and 64 deletions.
2 changes: 2 additions & 0 deletions .stickler.yml
@@ -0,0 +1,2 @@
branches:
ignore: ['2.x', '2.next']
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -30,6 +30,7 @@ before_script:
- sh -c "composer global require 'phpunit/phpunit=3.7.33'"
- sh -c "ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ./vendors/PHPUnit"
- sudo locale-gen de_DE
- sudo locale-gen es_ES
- 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_test3;'; fi"
Expand All @@ -41,6 +42,8 @@ before_script:
- sh -c "if [ '$PHPCS' = '1' ]; then composer global require 'cakephp/cakephp-codesniffer:1.*'; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then ~/.composer/vendor/bin/phpcs --config-set installed_paths ~/.composer/vendor/cakephp/cakephp-codesniffer; fi"
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.0" ]] ; then print "yes" | pecl install apcu-5.1.3; else print "yes" | pecl install apcu-4.0.11; fi
- echo -e "extension = apcu.so\napc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- phpenv rehash
- set +H
- echo "<?php
Expand Down
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -5,8 +5,6 @@
[![Bake Status](https://secure.travis-ci.org/cakephp/cakephp.png?branch=master)](http://travis-ci.org/cakephp/cakephp)
[![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/cakephp/cakephp/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/cakephp/cakephp/)

[![CakePHP](http://cakephp.org/img/cake-logo.png)](http://www.cakephp.org)

CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.

Expand Down
8 changes: 5 additions & 3 deletions app/View/Pages/home.ctp
Expand Up @@ -94,7 +94,7 @@ if (isset($filePresent)):
$errorMsg = $connectionError->getMessage();
if (method_exists($connectionError, 'getAttributes')):
$attributes = $connectionError->getAttributes();
if (isset($errorMsg['message'])):
if (isset($attributes['message'])):
$errorMsg .= '<br />' . $attributes['message'];
endif;
endif;
Expand Down Expand Up @@ -209,8 +209,10 @@ You can also add some CSS styles for your pages at: %s.',
<ul><li><?php echo __d('cake_dev', 'A comprehensive list of all CakePHP plugins created by the community'); ?></li></ul></li>
<li><a href="http://community.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Community Center'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything related to the CakePHP community in one place'); ?></li></ul></li>
<li><a href="https://groups.google.com/group/cake-php"><?php echo __d('cake_dev', 'CakePHP Google Group'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Community mailing list'); ?></li></ul></li>
<li><a href="http://discourse.cakephp.org/">CakePHP Official Forum </a>
<ul><li>CakePHP discussion forum</li></ul></li>
<li><a href="http://discourse.cakephp.org/"><?php echo __d('cake_dev', 'CakePHP Official Forum'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP discussion forum'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __d('cake_dev', 'Live chat about CakePHP'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/"><?php echo __d('cake_dev', 'CakePHP Code'); ?> </a>
Expand Down
37 changes: 37 additions & 0 deletions app/composer.json
@@ -0,0 +1,37 @@
{
"name": "cakephp/app",
"description": "CakePHP Application skeleton",
"type": "library",
"keywords": ["application", "cakephp"],
"homepage": "http://cakephp.org",
"license": "MIT",
"authors": [
{
"name": "CakePHP Community",
"homepage": "https://github.com/cakephp/cakephp/graphs/contributors"
}
],
"support": {
"issues": "https://github.com/cakephp/cakephp/issues",
"forum": "http://stackoverflow.com/tags/cakephp",
"irc": "irc://irc.freenode.org/cakephp",
"source": "https://github.com/cakephp/cakephp"
},
"require": {
"php": ">=5.3.0",
"ext-mcrypt": "*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"cakephp/cakephp": "~2.8"
},
"suggest": {
"cakephp/cakephp-codesniffer": "Easily check code formatting against the CakePHP coding standards."
},
"bin": [
"lib/Cake/Console/cake"
],
"config": {
"vendor-dir": "Vendor/"
}
}
4 changes: 2 additions & 2 deletions build.xml
Expand Up @@ -213,10 +213,10 @@
-->
<target name="distribute" depends="prepare" description="Upload pear packages to pear.cakephp.org">
<echo msg="Uploading tgz file to cakephp.org" />
<exec command="scp ${dist.dir}/${pear.package}.tgz cakephp@cakephp.org:${pirum.dir}" dir="." checkreturn="true" />
<exec command="scp ${dist.dir}/${pear.package}.tgz cakephp@pear.cakephp.org:${pirum.dir}" dir="." checkreturn="true" />

<echo msg="Adding new release to pirum" />
<exec command="ssh cakephp@cakephp.org pirum add ${pirum.dir} ${pirum.dir}/${pear.package}.tgz" checkreturn="true" />
<exec command="ssh cakephp@pear.cakephp.org pirum add ${pirum.dir} ${pirum.dir}/${pear.package}.tgz" checkreturn="true" />
</target>

<target name="codestyle" description="Check codestyle (human readable format)">
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Expand Up @@ -23,9 +23,11 @@
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"cakephp/debug_kit" : "^2.2.0",
"cakephp/cakephp-codesniffer": "^1.0.0"
},
"config": {
"vendor-dir": "vendors/"
},
"bin": [
"lib/Cake/Console/cake"
]
Expand Down
51 changes: 36 additions & 15 deletions lib/Cake/Cache/Engine/ApcEngine.php
Expand Up @@ -31,6 +31,13 @@ class ApcEngine extends CacheEngine {
*/
protected $_compiledGroupNames = array();

/**
* APC or APCu extension
*
* @var string
*/
protected $_apcExtension = 'apc';

/**
* Initialize the Cache Engine
*
Expand All @@ -47,6 +54,10 @@ public function init($settings = array()) {
}
$settings += array('engine' => 'Apc');
parent::init($settings);
if (function_exists('apcu_dec')) {
$this->_apcExtension = 'apcu';
return true;
}
return function_exists('apc_dec');
}

Expand All @@ -63,8 +74,9 @@ public function write($key, $value, $duration) {
if ($duration) {
$expires = time() + $duration;
}
apc_store($key . '_expires', $expires, $duration);
return apc_store($key, $value, $duration);
$func = $this->_apcExtension . '_store';
$func($key . '_expires', $expires, $duration);
return $func($key, $value, $duration);
}

/**
Expand All @@ -75,11 +87,12 @@ public function write($key, $value, $duration) {
*/
public function read($key) {
$time = time();
$cachetime = (int)apc_fetch($key . '_expires');
$func = $this->_apcExtension . '_fetch';
$cachetime = (int)$func($key . '_expires');
if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
return false;
}
return apc_fetch($key);
return $func($key);
}

/**
Expand All @@ -90,7 +103,8 @@ public function read($key) {
* @return New incremented value, false otherwise
*/
public function increment($key, $offset = 1) {
return apc_inc($key, $offset);
$func = $this->_apcExtension . '_inc';
return $func($key, $offset);
}

/**
Expand All @@ -101,7 +115,8 @@ public function increment($key, $offset = 1) {
* @return New decremented value, false otherwise
*/
public function decrement($key, $offset = 1) {
return apc_dec($key, $offset);
$func = $this->_apcExtension . '_dec';
return $func($key, $offset);
}

/**
Expand All @@ -111,7 +126,8 @@ public function decrement($key, $offset = 1) {
* @return bool True if the value was successfully deleted, false if it didn't exist or couldn't be removed
*/
public function delete($key) {
return apc_delete($key);
$func = $this->_apcExtension . '_delete';
return $func($key);
}

/**
Expand All @@ -125,19 +141,20 @@ public function clear($check) {
if ($check) {
return true;
}
$func = $this->_apcExtension . '_delete';
if (class_exists('APCIterator', false)) {
$iterator = new APCIterator(
'user',
'/^' . preg_quote($this->settings['prefix'], '/') . '/',
APC_ITER_NONE
);
apc_delete($iterator);
$func($iterator);
return true;
}
$cache = apc_cache_info('user');
$cache = $this->_apcExtension === 'apc' ? apc_cache_info('user') : apcu_cache_info();
foreach ($cache['cache_list'] as $key) {
if (strpos($key['info'], $this->settings['prefix']) === 0) {
apc_delete($key['info']);
$func($key['info']);
}
}
return true;
Expand All @@ -157,11 +174,13 @@ public function groups() {
}
}

$groups = apc_fetch($this->_compiledGroupNames);
$fetchFunc = $this->_apcExtension . '_fetch';
$storeFunc = $this->_apcExtension . '_store';
$groups = $fetchFunc($this->_compiledGroupNames);
if (count($groups) !== count($this->settings['groups'])) {
foreach ($this->_compiledGroupNames as $group) {
if (!isset($groups[$group])) {
apc_store($group, 1);
$storeFunc($group, 1);
$groups[$group] = 1;
}
}
Expand All @@ -184,7 +203,8 @@ public function groups() {
* @return bool success
*/
public function clearGroup($group) {
apc_inc($this->settings['prefix'] . $group, 1, $success);
$func = $this->_apcExtension . '_inc';
$func($this->settings['prefix'] . $group, 1, $success);
return $success;
}

Expand All @@ -203,7 +223,8 @@ public function add($key, $value, $duration) {
if ($duration) {
$expires = time() + $duration;
}
apc_add($key . '_expires', $expires, $duration);
return apc_add($key, $value, $duration);
$func = $this->_apcExtension . '_add';
$func($key . '_expires', $expires, $duration);
return $func($key, $value, $duration);
}
}
2 changes: 1 addition & 1 deletion lib/Cake/Cache/Engine/FileEngine.php
Expand Up @@ -132,7 +132,7 @@ public function write($key, $data, $duration) {
}

$expires = time() + $duration;
$contents = $expires . $lineBreak . $data . $lineBreak;
$contents = implode(array($expires, $lineBreak, $data, $lineBreak));

if ($this->settings['lock']) {
$this->_File->flock(LOCK_EX);
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Console/Command/Task/ControllerTask.php
Expand Up @@ -182,11 +182,11 @@ protected function _interactive() {
$components = $this->doComponents();

$wannaUseSession = $this->in(
__d('cake_console', "Would you like to use Session flash messages?"), array('y', 'n'), 'y'
__d('cake_console', "Would you like to use the FlashComponent to display flash messages?"), array('y', 'n'), 'y'
);

if (strtolower($wannaUseSession) === 'y') {
array_push($components, 'Session');
array_push($components, 'Session', 'Flash');
}
array_unique($components);
}
Expand Down Expand Up @@ -384,9 +384,9 @@ public function doHelpers() {
* @return array Components the user wants to use.
*/
public function doComponents() {
$components = array('Paginator', 'Flash');
$components = array('Paginator');
return array_merge($components, $this->_doPropertyChoices(
__d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent and FlashComponent?"),
__d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"),
__d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
));
}
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/Console/Templates/skel/View/Pages/home.ctp
Expand Up @@ -214,6 +214,8 @@ You can also add some CSS styles for your pages at: %s.',
<ul><li><?php echo __d('cake_dev', 'Everything related to the CakePHP community in one place'); ?></li></ul></li>
<li><a href="https://groups.google.com/group/cake-php"><?php echo __d('cake_dev', 'CakePHP Google Group'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Community mailing list'); ?></li></ul></li>
<li><a href="http://discourse.cakephp.org/"><?php echo __d('cake_dev', 'CakePHP Official Forum'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP discussion forum'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __d('cake_dev', 'Live chat about CakePHP'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/"><?php echo __d('cake_dev', 'CakePHP Code'); ?> </a>
Expand Down
10 changes: 7 additions & 3 deletions lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -359,7 +359,7 @@ protected function _unauthenticated(Controller $controller) {
return true;
}

if (!$controller->request->is('ajax')) {
if (!$controller->request->is('ajax') && !$controller->request->is('json')) {
$this->flash($this->authError);
$this->Session->write('Auth.redirect', $controller->request->here(false));
$controller->redirect($this->loginAction);
Expand Down Expand Up @@ -611,8 +611,12 @@ public function login($user = null) {
$user = $this->identify($this->request, $this->response);
}
if ($user) {
$this->Session->renew();
$this->Session->write(static::$sessionKey, $user);
if (static::$sessionKey) {
$this->Session->renew();
$this->Session->write(static::$sessionKey, $user);
} else {
static::$_user = $user;
}
$event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user));
$this->_Collection->getController()->getEventManager()->dispatch($event);
}
Expand Down
7 changes: 6 additions & 1 deletion lib/Cake/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -505,7 +505,12 @@ public function accepts($type = null) {
* in the request content type will be returned.
*/
public function requestedWith($type = null) {
if (!$this->request->is('post') && !$this->request->is('put') && !$this->request->is('delete')) {
if (
!$this->request->is('patch') &&
!$this->request->is('post') &&
!$this->request->is('put') &&
!$this->request->is('delete')
) {
return null;
}
if (is_array($type)) {
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/I18n/L10n.php
Expand Up @@ -272,6 +272,7 @@ class L10n {
'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr'),
'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'),
'is' => array('language' => 'Icelandic', 'locale' => 'isl', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'),
'is-is' => array('language' => 'Icelandic (Iceland)', 'locale' => 'is_is', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'),
'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'),
'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'),
'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr'),
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/Model/Datasource/Database/Sqlite.php
Expand Up @@ -185,6 +185,9 @@ public function describe($model) {
'default' => $default,
'length' => $this->length($column['type'])
);
if (in_array($fields[$column['name']]['type'], array('timestamp', 'datetime')) && strtoupper($fields[$column['name']]['default']) === 'CURRENT_TIMESTAMP') {
$fields[$column['name']]['default'] = null;
}
if ($column['pk'] == 1) {
$fields[$column['name']]['key'] = $this->index['PRI'];
$fields[$column['name']]['null'] = false;
Expand Down

0 comments on commit ae42deb

Please sign in to comment.