Skip to content

Commit

Permalink
Merge branch '3.next'
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 15, 2018
2 parents d4e2693 + f0dad59 commit de7ebdb
Show file tree
Hide file tree
Showing 556 changed files with 27,358 additions and 13,186 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Expand Up @@ -16,4 +16,4 @@
// @license https://opensource.org/licenses/mit-license.php MIT License
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
3.5.15
3.6.0-RC2
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -65,6 +65,7 @@
"TestPluginTwo\\": "tests/test_app/Plugin/TestPluginTwo/src/",
"Company\\TestPluginThree\\": "tests/test_app/Plugin/Company/TestPluginThree/src/",
"Company\\TestPluginThree\\Test\\": "tests/test_app/Plugin/Company/TestPluginThree/tests/",
"ParentPlugin\\": "tests/test_app/Plugin/ParentPlugin/src/",
"PluginJs\\": "tests/test_app/Plugin/PluginJs/src/"
}
},
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Expand Up @@ -26,7 +26,7 @@ parameters:
- '#Call to an undefined method object::__toString\(\)#'
- '#Call to an undefined method object::toArray\(\)#'
- '#Call to an undefined method object::__debugInfo\(\)#'
- '#Method PDO::lastInsertId\(\) invoked with 2 parameters, 0-1 required#'
- '#Cannot call method lastInsertId\(\) on null#'
earlyTerminatingMethodCalls:
Cake\Shell\Shell:
- abort
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Expand Up @@ -11,6 +11,9 @@
<php>
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>
<!-- E_ALL & ~E_USER_DEPRECATED (16383)-->
<!-- E_ALL (32767) -->
<ini name="error_reporting" value="32767"/>
</php>

<testsuites>
Expand Down
12 changes: 10 additions & 2 deletions src/Auth/BaseAuthenticate.php
Expand Up @@ -18,7 +18,7 @@
use Cake\Event\EventListenerInterface;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\ORM\TableRegistry;
use Cake\ORM\Locator\LocatorAwareTrait;

/**
* Base Authentication class with common methods and properties.
Expand All @@ -29,6 +29,7 @@ abstract class BaseAuthenticate implements EventListenerInterface
{

use InstanceConfigTrait;
use LocatorAwareTrait;

/**
* Default config for this object.
Expand Down Expand Up @@ -91,6 +92,13 @@ public function __construct(ComponentRegistry $registry, array $config = [])
{
$this->_registry = $registry;
$this->setConfig($config);

if ($this->getConfig('scope') || $this->getConfig('contain')) {
deprecationWarning(
'The `scope` and `contain` options for Authentication are deprecated. ' .
'Use the `finder` option instead to define additional conditions.'
);
}
}

/**
Expand Down Expand Up @@ -145,7 +153,7 @@ protected function _findUser($username, $password = null)
protected function _query($username)
{
$config = $this->_config;
$table = TableRegistry::get($config['userModel']);
$table = $this->getTableLocator()->get($config['userModel']);

$options = [
'conditions' => [$table->aliasField($config['fields']['username']) => $username]
Expand Down
12 changes: 7 additions & 5 deletions src/Auth/BasicAuthenticate.php
Expand Up @@ -14,9 +14,9 @@
*/
namespace Cake\Auth;

use Cake\Http\Exception\UnauthorizedException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\Network\Exception\UnauthorizedException;

/**
* Basic Authentication adapter for AuthComponent.
Expand Down Expand Up @@ -89,25 +89,27 @@ public function getUser(ServerRequest $request)
* @param \Cake\Http\ServerRequest $request A request object.
* @param \Cake\Http\Response $response A response object.
* @return void
* @throws \Cake\Network\Exception\UnauthorizedException
* @throws \Cake\Http\Exception\UnauthorizedException
*/
public function unauthenticated(ServerRequest $request, Response $response)
{
$Exception = new UnauthorizedException();
$Exception->responseHeader([$this->loginHeaders($request)]);
$Exception->responseHeader($this->loginHeaders($request));
throw $Exception;
}

/**
* Generate the login headers
*
* @param \Cake\Http\ServerRequest $request Request object.
* @return string Headers for logging in.
* @return array Headers for logging in.
*/
public function loginHeaders(ServerRequest $request)
{
$realm = $this->getConfig('realm') ?: $request->getEnv('SERVER_NAME');

return sprintf('WWW-Authenticate: Basic realm="%s"', $realm);
return [
'WWW-Authenticate' => sprintf('Basic realm="%s"', $realm)
];
}
}
6 changes: 4 additions & 2 deletions src/Auth/DigestAuthenticate.php
Expand Up @@ -212,7 +212,7 @@ public static function password($username, $password, $realm)
* Generate the login headers
*
* @param \Cake\Http\ServerRequest $request Request object.
* @return string Headers for logging in.
* @return array Headers for logging in.
*/
public function loginHeaders(ServerRequest $request)
{
Expand Down Expand Up @@ -240,7 +240,9 @@ public function loginHeaders(ServerRequest $request)
}
}

