Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.5' into 3.0
Browse files Browse the repository at this point in the history
Conflicts:
	Cake/Cache/Engine/MemcachedEngine.php
	Cake/Console/Command/CommandListShell.php
	Cake/Error/ExceptionRenderer.php
	Cake/Model/Model.php
	Cake/Network/Email/Email.php
	Cake/Network/Request.php
	Cake/Test/Fixture/DatatypeFixture.php
	Cake/Test/TestApp/View/Pages/home.ctp
	Cake/Test/TestCase/Console/Command/CommandListShellTest.php
	Cake/Test/TestCase/Controller/Component/AuthComponentTest.php
	Cake/Test/TestCase/Event/EventManagerTest.php
	Cake/Test/TestCase/Model/ModelIntegrationTest.php
	Cake/Test/TestCase/Routing/RouterTest.php
	Cake/Test/TestCase/Utility/DebuggerTest.php
	Cake/TestSuite/Coverage/BaseCoverageReport.php
	Cake/Utility/File.php
	Cake/Utility/Validation.php
	Cake/View/Helper/FormHelper.php
	Cake/View/Helper/PaginatorHelper.php
	README.md
	app/Config/acl.php
	app/Config/core.php
	app/Config/routes.php
	app/Console/cake.php
	app/View/Layouts/default.ctp
	app/View/Pages/home.ctp
	lib/Cake/Console/Command/ConsoleShell.php
	lib/Cake/Console/Templates/skel/Config/acl.ini.php
	lib/Cake/Console/Templates/skel/Config/acl.php
	lib/Cake/Console/Templates/skel/webroot/test.php
	lib/Cake/Log/Engine/BaseLog.php
	lib/Cake/Model/Datasource/Database/Mysql.php
	lib/Cake/Model/Datasource/Database/Postgres.php
	lib/Cake/Model/Datasource/Database/Sqlite.php
	lib/Cake/Model/Datasource/Database/Sqlserver.php
	lib/Cake/Model/Datasource/DboSource.php
	lib/Cake/Network/Http/HttpSocket.php
	lib/Cake/Routing/Router.php
	lib/Cake/Test/Case/Cache/CacheTest.php
	lib/Cake/Test/Case/Model/CakeSchemaTest.php
	lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
	lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php
	lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php
	lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
	lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php
	lib/Cake/Test/Case/Utility/StringTest.php
  • Loading branch information
markstory committed Oct 16, 2013
2 parents 8c003c6 + 42228c6 commit 8393dac
Show file tree
Hide file tree
Showing 78 changed files with 2,260 additions and 424 deletions.
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
@@ -1,35 +1,35 @@
# How to contribute

