Skip to content

Commit

Permalink
Merge branch '3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 30, 2016
2 parents 2f0bf24 + 7d79b1b commit ca85baa
Show file tree
Hide file tree
Showing 96 changed files with 5,353 additions and 1,274 deletions.
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,7 +1,6 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -164,7 +164,7 @@ component-%:
- (git branch -D $* 2> /dev/null)
git checkout -b $*
git filter-branch --prune-empty --subdirectory-filter src/$(shell php -r "echo ucfirst('$*');") -f $*
git push $* $*:$(CURRENT_BRANCH)
git push -f $* $*:$(CURRENT_BRANCH)
git checkout $(CURRENT_BRANCH) > /dev/null

tag-component-%: component-% guard-VERSION guard-GITHUB_USER
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -22,7 +22,7 @@ recommend using the [app skeleton](https://github.com/cakephp/app) as
a starting point. For existing applications you can run the following:

``` bash
$ composer require cakephp/cakephp:"~3.1"
$ composer require cakephp/cakephp:"~3.2"
```

## Running Tests
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Expand Up @@ -16,4 +16,4 @@
// @license http://www.opensource.org/licenses/mit-license.php MIT License
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
3.1.9
3.2.0-RC1
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -27,7 +27,7 @@ init:

install:
- cd c:\
- appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.5.8-nts-Win32-VC11-x86.zip -FileName php.zip
- appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.5.10-nts-Win32-VC11-x86.zip -FileName php.zip
- 7z x php.zip -oc:\php
- appveyor DownloadFile https://dl.dropboxusercontent.com/s/euip490d9183jkr/SQLSRV32.cab -FileName sqlsrv.cab
- 7z x sqlsrv.cab -oc:\php\ext php*_55_nts.dll
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Expand Up @@ -18,11 +18,10 @@
"source": "https://github.com/cakephp/cakephp"
},
"require": {
"php": ">=5.4.16",
"php": ">=5.5.9",
"ext-intl": "*",
"ext-mbstring": "*",
"nesbot/Carbon": "1.13.*",
"ircmaxell/password-compat": "1.0.*",
"cakephp/chronos": "*",
"aura/intl": "1.1.*",
"psr/log": "1.0"
},
Expand Down
48 changes: 19 additions & 29 deletions src/Cache/Engine/ApcEngine.php
Expand Up @@ -14,7 +14,7 @@
*/
namespace Cake\Cache\Engine;

use APCIterator;
use APCUIterator;
use Cake\Cache\CacheEngine;

/**
Expand Down Expand Up @@ -42,7 +42,7 @@ class ApcEngine extends CacheEngine
*/
public function init(array $config = [])
{
if (!extension_loaded('apc')) {
if (!extension_loaded('apcu')) {
return false;
}

Expand All @@ -66,8 +66,8 @@ public function write($key, $value)
if ($duration) {
$expires = time() + $duration;
}
apc_store($key . '_expires', $expires, $duration);
return apc_store($key, $value, $duration);
apcu_store($key . '_expires', $expires, $duration);
return apcu_store($key, $value, $duration);
}

/**
Expand All @@ -82,11 +82,11 @@ public function read($key)
$key = $this->_key($key);

$time = time();
$cachetime = (int)apc_fetch($key . '_expires');
$cachetime = (int)apcu_fetch($key . '_expires');
if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->_config['duration']) < $cachetime)) {
return false;
}
return apc_fetch($key);
return apcu_fetch($key);
}

/**
Expand All @@ -100,7 +100,7 @@ public function increment($key, $offset = 1)
{
$key = $this->_key($key);

return apc_inc($key, $offset);
return apcu_inc($key, $offset);
}

/**
Expand All @@ -114,7 +114,7 @@ public function decrement($key, $offset = 1)
{
$key = $this->_key($key);

return apc_dec($key, $offset);
return apcu_dec($key, $offset);
}

/**
Expand All @@ -127,7 +127,7 @@ public function delete($key)
{
$key = $this->_key($key);

return apc_delete($key);
return apcu_delete($key);
}

/**
Expand All @@ -142,21 +142,11 @@ public function clear($check)
if ($check) {
return true;
}
if (class_exists('APCIterator', false)) {
$iterator = new APCIterator(
'user',
'/^' . preg_quote($this->_config['prefix'], '/') . '/',
APC_ITER_NONE
);
apc_delete($iterator);
return true;
}
$cache = apc_cache_info('user');
foreach ($cache['cache_list'] as $key) {
if (strpos($key['info'], $this->_config['prefix']) === 0) {
apc_delete($key['info']);
}
}
$iterator = new APCUIterator(
'/^' . preg_quote($this->_config['prefix'], '/') . '/',
APC_ITER_NONE
);
apcu_delete($iterator);
return true;
}

Expand All @@ -178,8 +168,8 @@ public function add($key, $value)
if ($duration) {
$expires = time() + $duration;
}
apc_add($key . '_expires', $expires, $duration);
return apc_add($key, $value, $duration);
apcu_add($key . '_expires', $expires, $duration);
return apcu_add($key, $value, $duration);
}

/**
Expand All @@ -197,11 +187,11 @@ public function groups()
}
}

$groups = apc_fetch($this->_compiledGroupNames);
$groups = apcu_fetch($this->_compiledGroupNames);
if (count($groups) !== count($this->_config['groups'])) {
foreach ($this->_compiledGroupNames as $group) {
if (!isset($groups[$group])) {
apc_store($group, 1);
apcu_store($group, 1);
$groups[$group] = 1;
}
}
Expand All @@ -225,7 +215,7 @@ public function groups()
*/
public function clearGroup($group)
{
apc_inc($this->_config['prefix'] . $group, 1, $success);
apcu_inc($this->_config['prefix'] . $group, 1, $success);
return $success;
}
}
26 changes: 26 additions & 0 deletions src/Console/Exception/StopException.php
@@ -0,0 +1,26 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/3.0/en/development/errors.html#error-exception-configuration
* @since 3.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Exception;