return 'WWW-Authenticate: Digest ' . implode(',', $opts);
return [
'WWW-Authenticate' => 'Digest ' . implode(',', $opts)
];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Auth/Storage/SessionStorage.php
Expand Up @@ -34,14 +34,14 @@ class SessionStorage implements StorageInterface
* Stores user record array if fetched from session or false if session
* does not have user record.
*
* @var \ArrayAccess|array|bool
* @var \ArrayAccess|array|false
*/
protected $_user;

/**
* Session object.
*
* @var \Cake\Network\Session
* @var \Cake\Http\Session
*/
protected $_session;

Expand Down
2 changes: 1 addition & 1 deletion src/Auth/Storage/StorageInterface.php
Expand Up @@ -23,7 +23,7 @@ interface StorageInterface
/**
* Read user record.
*
* @return array|null
* @return \ArrayAccess|array|null
*/
public function read();

Expand Down
26 changes: 15 additions & 11 deletions src/Cache/Cache.php
Expand Up @@ -33,28 +33,28 @@
*
* ```
* Cache::config('shared', [
* 'className' => 'Cake\Cache\Engine\ApcEngine',
* 'className' => 'Cake\Cache\Engine\ApcuEngine',
* 'prefix' => 'my_app_'
* ]);
* ```
*
* This would configure an APC cache engine to the 'shared' alias. You could then read and write
* This would configure an APCu cache engine to the 'shared' alias. You could then read and write
* to that cache alias by using it for the `$config` parameter in the various Cache methods.
*
* In general all Cache operations are supported by all cache engines.
* However, Cache::increment() and Cache::decrement() are not supported by File caching.
*
* There are 5 built-in caching engines:
* There are 6 built-in caching engines:
*
* - `FileEngine` - Uses simple files to store content. Poor performance, but good for
* storing large objects, or things that are not IO sensitive. Well suited to development
* as it is an easy cache to inspect and manually flush.
* - `ApcEngine` - Uses the APC object cache, one of the fastest caching engines.
* - `ApcuEngine` - Uses the APCu object cache, one of the fastest caching engines.
* - `MemcacheEngine` - Uses the PECL::Memcache extension and Memcached for storage.
* Fast reads/writes, and benefits from memcache being distributed.
* - `XcacheEngine` - Uses the Xcache extension, an alternative to APC.
* Fast reads/writes, and benefits from memcache being distributed.
* - `XcacheEngine` - Uses the Xcache extension, an alternative to APCu.
* - `WincacheEngine` - Uses Windows Cache Extension for PHP. Supports wincache 1.1.0 and higher.
* This engine is recommended to people deploying on windows with IIS.
* This engine is recommended to people deploying on windows with IIS.
* - `RedisEngine` - Uses redis and php-redis extension to store cache data.
*
* See Cache engine documentation for expected configuration keys.
Expand All @@ -73,7 +73,8 @@ class Cache
* @var array
*/
protected static $_dsnClassMap = [
'apc' => 'Cake\Cache\Engine\ApcEngine',
'apc' => 'Cake\Cache\Engine\ApcuEngine', // @deprecated Since 3.6. Use apcu instead.
'apcu' => 'Cake\Cache\Engine\ApcuEngine',
'file' => 'Cake\Cache\Engine\FileEngine',
'memcached' => 'Cake\Cache\Engine\MemcachedEngine',
'null' => 'Cake\Cache\Engine\NullEngine',
Expand Down Expand Up @@ -140,6 +141,7 @@ public static function setRegistry(ObjectRegistry $registry)
*/
public static function registry(ObjectRegistry $registry = null)
{
deprecationWarning('Use Cache::getRegistry() and Cache::setRegistry() instead.');
if ($registry) {
static::setRegistry($registry);
}
Expand Down Expand Up @@ -176,10 +178,12 @@ protected static function _buildEngine($name)
return;
}

if ($config['fallback'] === false) {
throw $e;
}

if ($config['fallback'] === $name) {
throw new InvalidArgumentException(
sprintf('"%s" cache configuration cannot fallback to itself.', $name)
);
throw new InvalidArgumentException(sprintf('"%s" cache configuration cannot fallback to itself.', $name), null, $e);
}

$fallbackEngine = clone static::engine($config['fallback']);
Expand Down
21 changes: 20 additions & 1 deletion src/Cache/CacheEngine.php
Expand Up @@ -38,14 +38,17 @@ abstract class CacheEngine
* with either another cache config or another application.
* - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
* cache::gc from ever being called automatically.
* - `warnOnWriteFailures` Some engines, such as ApcuEngine, may raise warnings on
* write failures.
*
* @var array
*/
protected $_defaultConfig = [
'duration' => 3600,
'groups' => [],
'prefix' => 'cake_',
'probability' => 100
'probability' => 100,
'warnOnWriteFailures' => true,
];

/**
Expand Down Expand Up @@ -276,4 +279,20 @@ protected function _key($key)

return $this->_config['prefix'] . $key;
}

/**
* Cache Engines may trigger warnings if they encounter failures during operation,
* if option warnOnWriteFailures is set to true.
*
* @param string $message The warning message.
* @return void
*/
protected function warning($message)
{
if ($this->getConfig('warnOnWriteFailures') !== true) {
return;
}

triggerWarning($message);
}
}

0 comments on commit de7ebdb

Please sign in to comment.