CakePHP loves to welcome your contributions. There are several ways to help out:
* Create a ticket in Lighthouse, if you have found a bug
* Write testcases for open bug tickets
* Write patches for open bug/feature tickets, preferably with testcases included
* Create an [issue](https://github.com/cakephp/cakephp/issues) on GitHub, if you have found a bug
* Write testcases for open bug issues
* Write patches for open bug/feature issues, preferably with testcases included
* Contribute to the [documentation](https://github.com/cakephp/docs)

There are a few guidelines that we need contributors to follow so that we have a
chance of keeping on top of things.

## Getting Started

* Make sure you have a [GitHub account](https://github.com/signup/free)
* Submit a ticket for your issue, assuming one does not already exist.
* Make sure you have a [GitHub account](https://github.com/signup/free).
* Submit an [issue](https://github.com/cakephp/cakephp/issues), assuming one does not already exist.
* Clearly describe the issue including steps to reproduce when it is a bug.
* Make sure you fill in the earliest version that you know has the issue.
* Fork the repository on GitHub.

## Making Changes

* Create a topic branch from where you want to base your work.
* This is usually the master branch
* This is usually the master branch.
* Only target release branches if you are certain your fix must be on that
branch
branch.
* To quickly create a topic branch based on master; `git branch
master/my_contribution master` then checkout the new branch with `git
checkout master/my_contribution`. Better avoid working directly on the
`master` branch, to avoid conflicts if you pull in updates from origin.
* Make commits of logical units.
* Check for unnecessary whitespace with `git diff --check` before committing.
* Use descriptive commit messages and reference the #ticket number
* Use descriptive commit messages and reference the #issue number.
* Core testcases should continue to pass. You can run tests locally or enable
[travis-ci](https://travis-ci.org/) for your fork, so all tests and codesniffs
will be executed.
Expand All @@ -55,7 +55,7 @@ CakePHP tests requires [PHPUnit](http://www.phpunit.de/manual/current/en/install

./lib/Cake/Console/cake test core AllTests --stderr

To run the sniffs for CakePHP coding standards
To run the sniffs for CakePHP coding standards:

phpcs -p --extensions=php --standard=CakePHP ./lib/Cake

Expand All @@ -67,7 +67,7 @@ for the sniff and phpcs.
# Additional Resources

* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
* [Bug tracker](https://cakephp.lighthouseapp.com/projects/42648-cakephp)
* [Existing issues](https://github.com/cakephp/cakephp/issues)
* [General GitHub documentation](https://help.github.com/)
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
* #cakephp IRC channel on freenode.org
34 changes: 34 additions & 0 deletions Cake/Cache/Cache.php
Expand Up @@ -453,4 +453,38 @@ public static function enabled() {
return static::$_enabled;
}

/**
* Provides the ability to easily do read-through caching.
*
* When called if the $key is not set in $config, the $callable function
* will be invoked. The results will then be stored into the cache config
* at key.
*
* Examples:
*
* Using a Closure to provide data, assume $this is a Model:
*
* {{{
* $model = $this;
* $results = Cache::remember('all_articles', function() use ($model) {
* return $model->find('all');
* });
* }}}
*
* @param string $key The cache key to read/store data at.
* @param callable $callable The callable that provides data in the case when
* the cache key is empty. Can be any callable type supported by your PHP.
* @param string $config The cache configuration to use for this operation.
* Defaults to default.
*/
public static function remember($key, $callable, $config = 'default') {
$existing = self::read($key, $config);
if ($existing !== false) {
return $existing;
}
$results = call_user_func($callable);
self::write($key, $results, $config);
return $results;
}

}
33 changes: 31 additions & 2 deletions Cake/Cache/Engine/MemcachedEngine.php
Expand Up @@ -46,11 +46,27 @@ class MemcachedEngine extends CacheEngine {
* - compress = boolean, default => false
* - persistent = string The name of the persistent connection. All configurations using
* the same persistent value will share a single underlying connection.
* - serialize = string, default => php. The serializer engine used to serialize data.
* Available engines are php, igbinary and json. Beside php, the memcached extension
* must be compiled with the appropriate serializer support.
*
* @var array
*/
public $settings = array();

/**
* List of available serializer engines
*
* Memcached must be compiled with json and igbinary support to use these engines
*
* @var array
*/
protected $_serializers = array(
'igbinary' => Memcached::SERIALIZER_IGBINARY,
'json' => Memcached::SERIALIZER_JSON,
'php' => Memcached::SERIALIZER_PHP
);

/**
* Initialize the Cache Engine
*
Expand All @@ -75,6 +91,7 @@ public function init($settings = array()) {
'persistent' => false,
'login' => null,
'password' => null,
'serialize' => 'php'
);
parent::init($settings);

Expand Down Expand Up @@ -117,14 +134,26 @@ public function init($settings = array()) {
/**
* Settings the memcached instance
*
* @throws CacheException when the Memcached extension is not built with the desired serializer engine
*/
protected function _setOptions() {
$this->_Memcached->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);

if (\Memcached::HAVE_IGBINARY) {
$this->_Memcached->setOption(\Memcached::OPT_SERIALIZER, \Memcached::SERIALIZER_IGBINARY);
$serializer = strtolower($this->settings['serialize']);
if (!isset($this->_serializers[$serializer])) {
throw new Error\Exception(
__d('cake_dev', '%s is not a valid serializer engine for Memcached', $serializer)
);
}

if ($serializer !== 'php' && !constant('Memcached::HAVE_' . strtoupper($serializer))) {
throw new Error\Exception(
__d('cake_dev', 'Memcached extension is not compiled with %s support', $serializer)
);
}

$this->_Memcached->setOption(Memcached::OPT_SERIALIZER, $this->_serializers[$serializer]);

// Check for Amazon ElastiCache instance
if (defined('Memcached::OPT_CLIENT_MODE') && defined('Memcached::DYNAMIC_CLIENT_MODE')) {
$this->_Memcached->setOption(\Memcached::OPT_CLIENT_MODE, \Memcached::DYNAMIC_CLIENT_MODE);
Expand Down
2 changes: 0 additions & 2 deletions Cake/Cache/Engine/RedisEngine.php
Expand Up @@ -207,8 +207,6 @@ public function clearGroup($group) {

/**
* Disconnects from the redis server
*
* @return void
*/
public function __destruct() {
if (!$this->settings['persistent']) {
Expand Down
2 changes: 1 addition & 1 deletion Cake/Console/Command/AclShell.php
Expand Up @@ -79,7 +79,7 @@ public function startup() {
!is_subclass_of($className, 'Cake\Controller\Component\Acl\DbAcl')
) {
$out = "--------------------------------------------------\n";
$out .= __d('cake_console', 'Error: Your current Cake configuration is set to an ACL implementation other than DB.') . "\n";
$out .= __d('cake_console', 'Error: Your current CakePHP configuration is set to an ACL implementation other than DB.') . "\n";
$out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
$out .= "--------------------------------------------------\n";
$out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
Expand Down
51 changes: 8 additions & 43 deletions Cake/Console/Command/CommandListShell.php
Expand Up @@ -26,6 +26,13 @@
*/
class CommandListShell extends Shell {

/**
* Contains tasks to load and instantiate
*
* @var array
*/
public $tasks = array('Command');

/**
* startup
*
Expand Down Expand Up @@ -57,7 +64,7 @@ public function main() {
$this->out(__d('cake_console', "<info>Available Shells:</info>"), 2);
}

$shellList = $this->_getShellList();
$shellList = $this->Command->getShellList();
if (empty($shellList)) {
return;
}
Expand All @@ -69,48 +76,6 @@ public function main() {
}
}

/**
* Gets the shell command listing.
*
* @return array
*/
protected function _getShellList() {
$skipFiles = array('AppShell');

$plugins = Plugin::loaded();
$shellList = array_fill_keys($plugins, null) + array('CORE' => null, 'app' => null);

$corePath = App::core('Console/Command');
$shells = App::objects('file', $corePath[0]);
$shells = array_diff($shells, $skipFiles);
$this->_appendShells('CORE', $shells, $shellList);

$appShells = App::objects('Console/Command', null, false);
$appShells = array_diff($appShells, $shells, $skipFiles);
$this->_appendShells('app', $appShells, $shellList);

foreach ($plugins as $plugin) {
$pluginShells = App::objects($plugin . '.Console/Command');
$this->_appendShells($plugin, $pluginShells, $shellList);
}

return array_filter($shellList);
}

/**
* Scan the provided paths for shells, and append them into $shellList
*
* @param string $type
* @param array $shells
* @param array $shellList
* @return void
*/
protected function _appendShells($type, $shells, &$shellList) {
foreach ($shells as $shell) {
$shellList[$type][] = Inflector::underscore(str_replace('Shell', '', $shell));
}
}

/**
* Output text.
*
Expand Down
2 changes: 1 addition & 1 deletion Cake/Console/Command/SchemaShell.php
Expand Up @@ -84,7 +84,7 @@ public function startup() {
$name = $this->params['name'] = $splitName;
}

if ($name) {
if ($name && empty($this->params['file'])) {
$this->params['file'] = Inflector::underscore($name);
}

Expand Down
4 changes: 2 additions & 2 deletions Cake/Controller/Component/AuthComponent.php
Expand Up @@ -188,7 +188,7 @@ class AuthComponent extends Component {
* Normally, if a user is redirected to the $loginAction page, the location they
* were redirected from will be stored in the session so that they can be
* redirected back after a successful login. If this session value is not
* set, redirectUrl() method will return the url specified in $loginRedirect.
* set, redirectUrl() method will return the URL specified in $loginRedirect.
*
* @var mixed
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#AuthComponent::$loginRedirect
Expand Down Expand Up @@ -376,7 +376,7 @@ protected function _unauthenticated(Controller $controller) {
}

/**
* Normalizes $loginAction and checks if current request url is same as login action.
* Normalizes $loginAction and checks if current request URL is same as login action.
*
* @param Controller $controller A reference to the controller object.
* @return boolean True if current action is login action else false.
Expand Down
3 changes: 3 additions & 0 deletions Cake/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -409,6 +409,9 @@ public function requestedWith($type = null) {
}

list($contentType) = explode(';', env('CONTENT_TYPE'));
if ($contentType === '') {
list($contentType) = explode(';', CakeRequest::header('CONTENT_TYPE'));
}
if (!$type) {
return $this->response->mapType($contentType);
}
Expand Down
2 changes: 1 addition & 1 deletion Cake/Controller/Component/SecurityComponent.php
Expand Up @@ -260,7 +260,7 @@ protected function _requireMethod($method, $actions = array()) {
if (isset($actions[0]) && is_array($actions[0])) {
$actions = $actions[0];
}
$this->{'require' . $method} = (empty($actions)) ? array('*'): $actions;
$this->{'require' . $method} = (empty($actions)) ? array('*') : $actions;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Cake/Controller/Controller.php
Expand Up @@ -680,7 +680,7 @@ public function shutdownProcess() {

/**
* Loads and instantiates models required by this controller.
* If the model is non existent, it will throw a missing database table error, as Cake generates
* If the model is non existent, it will throw a missing database table error, as CakePHP generates
* dynamic models for the time being.
*
* @param string $modelClass Name of model class to load.
Expand Down Expand Up @@ -957,7 +957,7 @@ public function beforeRender(Event $event) {
*
* If this method returns false the controller will not continue on to redirect the request.
* The $url, $status and $exit variables have same meaning as for the controller's method. You can also
* return a string which will be interpreted as the url to redirect to or return associative array with
* return a string which will be interpreted as the URL to redirect to or return associative array with
* key 'url' and optionally 'status' and 'exit'.
*
* @param Event $event An Event instance
Expand All @@ -967,7 +967,7 @@ public function beforeRender(Event $event) {
* @param boolean $exit If true, exit() will be called after the redirect
* @return mixed
* false to stop redirection event,
* string controllers a new redirection url or
* string controllers a new redirection URL or
* array with the keys url, status and exit to be used by the redirect method.
* @link http://book.cakephp.org/2.0/en/controllers.html#request-life-cycle-callbacks
*/
Expand Down
2 changes: 1 addition & 1 deletion Cake/Core/Configure.php
Expand Up @@ -92,7 +92,7 @@ public static function write($config, $value = null) {
}

/**
* Used to read information stored in Configure. Its not
* Used to read information stored in Configure. It's not
* possible to store `null` values in Configure.
*
* Usage:
Expand Down
1 change: 0 additions & 1 deletion Cake/Error/ExceptionRenderer.php
Expand Up @@ -80,7 +80,6 @@ class ExceptionRenderer {
* code error depending on the code used to construct the error.
*
* @param \Exception $exception Exception
* @return void
*/
public function __construct(\Exception $exception) {
$this->controller = $this->_getController($exception);
Expand Down
2 changes: 0 additions & 2 deletions Cake/I18n/I18n.php
Expand Up @@ -100,8 +100,6 @@ class I18n {

/**
* Constructor, use I18n::getInstance() to get the i18n translation object.
*
* @return void
*/
public function __construct() {
$this->l10n = new L10n();
Expand Down
1 change: 0 additions & 1 deletion Cake/Log/Engine/BaseLog.php
Expand Up @@ -33,7 +33,6 @@ abstract class BaseLog implements LogInterface {
* __construct method
*
* @param array $config Configuration array
* @return void
*/
public function __construct(array $config = []) {
$this->config($config);
Expand Down
14 changes: 9 additions & 5 deletions Cake/Log/Engine/FileLog.php
Expand Up @@ -185,17 +185,21 @@ protected function _rotateFile($filename) {
}

if ($this->_config['rotate'] === 0) {
return unlink($filepath);
$result = unlink($filepath);
} else {
$result = rename($filepath, $filepath . '.' . time());
}

if ($this->_config['rotate']) {
$files = glob($filepath . '.*');
if (count($files) === $this->_config['rotate']) {
$files = glob($filepath . '.*');
if ($files) {
$filesToDelete = count($files) - $this->_config['rotate'];
while ($filesToDelete > 0) {
unlink(array_shift($files));
$filesToDelete--;
}
}

return rename($filepath, $filepath . '.' . time());
return $result;
}

}

0 comments on commit 8393dac

Please sign in to comment.