use Cake\Core\Exception\Exception;

/**
* Exception class for halting errors in console tasks
*
* @see Cake\Console\Shell::_stop()
* @see Cake\Console\Shell::error()
*/
class StopException extends Exception
{
}
74 changes: 68 additions & 6 deletions src/Console/Shell.php
Expand Up @@ -15,6 +15,7 @@
namespace Cake\Console;

use Cake\Console\Exception\ConsoleException;
use Cake\Console\Exception\StopException;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Datasource\ModelAwareTrait;
Expand Down Expand Up @@ -646,6 +647,47 @@ public function err($message = null, $newlines = 1)
$this->_io->err($message, $newlines);
}

/**
* Convenience method for out() that wraps message between <info /> tag
*
* @param string|array|null $message A string or an array of strings to output
* @param int $newlines Number of newlines to append
* @param int $level The message's output level, see above.
* @return int|bool Returns the number of bytes returned from writing to stdout.
* @see http://book.cakephp.org/3.0/en/console-and-shells.html#Shell::out
*/
public function info($message = null, $newlines = 1, $level = Shell::NORMAL)
{
return $this->out('<info>' . $message . '</info>', $newlines, $level);
}

/**
* Convenience method for err() that wraps message between <warning /> tag
*
* @param string|array|null $message A string or an array of strings to output
* @param int $newlines Number of newlines to append
* @return int|bool Returns the number of bytes returned from writing to stderr.
* @see http://book.cakephp.org/3.0/en/console-and-shells.html#Shell::err
*/
public function warn($message = null, $newlines = 1)
{
return $this->err('<warning>' . $message . '</warning>', $newlines);
}

/**
* Convenience method for out() that wraps message between <success /> tag
*
* @param string|array|null $message A string or an array of strings to output
* @param int $newlines Number of newlines to append
* @param int $level The message's output level, see above.
* @return int|bool Returns the number of bytes returned from writing to stdout.
* @see http://book.cakephp.org/3.0/en/console-and-shells.html#Shell::out
*/
public function success($message = null, $newlines = 1, $level = Shell::NORMAL)
{
return $this->out('<success>' . $message . '</success>', $newlines, $level);
}

/**
* Returns a single or multiple linefeeds sequences.
*
Expand All @@ -671,25 +713,44 @@ public function hr($newlines = 0, $width = 63)
$this->_io->hr($newlines, $width);
}

/**
* Displays a formatted error message
* and exits the application with status code 1
*
* @param string $message The error message
* @param int $exitCode The exit code for the shell task.
* @throws \Cake\Console\Exception\StopException
* @return void
* @link http://book.cakephp.org/3.0/en/console-and-shells.html#styling-output
*/
public function abort($message, $exitCode = self::CODE_ERROR)
{
$this->_io->err('<error>' . $message . '</error>');
throw new StopException($message, $exitCode);
}

/**
* Displays a formatted error message
* and exits the application with status code 1
*
* @param string $title Title of the error
* @param string|null $message An optional error message
* @param int $exitCode The exit code for the shell task.
* @throws \Cake\Console\Exception\StopException
* @return int Error code
* @link http://book.cakephp.org/3.0/en/console-and-shells.html#styling-output
* @deprecated Since 3.2.0. Use Shell::abort() instead.
*/
public function error($title, $message = null)
public function error($title, $message = null, $exitCode = self::CODE_ERROR)
{
$this->_io->err(sprintf('<error>Error:</error> %s', $title));

if (!empty($message)) {
$this->_io->err($message);
}
$this->_stop(self::CODE_ERROR);

return self::CODE_ERROR;
$this->_stop($exitCode);
return $exitCode;
}

/**
Expand Down Expand Up @@ -786,15 +847,16 @@ public function helper($name, array $settings = [])
}

/**
* Stop execution of the current script. Wraps exit() making
* testing easier.
* Stop execution of the current script.
* Raises a StopException to try and halt the execution.
*
* @param int|string $status see http://php.net/exit for values
* @throws \Cake\Console\Exception\StopException
* @return void
*/
protected function _stop($status = 0)
{
exit($status);
throw new StopException('Halting error reached', $status);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Console/ShellDispatcher.php
Expand Up @@ -15,6 +15,7 @@
namespace Cake\Console;

use Cake\Console\Exception\MissingShellException;
use Cake\Console\Exception\StopException;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Exception\Exception;
Expand Down Expand Up @@ -176,7 +177,11 @@ protected function _bootstrap()
*/
public function dispatch($extra = [])
{
$result = $this->_dispatch($extra);
try {
$result = $this->_dispatch($extra);
} catch (StopException $e) {
return $e->getCode();
}
if ($result === null || $result === true) {
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/CsrfComponent.php
Expand Up @@ -94,7 +94,7 @@ public function startup(Event $event)
if ($request->is('get') && $cookieData === null) {
$this->_setCookie($request, $response);
}
if (!$request->is(['head', 'get', 'options'])) {
if ($request->is(['put', 'post', 'delete', 'patch']) || !empty($request->data)) {
$this->_validateToken($request);
unset($request->data[$this->_config['field']]);
}
Expand Down

0 comments on commit ca85baa

Please sign in to comment.