Upgrade cakephp to 2.10.24
This commit is contained in:
parent
c73393579d
commit
c3ce9913cf
|
@ -9,6 +9,10 @@ CakePHP loves to welcome your contributions. There are several ways to help out:
|
|||
There are a few guidelines that we need contributors to follow so that we have a
|
||||
chance of keeping on top of things.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Help us keep CakePHP open and inclusive. Please read and follow our [Code of Conduct](https://github.com/cakephp/code-of-conduct/blob/master/CODE_OF_CONDUCT.md).
|
||||
|
||||
## Getting Started
|
||||
|
||||
* Make sure you have a [GitHub account](https://github.com/signup/free).
|
||||
|
@ -33,14 +37,14 @@ chance of keeping on top of things.
|
|||
* Core test cases 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.
|
||||
* Your work should apply the CakePHP coding standards.
|
||||
* Your work should apply the [CakePHP coding standards](https://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html).
|
||||
|
||||
## Which branch to base the work
|
||||
|
||||
* Bugfix branches will be based on master.
|
||||
* New features that are backwards compatible will be based on next minor release
|
||||
branch.
|
||||
* New features or other non-BC changes will go in the next major release branch.
|
||||
* New features or other non backwards compatible changes will go in the next major release branch.
|
||||
|
||||
## Submitting Changes
|
||||
|
||||
|
@ -50,8 +54,8 @@ chance of keeping on top of things.
|
|||
|
||||
## Test cases and codesniffer
|
||||
|
||||
CakePHP tests requires [PHPUnit](http://www.phpunit.de/manual/current/en/installation.html)
|
||||
3.5 or higher. To run the test cases locally use the following command:
|
||||
CakePHP tests requires [PHPUnit](https://phpunit.de/manual/current/en/installation.html)
|
||||
3.7, version 4 is not compatible. To run the test cases locally use the following command:
|
||||
|
||||
./lib/Cake/Console/cake test core AllTests --stderr
|
||||
|
||||
|
@ -60,12 +64,16 @@ To run the sniffs for CakePHP coding standards:
|
|||
phpcs -p --extensions=php --standard=CakePHP ./lib/Cake
|
||||
|
||||
Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
|
||||
repository to setup the CakePHP standard. The README contains installation info
|
||||
repository to setup the CakePHP standard. The [README](https://github.com/cakephp/cakephp-codesniffer/blob/master/README.md) contains installation info
|
||||
for the sniff and phpcs.
|
||||
|
||||
## Reporting a Security Issue
|
||||
|
||||
If you've found a security related issue in CakePHP, please don't open an issue in GitHub. Instead contact us at security@cakephp.org. For more information on how we handle security issues, [see the CakePHP Security Issue Process](https://book.cakephp.org/2.0/en/contributing/tickets.html#reporting-security-issues).
|
||||
|
||||
# Additional Resources
|
||||
|
||||
* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
|
||||
* [CakePHP coding standards](https://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
|
||||
* [Existing issues](https://github.com/cakephp/cakephp/issues)
|
||||
* [Development Roadmaps](https://github.com/cakephp/cakephp/wiki#roadmaps)
|
||||
* [General GitHub documentation](https://help.github.com/)
|
||||
|
|
|
@ -40,7 +40,7 @@ CREATE TABLE aros (
|
|||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
/* this indexes will improve acl perfomance */
|
||||
/* this indexes will improve acl performance */
|
||||
CREATE INDEX idx_acos_lft_rght ON `acos` (`lft`, `rght`);
|
||||
|
||||
CREATE INDEX idx_acos_alias ON `acos` (`alias`);
|
||||
|
|
|
@ -4,37 +4,57 @@
|
|||
*
|
||||
* Use it to configure database for Sessions
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.Config.Schema
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
/**
|
||||
* Using the Schema command line utility
|
||||
* cake schema run create Sessions
|
||||
*
|
||||
*/
|
||||
class SessionsSchema extends CakeSchema {
|
||||
|
||||
/**
|
||||
* Name property
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = 'Sessions';
|
||||
|
||||
/**
|
||||
* Before callback.
|
||||
*
|
||||
* @param array $event Schema object properties
|
||||
* @return bool Should process continue
|
||||
*/
|
||||
public function before($event = array()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* After callback.
|
||||
*
|
||||
* @param array $event Schema object properties
|
||||
* @return void
|
||||
*/
|
||||
public function after($event = array()) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The cake_sessions table definition
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $cake_sessions = array(
|
||||
'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'),
|
||||
'data' => array('type' => 'text', 'null' => true, 'default' => null),
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
|
@ -10,7 +8,7 @@
|
|||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.Config
|
||||
* @since CakePHP(tm) v 2.0.0
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
|
@ -35,7 +33,6 @@
|
|||
*
|
||||
* from =>
|
||||
* The origin email. See CakeEmail::from() about the valid values
|
||||
*
|
||||
*/
|
||||
class EmailConfig {
|
||||
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
* This file is application-wide controller file. You can put all
|
||||
* application-wide controller-related methods here.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.Controller
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
App::uses('Controller', 'Controller');
|
||||
App::uses('CrudControllerTrait', 'Crud.Lib');
|
||||
|
@ -28,7 +28,7 @@ App::uses('CrudControllerTrait', 'Crud.Lib');
|
|||
* will inherit them.
|
||||
*
|
||||
* @package app.Controller
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
|
||||
* @link https://book.cakephp.org/2.0/en/controllers.html#the-app-controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
use CrudControllerTrait;
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
* This file is application-wide model file. You can put all
|
||||
* application-wide model-related methods here.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.Model
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Model', 'Model');
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Emails.html
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Emails.text
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<?php echo $content; ?>
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Errors
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<h2><?php echo $message; ?></h2>
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Errors
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<h2><?php echo $message; ?></h2>
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
* This file is application-wide helper file. You can put all
|
||||
* application-wide helper-related methods here.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Helper
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Helper', 'View');
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Layouts.Email.html
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $title_for_layout; ?></title>
|
||||
<title><?php echo $this->fetch('title'); ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
|
||||
<p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p>
|
||||
<p>This email was sent using the <a href="https://cakephp.org">CakePHP Framework</a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,21 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Layouts.Email.text
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
|
||||
This email was sent using the CakePHP Framework, http://cakephp.org.
|
||||
This email was sent using the CakePHP Framework, https://cakephp.org.
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Layouts
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Layouts
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
|
||||
|
@ -25,7 +23,7 @@ $cakeVersion = __d('cake_dev', 'CakePHP %s', Configure::version())
|
|||
<?php echo $this->Html->charset(); ?>
|
||||
<title>
|
||||
<?php echo $cakeDescription ?>:
|
||||
<?php echo $title_for_layout; ?>
|
||||
<?php echo $this->fetch('title'); ?>
|
||||
</title>
|
||||
<?php
|
||||
echo $this->Html->meta('icon');
|
||||
|
@ -40,18 +38,18 @@ $cakeVersion = __d('cake_dev', 'CakePHP %s', Configure::version())
|
|||
<body>
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<h1><?php echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
|
||||
<h1><?php echo $this->Html->link($cakeDescription, 'https://cakephp.org'); ?></h1>
|
||||
</div>
|
||||
<div id="content">
|
||||
|
||||
<?php echo $this->Session->flash(); ?>
|
||||
<?php echo $this->Flash->render(); ?>
|
||||
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<?php echo $this->Html->link(
|
||||
$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
|
||||
'http://www.cakephp.org/',
|
||||
'https://cakephp.org/',
|
||||
array('target' => '_blank', 'escape' => false, 'id' => 'cake-powered')
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Layouts
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
|
||||
|
@ -24,7 +22,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
|
|||
<?php echo $this->Html->charset(); ?>
|
||||
<title>
|
||||
<?php echo $cakeDescription ?>:
|
||||
<?php echo $title_for_layout; ?>
|
||||
<?php echo $this->fetch('title'); ?>
|
||||
</title>
|
||||
<?php
|
||||
echo $this->Html->meta('icon');
|
||||
|
@ -39,7 +37,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
|
|||
<body>
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<h1><?php echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
|
||||
<h1><?php echo $this->Html->link($cakeDescription, 'https://cakephp.org'); ?></h1>
|
||||
</div>
|
||||
<div id="content">
|
||||
|
||||
|
@ -50,7 +48,7 @@ $cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework
|
|||
<div id="footer">
|
||||
<?php echo $this->Html->link(
|
||||
$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
|
||||
'http://www.cakephp.org/',
|
||||
'https://cakephp.org/',
|
||||
array('target' => '_blank', 'escape' => false)
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Layouts
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php echo $this->Html->charset(); ?>
|
||||
<title><?php echo $page_title; ?></title>
|
||||
<title><?php echo $pageTitle; ?></title>
|
||||
|
||||
<?php if (Configure::read('debug') == 0): ?>
|
||||
<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
if (Configure::read('debug') == 0):
|
||||
echo sprintf('<meta http-equiv="Refresh" content="%s;url=%s" />', $pause, $url);
|
||||
endif;
|
||||
?>
|
||||
<style><!--
|
||||
P { text-align:center; font:bold 1.1em sans-serif }
|
||||
A { color:#444; text-decoration:none }
|
||||
|
@ -32,6 +32,8 @@ A:HOVER { text-decoration: underline; color:#44E }
|
|||
--></style>
|
||||
</head>
|
||||
<body>
|
||||
<p><a href="<?php echo $url; ?>"><?php echo $message; ?></a></p>
|
||||
<p>
|
||||
<?php echo $this->Html->link($message, $url); ?>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3,7 +3,7 @@ if (!isset($channel)):
|
|||
$channel = array();
|
||||
endif;
|
||||
if (!isset($channel['title'])):
|
||||
$channel['title'] = $title_for_layout;
|
||||
$channel['title'] = $this->fetch('title');
|
||||
endif;
|
||||
|
||||
echo $this->Rss->document(
|
||||
|
@ -11,4 +11,3 @@ echo $this->Rss->document(
|
|||
array(), $channel, $this->fetch('content')
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.View.Pages
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
*/
|
||||
|
@ -15,35 +13,31 @@ App::uses('Debugger', 'Utility');
|
|||
?>
|
||||
<h2><?php echo __d('cake_dev', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
|
||||
<p>
|
||||
<a href="http://cakephp.org/changelogs/<?php echo Configure::version(); ?>"><?php echo __d('cake_dev', 'Read the changelog'); ?> </a>
|
||||
<?php echo $this->Html->link(__d('cake_dev', 'Read the changelog'), 'https://cakephp.org/changelogs/' . Configure::version()); ?>
|
||||
</p>
|
||||
<?php
|
||||
if (Configure::read('debug') > 0):
|
||||
Debugger::checkSecurityKeys();
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
if (file_exists(WWW_ROOT . 'css' . DS . 'cake.generic.css')):
|
||||
?>
|
||||
<p id="url-rewriting-warning" style="background-color:#e32; color:#fff;">
|
||||
<?php if (file_exists(WWW_ROOT . 'css' . DS . 'cake.generic.css')): ?>
|
||||
<p id="url-rewriting-warning" style="background-color:#e32; color:#fff;">
|
||||
<?php echo __d('cake_dev', 'URL rewriting is not properly configured on your server.'); ?>
|
||||
1) <a target="_blank" href="http://book.cakephp.org/2.0/en/installation/url-rewriting.html" style="color:#fff;">Help me configure it</a>
|
||||
2) <a target="_blank" href="http://book.cakephp.org/2.0/en/development/configuration.html#cakephp-core-configuration" style="color:#fff;">I don't / can't use URL rewriting</a>
|
||||
</p>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
1) <a target="_blank" href="https://book.cakephp.org/2.0/en/installation/url-rewriting.html" style="color:#fff;">Help me configure it</a>
|
||||
2) <a target="_blank" href="https://book.cakephp.org/2.0/en/development/configuration.html#cakephp-core-configuration" style="color:#fff;">I don't / can't use URL rewriting</a>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<p>
|
||||
<?php
|
||||
if (version_compare(PHP_VERSION, '5.2.8', '>=')):
|
||||
if (version_compare(PHP_VERSION, '5.2.8', '>=')):
|
||||
echo '<span class="notice success">';
|
||||
echo __d('cake_dev', 'Your version of PHP is 5.2.8 or higher.');
|
||||
echo '</span>';
|
||||
else:
|
||||
else:
|
||||
echo '<span class="notice">';
|
||||
echo __d('cake_dev', 'Your version of PHP is too low. You need PHP 5.2.8 or higher to use CakePHP.');
|
||||
echo '</span>';
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
<p>
|
||||
|
@ -64,11 +58,11 @@ endif;
|
|||
$settings = Cache::settings();
|
||||
if (!empty($settings)):
|
||||
echo '<span class="notice success">';
|
||||
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>'. $settings['engine'] . 'Engine</em>', 'APP/Config/core.php');
|
||||
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>' . $settings['engine'] . 'Engine</em>', CONFIG . 'core.php');
|
||||
echo '</span>';
|
||||
else:
|
||||
echo '<span class="notice">';
|
||||
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php');
|
||||
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', CONFIG . 'core.php');
|
||||
echo '</span>';
|
||||
endif;
|
||||
?>
|
||||
|
@ -76,7 +70,7 @@ endif;
|
|||
<p>
|
||||
<?php
|
||||
$filePresent = null;
|
||||
if (file_exists(APP . 'Config' . DS . 'database.php')):
|
||||
if (file_exists(CONFIG . 'database.php')):
|
||||
echo '<span class="notice success">';
|
||||
echo __d('cake_dev', 'Your database configuration file is present.');
|
||||
$filePresent = true;
|
||||
|
@ -85,7 +79,7 @@ endif;
|
|||
echo '<span class="notice">';
|
||||
echo __d('cake_dev', 'Your database configuration file is NOT present.');
|
||||
echo '<br/>';
|
||||
echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php');
|
||||
echo __d('cake_dev', 'Rename %s to %s', CONFIG . 'database.php.default', CONFIG . 'database.php');
|
||||
echo '</span>';
|
||||
endif;
|
||||
?>
|
||||
|
@ -100,13 +94,13 @@ 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;
|
||||
}
|
||||
?>
|
||||
<p>
|
||||
?>
|
||||
<p>
|
||||
<?php
|
||||
if ($connected && $connected->isConnected()):
|
||||
echo '<span class="notice success">';
|
||||
|
@ -120,17 +114,18 @@ if (isset($filePresent)):
|
|||
echo '</span>';
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<?php
|
||||
App::uses('Validation', 'Utility');
|
||||
if (!Validation::alphaNumeric('cakephp')):
|
||||
endif;
|
||||
|
||||
App::uses('Validation', 'Utility');
|
||||
if (!Validation::alphaNumeric('cakephp')):
|
||||
echo '<p><span class="notice">';
|
||||
echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.');
|
||||
echo '<br/>';
|
||||
echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
|
||||
echo '</span></p>';
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
|
||||
<p>
|
||||
|
@ -143,7 +138,7 @@ if (isset($filePresent)):
|
|||
echo '<span class="notice">';
|
||||
echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.');
|
||||
echo '<br/>';
|
||||
echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit'));
|
||||
echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit/tree/2.2'));
|
||||
echo '</span>';
|
||||
endif;
|
||||
?>
|
||||
|
@ -164,7 +159,7 @@ You can also add some CSS styles for your pages at: %s.',
|
|||
<?php
|
||||
echo $this->Html->link(
|
||||
sprintf('<strong>%s</strong> %s', __d('cake_dev', 'New'), __d('cake_dev', 'CakePHP 2.0 Docs')),
|
||||
'http://book.cakephp.org/2.0/en/',
|
||||
'https://book.cakephp.org/2.0/en/',
|
||||
array('target' => '_blank', 'escape' => false)
|
||||
);
|
||||
?>
|
||||
|
@ -173,7 +168,7 @@ You can also add some CSS styles for your pages at: %s.',
|
|||
<?php
|
||||
echo $this->Html->link(
|
||||
__d('cake_dev', 'The 15 min Blog Tutorial'),
|
||||
'http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html',
|
||||
'https://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html',
|
||||
array('target' => '_blank', 'escape' => false)
|
||||
);
|
||||
?>
|
||||
|
@ -183,7 +178,7 @@ You can also add some CSS styles for your pages at: %s.',
|
|||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
<?php echo $this->Html->link('DebugKit', 'https://github.com/cakephp/debug_kit') ?>:
|
||||
<?php echo $this->Html->link('DebugKit', 'https://github.com/cakephp/debug_kit/tree/2.2') ?>:
|
||||
<?php echo __d('cake_dev', 'provides a debugging toolbar and enhanced debugging tools for CakePHP applications.'); ?>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -202,20 +197,22 @@ You can also add some CSS styles for your pages at: %s.',
|
|||
</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="http://cakephp.org">CakePHP</a>
|
||||
<li><a href="https://cakephp.org">CakePHP</a>
|
||||
<ul><li><?php echo __d('cake_dev', 'The Rapid Development Framework'); ?></li></ul></li>
|
||||
<li><a href="http://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a>
|
||||
<li><a href="https://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a>
|
||||
<ul><li><?php echo __d('cake_dev', 'Your Rapid Development Cookbook'); ?></li></ul></li>
|
||||
<li><a href="http://api.cakephp.org"><?php echo __d('cake_dev', 'CakePHP API'); ?> </a>
|
||||
<li><a href="https://api.cakephp.org"><?php echo __d('cake_dev', 'CakePHP API'); ?> </a>
|
||||
<ul><li><?php echo __d('cake_dev', 'Quick API Reference'); ?></li></ul></li>
|
||||
<li><a href="http://bakery.cakephp.org"><?php echo __d('cake_dev', 'The Bakery'); ?> </a>
|
||||
<li><a href="https://bakery.cakephp.org"><?php echo __d('cake_dev', 'The Bakery'); ?> </a>
|
||||
<ul><li><?php echo __d('cake_dev', 'Everything CakePHP'); ?></li></ul></li>
|
||||
<li><a href="http://plugins.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Plugins'); ?> </a>
|
||||
<li><a href="https://plugins.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Plugins'); ?> </a>
|
||||
<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>
|
||||
<li><a href="https://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>
|
||||
|
@ -224,10 +221,10 @@ You can also add some CSS styles for your pages at: %s.',
|
|||
<ul><li><?php echo __d('cake_dev', 'CakePHP Issues'); ?></li></ul></li>
|
||||
<li><a href="https://github.com/cakephp/cakephp/wiki#roadmaps"><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?> </a>
|
||||
<ul><li><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?></li></ul></li>
|
||||
<li><a href="http://training.cakephp.org"><?php echo __d('cake_dev', 'Training'); ?> </a>
|
||||
<li><a href="https://training.cakephp.org"><?php echo __d('cake_dev', 'Training'); ?> </a>
|
||||
<ul><li><?php echo __d('cake_dev', 'Join a live session and get skilled with the framework'); ?></li></ul></li>
|
||||
<li><a href="http://cakefest.org"><?php echo __d('cake_dev', 'CakeFest'); ?> </a>
|
||||
<li><a href="https://cakefest.org"><?php echo __d('cake_dev', 'CakeFest'); ?> </a>
|
||||
<ul><li><?php echo __d('cake_dev', 'Don\'t miss our annual CakePHP conference'); ?></li></ul></li>
|
||||
<li><a href="http://cakefoundation.org"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
|
||||
<li><a href="https://cakefoundation.org"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
|
||||
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
|
||||
</ul>
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app
|
||||
* @since CakePHP(tm) v 0.10.0.1076
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
require 'webroot' . DIRECTORY_SEPARATOR . 'index.php';
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
@charset "utf-8";
|
||||
/**
|
||||
*
|
||||
* Generic CSS for CakePHP
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.webroot.css
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
* {
|
||||
|
@ -84,7 +83,7 @@ p {
|
|||
line-height:20px;
|
||||
background: #003d4c url('../img/cake.icon.png') no-repeat left;
|
||||
color: #fff;
|
||||
padding: 0px 30px;
|
||||
padding: 0 30px;
|
||||
}
|
||||
#header h1 a {
|
||||
color: #fff;
|
||||
|
@ -174,7 +173,7 @@ td.actions {
|
|||
white-space: nowrap;
|
||||
}
|
||||
table td.actions a {
|
||||
margin: 0px 6px;
|
||||
margin: 0 6px;
|
||||
padding:2px 5px;
|
||||
}
|
||||
|
||||
|
@ -336,7 +335,7 @@ option {
|
|||
input[type=checkbox] {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin: 0px 6px 7px 2px;
|
||||
margin: 0 6px 7px 2px;
|
||||
width: auto;
|
||||
}
|
||||
div.checkbox label {
|
||||
|
@ -365,7 +364,7 @@ form .submit input[type=submit] {
|
|||
background-image: -moz-linear-gradient(top, #76BF6B, #3B8230);
|
||||
border-color: #2d6324;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 0 -1px 0;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
form .submit input[type=submit]:hover {
|
||||
|
@ -527,11 +526,11 @@ input[type=submit],
|
|||
-moz-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
text-shadow: #fff 0px 1px 0px;
|
||||
text-shadow: #fff 0 1px 0;
|
||||
min-width: 0;
|
||||
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2);
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0px 1px 1px rgba(0, 0, 0, 0.2);
|
||||
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
@ -551,7 +550,7 @@ input[type=submit]:active,
|
|||
background-image: -ms-linear-gradient(top, #dfdfdf, #eee);
|
||||
background-image: -o-linear-gradient(top, #dfdfdf, #eee);
|
||||
background-image: linear-gradient(top, #dfdfdf, #eee);
|
||||
text-shadow: #eee 0px 1px 0px;
|
||||
text-shadow: #eee 0 1px 0;
|
||||
-moz-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
|
@ -627,15 +626,15 @@ pre {
|
|||
-moz-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
margin: 0px 4px 10px 2px;
|
||||
margin: 0 4px 10px 2px;
|
||||
font-family: sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
-moz-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3);
|
||||
box-shadow: inset 0px 1px 0 rgba(0, 0, 0, 0.3);
|
||||
-moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3);
|
||||
-webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3);
|
||||
box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.cake-code-dump pre {
|
||||
position: relative;
|
||||
|
@ -647,13 +646,13 @@ pre {
|
|||
.cake-stack-trace pre {
|
||||
color: #000;
|
||||
background-color: #F0F0F0;
|
||||
margin: 0px 0 10px 0;
|
||||
margin: 0 0 10px 0;
|
||||
padding: 1em;
|
||||
overflow: auto;
|
||||
text-shadow: none;
|
||||
}
|
||||
.cake-stack-trace li {
|
||||
padding: 10px 5px 0px;
|
||||
padding: 10px 5px 0;
|
||||
margin: 0 0 4px 0;
|
||||
font-family: monospace;
|
||||
border: 1px solid #bbb;
|
||||
|
@ -709,7 +708,7 @@ pre {
|
|||
}
|
||||
.code-coverage-results div.start {
|
||||
border:1px solid #aaa;
|
||||
border-width:1px 1px 0px 1px;
|
||||
border-width:1px 1px 0 1px;
|
||||
margin-top:30px;
|
||||
padding-top:5px;
|
||||
}
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Index
|
||||
*
|
||||
* The Front Controller for handling every request
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package app.webroot
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -26,14 +24,13 @@ if (!defined('DS')) {
|
|||
}
|
||||
|
||||
/**
|
||||
* These defines should only be edited if you have cake installed in
|
||||
* These defines should only be edited if you have CakePHP installed in
|
||||
* a directory layout other than the way it is distributed.
|
||||
* When using custom settings be sure to use the DS and do not add a trailing DS.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The full path to the directory which holds "app", WITHOUT a trailing DS.
|
||||
*
|
||||
*/
|
||||
if (!defined('ROOT')) {
|
||||
define('ROOT', dirname(dirname(dirname(__FILE__))));
|
||||
|
@ -41,12 +38,18 @@ if (!defined('ROOT')) {
|
|||
|
||||
/**
|
||||
* The actual directory name for the "app".
|
||||
*
|
||||
*/
|
||||
if (!defined('APP_DIR')) {
|
||||
define('APP_DIR', basename(dirname(dirname(__FILE__))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Config Directory
|
||||
*/
|
||||
if (!defined('CONFIG')) {
|
||||
define('CONFIG', ROOT . DS . APP_DIR . DS . 'Config' . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
|
||||
*
|
||||
|
@ -63,10 +66,19 @@ if (!defined('APP_DIR')) {
|
|||
*/
|
||||
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
|
||||
|
||||
/**
|
||||
* This auto-detects CakePHP as a composer installed library.
|
||||
* You may remove this if you are not planning to use composer (not recommended, though).
|
||||
*/
|
||||
$vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib';
|
||||
$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
|
||||
if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) {
|
||||
define('CAKE_CORE_INCLUDE_PATH', $vendorPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Editing below this line should NOT be necessary.
|
||||
* Change at your own risk.
|
||||
*
|
||||
*/
|
||||
if (!defined('WEBROOT_DIR')) {
|
||||
define('WEBROOT_DIR', basename(dirname(__FILE__)));
|
||||
|
@ -75,9 +87,9 @@ if (!defined('WWW_ROOT')) {
|
|||
define('WWW_ROOT', dirname(__FILE__) . DS);
|
||||
}
|
||||
|
||||
// for built-in server
|
||||
if (php_sapi_name() === 'cli-server') {
|
||||
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
|
||||
// For the built-in server
|
||||
if (PHP_SAPI === 'cli-server') {
|
||||
if ($_SERVER['PHP_SELF'] !== '/' . basename(__FILE__) && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
|
||||
return false;
|
||||
}
|
||||
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
||||
|
@ -90,10 +102,8 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
|||
if (!include 'Cake' . DS . 'bootstrap.php') {
|
||||
$failed = true;
|
||||
}
|
||||
} else {
|
||||
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
|
||||
} elseif (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
|
||||
$failed = true;
|
||||
}
|
||||
}
|
||||
if (!empty($failed)) {
|
||||
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
/**
|
||||
* Web Access Frontend for TestSuite
|
||||
*
|
||||
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) Tests <https://book.cakephp.org/2.0/en/development/testing.html>
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://book.cakephp.org/2.0/en/development/testing.html
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://book.cakephp.org/2.0/en/development/testing.html
|
||||
* @package app.webroot
|
||||
* @since CakePHP(tm) v 1.2.0.4433
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
set_time_limit(0);
|
||||
|
@ -27,14 +27,13 @@ if (!defined('DS')) {
|
|||
}
|
||||
|
||||
/**
|
||||
* These defines should only be edited if you have cake installed in
|
||||
* These defines should only be edited if you have CakePHP installed in
|
||||
* a directory layout other than the way it is distributed.
|
||||
* When using custom settings be sure to use the DS and do not add a trailing DS.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The full path to the directory which holds "app", WITHOUT a trailing DS.
|
||||
*
|
||||
*/
|
||||
if (!defined('ROOT')) {
|
||||
define('ROOT', dirname(dirname(dirname(__FILE__))));
|
||||
|
@ -42,12 +41,18 @@ if (!defined('ROOT')) {
|
|||
|
||||
/**
|
||||
* The actual directory name for the "app".
|
||||
*
|
||||
*/
|
||||
if (!defined('APP_DIR')) {
|
||||
define('APP_DIR', basename(dirname(dirname(__FILE__))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Config Directory
|
||||
*/
|
||||
if (!defined('CONFIG')) {
|
||||
define('CONFIG', ROOT . DS . APP_DIR . DS . 'Config' . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
* The absolute path to the "Cake" directory, WITHOUT a trailing DS.
|
||||
*
|
||||
|
@ -61,10 +66,19 @@ if (!defined('APP_DIR')) {
|
|||
*/
|
||||
//define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
|
||||
|
||||
/**
|
||||
* This auto-detects CakePHP as a composer installed library.
|
||||
* You may remove this if you are not planning to use composer (not recommended, though).
|
||||
*/
|
||||
$vendorPath = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib';
|
||||
$dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php';
|
||||
if (!defined('CAKE_CORE_INCLUDE_PATH') && file_exists($vendorPath . DS . $dispatcher)) {
|
||||
define('CAKE_CORE_INCLUDE_PATH', $vendorPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Editing below this line should not be necessary.
|
||||
* Change at your own risk.
|
||||
*
|
||||
*/
|
||||
if (!defined('WEBROOT_DIR')) {
|
||||
define('WEBROOT_DIR', basename(dirname(__FILE__)));
|
||||
|
@ -86,11 +100,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
|||
}
|
||||
}
|
||||
if (!empty($failed)) {
|
||||
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
||||
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/test.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
||||
}
|
||||
|
||||
if (Configure::read('debug') < 1) {
|
||||
throw new NotFoundException(__d('cake_dev', 'Debug setting does not allow access to this url.'));
|
||||
throw new NotFoundException(__d('cake_dev', 'Debug setting does not allow access to this URL.'));
|
||||
}
|
||||
|
||||
require_once CAKE . 'TestSuite' . DS . 'CakeTestSuiteDispatcher.php';
|
||||
|
|
|
@ -9,4 +9,4 @@ build.dir = build
|
|||
dist.dir = dist
|
||||
|
||||
# Server
|
||||
pirum.dir = /home/cakephp/www-live/pear.cakephp.org
|
||||
pirum.dir = /var/lib/dokku/data/storage/pear
|
||||
|
|
|
@ -136,7 +136,6 @@
|
|||
<dependencies>
|
||||
<php minimum_version="5.2.8" />
|
||||
<pear minimum_version="1.9.0" recommended_version="1.9.4" />
|
||||
<package name="PHPUnit" channel="pear.phpunit.de" minimum_version="3.5.0" type="optional" />
|
||||
</dependencies>
|
||||
<dirroles key="bin">script</dirroles>
|
||||
<dirroles key="Cake/Console/Templates/skel">php</dirroles>
|
||||
|
@ -214,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 root@new.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" />
|
||||
<echo msg="Rebuilding pear.cakephp.org container" />
|
||||
<exec command="ssh root@new.cakephp.org dokku ps:rebuild pear" checkreturn="true" />
|
||||
</target>
|
||||
|
||||
<target name="codestyle" description="Check codestyle (human readable format)">
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"description": "The CakePHP framework",
|
||||
"type": "library",
|
||||
"keywords": ["framework"],
|
||||
"homepage": "http://cakephp.org",
|
||||
"homepage": "https://cakephp.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
|
@ -13,19 +13,34 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/cakephp/cakephp/issues",
|
||||
"forum": "http://stackoverflow.com/tags/cakephp",
|
||||
"forum": "https://stackoverflow.com/tags/cakephp",
|
||||
"irc": "irc://irc.freenode.org/cakephp",
|
||||
"source": "https://github.com/cakephp/cakephp"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.8",
|
||||
"ext-mcrypt": "*"
|
||||
"php": ">=5.3.0,<8.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-openssl": "You need to install ext-openssl or ext-mcrypt to use AES-256 encryption",
|
||||
"ext-mcrypt": "You need to install ext-openssl or ext-mcrypt to use AES-256 encryption"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "3.7.*",
|
||||
"cakephp/debug_kit" : "2.2.*"
|
||||
"phpunit/phpunit": "^3.7",
|
||||
"cakephp/cakephp-codesniffer": "^1.0.0"
|
||||
},
|
||||
"config": {
|
||||
"vendor-dir": "vendors/",
|
||||
"process-timeout": 0
|
||||
},
|
||||
"bin": [
|
||||
"lib/Cake/Console/cake"
|
||||
]
|
||||
],
|
||||
"scripts": {
|
||||
"check": [
|
||||
"@cs-check",
|
||||
"@test"
|
||||
],
|
||||
"cs-check": "./vendors/bin/phpcs -p --extensions=php --standard=CakePHP ./lib/Cake",
|
||||
"test": "./lib/Cake/Console/cake test core AllTests --stderr --verbose"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,17 +7,17 @@
|
|||
* - requires App.baseUrl to be uncommented in app/Config/core.php
|
||||
* - app/webroot is not set as a document root.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -352,7 +352,11 @@ class FileEngine extends CacheEngine {
|
|||
if (!$createKey && !$path->isFile()) {
|
||||
return false;
|
||||
}
|
||||
if (empty($this->_File) || $this->_File->getBaseName() !== $key) {
|
||||
if (
|
||||
empty($this->_File) ||
|
||||
$this->_File->getBaseName() !== $key ||
|
||||
$this->_File->valid() === false
|
||||
) {
|
||||
$exists = file_exists($path->getPathname());
|
||||
try {
|
||||
$this->_File = $path->openFile('c+');
|
||||
|
|
|
@ -228,7 +228,7 @@ class RedisEngine extends CacheEngine {
|
|||
* Disconnects from the redis server
|
||||
*/
|
||||
public function __destruct() {
|
||||
if (!$this->settings['persistent']) {
|
||||
if (empty($this->settings['persistent']) && $this->_Redis !== null) {
|
||||
$this->_Redis->close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ class CompletionShell extends AppShell {
|
|||
*/
|
||||
protected function _output($options = array()) {
|
||||
if ($options) {
|
||||
return $this->out(implode($options, ' '));
|
||||
return $this->out(implode(' ', $options));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class SchemaShell extends AppShell {
|
|||
$this->out('Cake Schema Shell');
|
||||
$this->hr();
|
||||
|
||||
Configure::write('Cache.disable', 1);
|
||||
Configure::write('Cache.disable', true);
|
||||
|
||||
$name = $path = $connection = $plugin = null;
|
||||
if (!empty($this->params['name'])) {
|
||||
|
|
|
@ -224,7 +224,7 @@ class ModelTask extends BakeTask {
|
|||
if (!array_key_exists('id', $fields)) {
|
||||
$primaryKey = $this->findPrimaryKey($fields);
|
||||
}
|
||||
|
||||
$displayField = null;
|
||||
if ($knownToExist) {
|
||||
$displayField = $tempModel->hasField(array('name', 'title'));
|
||||
if (!$displayField) {
|
||||
|
@ -388,7 +388,7 @@ class ModelTask extends BakeTask {
|
|||
sort($options);
|
||||
$default = 1;
|
||||
foreach ($options as $option) {
|
||||
if ($option{0} !== '_') {
|
||||
if ($option[0] !== '_') {
|
||||
$choices[$default] = $option;
|
||||
$default++;
|
||||
}
|
||||
|
|
|
@ -291,8 +291,8 @@ class TestShell extends Shell {
|
|||
public function available() {
|
||||
$params = $this->_parseArgs();
|
||||
$testCases = CakeTestLoader::generateTestList($params);
|
||||
$app = $params['app'];
|
||||
$plugin = $params['plugin'];
|
||||
$app = isset($params['app']) ? $params['app'] : null;
|
||||
$plugin = isset($params['plugin']) ? $params['plugin'] : null;
|
||||
|
||||
$title = "Core Test Cases:";
|
||||
$category = 'core';
|
||||
|
@ -360,23 +360,19 @@ class TestShell extends Shell {
|
|||
}
|
||||
|
||||
$testFile = $testCase = null;
|
||||
|
||||
$testCaseFolder = str_replace(APP, '', APP_TEST_CASES);
|
||||
if (preg_match('@Test[\\\/]@', $file)) {
|
||||
|
||||
if (substr($file, -8) === 'Test.php') {
|
||||
|
||||
$testCase = substr($file, 0, -8);
|
||||
$testCase = str_replace(DS, '/', $testCase);
|
||||
|
||||
if ($testCase = preg_replace('@.*Test\/Case\/@', '', $testCase)) {
|
||||
|
||||
$testCaseFolderEscaped = str_replace('/', '\/', $testCaseFolder);
|
||||
$testCase = preg_replace('@.*' . $testCaseFolderEscaped . '\/@', '', $testCase);
|
||||
if (!empty($testCase)) {
|
||||
if ($category === 'core') {
|
||||
$testCase = str_replace('lib/Cake', '', $testCase);
|
||||
}
|
||||
|
||||
return $testCase;
|
||||
}
|
||||
|
||||
throw new Exception(__d('cake_dev', 'Test case %s cannot be run via this shell', $testFile));
|
||||
}
|
||||
}
|
||||
|
@ -397,11 +393,11 @@ class TestShell extends Shell {
|
|||
}
|
||||
|
||||
if ($category === 'app') {
|
||||
$testFile = str_replace(APP, APP . 'Test/Case/', $file) . 'Test.php';
|
||||
$testFile = str_replace(APP, APP_TEST_CASES . '/', $file) . 'Test.php';
|
||||
} else {
|
||||
$testFile = preg_replace(
|
||||
"@((?:plugins|Plugin)[\\/]{$category}[\\/])(.*)$@",
|
||||
'\1Test/Case/\2Test.php',
|
||||
'\1' . $testCaseFolder . '/\2Test.php',
|
||||
$file
|
||||
);
|
||||
}
|
||||
|
@ -412,8 +408,7 @@ class TestShell extends Shell {
|
|||
|
||||
$testCase = substr($testFile, 0, -8);
|
||||
$testCase = str_replace(DS, '/', $testCase);
|
||||
$testCase = preg_replace('@.*Test/Case/@', '', $testCase);
|
||||
|
||||
$testCase = preg_replace('@.*' . $testCaseFolder . '/@', '', $testCase);
|
||||
return $testCase;
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ class UpgradeShell extends AppShell {
|
|||
foreach ($helpers as $helper) {
|
||||
$helper = preg_replace('/Helper$/', '', $helper);
|
||||
$oldHelper = $helper;
|
||||
$oldHelper{0} = strtolower($oldHelper{0});
|
||||
$oldHelper[0] = strtolower($oldHelper[0]);
|
||||
$patterns[] = array(
|
||||
"\${$oldHelper} to \$this->{$helper}",
|
||||
"/\\\${$oldHelper}->/",
|
||||
|
|
|
@ -620,8 +620,8 @@ class ConsoleOptionParser {
|
|||
if (substr($name, 0, 2) === '--') {
|
||||
return isset($this->_options[substr($name, 2)]);
|
||||
}
|
||||
if ($name{0} === '-' && $name{1} !== '-') {
|
||||
return isset($this->_shortOptions[$name{1}]);
|
||||
if ($name[0] === '-' && $name[1] !== '-') {
|
||||
return isset($this->_shortOptions[$name[1]]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ class ConsoleOutput {
|
|||
$styleInfo[] = static::$_options[$option];
|
||||
}
|
||||
}
|
||||
return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m";
|
||||
return "\033[" . implode(';', $styleInfo) . 'm' . $matches['text'] . "\033[0m";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -764,8 +764,6 @@ class Shell extends CakeObject {
|
|||
* @link https://book.cakephp.org/2.0/en/console-and-shells.html#Shell::createFile
|
||||
*/
|
||||
public function createFile($path, $contents) {
|
||||
$path = str_replace(DS . DS, DS, $path);
|
||||
|
||||
$this->out();
|
||||
|
||||
if (is_file($path) && empty($this->params['force']) && $this->interactive === true) {
|
||||
|
@ -808,12 +806,12 @@ class Shell extends CakeObject {
|
|||
return $this->_helpers[$name];
|
||||
}
|
||||
list($plugin, $helperClassName) = pluginSplit($name, true);
|
||||
$helperClassName = Inflector::camelize($name) . "ShellHelper";
|
||||
App::uses($helperClassName, $plugin . "Console/Helper");
|
||||
if (!class_exists($helperClassName)) {
|
||||
$helperClassNameShellHelper = Inflector::camelize($helperClassName) . "ShellHelper";
|
||||
App::uses($helperClassNameShellHelper, $plugin . "Console/Helper");
|
||||
if (!class_exists($helperClassNameShellHelper)) {
|
||||
throw new RuntimeException("Class " . $helperClassName . " not found");
|
||||
}
|
||||
$helper = new $helperClassName($this->stdout);
|
||||
$helper = new $helperClassNameShellHelper($this->stdout);
|
||||
$this->_helpers[$name] = $helper;
|
||||
return $helper;
|
||||
}
|
||||
|
|
|
@ -140,8 +140,11 @@ class ShellDispatcher {
|
|||
define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'Templates' . DS . 'skel' . DS . 'tmp' . DS);
|
||||
}
|
||||
|
||||
if (!defined('CONFIG')) {
|
||||
define('CONFIG', ROOT . DS . APP_DIR . DS . 'Config' . DS);
|
||||
}
|
||||
// $boot is used by Cake/bootstrap.php file
|
||||
$boot = file_exists(ROOT . DS . APP_DIR . DS . 'Config' . DS . 'bootstrap.php');
|
||||
$boot = file_exists(CONFIG . 'bootstrap.php');
|
||||
require CORE_PATH . 'Cake' . DS . 'bootstrap.php';
|
||||
|
||||
if (!file_exists(CONFIG . 'core.php')) {
|
||||
|
@ -220,7 +223,7 @@ class ShellDispatcher {
|
|||
}
|
||||
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));
|
||||
$added = in_array($command, $methods);
|
||||
$private = $command[0] === '_' && method_exists($Shell, $command);
|
||||
$private = substr($command, 0, 1) === '_' && method_exists($Shell, $command);
|
||||
|
||||
if (!$private) {
|
||||
if ($added) {
|
||||
|
|
|
@ -131,12 +131,11 @@
|
|||
* @return void
|
||||
*/
|
||||
public function <?php echo $admin; ?>delete($id = null) {
|
||||
$this-><?php echo $currentModelName; ?>->id = $id;
|
||||
if (!$this-><?php echo $currentModelName; ?>->exists()) {
|
||||
if (!$this-><?php echo $currentModelName; ?>->exists($id)) {
|
||||
throw new NotFoundException(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
if ($this-><?php echo $currentModelName; ?>->delete()) {
|
||||
if ($this-><?php echo $currentModelName; ?>->delete($id)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Flash->success(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'));
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteRule ^$ webroot/ [L]
|
||||
RewriteRule (.*) webroot/$1 [L]
|
||||
</IfModule>
|
|
@ -0,0 +1,6 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
|
@ -248,7 +248,7 @@ class CookieComponent extends Component {
|
|||
* $this->Cookie->read(Name.key);
|
||||
*
|
||||
* @param string $key Key of the value to be obtained. If none specified, obtain map key => values
|
||||
* @return string|null Value for specified key
|
||||
* @return string|array|null Value for specified key
|
||||
* @link https://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::read
|
||||
*/
|
||||
public function read($key = null) {
|
||||
|
|
|
@ -72,6 +72,13 @@ class RequestHandlerComponent extends Component {
|
|||
*/
|
||||
public $ext = null;
|
||||
|
||||
/**
|
||||
* Array of parameters parsed from the URL.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $params = null;
|
||||
|
||||
/**
|
||||
* The template to use when rendering the given content type.
|
||||
*
|
||||
|
@ -132,7 +139,7 @@ class RequestHandlerComponent extends Component {
|
|||
if (empty($this->ext) || $this->ext === 'html') {
|
||||
$this->_setExtension();
|
||||
}
|
||||
$this->params = $controller->params;
|
||||
$this->params = $controller->request->params;
|
||||
if (!empty($this->settings['viewClassMap'])) {
|
||||
$this->viewClassMap($this->settings['viewClassMap']);
|
||||
}
|
||||
|
@ -213,7 +220,7 @@ class RequestHandlerComponent extends Component {
|
|||
|
||||
foreach ($this->_inputTypeMap as $type => $handler) {
|
||||
if ($this->requestedWith($type)) {
|
||||
$input = call_user_func_array(array($controller->request, 'input'), $handler);
|
||||
$input = (array)call_user_func_array(array($controller->request, 'input'), $handler);
|
||||
$controller->request->data = $input;
|
||||
}
|
||||
}
|
||||
|
@ -264,9 +271,11 @@ class RequestHandlerComponent extends Component {
|
|||
}
|
||||
if (!empty($status)) {
|
||||
$statusCode = $this->response->httpCodes($status);
|
||||
if (is_array($statusCode)) {
|
||||
$code = key($statusCode);
|
||||
$this->response->statusCode($code);
|
||||
}
|
||||
}
|
||||
$this->response->body($this->requestAction($url, array('return', 'bare' => false)));
|
||||
$this->response->send();
|
||||
$this->_stop();
|
||||
|
|
|
@ -45,9 +45,9 @@ class SessionComponent extends Component {
|
|||
*
|
||||
* In your controller: $this->Session->write('Controller.sessKey', 'session value');
|
||||
*
|
||||
* @param string $name The name of the key your are setting in the session.
|
||||
* @param string|array $name The name of the key your are setting in the session.
|
||||
* This should be in a Controller.key format for better organizing
|
||||
* @param string $value The value you want to store in a session.
|
||||
* @param mixed $value The value you want to store in a session.
|
||||
* @return bool Success
|
||||
* @link https://book.cakephp.org/2.0/en/core-libraries/components/sessions.html#SessionComponent::write
|
||||
*/
|
||||
|
|
|
@ -48,11 +48,18 @@ App::uses('CakeEventManager', 'Event');
|
|||
* @property AuthComponent $Auth
|
||||
* @property CookieComponent $Cookie
|
||||
* @property EmailComponent $Email
|
||||
* @property FlashComponent $Flash
|
||||
* @property PaginatorComponent $Paginator
|
||||
* @property RequestHandlerComponent $RequestHandler
|
||||
* @property SecurityComponent $Security
|
||||
* @property SessionComponent $Session
|
||||
* @property FlashComponent $Flash
|
||||
* @property string $action The action handling the current request. Deprecated, use CakeRequest::$action instead.
|
||||
* @property string $base Base URL path. Deprecated, use CakeRequest::$base instead.
|
||||
* @property array $data POST data. Deprecated, use CakeRequest::$data instead.
|
||||
* @property string $here The full address to the current request. Deprecated, use CakeRequest::$here instead.
|
||||
* @property array $paginate Pagination settings.
|
||||
* @property array $params Array of parameters parsed from the URL. Deprecated, use CakeRequest::$params instead.
|
||||
* @property string $webroot Webroot path segment for the request.
|
||||
* @link https://book.cakephp.org/2.0/en/controllers.html
|
||||
*/
|
||||
class Controller extends CakeObject implements CakeEventListener {
|
||||
|
@ -80,7 +87,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* The default value is `true`.
|
||||
*
|
||||
* @var mixed
|
||||
* @var bool|array
|
||||
* @link https://book.cakephp.org/2.0/en/controllers.html#components-helpers-and-uses
|
||||
*/
|
||||
public $uses = true;
|
||||
|
@ -153,9 +160,9 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
/**
|
||||
* The name of the layout file to render the view inside of. The name specified
|
||||
* is the filename of the layout in /app/View/Layouts without the .ctp
|
||||
* extension.
|
||||
* extension. If `false` then no layout is rendered.
|
||||
*
|
||||
* @var string
|
||||
* @var string|bool
|
||||
*/
|
||||
public $layout = 'default';
|
||||
|
||||
|
@ -287,8 +294,9 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
|
||||
/**
|
||||
* Holds any validation errors produced by the last call of the validateErrors() method.
|
||||
* Contains `false` if no validation errors happened.
|
||||
*
|
||||
* @var array
|
||||
* @var array|bool
|
||||
*/
|
||||
public $validationErrors = null;
|
||||
|
||||
|
@ -573,7 +581,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
if ($this->uses === true) {
|
||||
$this->uses = array($pluginDot . $this->modelClass);
|
||||
}
|
||||
if (isset($appVars['uses']) && $appVars['uses'] === $this->uses) {
|
||||
if (is_array($this->uses) && isset($appVars['uses']) && $appVars['uses'] === $this->uses) {
|
||||
array_unshift($this->uses, $pluginDot . $this->modelClass);
|
||||
}
|
||||
if ($pluginController) {
|
||||
|
@ -598,10 +606,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
* @return void
|
||||
*/
|
||||
protected function _mergeUses($merge) {
|
||||
if (!isset($merge['uses'])) {
|
||||
return;
|
||||
}
|
||||
if ($merge['uses'] === true) {
|
||||
if (!isset($merge['uses']) || $merge['uses'] === true || !is_array($this->uses)) {
|
||||
return;
|
||||
}
|
||||
$this->uses = array_merge(
|
||||
|
@ -707,7 +712,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
* 800 => 'Unexpected Minotaur'
|
||||
* )); // sets these new values, and returns true
|
||||
*
|
||||
* @return array Associative array of the HTTP codes as keys, and the message
|
||||
* @return array|null|true Associative array of the HTTP codes as keys, and the message
|
||||
* strings as values, or null of the given $code does not exist.
|
||||
* @deprecated 3.0.0 Since 2.4. Will be removed in 3.0. Use CakeResponse::httpCodes().
|
||||
*/
|
||||
|
@ -752,7 +757,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* @param string|array $url A string or array-based URL pointing to another location within the app,
|
||||
* or an absolute URL
|
||||
* @param int|array|null $status HTTP status code (eg: 301). Defaults to 302 when null is passed.
|
||||
* @param int|array|null|string $status HTTP status code (eg: 301). Defaults to 302 when null is passed.
|
||||
* @param bool $exit If true, exit() will be called after the redirect
|
||||
* @return CakeResponse|null
|
||||
* @triggers Controller.beforeRedirect $this, array($url, $status, $exit)
|
||||
|
@ -838,7 +843,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
* Saves a variable for use inside a view template.
|
||||
*
|
||||
* @param string|array $one A string or an array of data.
|
||||
* @param string|array $two Value in case $one is a string (which then works as the key).
|
||||
* @param mixed $two Value in case $one is a string (which then works as the key).
|
||||
* Unused if $one is an associative array, otherwise serves as the values to $one's keys.
|
||||
* @return void
|
||||
* @link https://book.cakephp.org/2.0/en/controllers.html#interacting-with-views
|
||||
|
@ -900,7 +905,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* `$errors = $this->validateErrors($this->Article, $this->User);`
|
||||
*
|
||||
* @return array Validation errors, or false if none
|
||||
* @return array|false Validation errors, or false if none
|
||||
* @deprecated 3.0.0 This method will be removed in 3.0
|
||||
*/
|
||||
public function validateErrors() {
|
||||
|
@ -925,7 +930,7 @@ class Controller extends CakeObject implements CakeEventListener {
|
|||
/**
|
||||
* Instantiates the correct view class, hands it its data, and uses it to render the view output.
|
||||
*
|
||||
* @param string $view View to use for rendering
|
||||
* @param bool|string $view View to use for rendering
|
||||
* @param string $layout Layout to use
|
||||
* @return CakeResponse A response object containing the rendered view.
|
||||
* @triggers Controller.beforeRender $this
|
||||
|
|
|
@ -0,0 +1,796 @@
|
|||
<?php
|
||||
/**
|
||||
* Request object for handling alternative HTTP requests
|
||||
*
|
||||
* Alternative HTTP requests can come from wireless units like mobile phones, palmtop computers,
|
||||
* and the like. These units have no use for Ajax requests, and this Component can tell how Cake
|
||||
* should respond to the different needs of a handheld computer and a desktop machine.
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Controller.Component
|
||||
* @since CakePHP(tm) v 0.10.4.1076
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Component', 'Controller');
|
||||
App::uses('Xml', 'Utility');
|
||||
|
||||
/**
|
||||
* Request object for handling alternative HTTP requests
|
||||
*
|
||||
* Alternative HTTP requests can come from wireless units like mobile phones, palmtop computers,
|
||||
* and the like. These units have no use for Ajax requests, and this Component can tell how Cake
|
||||
* should respond to the different needs of a handheld computer and a desktop machine.
|
||||
*
|
||||
* @package Cake.Controller.Component
|
||||
* @link https://book.cakephp.org/2.0/en/core-libraries/components/request-handling.html
|
||||
*/
|
||||
class RequestHandlerComponent extends Component {
|
||||
|
||||
/**
|
||||
* The layout that will be switched to for Ajax requests
|
||||
*
|
||||
* @var string
|
||||
* @see RequestHandler::setAjax()
|
||||
*/
|
||||
public $ajaxLayout = 'ajax';
|
||||
|
||||
/**
|
||||
* Determines whether or not callbacks will be fired on this component
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $enabled = true;
|
||||
|
||||
/**
|
||||
* Holds the reference to Controller::$request
|
||||
*
|
||||
* @var CakeRequest
|
||||
*/
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Holds the reference to Controller::$response
|
||||
*
|
||||
* @var CakeResponse
|
||||
*/
|
||||
public $response;
|
||||
|
||||
/**
|
||||
* Contains the file extension parsed out by the Router
|
||||
*
|
||||
* @var string
|
||||
* @see Router::parseExtensions()
|
||||
*/
|
||||
public $ext = null;
|
||||
|
||||
/**
|
||||
* Array of parameters parsed from the URL.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $params = null;
|
||||
|
||||
/**
|
||||
* The template to use when rendering the given content type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_renderType = null;
|
||||
|
||||
/**
|
||||
* A mapping between extensions and deserializers for request bodies of that type.
|
||||
* By default only JSON and XML are mapped, use RequestHandlerComponent::addInputType()
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_inputTypeMap = array(
|
||||
'json' => array('json_decode', true)
|
||||
);
|
||||
|
||||
/**
|
||||
* A mapping between type and viewClass
|
||||
* By default only JSON and XML are mapped, use RequestHandlerComponent::viewClassMap()
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_viewClassMap = array(
|
||||
'json' => 'Json',
|
||||
'xml' => 'Xml'
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor. Parses the accepted content types accepted by the client using HTTP_ACCEPT
|
||||
*
|
||||
* @param ComponentCollection $collection ComponentCollection object.
|
||||
* @param array $settings Array of settings.
|
||||
*/
|
||||
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||
parent::__construct($collection, $settings + array('checkHttpCache' => true));
|
||||
$this->addInputType('xml', array(array($this, 'convertXml')));
|
||||
|
||||
$Controller = $collection->getController();
|
||||
$this->request = $Controller->request;
|
||||
$this->response = $Controller->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a file extension has been parsed by the Router, or if the
|
||||
* HTTP_ACCEPT_TYPE has matches only one content type with the supported extensions.
|
||||
* If there is only one matching type between the supported content types & extensions,
|
||||
* and the requested mime-types, RequestHandler::$ext is set to that value.
|
||||
*
|
||||
* @param Controller $controller A reference to the controller
|
||||
* @return void
|
||||
* @see Router::parseExtensions()
|
||||
*/
|
||||
public function initialize(Controller $controller) {
|
||||
if (isset($this->request->params['ext'])) {
|
||||
$this->ext = $this->request->params['ext'];
|
||||
}
|
||||
if (empty($this->ext) || $this->ext === 'html') {
|
||||
$this->_setExtension();
|
||||
}
|
||||
$this->params = $controller->request->params;
|
||||
if (!empty($this->settings['viewClassMap'])) {
|
||||
$this->viewClassMap($this->settings['viewClassMap']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the extension based on the accept headers.
|
||||
* Compares the accepted types and configured extensions.
|
||||
* If there is one common type, that is assigned as the ext/content type
|
||||
* for the response.
|
||||
* Type with the highest weight will be set. If the highest weight has more
|
||||
* then one type matching the extensions, the order in which extensions are specified
|
||||
* determines which type will be set.
|
||||
*
|
||||
* If html is one of the preferred types, no content type will be set, this
|
||||
* is to avoid issues with browsers that prefer html and several other content types.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _setExtension() {
|
||||
$accept = $this->request->parseAccept();
|
||||
if (empty($accept)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$accepts = $this->response->mapType($accept);
|
||||
$preferedTypes = current($accepts);
|
||||
if (array_intersect($preferedTypes, array('html', 'xhtml'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$extensions = Router::extensions();
|
||||
foreach ($accepts as $types) {
|
||||
$ext = array_intersect($extensions, $types);
|
||||
if ($ext) {
|
||||
$this->ext = current($ext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The startup method of the RequestHandler enables several automatic behaviors
|
||||
* related to the detection of certain properties of the HTTP request, including:
|
||||
*
|
||||
* - Disabling layout rendering for Ajax requests (based on the HTTP_X_REQUESTED_WITH header)
|
||||
* - If Router::parseExtensions() is enabled, the layout and template type are
|
||||
* switched based on the parsed extension or Accept-Type header. For example, if `controller/action.xml`
|
||||
* is requested, the view path becomes `app/View/Controller/xml/action.ctp`. Also if
|
||||
* `controller/action` is requested with `Accept-Type: application/xml` in the headers
|
||||
* the view path will become `app/View/Controller/xml/action.ctp`. Layout and template
|
||||
* types will only switch to mime-types recognized by CakeResponse. If you need to declare
|
||||
* additional mime-types, you can do so using CakeResponse::type() in your controllers beforeFilter()
|
||||
* method.
|
||||
* - If a helper with the same name as the extension exists, it is added to the controller.
|
||||
* - If the extension is of a type that RequestHandler understands, it will set that
|
||||
* Content-type in the response header.
|
||||
* - If the XML data is POSTed, the data is parsed into an XML object, which is assigned
|
||||
* to the $data property of the controller, which can then be saved to a model object.
|
||||
*
|
||||
* @param Controller $controller A reference to the controller
|
||||
* @return void
|
||||
*/
|
||||
public function startup(Controller $controller) {
|
||||
$controller->request->params['isAjax'] = $this->request->is('ajax');
|
||||
$isRecognized = (
|
||||
!in_array($this->ext, array('html', 'htm')) &&
|
||||
$this->response->getMimeType($this->ext)
|
||||
);
|
||||
|
||||
if (!empty($this->ext) && $isRecognized) {
|
||||
$this->renderAs($controller, $this->ext);
|
||||
} elseif ($this->request->is('ajax')) {
|
||||
$this->renderAs($controller, 'ajax');
|
||||
} elseif (empty($this->ext) || in_array($this->ext, array('html', 'htm'))) {
|
||||
$this->respondAs('html', array('charset' => Configure::read('App.encoding')));
|
||||
}
|
||||
|
||||
foreach ($this->_inputTypeMap as $type => $handler) {
|
||||
if ($this->requestedWith($type)) {
|
||||
$input = (array)call_user_func_array(array($controller->request, 'input'), $handler);
|
||||
$controller->request->data = $input;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to parse xml input data, due to lack of anonymous functions
|
||||
* this lives here.
|
||||
*
|
||||
* @param string $xml XML string.
|
||||
* @return array Xml array data
|
||||
*/
|
||||
public function convertXml($xml) {
|
||||
try {
|
||||
$xml = Xml::build($xml, array('readFile' => false));
|
||||
if (isset($xml->data)) {
|
||||
return Xml::toArray($xml->data);
|
||||
}
|
||||
return Xml::toArray($xml);
|
||||
} catch (XmlException $e) {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles (fakes) redirects for Ajax requests using requestAction()
|
||||
* Modifies the $_POST and $_SERVER['REQUEST_METHOD'] to simulate a new GET request.
|
||||
*
|
||||
* @param Controller $controller A reference to the controller
|
||||
* @param string|array $url A string or array containing the redirect location
|
||||
* @param int|array $status HTTP Status for redirect
|
||||
* @param bool $exit Whether to exit script, defaults to `true`.
|
||||
* @return void
|
||||
*/
|
||||
public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) {
|
||||
if (!$this->request->is('ajax')) {
|
||||
return;
|
||||
}
|
||||
if (empty($url)) {
|
||||
return;
|
||||
}
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
foreach ($_POST as $key => $val) {
|
||||
unset($_POST[$key]);
|
||||
}
|
||||
if (is_array($url)) {
|
||||
$url = Router::url($url + array('base' => false));
|
||||
}
|
||||
if (!empty($status)) {
|
||||
$statusCode = $this->response->httpCodes($status);
|
||||
if (is_array($statusCode)) {
|
||||
$code = key($statusCode);
|
||||
$this->response->statusCode($code);
|
||||
}
|
||||
}
|
||||
$this->response->body($this->requestAction($url, array('return', 'bare' => false)));
|
||||
$this->response->send();
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the response can be considered different according to the request
|
||||
* headers, and the caching response headers. If it was not modified, then the
|
||||
* render process is skipped. And the client will get a blank response with a
|
||||
* "304 Not Modified" header.
|
||||
*
|
||||
* @param Controller $controller Controller instance.
|
||||
* @return bool False if the render process should be aborted.
|
||||
*/
|
||||
public function beforeRender(Controller $controller) {
|
||||
if ($this->settings['checkHttpCache'] && $this->response->checkNotModified($this->request)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current HTTP request is Ajax, false otherwise
|
||||
*
|
||||
* @return bool True if call is Ajax
|
||||
* @deprecated 3.0.0 Use `$this->request->is('ajax')` instead.
|
||||
*/
|
||||
public function isAjax() {
|
||||
return $this->request->is('ajax');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current HTTP request is coming from a Flash-based client
|
||||
*
|
||||
* @return bool True if call is from Flash
|
||||
* @deprecated 3.0.0 Use `$this->request->is('flash')` instead.
|
||||
*/
|
||||
public function isFlash() {
|
||||
return $this->request->is('flash');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current request is over HTTPS, false otherwise.
|
||||
*
|
||||
* @return bool True if call is over HTTPS
|
||||
* @deprecated 3.0.0 Use `$this->request->is('ssl')` instead.
|
||||
*/
|
||||
public function isSSL() {
|
||||
return $this->request->is('ssl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current call accepts an XML response, false otherwise
|
||||
*
|
||||
* @return bool True if client accepts an XML response
|
||||
*/
|
||||
public function isXml() {
|
||||
return $this->prefers('xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current call accepts an RSS response, false otherwise
|
||||
*
|
||||
* @return bool True if client accepts an RSS response
|
||||
*/
|
||||
public function isRss() {
|
||||
return $this->prefers('rss');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current call accepts an Atom response, false otherwise
|
||||
*
|
||||
* @return bool True if client accepts an RSS response
|
||||
*/
|
||||
public function isAtom() {
|
||||
return $this->prefers('atom');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if user agent string matches a mobile web browser, or if the
|
||||
* client accepts WAP content.
|
||||
*
|
||||
* @return bool True if user agent is a mobile web browser
|
||||
*/
|
||||
public function isMobile() {
|
||||
return $this->request->is('mobile') || $this->accepts('wap');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the client accepts WAP content
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWap() {
|
||||
return $this->prefers('wap');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current call a POST request
|
||||
*
|
||||
* @return bool True if call is a POST
|
||||
* @deprecated 3.0.0 Use $this->request->is('post'); from your controller.
|
||||
*/
|
||||
public function isPost() {
|
||||
return $this->request->is('post');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current call a PUT request
|
||||
*
|
||||
* @return bool True if call is a PUT
|
||||
* @deprecated 3.0.0 Use $this->request->is('put'); from your controller.
|
||||
*/
|
||||
public function isPut() {
|
||||
return $this->request->is('put');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current call a GET request
|
||||
*
|
||||
* @return bool True if call is a GET
|
||||
* @deprecated 3.0.0 Use $this->request->is('get'); from your controller.
|
||||
*/
|
||||
public function isGet() {
|
||||
return $this->request->is('get');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current call a DELETE request
|
||||
*
|
||||
* @return bool True if call is a DELETE
|
||||
* @deprecated 3.0.0 Use $this->request->is('delete'); from your controller.
|
||||
*/
|
||||
public function isDelete() {
|
||||
return $this->request->is('delete');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Prototype version if call is Ajax, otherwise empty string.
|
||||
* The Prototype library sets a special "Prototype version" HTTP header.
|
||||
*
|
||||
* @return string|bool When Ajax the prototype version of component making the call otherwise false
|
||||
*/
|
||||
public function getAjaxVersion() {
|
||||
$httpX = env('HTTP_X_PROTOTYPE_VERSION');
|
||||
return ($httpX === null) ? false : $httpX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds/sets the Content-type(s) for the given name. This method allows
|
||||
* content-types to be mapped to friendly aliases (or extensions), which allows
|
||||
* RequestHandler to automatically respond to requests of that type in the
|
||||
* startup method.
|
||||
*
|
||||
* @param string $name The name of the Content-type, i.e. "html", "xml", "css"
|
||||
* @param string|array $type The Content-type or array of Content-types assigned to the name,
|
||||
* i.e. "text/html", or "application/xml"
|
||||
* @return void
|
||||
* @deprecated 3.0.0 Use `$this->response->type()` instead.
|
||||
*/
|
||||
public function setContent($name, $type = null) {
|
||||
$this->response->type(array($name => $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server name from which this request was referred
|
||||
*
|
||||
* @return string Server address
|
||||
* @deprecated 3.0.0 Use $this->request->referer() from your controller instead
|
||||
*/
|
||||
public function getReferer() {
|
||||
return $this->request->referer(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets remote client IP
|
||||
*
|
||||
* @param bool $safe Use safe = false when you think the user might manipulate
|
||||
* their HTTP_CLIENT_IP header. Setting $safe = false will also look at HTTP_X_FORWARDED_FOR
|
||||
* @return string Client IP address
|
||||
* @deprecated 3.0.0 Use $this->request->clientIp() from your, controller instead.
|
||||
*/
|
||||
public function getClientIP($safe = true) {
|
||||
return $this->request->clientIp($safe);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which content types the client accepts. Acceptance is based on
|
||||
* the file extension parsed by the Router (if present), and by the HTTP_ACCEPT
|
||||
* header. Unlike CakeRequest::accepts() this method deals entirely with mapped content types.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* `$this->RequestHandler->accepts(array('xml', 'html', 'json'));`
|
||||
*
|
||||
* Returns true if the client accepts any of the supplied types.
|
||||
*
|
||||
* `$this->RequestHandler->accepts('xml');`
|
||||
*
|
||||
* Returns true if the client accepts xml.
|
||||
*
|
||||
* @param string|array $type Can be null (or no parameter), a string type name, or an
|
||||
* array of types
|
||||
* @return mixed If null or no parameter is passed, returns an array of content
|
||||
* types the client accepts. If a string is passed, returns true
|
||||
* if the client accepts it. If an array is passed, returns true
|
||||
* if the client accepts one or more elements in the array.
|
||||
* @see RequestHandlerComponent::setContent()
|
||||
*/
|
||||
public function accepts($type = null) {
|
||||
$accepted = $this->request->accepts();
|
||||
|
||||
if (!$type) {
|
||||
return $this->mapType($accepted);
|
||||
}
|
||||
if (is_array($type)) {
|
||||
foreach ($type as $t) {
|
||||
$t = $this->mapAlias($t);
|
||||
if (in_array($t, $accepted)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (is_string($type)) {
|
||||
return in_array($this->mapAlias($type), $accepted);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the content type of the data the client has sent (i.e. in a POST request)
|
||||
*
|
||||
* @param string|array $type Can be null (or no parameter), a string type name, or an array of types
|
||||
* @return mixed If a single type is supplied a boolean will be returned. If no type is provided
|
||||
* The mapped value of CONTENT_TYPE will be returned. If an array is supplied the first type
|
||||
* in the request content type will be returned.
|
||||
*/
|
||||
public function requestedWith($type = null) {
|
||||
if (
|
||||
!$this->request->is('patch') &&
|
||||
!$this->request->is('post') &&
|
||||
!$this->request->is('put') &&
|
||||
!$this->request->is('delete')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (is_array($type)) {
|
||||
foreach ($type as $t) {
|
||||
if ($this->requestedWith($t)) {
|
||||
return $t;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
list($contentType) = explode(';', env('CONTENT_TYPE'));
|
||||
if ($contentType === '') {
|
||||
list($contentType) = explode(';', CakeRequest::header('CONTENT_TYPE'));
|
||||
}
|
||||
if (!$type) {
|
||||
return $this->mapType($contentType);
|
||||
}
|
||||
if (is_string($type)) {
|
||||
return ($type === $this->mapType($contentType));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which content-types the client prefers. If no parameters are given,
|
||||
* the single content-type that the client most likely prefers is returned. If $type is
|
||||
* an array, the first item in the array that the client accepts is returned.
|
||||
* Preference is determined primarily by the file extension parsed by the Router
|
||||
* if provided, and secondarily by the list of content-types provided in
|
||||
* HTTP_ACCEPT.
|
||||
*
|
||||
* @param string|array $type An optional array of 'friendly' content-type names, i.e.
|
||||
* 'html', 'xml', 'js', etc.
|
||||
* @return mixed If $type is null or not provided, the first content-type in the
|
||||
* list, based on preference, is returned. If a single type is provided
|
||||
* a boolean will be returned if that type is preferred.
|
||||
* If an array of types are provided then the first preferred type is returned.
|
||||
* If no type is provided the first preferred type is returned.
|
||||
* @see RequestHandlerComponent::setContent()
|
||||
*/
|
||||
public function prefers($type = null) {
|
||||
$acceptRaw = $this->request->parseAccept();
|
||||
|
||||
if (empty($acceptRaw)) {
|
||||
return $this->ext;
|
||||
}
|
||||
$accepts = $this->mapType(array_shift($acceptRaw));
|
||||
|
||||
if (!$type) {
|
||||
if (empty($this->ext) && !empty($accepts)) {
|
||||
return $accepts[0];
|
||||
}
|
||||
return $this->ext;
|
||||
}
|
||||
|
||||
$types = (array)$type;
|
||||
|
||||
if (count($types) === 1) {
|
||||
if (!empty($this->ext)) {
|
||||
return in_array($this->ext, $types);
|
||||
}
|
||||
return in_array($types[0], $accepts);
|
||||
}
|
||||
|
||||
$intersect = array_values(array_intersect($accepts, $types));
|
||||
if (empty($intersect)) {
|
||||
return false;
|
||||
}
|
||||
return $intersect[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the layout and template paths for the content type defined by $type.
|
||||
*
|
||||
* ### Usage:
|
||||
*
|
||||
* Render the response as an 'ajax' response.
|
||||
*
|
||||
* `$this->RequestHandler->renderAs($this, 'ajax');`
|
||||
*
|
||||
* Render the response as an xml file and force the result as a file download.
|
||||
*
|
||||
* `$this->RequestHandler->renderAs($this, 'xml', array('attachment' => 'myfile.xml');`
|
||||
*
|
||||
* @param Controller $controller A reference to a controller object
|
||||
* @param string $type Type of response to send (e.g: 'ajax')
|
||||
* @param array $options Array of options to use
|
||||
* @return void
|
||||
* @see RequestHandlerComponent::setContent()
|
||||
* @see RequestHandlerComponent::respondAs()
|
||||
*/
|
||||
public function renderAs(Controller $controller, $type, $options = array()) {
|
||||
$defaults = array('charset' => 'UTF-8');
|
||||
|
||||
if (Configure::read('App.encoding') !== null) {
|
||||
$defaults['charset'] = Configure::read('App.encoding');
|
||||
}
|
||||
$options += $defaults;
|
||||
|
||||
if ($type === 'ajax') {
|
||||
$controller->layout = $this->ajaxLayout;
|
||||
return $this->respondAs('html', $options);
|
||||
}
|
||||
|
||||
$pluginDot = null;
|
||||
$viewClassMap = $this->viewClassMap();
|
||||
if (array_key_exists($type, $viewClassMap)) {
|
||||
list($pluginDot, $viewClass) = pluginSplit($viewClassMap[$type], true);
|
||||
} else {
|
||||
$viewClass = Inflector::classify($type);
|
||||
}
|
||||
$viewName = $viewClass . 'View';
|
||||
if (!class_exists($viewName)) {
|
||||
App::uses($viewName, $pluginDot . 'View');
|
||||
}
|
||||
if (class_exists($viewName)) {
|
||||
$controller->viewClass = $viewClass;
|
||||
} elseif (empty($this->_renderType)) {
|
||||
$controller->viewPath .= DS . $type;
|
||||
} else {
|
||||
$controller->viewPath = preg_replace(
|
||||
"/([\/\\\\]{$this->_renderType})$/",
|
||||
DS . $type,
|
||||
$controller->viewPath
|
||||
);
|
||||
}
|
||||
$this->_renderType = $type;
|
||||
$controller->layoutPath = $type;
|
||||
|
||||
if ($this->response->getMimeType($type)) {
|
||||
$this->respondAs($type, $options);
|
||||
}
|
||||
|
||||
$helper = ucfirst($type);
|
||||
|
||||
if (!in_array($helper, $controller->helpers) && empty($controller->helpers[$helper])) {
|
||||
App::uses('AppHelper', 'View/Helper');
|
||||
App::uses($helper . 'Helper', 'View/Helper');
|
||||
if (class_exists($helper . 'Helper')) {
|
||||
$controller->helpers[] = $helper;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the response header based on type map index name. This wraps several methods
|
||||
* available on CakeResponse. It also allows you to use Content-Type aliases.
|
||||
*
|
||||
* @param string|array $type Friendly type name, i.e. 'html' or 'xml', or a full content-type,
|
||||
* like 'application/x-shockwave'.
|
||||
* @param array $options If $type is a friendly type name that is associated with
|
||||
* more than one type of content, $index is used to select which content-type to use.
|
||||
* @return bool Returns false if the friendly type name given in $type does
|
||||
* not exist in the type map, or if the Content-type header has
|
||||
* already been set by this method.
|
||||
* @see RequestHandlerComponent::setContent()
|
||||
*/
|
||||
public function respondAs($type, $options = array()) {
|
||||
$defaults = array('index' => null, 'charset' => null, 'attachment' => false);
|
||||
$options = $options + $defaults;
|
||||
|
||||
$cType = $type;
|
||||
if (strpos($type, '/') === false) {
|
||||
$cType = $this->response->getMimeType($type);
|
||||
}
|
||||
if (is_array($cType)) {
|
||||
if (isset($cType[$options['index']])) {
|
||||
$cType = $cType[$options['index']];
|
||||
}
|
||||
|
||||
if ($this->prefers($cType)) {
|
||||
$cType = $this->prefers($cType);
|
||||
} else {
|
||||
$cType = $cType[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$type) {
|
||||
return false;
|
||||
}
|
||||
if (empty($this->request->params['requested'])) {
|
||||
$this->response->type($cType);
|
||||
}
|
||||
if (!empty($options['charset'])) {
|
||||
$this->response->charset($options['charset']);
|
||||
}
|
||||
if (!empty($options['attachment'])) {
|
||||
$this->response->download($options['attachment']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current response type (Content-type header), or null if not alias exists
|
||||
*
|
||||
* @return mixed A string content type alias, or raw content type if no alias map exists,
|
||||
* otherwise null
|
||||
*/
|
||||
public function responseType() {
|
||||
return $this->mapType($this->response->type());
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a content-type back to an alias
|
||||
*
|
||||
* @param string|array $cType Either a string content type to map, or an array of types.
|
||||
* @return string|array Aliases for the types provided.
|
||||
* @deprecated 3.0.0 Use $this->response->mapType() in your controller instead.
|
||||
*/
|
||||
public function mapType($cType) {
|
||||
return $this->response->mapType($cType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a content type alias back to its mime-type(s)
|
||||
*
|
||||
* @param string|array $alias String alias to convert back into a content type. Or an array of aliases to map.
|
||||
* @return string|null Null on an undefined alias. String value of the mapped alias type. If an
|
||||
* alias maps to more than one content type, the first one will be returned.
|
||||
*/
|
||||
public function mapAlias($alias) {
|
||||
if (is_array($alias)) {
|
||||
return array_map(array($this, 'mapAlias'), $alias);
|
||||
}
|
||||
$type = $this->response->getMimeType($alias);
|
||||
if ($type) {
|
||||
if (is_array($type)) {
|
||||
return $type[0];
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new mapped input type. Mapped input types are automatically
|
||||
* converted by RequestHandlerComponent during the startup() callback.
|
||||
*
|
||||
* @param string $type The type alias being converted, ie. json
|
||||
* @param array $handler The handler array for the type. The first index should
|
||||
* be the handling callback, all other arguments should be additional parameters
|
||||
* for the handler.
|
||||
* @return void
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function addInputType($type, $handler) {
|
||||
if (!is_array($handler) || !isset($handler[0]) || !is_callable($handler[0])) {
|
||||
throw new CakeException(__d('cake_dev', 'You must give a handler callback.'));
|
||||
}
|
||||
$this->_inputTypeMap[$type] = $handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter/setter for viewClassMap
|
||||
*
|
||||
* @param array|string $type The type string or array with format `array('type' => 'viewClass')` to map one or more
|
||||
* @param array $viewClass The viewClass to be used for the type without `View` appended
|
||||
* @return array|string Returns viewClass when only string $type is set, else array with viewClassMap
|
||||
*/
|
||||
public function viewClassMap($type = null, $viewClass = null) {
|
||||
if (!$viewClass && is_string($type) && isset($this->_viewClassMap[$type])) {
|
||||
return $this->_viewClassMap[$type];
|
||||
}
|
||||
if (is_string($type)) {
|
||||
$this->_viewClassMap[$type] = $viewClass;
|
||||
} elseif (is_array($type)) {
|
||||
foreach ($type as $key => $value) {
|
||||
$this->viewClassMap($key, $value);
|
||||
}
|
||||
}
|
||||
return $this->_viewClassMap;
|
||||
}
|
||||
|
||||
}
|
|
@ -591,7 +591,7 @@ class App {
|
|||
*
|
||||
* @param string|array $type The type of Class if passed as a string, or all params can be passed as
|
||||
* a single array to $type.
|
||||
* @param string $name Name of the Class or a unique name for the file
|
||||
* @param string|array $name Name of the Class or a unique name for the file
|
||||
* @param bool|array $parent boolean true if Class Parent should be searched, accepts key => value
|
||||
* array('parent' => $parent, 'file' => $file, 'search' => $search, 'ext' => '$ext');
|
||||
* $ext allows setting the extension of the file name
|
||||
|
|
|
@ -114,6 +114,9 @@ class Configure {
|
|||
class_exists('Debugger');
|
||||
class_exists('CakeText');
|
||||
}
|
||||
if (!defined('TESTS')) {
|
||||
define('TESTS', APP . 'Test' . DS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
|
||||
App::uses('CakeEventListener', 'Event');
|
||||
App::uses('CakeEvent', 'Event');
|
||||
|
||||
/**
|
||||
* The event manager is responsible for keeping track of event listeners, passing the correct
|
||||
|
@ -80,7 +81,7 @@ class CakeEventManager {
|
|||
/**
|
||||
* Adds a new listener to an event. Listeners
|
||||
*
|
||||
* @param callback|CakeEventListener $callable PHP valid callback type or instance of CakeEventListener to be called
|
||||
* @param callable|CakeEventListener $callable PHP valid callback type or instance of CakeEventListener to be called
|
||||
* when the event named with $eventKey is triggered. If a CakeEventListener instance is passed, then the `implementedEvents`
|
||||
* method will be called on the object to register the declared events individually as methods to be managed by this class.
|
||||
* It is possible to define multiple event handlers per event name.
|
||||
|
@ -145,7 +146,7 @@ class CakeEventManager {
|
|||
*
|
||||
* @param array $function the array taken from a handler definition for an event
|
||||
* @param CakeEventListener $object The handler object
|
||||
* @return callback
|
||||
* @return callable
|
||||
*/
|
||||
protected function _extractCallable($function, $object) {
|
||||
$method = $function['callable'];
|
||||
|
@ -160,7 +161,7 @@ class CakeEventManager {
|
|||
/**
|
||||
* Removes a listener from the active listeners.
|
||||
*
|
||||
* @param callback|CakeEventListener $callable any valid PHP callback type or an instance of CakeEventListener
|
||||
* @param callable|CakeEventListener $callable any valid PHP callback type or an instance of CakeEventListener
|
||||
* @param string $eventKey The event unique identifier name with which the callback has been associated
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -137,6 +137,7 @@ class L10n {
|
|||
/* Latvian */ 'lav' => 'lv',
|
||||
/* Limburgish */ 'lim' => 'li',
|
||||
/* Lithuanian */ 'lit' => 'lt',
|
||||
/* Luxembourgish */ 'ltz' => 'lb',
|
||||
/* Macedonian */ 'mkd' => 'mk',
|
||||
/* Macedonian - bibliographic */ 'mac' => 'mk',
|
||||
/* Malaysian */ 'msa' => 'ms',
|
||||
|
@ -255,6 +256,7 @@ class L10n {
|
|||
'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'fi-fi' => array('language' => 'Finnish (Finland)', 'locale' => 'fi_fi', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'fo-fo' => array('language' => 'Faeroese (Faroe Island)', 'locale' => 'fo_fo', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'fr' => array('language' => 'French (Standard)', 'locale' => 'fra', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'fr-be' => array('language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'fr-ca' => array('language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
|
@ -284,6 +286,7 @@ class L10n {
|
|||
'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'),
|
||||
'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'),
|
||||
'koi8-r' => array('language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r', 'direction' => 'ltr'),
|
||||
'lb' => array('language' => 'Luxembourgish', 'locale' => 'ltz', 'localeFallback' => 'ltz', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'li' => array('language' => 'Limburgish', 'locale' => 'lim', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||
|
|
|
@ -398,7 +398,7 @@ class CakeLog {
|
|||
*
|
||||
* @param int|string $type Type of message being written. When value is an integer
|
||||
* or a string matching the recognized levels, then it will
|
||||
* be treated log levels. Otherwise it's treated as scope.
|
||||
* be treated as a log level. Otherwise it's treated as a scope.
|
||||
* @param string $message Message content to log
|
||||
* @param string|array $scope The scope(s) a log message is being created in.
|
||||
* See CakeLog::config() for more information on logging scopes.
|
||||
|
|
|
@ -306,7 +306,7 @@ class ContainableBehavior extends ModelBehavior {
|
|||
if (!$optionKey && is_string($key) && preg_match('/^[a-z(]/', $key) && (!isset($Model->{$key}) || !is_object($Model->{$key}))) {
|
||||
$option = 'fields';
|
||||
$val = array($key);
|
||||
if ($key{0} === '(') {
|
||||
if ($key[0] === '(') {
|
||||
$val = preg_split('/\s*,\s*/', substr($key, 1, -1));
|
||||
} elseif (preg_match('/ASC|DESC$/', $key)) {
|
||||
$option = 'order';
|
||||
|
|
|
@ -344,7 +344,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
public function afterFind(Model $Model, $results, $primary = false) {
|
||||
$Model->virtualFields = $this->runtime[$Model->alias]['virtualFields'];
|
||||
|
||||
$this->runtime[$Model->alias]['virtualFields'] = $this->runtime[$Model->alias]['fields'] = array();
|
||||
$this->runtime[$Model->alias]['virtualFields'] = array();
|
||||
if (!empty($this->runtime[$Model->alias]['restoreFields'])) {
|
||||
$this->runtime[$Model->alias]['fields'] = $this->runtime[$Model->alias]['restoreFields'];
|
||||
unset($this->runtime[$Model->alias]['restoreFields']);
|
||||
|
|
|
@ -225,7 +225,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
}
|
||||
$parentIsSet = array_key_exists($parent, $Model->data[$Model->alias]);
|
||||
|
||||
if (!$Model->id || !$Model->exists()) {
|
||||
if (!$Model->id || !$Model->exists($Model->getID())) {
|
||||
if ($parentIsSet && $Model->data[$Model->alias][$parent]) {
|
||||
$parentNode = $this->_getNode($Model, $Model->data[$Model->alias][$parent]);
|
||||
if (!$parentNode) {
|
||||
|
|
|
@ -420,6 +420,7 @@ class CakeSchema extends CakeObject {
|
|||
$type = $value;
|
||||
$value = array('type' => $type);
|
||||
}
|
||||
$value['type'] = addslashes($value['type']);
|
||||
$col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
|
||||
unset($value['type']);
|
||||
$col .= implode(', ', $this->_values($value));
|
||||
|
@ -624,6 +625,7 @@ class CakeSchema extends CakeObject {
|
|||
if ($Obj->primaryKey === $name && !$hasPrimaryAlready && !isset($value['key'])) {
|
||||
$value['key'] = 'primary';
|
||||
}
|
||||
if (substr($value['type'], 0, 4) !== 'enum') {
|
||||
if (!isset($db->columns[$value['type']])) {
|
||||
trigger_error(__d('cake_dev', 'Schema generation error: invalid column type %s for %s.%s does not exist in DBO', $value['type'], $Obj->name, $name), E_USER_NOTICE);
|
||||
continue;
|
||||
|
@ -636,6 +638,7 @@ class CakeSchema extends CakeObject {
|
|||
}
|
||||
unset($value['limit']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($value['default']) && ($value['default'] === '' || ($value['default'] === false && $value['type'] !== 'boolean'))) {
|
||||
unset($value['default']);
|
||||
|
|
|
@ -432,7 +432,7 @@ class CakeSession {
|
|||
* Writes value to given session variable name.
|
||||
*
|
||||
* @param string|array $name Name of variable
|
||||
* @param string $value Value to write
|
||||
* @param mixed $value Value to write
|
||||
* @return bool True if the write was successful, false if the write failed
|
||||
*/
|
||||
public static function write($name, $value = null) {
|
||||
|
@ -575,7 +575,7 @@ class CakeSession {
|
|||
$sessionConfig['cacheLimiter'] = 'must-revalidate';
|
||||
}
|
||||
|
||||
if (empty($_SESSION)) {
|
||||
if (empty($_SESSION) && !headers_sent() && (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE)) {
|
||||
if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) {
|
||||
foreach ($sessionConfig['ini'] as $setting => $value) {
|
||||
if (ini_set($setting, $value) === false) {
|
||||
|
@ -587,8 +587,9 @@ class CakeSession {
|
|||
if (!empty($sessionConfig['handler']) && !isset($sessionConfig['handler']['engine'])) {
|
||||
call_user_func_array('session_set_save_handler', $sessionConfig['handler']);
|
||||
}
|
||||
if (!empty($sessionConfig['handler']['engine'])) {
|
||||
if (!empty($sessionConfig['handler']['engine']) && !headers_sent()) {
|
||||
$handler = static::_getHandler($sessionConfig['handler']['engine']);
|
||||
if (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE) {
|
||||
session_set_save_handler(
|
||||
array($handler, 'open'),
|
||||
array($handler, 'close'),
|
||||
|
@ -598,6 +599,7 @@ class CakeSession {
|
|||
array($handler, 'gc')
|
||||
);
|
||||
}
|
||||
}
|
||||
Configure::write('Session', $sessionConfig);
|
||||
static::$sessionTime = static::$time;
|
||||
if (!static::$_useForwardsCompatibleTimeout) {
|
||||
|
|
|
@ -120,6 +120,7 @@ class Mysql extends DboSource {
|
|||
'primary_key' => array('name' => 'NOT NULL AUTO_INCREMENT'),
|
||||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||
'text' => array('name' => 'text'),
|
||||
'enum' => array('name' => 'enum'),
|
||||
'biginteger' => array('name' => 'bigint', 'limit' => '20'),
|
||||
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
|
||||
'smallinteger' => array('name' => 'smallint', 'limit' => '6', 'formatter' => 'intval'),
|
||||
|
@ -305,7 +306,7 @@ class Mysql extends DboSource {
|
|||
* Query charset by collation
|
||||
*
|
||||
* @param string $name Collation name
|
||||
* @return string Character set name
|
||||
* @return string|false Character set name
|
||||
*/
|
||||
public function getCharsetName($name) {
|
||||
if ((bool)version_compare($this->getVersion(), "5", "<")) {
|
||||
|
@ -391,7 +392,7 @@ class Mysql extends DboSource {
|
|||
* @param array $fields The fields to update.
|
||||
* @param array $values The values to set.
|
||||
* @param mixed $conditions The conditions to use.
|
||||
* @return array
|
||||
* @return bool
|
||||
*/
|
||||
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
|
||||
if (!$this->_useAlias) {
|
||||
|
@ -545,7 +546,7 @@ class Mysql extends DboSource {
|
|||
*
|
||||
* @param array $compare Result of a CakeSchema::compare()
|
||||
* @param string $table The table name.
|
||||
* @return array Array of alter statements to make.
|
||||
* @return string|false String of alter statements to make.
|
||||
*/
|
||||
public function alterSchema($compare, $table = null) {
|
||||
if (!is_array($compare)) {
|
||||
|
|
|
@ -251,7 +251,7 @@ class Postgres extends DboSource {
|
|||
'default' => preg_replace(
|
||||
"/^'(.*)'$/",
|
||||
"$1",
|
||||
preg_replace('/::.*/', '', $c->default)
|
||||
preg_replace('/::[\w\s]+/', '', $c->default)
|
||||
),
|
||||
'length' => $length,
|
||||
);
|
||||
|
@ -765,10 +765,10 @@ class Postgres extends DboSource {
|
|||
/**
|
||||
* resultSet method
|
||||
*
|
||||
* @param array &$results The results
|
||||
* @param PDOStatement $results The results
|
||||
* @return void
|
||||
*/
|
||||
public function resultSet(&$results) {
|
||||
public function resultSet($results) {
|
||||
$this->map = array();
|
||||
$numFields = $results->columnCount();
|
||||
$index = 0;
|
||||
|
|
|
@ -179,7 +179,6 @@ class Sqlite extends DboSource {
|
|||
);
|
||||
|
||||
foreach ($result as $column) {
|
||||
$column = (array)$column;
|
||||
$default = ($column['dflt_value'] === 'NULL') ? null : trim($column['dflt_value'], "'");
|
||||
|
||||
$fields[$column['name']] = array(
|
||||
|
@ -299,7 +298,7 @@ class Sqlite extends DboSource {
|
|||
/**
|
||||
* Generate ResultSet
|
||||
*
|
||||
* @param mixed $results The results to modify.
|
||||
* @param PDOStatement $results The results to modify.
|
||||
* @return void
|
||||
*/
|
||||
public function resultSet($results) {
|
||||
|
|
|
@ -109,7 +109,7 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* Result
|
||||
*
|
||||
* @var array
|
||||
* @var array|PDOStatement
|
||||
*/
|
||||
protected $_result = null;
|
||||
|
||||
|
@ -247,6 +247,13 @@ class DboSource extends DataSource {
|
|||
*/
|
||||
protected $_methodCacheChange = false;
|
||||
|
||||
/**
|
||||
* Map of the columns contained in a result.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $map = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -272,6 +279,16 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the database.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function connect() {
|
||||
// This method is implemented in subclasses
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconnects to database server with optional new settings
|
||||
*
|
||||
|
@ -350,6 +367,18 @@ class DboSource extends DataSource {
|
|||
$column = $this->introspectType($data);
|
||||
}
|
||||
|
||||
$isStringEnum = false;
|
||||
if (strpos($column, "enum") === 0) {
|
||||
$firstValue = null;
|
||||
if (preg_match("/(enum\()(.*)(\))/i", $column, $acceptingValues)) {
|
||||
$values = explode(",", $acceptingValues[2]);
|
||||
$firstValue = $values[0];
|
||||
}
|
||||
if (is_string($firstValue)) {
|
||||
$isStringEnum = true;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($column) {
|
||||
case 'binary':
|
||||
return $this->_connection->quote($data, PDO::PARAM_LOB);
|
||||
|
@ -365,11 +394,12 @@ class DboSource extends DataSource {
|
|||
if (is_float($data)) {
|
||||
return str_replace(',', '.', strval($data));
|
||||
}
|
||||
if ((is_int($data) || $data === '0') || (
|
||||
if (((is_int($data) || $data === '0') || (
|
||||
is_numeric($data) &&
|
||||
strpos($data, ',') === false &&
|
||||
$data[0] != '0' &&
|
||||
strpos($data, 'e') === false)
|
||||
) && !$isStringEnum
|
||||
) {
|
||||
return $data;
|
||||
}
|
||||
|
@ -619,6 +649,16 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a map of the columns contained in a result
|
||||
*
|
||||
* @param PDOStatement $results The results to format.
|
||||
* @return void
|
||||
*/
|
||||
public function resultSet($results) {
|
||||
// This method is implemented in subclasses
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a row from current resultset as an array
|
||||
*
|
||||
|
@ -913,7 +953,7 @@ class DboSource extends DataSource {
|
|||
)
|
||||
);
|
||||
}
|
||||
if (preg_match('/^[\w-_\s]*[\w-_]+/', $data)) {
|
||||
if (preg_match('/^[\w\-_\s]*[\w\-_]+/', $data)) {
|
||||
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote);
|
||||
}
|
||||
return $this->cacheMethod(__FUNCTION__, $cacheKey, $data);
|
||||
|
@ -1076,7 +1116,7 @@ class DboSource extends DataSource {
|
|||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$schema = $Model->schema();
|
||||
$valueInsert[] = $this->value($values[$i], $Model->getColumnType($fields[$i]), isset($schema[$fields[$i]]) ? $schema[$fields[$i]]['null'] : true);
|
||||
$valueInsert[] = $this->value($values[$i], $Model->getColumnType($fields[$i]), isset($schema[$fields[$i]]['null']) ? $schema[$fields[$i]]['null'] : true);
|
||||
$fieldInsert[] = $this->name($fields[$i]);
|
||||
if ($fields[$i] === $Model->primaryKey) {
|
||||
$id = $values[$i];
|
||||
|
@ -1566,6 +1606,7 @@ class DboSource extends DataSource {
|
|||
// Make one pass through children and collect by parent key
|
||||
// Make second pass through parents and associate children
|
||||
$mergedByFK = array();
|
||||
if (is_array($assocResultSet)) {
|
||||
foreach ($assocResultSet as $data) {
|
||||
$fk = $data[$association][$foreignKey];
|
||||
if (! array_key_exists($fk, $mergedByFK)) {
|
||||
|
@ -1585,6 +1626,7 @@ class DboSource extends DataSource {
|
|||
$mergedByFK[$fk][] = $data[$association];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($resultSet as &$result) {
|
||||
if (!isset($result[$modelAlias])) {
|
||||
|
@ -2175,7 +2217,7 @@ class DboSource extends DataSource {
|
|||
$update = $quoted . ' = ';
|
||||
|
||||
if ($quoteValues) {
|
||||
$update .= $this->value($value, $Model->getColumnType($field), isset($schema[$field]) ? $schema[$field]['null'] : true);
|
||||
$update .= $this->value($value, $Model->getColumnType($field), isset($schema[$field]['null']) ? $schema[$field]['null'] : true);
|
||||
} elseif ($Model->getColumnType($field) === 'boolean' && (is_int($value) || is_bool($value))) {
|
||||
$update .= $this->boolean($value, true);
|
||||
} elseif (!$alias) {
|
||||
|
@ -2518,7 +2560,7 @@ class DboSource extends DataSource {
|
|||
if (!empty($conditions)) {
|
||||
return $conditions;
|
||||
}
|
||||
$exists = $Model->exists();
|
||||
$exists = $Model->exists($Model->getID());
|
||||
if (!$exists && ($conditions !== null || !empty($Model->__safeUpdateMode))) {
|
||||
return false;
|
||||
} elseif (!$exists) {
|
||||
|
@ -2576,7 +2618,12 @@ class DboSource extends DataSource {
|
|||
$virtual = array();
|
||||
foreach ($fields as $field) {
|
||||
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
|
||||
$expression = $this->_quoteFields($Model->getVirtualField($field));
|
||||
$virtualFieldExpression = $Model->getVirtualField($field);
|
||||
if (is_object($virtualFieldExpression) && $virtualFieldExpression->type == 'expression') {
|
||||
$expression = $virtualFieldExpression->value;
|
||||
} else {
|
||||
$expression = $this->_quoteFields($virtualFieldExpression);
|
||||
}
|
||||
$virtual[] = '(' . $expression . ") {$this->alias} {$virtualField}";
|
||||
}
|
||||
return $virtual;
|
||||
|
@ -2885,7 +2932,12 @@ class DboSource extends DataSource {
|
|||
|
||||
if ($Model !== null) {
|
||||
if ($Model->isVirtualField($key)) {
|
||||
$key = $this->_quoteFields($Model->getVirtualField($key));
|
||||
$virtualField = $Model->getVirtualField($key);
|
||||
if (is_object($virtualField) && $virtualField->type == 'expression') {
|
||||
$key = $virtualField->value;
|
||||
} else {
|
||||
$key = $this->_quoteFields($virtualField);
|
||||
}
|
||||
$virtual = true;
|
||||
}
|
||||
|
||||
|
@ -3034,12 +3086,12 @@ class DboSource extends DataSource {
|
|||
if (!is_array($keys)) {
|
||||
$keys = array($keys);
|
||||
}
|
||||
|
||||
$keys = array_filter($keys);
|
||||
|
||||
$result = array();
|
||||
while (!empty($keys)) {
|
||||
list($key, $dir) = each($keys);
|
||||
$key = key($keys);
|
||||
$dir = current($keys);
|
||||
array_shift($keys);
|
||||
|
||||
if (is_numeric($key)) {
|
||||
|
@ -3230,18 +3282,7 @@ class DboSource extends DataSource {
|
|||
return (int)$length;
|
||||
}
|
||||
if (in_array($type, array('enum', 'set'))) {
|
||||
$values = array_map(function ($value) {
|
||||
return trim(trim($value), '\'"');
|
||||
}, explode(',', $length));
|
||||
|
||||
$maxLength = 0;
|
||||
foreach ($values as $key => $enumValue) {
|
||||
$tmpLength = strlen($enumValue);
|
||||
if ($tmpLength > $maxLength) {
|
||||
$maxLength = $tmpLength;
|
||||
}
|
||||
}
|
||||
return $maxLength;
|
||||
return null;
|
||||
}
|
||||
return (int)$length;
|
||||
}
|
||||
|
@ -3459,14 +3500,16 @@ class DboSource extends DataSource {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!isset($this->columns[$type])) {
|
||||
if (!isset($this->columns[$type]) && substr($type, 0, 4) !== 'enum') {
|
||||
trigger_error(__d('cake_dev', 'Column type %s does not exist', $type), E_USER_WARNING);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (substr($type, 0, 4) === 'enum') {
|
||||
$out = $this->name($name) . ' ' . $type;
|
||||
} else {
|
||||
$real = $this->columns[$type];
|
||||
$out = $this->name($name) . ' ' . $real['name'];
|
||||
|
||||
if (isset($column['length'])) {
|
||||
$length = $column['length'];
|
||||
} elseif (isset($column['limit'])) {
|
||||
|
@ -3479,6 +3522,7 @@ class DboSource extends DataSource {
|
|||
if (isset($length)) {
|
||||
$out .= '(' . $length . ')';
|
||||
}
|
||||
}
|
||||
|
||||
if (($column['type'] === 'integer' || $column['type'] === 'float') && isset($column['default']) && $column['default'] === '') {
|
||||
$column['default'] = null;
|
||||
|
@ -3500,7 +3544,7 @@ class DboSource extends DataSource {
|
|||
} elseif (isset($column['null']) && $column['null'] === false) {
|
||||
$out .= ' NOT NULL';
|
||||
}
|
||||
if ($type === 'timestamp' && isset($column['default']) && strtolower($column['default']) === 'current_timestamp') {
|
||||
if (in_array($type, array('timestamp', 'datetime')) && isset($column['default']) && strtolower($column['default']) === 'current_timestamp') {
|
||||
$out = str_replace(array("'CURRENT_TIMESTAMP'", "'current_timestamp'"), 'CURRENT_TIMESTAMP', $out);
|
||||
}
|
||||
return $this->_buildFieldParameters($out, $column, 'afterDefault');
|
||||
|
|
|
@ -58,7 +58,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
/**
|
||||
* Custom database table name, or null/false if no table association is desired.
|
||||
*
|
||||
* @var string
|
||||
* @var string|false
|
||||
* @link https://book.cakephp.org/2.0/en/models/model-attributes.html#usetable
|
||||
*/
|
||||
public $useTable = null;
|
||||
|
@ -68,7 +68,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* This field is also used in `find('list')` when called with no extra parameters in the fields list
|
||||
*
|
||||
* @var string
|
||||
* @var string|false
|
||||
* @link https://book.cakephp.org/2.0/en/models/model-attributes.html#displayfield
|
||||
*/
|
||||
public $displayField = null;
|
||||
|
@ -84,7 +84,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
/**
|
||||
* Container for the data that this model gets from persistent storage (usually, a database).
|
||||
*
|
||||
* @var array
|
||||
* @var array|false
|
||||
* @link https://book.cakephp.org/2.0/en/models/model-attributes.html#data
|
||||
*/
|
||||
public $data = array();
|
||||
|
@ -632,7 +632,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
/**
|
||||
* The ID of the model record that was last inserted.
|
||||
*
|
||||
* @var int
|
||||
* @var int|string
|
||||
*/
|
||||
protected $_insertID = null;
|
||||
|
||||
|
@ -699,7 +699,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* @param bool|int|string|array $id Set this ID for this model on startup,
|
||||
* can also be an array of options, see above.
|
||||
* @param string $table Name of database table to use.
|
||||
* @param string|false $table Name of database table to use.
|
||||
* @param string $ds DataSource connection name.
|
||||
*/
|
||||
public function __construct($id = false, $table = null, $ds = null) {
|
||||
|
@ -1196,7 +1196,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
* a one-item, two-dimensional array using $one for a key and $two as its value.)
|
||||
*
|
||||
* @param string|array|SimpleXmlElement|DomNode $one Array or string of data
|
||||
* @param string $two Value string for the alternative indata method
|
||||
* @param string|false $two Value string for the alternative indata method
|
||||
* @return array|null Data with all of $one's keys and values, otherwise null.
|
||||
* @link https://book.cakephp.org/2.0/en/models/saving-your-data.html
|
||||
*/
|
||||
|
@ -1358,7 +1358,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || $data[$val][0] === '-')) {
|
||||
if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || substr($data[$val], 0, 1) === '-')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1614,7 +1614,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* @param string|array $fields String of single field name, or an array of field names.
|
||||
* @param int|string $id The ID of the record to read
|
||||
* @return array Array of database fields, or false if not found
|
||||
* @return array|false Array of database fields, or false if not found
|
||||
* @link https://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-read
|
||||
*/
|
||||
public function read($fields = null, $id = null) {
|
||||
|
@ -1648,7 +1648,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* @param string $name The name of the field to get.
|
||||
* @param array $conditions SQL conditions (defaults to NULL).
|
||||
* @param string $order SQL ORDER BY fragment.
|
||||
* @param string|array $order SQL ORDER BY fragment.
|
||||
* @return string|false Field content, or false if not found.
|
||||
* @link https://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-field
|
||||
*/
|
||||
|
@ -1824,7 +1824,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
$exists = $this->exists();
|
||||
$exists = $this->exists($this->getID());
|
||||
$dateFields = array('modified', 'updated');
|
||||
|
||||
if (!$exists) {
|
||||
|
@ -1991,7 +1991,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
*/
|
||||
protected function _isUUIDField($field) {
|
||||
$field = $this->schema($field);
|
||||
return $field['length'] == 36 && in_array($field['type'], array('string', 'binary', 'uuid'));
|
||||
return $field !== null && $field['length'] == 36 && in_array($field['type'], array('string', 'binary', 'uuid'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2696,7 +2696,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!$this->exists()) {
|
||||
if (!$this->exists($this->getID())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2801,7 +2801,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
list(, $joinModel) = pluginSplit($data['with']);
|
||||
$Model = $this->{$joinModel};
|
||||
$records = $Model->find('all', array(
|
||||
'conditions' => array($Model->escapeField($data['foreignKey']) => $id),
|
||||
'conditions' => $this->_getConditionsForDeletingLinks($Model, $id, $data),
|
||||
'fields' => $Model->primaryKey,
|
||||
'recursive' => -1,
|
||||
'callbacks' => false
|
||||
|
@ -2815,6 +2815,19 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the conditions to be applied to Model::find() when determining which HABTM records should be deleted via
|
||||
* Model::_deleteLinks()
|
||||
*
|
||||
* @param Model $Model HABTM join model instance
|
||||
* @param mixed $id The ID of the primary model which is being deleted
|
||||
* @param array $relationshipConfig The relationship config defined on the primary model
|
||||
* @return array
|
||||
*/
|
||||
protected function _getConditionsForDeletingLinks(Model $Model, $id, array $relationshipConfig) {
|
||||
return array($Model->escapeField($relationshipConfig['foreignKey']) => $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes multiple model records based on a set of conditions.
|
||||
*
|
||||
|
@ -2997,7 +3010,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
*
|
||||
* @param string $type Type of find operation (all / first / count / neighbors / list / threaded)
|
||||
* @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks)
|
||||
* @return array|null Array of records, or Null on failure.
|
||||
* @return array|int|null Array of records, int if the type is count, or Null on failure.
|
||||
* @link https://book.cakephp.org/2.0/en/models/retrieving-your-data.html
|
||||
*/
|
||||
public function find($type = 'first', $query = array()) {
|
||||
|
@ -3151,7 +3164,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
* @param string $state Either "before" or "after"
|
||||
* @param array $query Query.
|
||||
* @param array $results Results.
|
||||
* @return int The number of records found, or false
|
||||
* @return int|false The number of records found, or false
|
||||
* @see Model::find()
|
||||
*/
|
||||
protected function _findCount($state, $query, $results = array()) {
|
||||
|
@ -3495,7 +3508,7 @@ class Model extends CakeObject implements CakeEventListener {
|
|||
* Additionally it populates the validationErrors property of the model with the same array.
|
||||
*
|
||||
* @param array|string $options An optional array of custom options to be made available in the beforeValidate callback
|
||||
* @return array Array of invalid fields and their error messages
|
||||
* @return array|bool Array of invalid fields and their error messages
|
||||
* @see Model::validates()
|
||||
*/
|
||||
public function invalidFields($options = array()) {
|
||||
|
|
|
@ -257,7 +257,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
|||
}
|
||||
}
|
||||
|
||||
$exists = $model->exists();
|
||||
$exists = $model->exists($model->getID());
|
||||
$methods = $this->getMethods();
|
||||
$fields = $this->_validationList($fieldList);
|
||||
|
||||
|
@ -280,7 +280,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
|||
* why the rule failed
|
||||
*
|
||||
* @param string $field The name of the field to invalidate
|
||||
* @param string $message Validation message explaining why the rule failed, defaults to true.
|
||||
* @param string|bool $message Validation message explaining why the rule failed, defaults to true.
|
||||
* @return void
|
||||
*/
|
||||
public function invalidate($field, $message = true) {
|
||||
|
@ -594,7 +594,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
|||
$this->_parseRules();
|
||||
if ($rule === null) {
|
||||
unset($this->_fields[$field]);
|
||||
} else {
|
||||
} elseif (array_key_exists($field, $this->_fields)) {
|
||||
$this->_fields[$field]->removeRule($rule);
|
||||
}
|
||||
return $this;
|
||||
|
|
|
@ -146,7 +146,7 @@ class Permission extends AppModel {
|
|||
case -1:
|
||||
return false;
|
||||
case 0:
|
||||
continue;
|
||||
break;
|
||||
case 1:
|
||||
return true;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ class Permission extends AppModel {
|
|||
$actions = array('_' . $actions);
|
||||
}
|
||||
foreach ($actions as $action) {
|
||||
if ($action{0} !== '_') {
|
||||
if ($action[0] !== '_') {
|
||||
$action = '_' . $action;
|
||||
}
|
||||
if (!in_array($action, $permKeys, true)) {
|
||||
|
|
|
@ -25,6 +25,11 @@ App::uses('Hash', 'Utility');
|
|||
*
|
||||
* `$request['controller']` or `$request->controller`.
|
||||
*
|
||||
* @property string $plugin The plugin handling the request. Will be `null` when there is no plugin.
|
||||
* @property string $controller The controller handling the current request.
|
||||
* @property string $action The action handling the current request.
|
||||
* @property array $named Array of named parameters parsed from the URL.
|
||||
* @property array $pass Array of passed arguments parsed from the URL.
|
||||
* @package Cake.Network
|
||||
*/
|
||||
class CakeRequest implements ArrayAccess {
|
||||
|
@ -241,6 +246,7 @@ class CakeRequest implements ArrayAccess {
|
|||
* @return string URI The CakePHP request path that is being accessed.
|
||||
*/
|
||||
protected function _url() {
|
||||
$uri = '';
|
||||
if (!empty($_SERVER['PATH_INFO'])) {
|
||||
return $_SERVER['PATH_INFO'];
|
||||
} elseif (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) {
|
||||
|
@ -250,7 +256,10 @@ class CakeRequest implements ArrayAccess {
|
|||
if ($qPosition !== false && strpos($_SERVER['REQUEST_URI'], '://') > $qPosition) {
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
} else {
|
||||
$uri = substr($_SERVER['REQUEST_URI'], strlen(Configure::read('App.fullBaseUrl')));
|
||||
$baseUrl = Configure::read('App.fullBaseUrl');
|
||||
if (substr($_SERVER['REQUEST_URI'], 0, strlen($baseUrl)) === $baseUrl) {
|
||||
$uri = substr($_SERVER['REQUEST_URI'], strlen($baseUrl));
|
||||
}
|
||||
}
|
||||
} elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) {
|
||||
$uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']);
|
||||
|
@ -303,7 +312,7 @@ class CakeRequest implements ArrayAccess {
|
|||
return $this->base = $base;
|
||||
}
|
||||
|
||||
if (!$baseUrl) {
|
||||
if (empty($baseUrl)) {
|
||||
$base = dirname(env('PHP_SELF'));
|
||||
// Clean up additional / which cause following code to fail..
|
||||
$base = preg_replace('#/+#', '/', $base);
|
||||
|
@ -502,14 +511,18 @@ class CakeRequest implements ArrayAccess {
|
|||
* defined with CakeRequest::addDetector(). Any detector can be called
|
||||
* as `is($type)` or `is$Type()`.
|
||||
*
|
||||
* @param string|array $type The type of request you want to check. If an array
|
||||
* @param string|string[] $type The type of request you want to check. If an array
|
||||
* this method will return true if the request matches any type.
|
||||
* @return bool Whether or not the request is the type you are checking.
|
||||
*/
|
||||
public function is($type) {
|
||||
if (is_array($type)) {
|
||||
$result = array_map(array($this, 'is'), $type);
|
||||
return count(array_filter($result)) > 0;
|
||||
foreach ($type as $_type) {
|
||||
if ($this->is($_type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$type = strtolower($type);
|
||||
if (!isset($this->_detectors[$type])) {
|
||||
|
@ -637,8 +650,12 @@ class CakeRequest implements ArrayAccess {
|
|||
* @see CakeRequest::is()
|
||||
*/
|
||||
public function isAll(array $types) {
|
||||
$result = array_filter(array_map(array($this, 'is'), $types));
|
||||
return count($result) === count($types);
|
||||
foreach ($types as $type) {
|
||||
if (!$this->is($type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -331,7 +331,7 @@ class CakeResponse {
|
|||
* Content type to send. This can be an 'extension' that will be transformed using the $_mimetypes array
|
||||
* or a complete mime-type
|
||||
*
|
||||
* @var int
|
||||
* @var string
|
||||
*/
|
||||
protected $_contentType = 'text/html';
|
||||
|
||||
|
@ -374,7 +374,7 @@ class CakeResponse {
|
|||
* Holds all the cache directives that will be converted
|
||||
* into headers when sending the request
|
||||
*
|
||||
* @var string
|
||||
* @var array
|
||||
*/
|
||||
protected $_cacheDirectives = array();
|
||||
|
||||
|
@ -672,8 +672,9 @@ class CakeResponse {
|
|||
*
|
||||
* For more on HTTP status codes see: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1
|
||||
*
|
||||
* @return mixed associative array of the HTTP codes as keys, and the message
|
||||
* strings as values, or null of the given $code does not exist.
|
||||
* @return array|null|true associative array of the HTTP codes as keys, and the message
|
||||
* strings as values, or null of the given $code does not exist. `true` if `$code` is
|
||||
* an array of valid codes.
|
||||
* @throws CakeException If an attempt is made to add an invalid status code
|
||||
*/
|
||||
public function httpCodes($code = null) {
|
||||
|
@ -717,8 +718,8 @@ class CakeResponse {
|
|||
*
|
||||
* e.g `type(array('jpg' => 'text/plain'));`
|
||||
*
|
||||
* @param string $contentType Content type key.
|
||||
* @return mixed current content type or false if supplied an invalid content type
|
||||
* @param array|string|null $contentType Content type key.
|
||||
* @return string|false current content type or false if supplied an invalid content type
|
||||
*/
|
||||
public function type($contentType = null) {
|
||||
if ($contentType === null) {
|
||||
|
@ -854,7 +855,7 @@ class CakeResponse {
|
|||
}
|
||||
|
||||
$this->maxAge($time);
|
||||
if (!$time) {
|
||||
if ((int)$time === 0) {
|
||||
$this->_setCacheControl();
|
||||
}
|
||||
return (bool)$public;
|
||||
|
@ -1160,18 +1161,19 @@ class CakeResponse {
|
|||
* @return bool whether the response was marked as not modified or not.
|
||||
*/
|
||||
public function checkNotModified(CakeRequest $request) {
|
||||
$etags = preg_split('/\s*,\s*/', $request->header('If-None-Match'), null, PREG_SPLIT_NO_EMPTY);
|
||||
$ifNoneMatchHeader = $request->header('If-None-Match');
|
||||
$etags = array();
|
||||
if (is_string($ifNoneMatchHeader)) {
|
||||
$etags = preg_split('/\s*,\s*/', $ifNoneMatchHeader, null, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
$modifiedSince = $request->header('If-Modified-Since');
|
||||
$checks = array();
|
||||
if ($responseTag = $this->etag()) {
|
||||
$etagMatches = in_array('*', $etags) || in_array($responseTag, $etags);
|
||||
$checks[] = in_array('*', $etags) || in_array($responseTag, $etags);
|
||||
}
|
||||
if ($modifiedSince) {
|
||||
$timeMatches = strtotime($this->modified()) === strtotime($modifiedSince);
|
||||
$checks[] = strtotime($this->modified()) === strtotime($modifiedSince);
|
||||
}
|
||||
if (!isset($etagMatches, $timeMatches)) {
|
||||
return false;
|
||||
}
|
||||
$checks = compact('etagMatches', 'timeMatches');
|
||||
if (empty($checks)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1227,7 +1229,7 @@ class CakeResponse {
|
|||
*
|
||||
* `$this->cookie((array) $options)`
|
||||
*
|
||||
* @param array $options Either null to get all cookies, string for a specific cookie
|
||||
* @param array|string $options Either null to get all cookies, string for a specific cookie
|
||||
* or array to set cookie.
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -1315,11 +1317,7 @@ class CakeResponse {
|
|||
$result[] = array('preg' => '@.@', 'original' => '*');
|
||||
continue;
|
||||
}
|
||||
|
||||
$original = $preg = $domain;
|
||||
if (strpos($domain, '://') === false) {
|
||||
$preg = ($requestIsSSL ? 'https://' : 'http://') . $domain;
|
||||
}
|
||||
$original = $domain;
|
||||
$preg = '@' . str_replace('*', '.*', $domain) . '@';
|
||||
$result[] = compact('original', 'preg');
|
||||
}
|
||||
|
@ -1467,7 +1465,7 @@ class CakeResponse {
|
|||
$file->open('rb');
|
||||
|
||||
$end = $start = false;
|
||||
if ($range) {
|
||||
if ($range && is_array($range)) {
|
||||
list($start, $end) = $range;
|
||||
}
|
||||
if ($start !== false) {
|
||||
|
|
|
@ -139,7 +139,9 @@ class CakeSocket {
|
|||
'tlsv1_1_client' => 'STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT',
|
||||
'tlsv1_2_client' => 'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT',
|
||||
'tlsv1_1_server' => 'STREAM_CRYPTO_METHOD_TLSv1_1_SERVER',
|
||||
'tlsv1_2_server' => 'STREAM_CRYPTO_METHOD_TLSv1_2_SERVER'
|
||||
'tlsv1_2_server' => 'STREAM_CRYPTO_METHOD_TLSv1_2_SERVER',
|
||||
'tlsv1_3_server' => 'STREAM_CRYPTO_METHOD_TLSv1_3_SERVER',
|
||||
'tlsv1_3_client' => 'STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT'
|
||||
);
|
||||
foreach ($conditionalCrypto as $key => $const) {
|
||||
if (defined($const)) {
|
||||
|
@ -154,6 +156,18 @@ class CakeSocket {
|
|||
if (isset($this->_encryptMethods['tlsv1_2_server'])) {
|
||||
$this->_encryptMethods['tls_server'] = STREAM_CRYPTO_METHOD_TLS_SERVER | STREAM_CRYPTO_METHOD_TLSv1_1_SERVER | STREAM_CRYPTO_METHOD_TLSv1_2_SERVER;
|
||||
}
|
||||
if (isset($this->_encryptMethods['tlsv1_3_client'])) {
|
||||
$this->_encryptMethods['tls_client'] = STREAM_CRYPTO_METHOD_TLS_CLIENT |
|
||||
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT |
|
||||
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT |
|
||||
STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT;
|
||||
}
|
||||
if (isset($this->_encryptMethods['tlsv1_3_server'])) {
|
||||
$this->_encryptMethods['tls_server'] = STREAM_CRYPTO_METHOD_TLS_SERVER |
|
||||
STREAM_CRYPTO_METHOD_TLSv1_1_SERVER |
|
||||
STREAM_CRYPTO_METHOD_TLSv1_2_SERVER |
|
||||
STREAM_CRYPTO_METHOD_TLSv1_3_SERVER;
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
||||
|
|
|
@ -589,7 +589,7 @@ class CakeEmail {
|
|||
*/
|
||||
protected function _setEmail($varName, $email, $name) {
|
||||
if (!is_array($email)) {
|
||||
$this->_validateEmail($email);
|
||||
$this->_validateEmail($email, $varName);
|
||||
if ($name === null) {
|
||||
$name = $email;
|
||||
}
|
||||
|
@ -601,7 +601,7 @@ class CakeEmail {
|
|||
if (is_int($key)) {
|
||||
$key = $value;
|
||||
}
|
||||
$this->_validateEmail($key);
|
||||
$this->_validateEmail($key, $varName);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
$this->{$varName} = $list;
|
||||
|
@ -611,11 +611,12 @@ class CakeEmail {
|
|||
/**
|
||||
* Validate email address
|
||||
*
|
||||
* @param string $email Email
|
||||
* @param string $email Email address to validate
|
||||
* @param string $context Which property was set
|
||||
* @return void
|
||||
* @throws SocketException If email address does not validate
|
||||
*/
|
||||
protected function _validateEmail($email) {
|
||||
protected function _validateEmail($email, $context) {
|
||||
if ($this->_emailPattern === null) {
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
return;
|
||||
|
@ -623,7 +624,10 @@ class CakeEmail {
|
|||
} elseif (preg_match($this->_emailPattern, $email)) {
|
||||
return;
|
||||
}
|
||||
throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email));
|
||||
if ($email == '') {
|
||||
throw new SocketException(__d('cake_dev', 'The email set for "%s" is empty.', $context));
|
||||
}
|
||||
throw new SocketException(__d('cake_dev', 'Invalid email set for "%s". You passed "%s".', $context, $email));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -659,7 +663,7 @@ class CakeEmail {
|
|||
*/
|
||||
protected function _addEmail($varName, $email, $name) {
|
||||
if (!is_array($email)) {
|
||||
$this->_validateEmail($email);
|
||||
$this->_validateEmail($email, $varName);
|
||||
if ($name === null) {
|
||||
$name = $email;
|
||||
}
|
||||
|
@ -671,7 +675,7 @@ class CakeEmail {
|
|||
if (is_int($key)) {
|
||||
$key = $value;
|
||||
}
|
||||
$this->_validateEmail($key);
|
||||
$this->_validateEmail($key, $varName);
|
||||
$list[$key] = $value;
|
||||
}
|
||||
$this->{$varName} = array_merge($this->{$varName}, $list);
|
||||
|
@ -788,7 +792,7 @@ class CakeEmail {
|
|||
}
|
||||
if ($this->_messageId !== false) {
|
||||
if ($this->_messageId === true) {
|
||||
$headers['Message-ID'] = '<' . str_replace('-', '', CakeText::UUID()) . '@' . $this->_domain . '>';
|
||||
$headers['Message-ID'] = '<' . str_replace('-', '', CakeText::uuid()) . '@' . $this->_domain . '>';
|
||||
} else {
|
||||
$headers['Message-ID'] = $this->_messageId;
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ class HttpSocket extends CakeSocket {
|
|||
* method and provide a more granular interface.
|
||||
*
|
||||
* @param string|array $request Either an URI string, or an array defining host/uri
|
||||
* @return mixed false on error, HttpSocketResponse on success
|
||||
* @return false|HttpSocketResponse false on error, HttpSocketResponse on success
|
||||
* @throws SocketException
|
||||
*/
|
||||
public function request($request = array()) {
|
||||
|
@ -449,10 +449,9 @@ class HttpSocket extends CakeSocket {
|
|||
* @param string|array $uri URI to request. Either a string uri, or a uri array, see HttpSocket::_parseUri()
|
||||
* @param array $query Querystring parameters to append to URI
|
||||
* @param array $request An indexed array with indexes such as 'method' or uri
|
||||
* @return mixed Result of request, either false on failure or the response to the request.
|
||||
* @return false|HttpSocketResponse Result of request, either false on failure or the response to the request.
|
||||
*/
|
||||
public function get($uri = null, $query = array(), $request = array()) {
|
||||
if (!empty($query)) {
|
||||
$uri = $this->_parseUri($uri, $this->config['request']['uri']);
|
||||
if (isset($uri['query'])) {
|
||||
$uri['query'] = array_merge($uri['query'], $query);
|
||||
|
@ -460,7 +459,6 @@ class HttpSocket extends CakeSocket {
|
|||
$uri['query'] = $query;
|
||||
}
|
||||
$uri = $this->_buildUri($uri);
|
||||
}
|
||||
|
||||
$request = Hash::merge(array('method' => 'GET', 'uri' => $uri), $request);
|
||||
return $this->request($request);
|
||||
|
@ -475,10 +473,9 @@ class HttpSocket extends CakeSocket {
|
|||
* @param string|array $uri URI to request. Either a string URI, or a URI array, see HttpSocket::_parseUri()
|
||||
* @param array $query Querystring parameters to append to URI
|
||||
* @param array $request An indexed array with indexes such as 'method' or uri
|
||||
* @return mixed Result of request, either false on failure or the response to the request.
|
||||
* @return false|HttpSocketResponse Result of request, either false on failure or the response to the request.
|
||||
*/
|
||||
public function head($uri = null, $query = array(), $request = array()) {
|
||||
if (!empty($query)) {
|
||||
$uri = $this->_parseUri($uri, $this->config['request']['uri']);
|
||||
if (isset($uri['query'])) {
|
||||
$uri['query'] = array_merge($uri['query'], $query);
|
||||
|
@ -486,7 +483,6 @@ class HttpSocket extends CakeSocket {
|
|||
$uri['query'] = $query;
|
||||
}
|
||||
$uri = $this->_buildUri($uri);
|
||||
}
|
||||
|
||||
$request = Hash::merge(array('method' => 'HEAD', 'uri' => $uri), $request);
|
||||
return $this->request($request);
|
||||
|
@ -507,7 +503,7 @@ class HttpSocket extends CakeSocket {
|
|||
* @param string|array $uri URI to request. See HttpSocket::_parseUri()
|
||||
* @param array $data Array of request body data keys and values.
|
||||
* @param array $request An indexed array with indexes such as 'method' or uri
|
||||
* @return mixed Result of request, either false on failure or the response to the request.
|
||||
* @return false|HttpSocketResponse Result of request, either false on failure or the response to the request.
|
||||
*/
|
||||
public function post($uri = null, $data = array(), $request = array()) {
|
||||
$request = Hash::merge(array('method' => 'POST', 'uri' => $uri, 'body' => $data), $request);
|
||||
|
@ -520,7 +516,7 @@ class HttpSocket extends CakeSocket {
|
|||
* @param string|array $uri URI to request, See HttpSocket::_parseUri()
|
||||
* @param array $data Array of request body data keys and values.
|
||||
* @param array $request An indexed array with indexes such as 'method' or uri
|
||||
* @return mixed Result of request
|
||||
* @return false|HttpSocketResponse Result of request
|
||||
*/
|
||||
public function put($uri = null, $data = array(), $request = array()) {
|
||||
$request = Hash::merge(array('method' => 'PUT', 'uri' => $uri, 'body' => $data), $request);
|
||||
|
@ -533,7 +529,7 @@ class HttpSocket extends CakeSocket {
|
|||
* @param string|array $uri URI to request, See HttpSocket::_parseUri()
|
||||
* @param array $data Array of request body data keys and values.
|
||||
* @param array $request An indexed array with indexes such as 'method' or uri
|
||||
* @return mixed Result of request
|
||||
* @return false|HttpSocketResponse Result of request
|
||||
*/
|
||||
public function patch($uri = null, $data = array(), $request = array()) {
|
||||
$request = Hash::merge(array('method' => 'PATCH', 'uri' => $uri, 'body' => $data), $request);
|
||||
|
@ -546,7 +542,7 @@ class HttpSocket extends CakeSocket {
|
|||
* @param string|array $uri URI to request (see {@link _parseUri()})
|
||||
* @param array $data Array of request body data keys and values.
|
||||
* @param array $request An indexed array with indexes such as 'method' or uri
|
||||
* @return mixed Result of request
|
||||
* @return false|HttpSocketResponse Result of request
|
||||
*/
|
||||
public function delete($uri = null, $data = array(), $request = array()) {
|
||||
$request = Hash::merge(array('method' => 'DELETE', 'uri' => $uri, 'body' => $data), $request);
|
||||
|
@ -593,7 +589,7 @@ class HttpSocket extends CakeSocket {
|
|||
if (is_array($port)) {
|
||||
$port = $port[0];
|
||||
}
|
||||
if ($url{0} === '/') {
|
||||
if ($url[0] === '/') {
|
||||
$url = $this->config['request']['uri']['host'] . ':' . $port . $url;
|
||||
}
|
||||
if (!preg_match('/^.+:\/\/|\*|^\//', $url)) {
|
||||
|
|
|
@ -1055,7 +1055,7 @@ class Router {
|
|||
* an array of arguments to convert into a query string.
|
||||
* @param array $extra Extra querystring parameters.
|
||||
* @param bool $escape Whether or not to use escaped &
|
||||
* @return array
|
||||
* @return string|null
|
||||
*/
|
||||
public static function queryString($q, $extra = array(), $escape = false) {
|
||||
if (empty($q) && empty($extra)) {
|
||||
|
|
|
@ -38,6 +38,7 @@ class AllControllersTest extends PHPUnit_Framework_TestSuite {
|
|||
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'PagesControllerTest.php');
|
||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ComponentTest.php');
|
||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ControllerMergeVarsTest.php');
|
||||
$suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ApplicationControllerTest.php');
|
||||
return $suite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,9 +189,13 @@ class CacheTest extends CakeTestCase {
|
|||
$result = Cache::config('tests', array('engine' => 'File', 'path' => TMP . 'tests'));
|
||||
$this->assertEquals(Cache::settings('tests'), $result['settings']);
|
||||
|
||||
if ($_cacheConfigSessions !== false) {
|
||||
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
||||
}
|
||||
if ($_cacheConfigTests !== false) {
|
||||
Cache::config('tests', $_cacheConfigTests['settings']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test that calling config() sets the 'default' configuration up.
|
||||
|
|
|
@ -380,25 +380,12 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
|
||||
$this->Task->execute();
|
||||
$result = file_get_contents($this->path . DS . 'default.pot');
|
||||
|
||||
$pattern = preg_quote('#Model/PersisterOne.php:validation for field title#', '\\');
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = preg_quote('#Model/PersisterOne.php:validation for field body#', '\\');
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post title is required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "You may enter up to %s chars \(minimum is %s chars\)"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post body is required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post body is super required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$this->assertContains('Model/PersisterOne.php:validation for field title', $result);
|
||||
$this->assertContains('Model/PersisterOne.php:validation for field body', $result);
|
||||
$this->assertContains('msgid "Post title is required"', $result);
|
||||
$this->assertContains('msgid "You may enter up to %s chars (minimum is %s chars)"', $result);
|
||||
$this->assertContains('msgid "Post body is required"', $result);
|
||||
$this->assertContains('msgid "Post body is super required"', $result);
|
||||
$this->assertContains('msgid "double \\"quoted\\" validation"', $result, 'Strings with quotes not handled correctly');
|
||||
$this->assertContains("msgid \"single 'quoted' validation\"", $result, 'Strings with quotes not handled correctly');
|
||||
}
|
||||
|
@ -429,21 +416,11 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
|
||||
$this->Task->execute();
|
||||
$result = file_get_contents($this->path . DS . 'test_plugin.pot');
|
||||
|
||||
$pattern = preg_quote('#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title#', '\\');
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = preg_quote('#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field body#', '\\');
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post title is required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post body is required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post body is super required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
$this->assertContains('Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title', $result);
|
||||
$this->assertContains('Plugin/TestPlugin/Model/TestPluginPost.php:validation for field body', $result);
|
||||
$this->assertContains('msgid "Post title is required"', $result);
|
||||
$this->assertContains('msgid "Post body is required"', $result);
|
||||
$this->assertContains('msgid "Post body is super required"', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -468,24 +445,12 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
|
||||
$this->Task->execute();
|
||||
$result = file_get_contents($this->path . DS . 'test_plugin.pot');
|
||||
|
||||
$pattern = preg_quote('#Model/TestPluginPost.php:validation for field title#', '\\');
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = preg_quote('#Model/TestPluginPost.php:validation for field body#', '\\');
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post title is required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post body is required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#msgid "Post body is super required"#';
|
||||
$this->assertRegExp($pattern, $result);
|
||||
|
||||
$pattern = '#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title#';
|
||||
$this->assertNotRegExp($pattern, $result);
|
||||
$this->assertContains('Model/TestPluginPost.php:validation for field title', $result);
|
||||
$this->assertContains('Model/TestPluginPost.php:validation for field body', $result);
|
||||
$this->assertContains('msgid "Post title is required"', $result);
|
||||
$this->assertContains('msgid "Post body is required"', $result);
|
||||
$this->assertContains('msgid "Post body is super required"', $result);
|
||||
$this->assertNotContains('Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
App::uses('AppController', 'Controller');
|
||||
/**
|
||||
* TransSessionIdController class for testing session.use_trans_sid=1.
|
||||
*
|
||||
* @package Cake.Test.Case.Controller
|
||||
*/
|
||||
class TransSessionIdController extends AppController {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param CakeRequest $request Request object for this controller.
|
||||
* @param CakeResponse $response Response object for this controller.
|
||||
*/
|
||||
public function __construct($request = null, $response = null) {
|
||||
parent::__construct($request, $response);
|
||||
$ini = Configure::read('Session.ini');
|
||||
$ini['session.use_cookies'] = 0;
|
||||
$ini['session.use_only_cookies'] = 0;
|
||||
$ini['session.use_trans_sid'] = 1;
|
||||
Configure::write('Session.ini', $ini);
|
||||
}
|
||||
|
||||
/**
|
||||
* For testing redirect URL with session.use_trans_sid=1.
|
||||
*
|
||||
* @return CakeResponse|null
|
||||
*/
|
||||
public function next() {
|
||||
$sessionName = session_name();
|
||||
$sessionId = $this->Session->id();
|
||||
return $this->redirect(array(
|
||||
'controller' => 'trans_session_id',
|
||||
'action' => 'next_step',
|
||||
'?' => array(
|
||||
$sessionName => $sessionId,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* ApplicationControllerTest class for testing controllers by using ControllerTestCase.
|
||||
*
|
||||
* ApplicationControllerTest extends ControllerTestCase in contrast
|
||||
* with ControllerTest that extends CakeTestCase.
|
||||
*
|
||||
* @package Cake.Test.Case.Controller
|
||||
*/
|
||||
class ApplicationControllerTest extends ControllerTestCase {
|
||||
|
||||
/**
|
||||
* setupDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
CakeSession::destroy();
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown() {
|
||||
CakeSession::destroy();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the redirect and session config with use_trans_sid=1.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRedirect() {
|
||||
$sessionId = 'o7k64tlhil9pakp89j6d8ovlqk';
|
||||
$this->testAction('/trans_session_id/next?CAKEPHP=' . $sessionId);
|
||||
$this->assertContains('/trans_session_id/next_step?CAKEPHP=' . $sessionId, $this->headers['Location']);
|
||||
$expectedConfig = array(
|
||||
'cookie' => 'CAKEPHP',
|
||||
'timeout' => 240,
|
||||
'ini' => array(
|
||||
'session.use_trans_sid' => 1,
|
||||
'session.cookie_path' => '/',
|
||||
'session.cookie_lifetime' => 14400,
|
||||
'session.name' => 'CAKEPHP',
|
||||
'session.gc_maxlifetime' => 14400,
|
||||
'session.cookie_httponly' => 1,
|
||||
'session.use_cookies' => 0,
|
||||
'session.use_only_cookies' => 0,
|
||||
),
|
||||
'defaults' => 'php',
|
||||
'cookieTimeout' => 240,
|
||||
'cacheLimiter' => 'must-revalidate',
|
||||
);
|
||||
$actualConfig = Configure::read('Session');
|
||||
$this->assertEquals($expectedConfig, $actualConfig);
|
||||
}
|
||||
|
||||
}
|
|
@ -399,6 +399,20 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$this->assertFalse(is_object($this->Controller->data));
|
||||
}
|
||||
|
||||
/**
|
||||
* testStartupCallbackJson method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testStartupCallbackJson() {
|
||||
$_SERVER['REQUEST_METHOD'] = 'PUT';
|
||||
$_SERVER['CONTENT_TYPE'] = 'application/json';
|
||||
$this->Controller->request = $this->getMock('CakeRequest', array('_readInput'));
|
||||
$this->RequestHandler->startup($this->Controller);
|
||||
$this->assertTrue(is_array($this->Controller->data));
|
||||
$this->assertFalse(is_object($this->Controller->data));
|
||||
}
|
||||
|
||||
/**
|
||||
* testStartupCallback with charset.
|
||||
*
|
||||
|
|
|
@ -7623,25 +7623,58 @@ class MultibyteTest extends CakeTestCase {
|
|||
$expected = 'ԀԂԄԆԈԊԌԎԐԒ';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$string = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև';
|
||||
$result = mb_strtoupper($string);
|
||||
$expected = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$string = 'ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ';
|
||||
$result = mb_strtoupper($string);
|
||||
$expected = 'ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$string = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ';
|
||||
$result = mb_strtoupper($string);
|
||||
$expected = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$string = 'ωkå';
|
||||
$result = mb_strtoupper($string);
|
||||
$expected = 'ΩKÅ';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testUsingMbStrtoupperArmenian method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUsingMbStrtoupperArmenian() {
|
||||
if (extension_loaded('mbstring') && version_compare(PHP_VERSION, '7.3', '>=')) {
|
||||
$this->markTestSkipped('PHP7.3+ built-in function mb_strtoupper() behaves slightly different from Multibyte::strtoupper()');
|
||||
}
|
||||
|
||||
$string = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև';
|
||||
$result = mb_strtoupper($string);
|
||||
$expected = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testUsingMbStrtoupperDiacritic method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUsingMbStrtoupperDiacritic() {
|
||||
if (extension_loaded('mbstring') && version_compare(PHP_VERSION, '7.3', '>=')) {
|
||||
$this->markTestSkipped('PHP7.3+ built-in function mb_strtoupper() behaves slightly different from Multibyte::strtoupper()');
|
||||
}
|
||||
|
||||
$string = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ';
|
||||
$result = mb_strtoupper($string);
|
||||
$expected = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testUsingMbStrtoupperLigatures method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUsingMbStrtoupperLigatures() {
|
||||
if (extension_loaded('mbstring') && version_compare(PHP_VERSION, '7.3', '>=')) {
|
||||
$this->markTestSkipped('PHP7.3+ built-in function mb_strtoupper() behaves slightly different from Multibyte::strtoupper()');
|
||||
}
|
||||
|
||||
$string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
|
||||
$result = mb_strtoupper($string);
|
||||
|
|
|
@ -1144,6 +1144,16 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
$TestModel->bindTranslation($translations);
|
||||
|
||||
$result = $TestModel->find('first');
|
||||
$TestModel->find('first', array(
|
||||
'fields' => array(
|
||||
'TranslatedItem.title',
|
||||
),
|
||||
));
|
||||
$TestModel->find('first', array(
|
||||
'fields' => array(
|
||||
'TranslatedItem.title',
|
||||
),
|
||||
));
|
||||
$this->assertArrayHasKey('Title', $result);
|
||||
$this->assertArrayHasKey('content', $result['Title'][0]);
|
||||
$this->assertArrayNotHasKey('title', $result);
|
||||
|
@ -1445,6 +1455,8 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
|
||||
public function testBeforeFindAllI18nConditions() {
|
||||
$this->skipIf(!$this->db instanceof Mysql, 'This test is only compatible with Mysql.');
|
||||
$dbName = $this->db->config['database'];
|
||||
|
||||
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
|
||||
$TestModel = new TranslatedArticle();
|
||||
$TestModel->cacheQueries = false;
|
||||
|
@ -1461,7 +1473,7 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName,
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
|
@ -1479,7 +1491,7 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName,
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
|
@ -1527,6 +1539,8 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
|
||||
public function testBeforeFindCountI18nConditions() {
|
||||
$this->skipIf(!$this->db instanceof Mysql, 'This test is only compatible with Mysql.');
|
||||
$dbName = $this->db->config['database'];
|
||||
|
||||
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
|
||||
$TestModel = new TranslatedArticle();
|
||||
$TestModel->cacheQueries = false;
|
||||
|
@ -1543,7 +1557,7 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName,
|
||||
),
|
||||
'conditions' => array(
|
||||
'`TranslatedArticle`.`id`' => (object)array(
|
||||
|
@ -1560,7 +1574,7 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName,
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
|
|
|
@ -64,6 +64,13 @@ class MyAppSchema extends CakeSchema {
|
|||
'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1),
|
||||
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
|
||||
'updated' => array('type' => 'datetime', 'null' => true, 'default' => null),
|
||||
'status' => array(
|
||||
'type' => 'enum(\'active\',\'deleted\')',
|
||||
'null' => false,
|
||||
'default' => 'active',
|
||||
'collate' => 'utf8_unicode_ci',
|
||||
'charset' => 'utf8',
|
||||
),
|
||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)),
|
||||
);
|
||||
|
||||
|
@ -809,6 +816,14 @@ class CakeSchemaTest extends CakeTestCase {
|
|||
'posts' => array(
|
||||
'add' => array(
|
||||
'summary' => array('type' => 'text', 'null' => true, 'after' => 'body'),
|
||||
'status' => array(
|
||||
'type' => 'enum(\'active\',\'deleted\')',
|
||||
'null' => false,
|
||||
'default' => 'active',
|
||||
'collate' => 'utf8_unicode_ci',
|
||||
'charset' => 'utf8',
|
||||
'after' => 'updated',
|
||||
),
|
||||
),
|
||||
'drop' => array(
|
||||
'tableParameters' => array(),
|
||||
|
|
|
@ -356,41 +356,6 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuildColumn method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildColumn() {
|
||||
$restore = $this->Dbo->columns;
|
||||
$this->Dbo->columns = array('varchar(255)' => 1);
|
||||
$data = array(
|
||||
'name' => 'testName',
|
||||
'type' => 'varchar(255)',
|
||||
'default',
|
||||
'null' => true,
|
||||
'key',
|
||||
'comment' => 'test'
|
||||
);
|
||||
$result = $this->Dbo->buildColumn($data);
|
||||
$expected = '`testName` DEFAULT NULL COMMENT \'test\'';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$data = array(
|
||||
'name' => 'testName',
|
||||
'type' => 'varchar(255)',
|
||||
'default',
|
||||
'null' => true,
|
||||
'key',
|
||||
'charset' => 'utf8',
|
||||
'collate' => 'utf8_unicode_ci'
|
||||
);
|
||||
$result = $this->Dbo->buildColumn($data);
|
||||
$expected = '`testName` CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL';
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->Dbo->columns = $restore;
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL 4.x returns index data in a different format,
|
||||
* Using a mock ensure that MySQL 4.x output is properly parsed.
|
||||
|
@ -3080,14 +3045,6 @@ SQL;
|
|||
$expected = '5,2';
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
$result = $this->Dbo->length("enum('test','me','now')");
|
||||
$expected = 4;
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
$result = $this->Dbo->length("set('a','b','cd')");
|
||||
$expected = 2;
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
$result = $this->Dbo->length(false);
|
||||
$this->assertNull($result);
|
||||
|
||||
|
@ -3100,6 +3057,26 @@ SQL;
|
|||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the length of enum column.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLengthEnum() {
|
||||
$result = $this->Dbo->length("enum('test','me','now')");
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the length of set column.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLengthSet() {
|
||||
$result = $this->Dbo->length("set('a','b','cd')");
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuildIndex method
|
||||
*
|
||||
|
@ -3154,7 +3131,7 @@ SQL;
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBuildColumn2() {
|
||||
public function testBuildColumn() {
|
||||
$data = array(
|
||||
'name' => 'testName',
|
||||
'type' => 'string',
|
||||
|
|
|
@ -1218,4 +1218,24 @@ class PostgresTest extends CakeTestCase {
|
|||
|
||||
$this->assertEquals('"col1" uuid', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that postgres describes default columns with functions correctly.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDescribeFunctionDefault() {
|
||||
$db = $this->Dbo;
|
||||
$db->execute('CREATE TABLE test_function_default_describe (id integer PRIMARY KEY, year int default date_part(\'year\'::text, now()))');
|
||||
$data = $db->describe('test_function_default_describe');
|
||||
|
||||
$expected = array(
|
||||
'type' => 'integer',
|
||||
'null' => true,
|
||||
'default' => 'date_part(\'year\', now())',
|
||||
'length' => null,
|
||||
);
|
||||
$this->assertSame($expected, $data['year']);
|
||||
$db->execute('DROP TABLE test_function_default_describe');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1028,6 +1028,11 @@ class DboSourceTest extends CakeTestCase {
|
|||
$this->markTestSkipped('This test can only run on MySQL');
|
||||
}
|
||||
$name = $this->db->fullTableName('enum_tests');
|
||||
|
||||
$query = "DROP TABLE IF EXISTS {$name};";
|
||||
$result = $this->db->query($query);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$query = "CREATE TABLE {$name} (mood ENUM('','happy','sad','ok') NOT NULL);";
|
||||
$result = $this->db->query($query);
|
||||
$this->assertTrue($result);
|
||||
|
@ -1047,6 +1052,40 @@ class DboSourceTest extends CakeTestCase {
|
|||
), $enumResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for MySQL enum datatype for a list of Integer stored as String
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIntValueAsStringOnEnum() {
|
||||
if (!$this->db instanceof Mysql) {
|
||||
$this->markTestSkipped('This test can only run on MySQL');
|
||||
}
|
||||
$name = $this->db->fullTableName('enum_faya_tests');
|
||||
|
||||
$query = "DROP TABLE IF EXISTS {$name};";
|
||||
$result = $this->db->query($query);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$query = "CREATE TABLE {$name} (faya enum('10','20','30','40') NOT NULL);";
|
||||
$result = $this->db->query($query);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$EnumFayaTest = ClassRegistry::init('EnumFayaTest');
|
||||
$enumResult = $EnumFayaTest->save(array('faya' => '10'));
|
||||
|
||||
$query = "DROP TABLE {$name};";
|
||||
$result = $this->db->query($query);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'EnumFayaTest' => array(
|
||||
'faya' => '10',
|
||||
'id' => '0'
|
||||
)
|
||||
), $enumResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* test order to generate query order clause for virtual fields
|
||||
*
|
||||
|
@ -1650,6 +1689,42 @@ class DboSourceTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test conditionKeysToString() with virtual field
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConditionKeysToStringVirtualFieldExpression() {
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$Article->virtualFields = array(
|
||||
'extra' => $Article->getDataSource()->expression('something virtual')
|
||||
);
|
||||
$conn = $this->getMock('MockPDO', array('quote'));
|
||||
$db = new DboTestSource();
|
||||
$db->setConnection($conn);
|
||||
|
||||
$conn->expects($this->at(0))
|
||||
->method('quote')
|
||||
->will($this->returnValue('just text'));
|
||||
|
||||
$conditions = array('Article.extra' => 'just text');
|
||||
$result = $db->conditionKeysToString($conditions, true, $Article);
|
||||
$expected = "(" . $Article->virtualFields['extra']->value . ") = just text";
|
||||
$this->assertEquals($expected, $result[0]);
|
||||
|
||||
$conn->expects($this->at(0))
|
||||
->method('quote')
|
||||
->will($this->returnValue('just text'));
|
||||
$conn->expects($this->at(1))
|
||||
->method('quote')
|
||||
->will($this->returnValue('other text'));
|
||||
|
||||
$conditions = array('Article.extra' => array('just text', 'other text'));
|
||||
$result = $db->conditionKeysToString($conditions, true, $Article);
|
||||
$expected = "(" . $Article->virtualFields['extra']->value . ") IN (just text, other text)";
|
||||
$this->assertEquals($expected, $result[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test conditionKeysToString() with virtual field
|
||||
*
|
||||
|
@ -2102,12 +2177,19 @@ class DboSourceTest extends CakeTestCase {
|
|||
|
||||
$result = $this->db->length('decimal(20,3)');
|
||||
$this->assertEquals('20,3', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test length parsing of enum column.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLengthEnum() {
|
||||
$result = $this->db->length('enum("one", "longer")');
|
||||
$this->assertEquals(6, $result);
|
||||
$this->assertNull($result);
|
||||
|
||||
$result = $this->db->length("enum('One Value','ANOTHER ... VALUE ...')");
|
||||
$this->assertEquals(21, $result);
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6486,6 +6486,8 @@ class ModelReadTest extends BaseModelTest {
|
|||
|
||||
public function testBuildQueryAllI18nConditions() {
|
||||
$this->skipIf(!$this->db instanceof Mysql, 'This test is only compatible with Mysql.');
|
||||
$dbName = $this->db->config['database'];
|
||||
|
||||
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
|
||||
$TestModel = new TranslatedArticle();
|
||||
$TestModel->cacheQueries = false;
|
||||
|
@ -6502,7 +6504,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
|
@ -6520,7 +6522,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
|
@ -6556,6 +6558,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
|
||||
public function testBuildQueryCountI18nConditions() {
|
||||
$this->skipIf(!$this->db instanceof Mysql, 'This test is only compatible with Mysql.');
|
||||
$dbName = $this->db->config['database'];
|
||||
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User');
|
||||
$TestModel = new TranslatedArticle();
|
||||
$TestModel->cacheQueries = false;
|
||||
|
@ -6572,7 +6575,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName
|
||||
),
|
||||
'conditions' => array(
|
||||
'`TranslatedArticle`.`id`' => (object)array(
|
||||
|
@ -6589,7 +6592,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
'table' => (object)array(
|
||||
'tablePrefix' => '',
|
||||
'table' => 'article_i18n',
|
||||
'schemaName' => 'cakephp_test',
|
||||
'schemaName' => $dbName
|
||||
),
|
||||
'conditions' => array(
|
||||
'TranslatedArticle.id' => (object)array(
|
||||
|
|
|
@ -2007,6 +2007,9 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertTrue(isset($Validator['other']));
|
||||
$this->assertFalse(isset($Validator['other']['numeric']));
|
||||
$this->assertTrue(isset($Validator['other']['between']));
|
||||
|
||||
$Validator->remove('other');
|
||||
$Validator->remove('other', 'between');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -215,9 +215,14 @@ class CakeRequestTest extends CakeTestCase {
|
|||
$request = new CakeRequest();
|
||||
$this->assertEquals('some/path', $request->url);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = Configure::read('App.fullBaseUrl') . '/other/path?url=https://cakephp.org';
|
||||
$base = Configure::read('App.fullBaseUrl');
|
||||
$_SERVER['REQUEST_URI'] = $base . '/other/path?url=https://cakephp.org';
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('other/path', $request->url);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = str_repeat('x', strlen($base) - 4) . '://?/other/path';
|
||||
$request = new CakeRequest();
|
||||
$this->assertEquals('', $request->url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -334,23 +334,34 @@ class CakeEmailTest extends CakeTestCase {
|
|||
/**
|
||||
* testBuildInvalidData
|
||||
*
|
||||
* @dataProvider invalidEmails
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage The email set for "_to" is empty.
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidEmail($value) {
|
||||
$this->CakeEmail->to($value);
|
||||
public function testInvalidEmail() {
|
||||
$this->CakeEmail->to('');
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuildInvalidData
|
||||
*
|
||||
* @dataProvider invalidEmails
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage Invalid email set for "_from". You passed "cake.@"
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidEmailAdd($value) {
|
||||
$this->CakeEmail->addTo($value);
|
||||
public function testInvalidFrom() {
|
||||
$this->CakeEmail->from('cake.@');
|
||||
}
|
||||
|
||||
/**
|
||||
* testBuildInvalidData
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage Invalid email set for "_to". You passed "1"
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidEmailAdd() {
|
||||
$this->CakeEmail->addTo('1');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -423,7 +434,7 @@ class CakeEmailTest extends CakeTestCase {
|
|||
* @return void
|
||||
*
|
||||
* @expectedException SocketException
|
||||
* @expectedExceptionMessage Invalid email: "fail.@example.com"
|
||||
* @expectedExceptionMessage Invalid email set for "_to". You passed "fail.@example.com"
|
||||
*/
|
||||
public function testUnsetEmailPattern() {
|
||||
$email = new CakeEmail();
|
||||
|
|
|
@ -701,7 +701,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
);
|
||||
$http = $this->getMock('TestHttpSocket', array('read', 'write', 'connect', 'request'), array($request));
|
||||
|
||||
$expected = array('method' => 'GET', 'uri' => '/_test');
|
||||
$expected = array('method' => 'GET', 'uri' => 'http://localhost:5984/_test');
|
||||
$http->expects($this->at(0))->method('request')->with($expected);
|
||||
$http->get('/_test');
|
||||
|
||||
|
|
|
@ -445,7 +445,8 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
), App::RESET);
|
||||
CakePlugin::load('TestPlugin');
|
||||
ConnectionManager::create('test_secondary', array(
|
||||
'datasource' => 'Database/TestLocalDriver'
|
||||
'datasource' => 'Database/TestLocalDriver',
|
||||
'prefix' => ''
|
||||
));
|
||||
$post = $this->getMockForModel('SecondaryPost', array('save'));
|
||||
$this->assertEquals('test_secondary', $post->useDbConfig);
|
||||
|
|
|
@ -231,7 +231,6 @@ class CakeTestFixtureTest extends CakeTestCase {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
$methods = array_diff(get_class_methods('DboSource'), array('enabled'));
|
||||
$methods[] = 'connect';
|
||||
|
||||
$this->criticDb = $this->getMock('DboSource', $methods);
|
||||
$this->criticDb->fullDebug = true;
|
||||
|
|
|
@ -421,6 +421,18 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
public function testNiceTimezoneConversion() {
|
||||
date_default_timezone_set('Europe/Copenhagen'); // server timezone
|
||||
$clientTimeZone = new DateTimeZone('Asia/Bangkok');
|
||||
$clientDateTime = new DateTime('2019-01-31 10:00:00', $clientTimeZone);
|
||||
// Convert to UTC.
|
||||
$actual = CakeTime::nice($clientDateTime, 'UTC', '%Y-%m-%d %H:%M:%S');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $clientDateTime->format('Y-m-d H:i:s');
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
/**
|
||||
* testNiceShort method
|
||||
*
|
||||
|
@ -966,23 +978,44 @@ class CakeTimeTest extends CakeTestCase {
|
|||
*/
|
||||
public function testFromStringWithDateTime() {
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
$date = new DateTime('+1 hour', new DateTimeZone('America/New_York'));
|
||||
$result = $this->Time->fromString($date, 'UTC');
|
||||
$date->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $date->format('U') + $date->getOffset();
|
||||
|
||||
$this->assertWithinMargin($expected, $result, 1);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
public function testFromStringWithDateTimeAsia() {
|
||||
date_default_timezone_set('Australia/Melbourne');
|
||||
|
||||
$date = new DateTime('+1 hour', new DateTimeZone('America/New_York'));
|
||||
$result = $this->Time->fromString($date, 'Asia/Kuwait');
|
||||
|
||||
$date->setTimezone(new DateTimeZone('Asia/Kuwait'));
|
||||
$expected = $date->format('U') + $date->getOffset();
|
||||
$this->assertWithinMargin($expected, $result, 1);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
public function testFromStringTimezoneConversionToUTC() {
|
||||
date_default_timezone_set('Europe/Copenhagen'); // server timezone
|
||||
$clientTimeZone = new DateTimeZone('Asia/Bangkok');
|
||||
$clientDateTime = new DateTime('2019-01-31 10:00:00', $clientTimeZone);
|
||||
// Convert to UTC.
|
||||
$actual = CakeTime::fromString($clientDateTime, 'UTC');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $clientDateTime->getTimestamp() + $clientDateTime->getOffset(); // 1548903600
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
public function testFromStringUTCtoCopenhagen() {
|
||||
date_default_timezone_set('UTC'); // server timezone
|
||||
$clientTimeZone = new DateTimeZone('UTC');
|
||||
$clientDateTime = new DateTime('2012-01-01 10:00:00', $clientTimeZone);
|
||||
$actual = CakeTime::fromString($clientDateTime, 'Europe/Copenhagen');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('Europe/Copenhagen'));
|
||||
$expected = $clientDateTime->getTimestamp() + $clientDateTime->getOffset(); // 1325415600
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
|
@ -998,6 +1031,24 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$this->assertEquals($result, $date->format('U'));
|
||||
}
|
||||
|
||||
public function testConvertToBangkok() {
|
||||
$serverTimeZoneName = 'Europe/Copenhagen';
|
||||
date_default_timezone_set($serverTimeZoneName);
|
||||
|
||||
$serverTimeZone = new DateTimeZone($serverTimeZoneName);
|
||||
$DateTime = new DateTime('2019-01-31 04:00:00', $serverTimeZone);
|
||||
$serverTimestamp = $DateTime->getTimestamp() + $DateTime->getOffset(); // 1548907200
|
||||
|
||||
$clientTimeZoneName = 'Asia/Bangkok';
|
||||
$clientTimeZone = new DateTimeZone($clientTimeZoneName);
|
||||
$DateTime->setTimezone($clientTimeZone);
|
||||
$expected = $DateTime->getTimestamp() + $DateTime->getOffset(); // 1548928800
|
||||
|
||||
$actual = CakeTime::convert($serverTimestamp, $clientTimeZoneName);
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
/**
|
||||
* test converting time specifiers using a time definition localfe file
|
||||
*
|
||||
|
@ -1149,6 +1200,28 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testI18nFormatTimezoneConversionToUTC() {
|
||||
date_default_timezone_set('Europe/Copenhagen'); // server timezone
|
||||
$clientTimeZone = new DateTimeZone('Asia/Bangkok');
|
||||
$clientDateTime = new DateTime('2019-01-31 10:00:00', $clientTimeZone);
|
||||
// Convert to UTC.
|
||||
$actual = CakeTime::i18nFormat($clientDateTime, '%Y-%m-%d %H:%M:%S', false, 'UTC');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $clientDateTime->format('Y-m-d H:i:s');
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
public function testI18nFormatUTCtoCopenhagen() {
|
||||
date_default_timezone_set('UTC');
|
||||
$clientTimeZone = new DateTimeZone('UTC');
|
||||
$clientDateTime = new DateTime('2012-01-01 10:00:00', $clientTimeZone);
|
||||
$actual = CakeTime::i18nFormat($clientDateTime, '%Y-%m-%d %H:%M', false, 'Europe/Copenhagen');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('Europe/Copenhagen'));
|
||||
$expected = $clientDateTime->format('Y-m-d H:i');
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test new format() syntax which inverts first and second parameters
|
||||
*
|
||||
|
@ -1217,7 +1290,7 @@ class CakeTimeTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCorrectTimezoneConversion() {
|
||||
public function testCorrectTimezoneConversionAsString() {
|
||||
date_default_timezone_set('UTC');
|
||||
$date = '2012-01-01 10:00:00';
|
||||
$converted = CakeTime::format($date, '%Y-%m-%d %H:%M', '', 'Europe/Copenhagen');
|
||||
|
@ -1226,4 +1299,27 @@ class CakeTimeTest extends CakeTestCase {
|
|||
$this->assertEquals($expected->format('Y-m-d H:i'), $converted);
|
||||
}
|
||||
|
||||
public function testCorrectTimezoneConversionAsObject() {
|
||||
date_default_timezone_set('UTC');
|
||||
$clientTimeZone = new DateTimeZone('UTC');
|
||||
$date = '2012-01-01 10:00:00';
|
||||
$clientDateTime = new DateTime($date, $clientTimeZone);
|
||||
$converted = CakeTime::format($clientDateTime, '%Y-%m-%d %H:%M', '', 'Europe/Copenhagen');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('Europe/Copenhagen'));
|
||||
$expected = $clientDateTime->format('Y-m-d H:i');
|
||||
$this->assertEquals($expected, $converted);
|
||||
}
|
||||
|
||||
public function testFormatTimezoneConversionToUTC() {
|
||||
date_default_timezone_set('Europe/Copenhagen'); // server timezone
|
||||
$clientTimeZone = new DateTimeZone('Asia/Bangkok');
|
||||
$clientDateTime = new DateTime('2019-01-31 10:00:00', $clientTimeZone);
|
||||
// Convert to UTC.
|
||||
$actual = CakeTime::format($clientDateTime, '%Y-%m-%d %H:%M:%S', false, 'UTC');
|
||||
$clientDateTime->setTimezone(new DateTimeZone('UTC'));
|
||||
$expected = $clientDateTime->format('Y-m-d H:i:s');
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->_restoreSystemTimezone();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -358,7 +358,7 @@ class SecurityTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that encrypted strings are comatible between the mcrypt and openssl engine.
|
||||
* Tests that encrypted strings are compatible between the mcrypt and openssl engine.
|
||||
*
|
||||
* @dataProvider plainTextProvider
|
||||
* @param string $txt Plain text to be encrypted.
|
||||
|
|
|
@ -2084,6 +2084,62 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validation errors with error options
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPasswordValidationWithOptions() {
|
||||
$Contact = ClassRegistry::getObject('Contact');
|
||||
$Contact->validationErrors['password'] = array('Please provide a password');
|
||||
|
||||
$result = $this->Form->input('Contact.password', array(
|
||||
'error' => array(
|
||||
'attributes' => array('class' => 'special-error-class'),
|
||||
)
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input password error'),
|
||||
'label' => array('for' => 'ContactPassword'),
|
||||
'Password',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'type' => 'password', 'name' => 'data[Contact][password]',
|
||||
'id' => 'ContactPassword', 'class' => 'form-error'
|
||||
),
|
||||
array('div' => array('class' => 'special-error-class')),
|
||||
'Please provide a password',
|
||||
'/div',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$Contact->validationErrors['password'] = array('Please provide a password<br>otherwise you will not be able to login');
|
||||
$result = $this->Form->input('Contact.password', array(
|
||||
'error' => array(
|
||||
'attributes' => array(
|
||||
'class' => 'special-error-class',
|
||||
'escape' => false,
|
||||
)
|
||||
)
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input password error'),
|
||||
'label' => array('for' => 'ContactPassword'),
|
||||
'Password',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'type' => 'password', 'name' => 'data[Contact][password]',
|
||||
'id' => 'ContactPassword', 'class' => 'form-error'
|
||||
),
|
||||
array('div' => array('class' => 'special-error-class')),
|
||||
'Please provide a password<br>otherwise you will not be able to login',
|
||||
'/div',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validation errors, when validation message is an empty string.
|
||||
*
|
||||
|
@ -7919,7 +7975,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->request->data['Contact']['published'] = '';
|
||||
$this->Form->request->data['Contact']['published'] = '';
|
||||
$result = $this->Form->year('Contact.published', 2006, 2007, array('class' => 'year'));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Contact][published][year]', 'id' => 'ContactPublishedYear', 'class' => 'year')),
|
||||
|
|
|
@ -245,7 +245,11 @@ class RssHelperTest extends CakeTestCase {
|
|||
array('title' => 'title3', 'guid' => 'http://www.example.com/guid3', 'link' => 'http://www.example.com/link3', 'description' => 'description3')
|
||||
);
|
||||
|
||||
$result = $this->Rss->items($items, create_function('$v', '$v[\'title\'] = $v[\'title\'] . \'-transformed\'; return $v;'));
|
||||
$result = $this->Rss->items($items, function ($v) {
|
||||
$v['title'] = $v['title'] . '-transformed';
|
||||
|
||||
return $v;
|
||||
});
|
||||
$expected = array(
|
||||
'<item',
|
||||
'<title', 'title1-transformed', '/title',
|
||||
|
|
|
@ -1495,13 +1495,13 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test setting a block's content to an object without __toString magic method
|
||||
*
|
||||
* This should produce a "Object of class TestObjectWithoutToString could not be converted to string" error
|
||||
* which gets thrown as a PHPUnit_Framework_Error Exception by PHPUnit.
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testBlockSetObjectWithoutToString() {
|
||||
$this->_checkException(
|
||||
'Object of class TestObjectWithoutToString could not be converted to string'
|
||||
);
|
||||
|
||||
$objectWithToString = new TestObjectWithoutToString();
|
||||
$this->View->assign('testWithObjectWithoutToString', $objectWithToString);
|
||||
}
|
||||
|
@ -1547,13 +1547,13 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test appending an object without __toString magic method to a block with append.
|
||||
*
|
||||
* This should produce a "Object of class TestObjectWithoutToString could not be converted to string" error
|
||||
* which gets thrown as a PHPUnit_Framework_Error Exception by PHPUnit.
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testBlockAppendObjectWithoutToString() {
|
||||
$this->_checkException(
|
||||
'Object of class TestObjectWithoutToString could not be converted to string'
|
||||
);
|
||||
|
||||
$object = new TestObjectWithoutToString();
|
||||
$this->View->assign('testBlock', 'Block ');
|
||||
$this->View->append('testBlock', $object);
|
||||
|
@ -1576,13 +1576,13 @@ class ViewTest extends CakeTestCase {
|
|||
/**
|
||||
* Test prepending an object without __toString magic method to a block with prepend.
|
||||
*
|
||||
* This should produce a "Object of class TestObjectWithoutToString could not be converted to string" error
|
||||
* which gets thrown as a PHPUnit_Framework_Error Exception by PHPUnit.
|
||||
*
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @return void
|
||||
*/
|
||||
public function testBlockPrependObjectWithoutToString() {
|
||||
$this->_checkException(
|
||||
'Object of class TestObjectWithoutToString could not be converted to string'
|
||||
);
|
||||
|
||||
$object = new TestObjectWithoutToString();
|
||||
$this->View->assign('test', 'Block ');
|
||||
$this->View->prepend('test', $object);
|
||||
|
@ -1839,4 +1839,12 @@ TEXT;
|
|||
$result = $this->View->get('title', $default);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
protected function _checkException($message) {
|
||||
if (version_compare(PHP_VERSION, '7.4', '>=')) {
|
||||
$this->setExpectedException('Error', $message);
|
||||
} else {
|
||||
$this->setExpectedException('PHPUnit_Framework_Error', $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,12 +77,11 @@
|
|||
* @return void
|
||||
*/
|
||||
public function delete($id = null) {
|
||||
$this->BakeArticle->id = $id;
|
||||
if (!$this->BakeArticle->exists()) {
|
||||
if (!$this->BakeArticle->exists($id)) {
|
||||
throw new NotFoundException(__('Invalid bake article'));
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
if ($this->BakeArticle->delete()) {
|
||||
if ($this->BakeArticle->delete($id)) {
|
||||
$this->Flash->success(__('The bake article has been deleted.'));
|
||||
} else {
|
||||
$this->Flash->error(__('The bake article could not be deleted. Please, try again.'));
|
||||
|
|
|
@ -71,12 +71,11 @@
|
|||
* @return void
|
||||
*/
|
||||
public function delete($id = null) {
|
||||
$this->BakeArticle->id = $id;
|
||||
if (!$this->BakeArticle->exists()) {
|
||||
if (!$this->BakeArticle->exists($id)) {
|
||||
throw new NotFoundException(__('Invalid bake article'));
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
if ($this->BakeArticle->delete()) {
|
||||
if ($this->BakeArticle->delete($id)) {
|
||||
return $this->flash(__('The bake article has been deleted.'), array('action' => 'index'));
|
||||
} else {
|
||||
return $this->flash(__('The bake article could not be deleted. Please, try again.'), array('action' => 'index'));
|
||||
|
|
|
@ -84,6 +84,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
$result = parent::run($result);
|
||||
if (!empty($this->fixtureManager)) {
|
||||
$this->fixtureManager->unload($this);
|
||||
unset($this->fixtureManager, $this->db);
|
||||
}
|
||||
|
||||
for ($i = ob_get_level(); $i < $level; ++$i) {
|
||||
|
@ -164,6 +165,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
if (isset($_GET['debug']) && $_GET['debug']) {
|
||||
ob_flush();
|
||||
}
|
||||
unset($this->_configure, $this->_pathRestore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -399,7 +401,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
$tags = (string)$tags;
|
||||
}
|
||||
$i++;
|
||||
if (is_string($tags) && $tags{0} === '<') {
|
||||
if (is_string($tags) && $tags[0] === '<') {
|
||||
$tags = array(substr($tags, 1) => array());
|
||||
} elseif (is_string($tags)) {
|
||||
$tagsTrimmed = preg_replace('/\s+/m', '', $tags);
|
||||
|
@ -866,7 +868,8 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
$availableDs = array_keys(ConnectionManager::enumConnectionObjects());
|
||||
|
||||
if ($mock->useDbConfig !== 'test' && in_array('test_' . $mock->useDbConfig, $availableDs)) {
|
||||
$mock->setDataSource('test_' . $mock->useDbConfig);
|
||||
$mock->useDbConfig = 'test_' . $mock->useDbConfig;
|
||||
$mock->setDataSource($mock->useDbConfig);
|
||||
} else {
|
||||
$mock->useDbConfig = 'test';
|
||||
$mock->setDataSource('test');
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
if (!class_exists('PHPUnit_TextUI_TestRunner')) {
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
}
|
||||
if (class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) {
|
||||
class_alias('SebastianBergmann\CodeCoverage\CodeCoverage', 'PHP_CodeCoverage');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Text', 'PHP_CodeCoverage_Report_Text');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\PHP', 'PHP_CodeCoverage_Report_PHP');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Clover', 'PHP_CodeCoverage_Report_Clover');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Html\Facade', 'PHP_CodeCoverage_Report_HTML');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Exception', 'PHP_CodeCoverage_Exception');
|
||||
}
|
||||
|
||||
App::uses('CakeFixtureManager', 'TestSuite/Fixture');
|
||||
|
||||
|
@ -45,6 +53,7 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
|
|||
* @param PHPUnit_Framework_Test $suite The test suite to run
|
||||
* @param array $arguments The CLI arguments
|
||||
* @param bool $exit Exits by default or returns the results
|
||||
* This argument is ignored if >PHPUnit5.2.0
|
||||
* @return void
|
||||
*/
|
||||
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array(), $exit = true) {
|
||||
|
@ -64,7 +73,7 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
|
|||
}
|
||||
}
|
||||
|
||||
$return = parent::doRun($suite, $arguments);
|
||||
$return = parent::doRun($suite, $arguments, $exit);
|
||||
$fixture->shutdown();
|
||||
return $return;
|
||||
}
|
||||
|
|
|
@ -95,19 +95,22 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
|||
unset($this->arguments['testFile']);
|
||||
|
||||
try {
|
||||
$result = $runner->doRun($suite, $this->arguments);
|
||||
$result = $runner->doRun($suite, $this->arguments, false);
|
||||
} catch (PHPUnit_Framework_Exception $e) {
|
||||
print $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
if ($exit) {
|
||||
if (isset($result) && $result->wasSuccessful()) {
|
||||
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
|
||||
} elseif (!isset($result) || $result->errorCount() > 0) {
|
||||
if (!isset($result) || $result->errorCount() > 0) {
|
||||
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
|
||||
}
|
||||
if ($result->failureCount() > 0) {
|
||||
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
|
||||
}
|
||||
|
||||
// Default to success even if there are warnings to match phpunit's behavior
|
||||
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,8 +16,24 @@
|
|||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Path to the tests directory of the app.
|
||||
*/
|
||||
if (!defined('TESTS')) {
|
||||
define('TESTS', APP . 'Test' . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to the test cases directory of CakePHP.
|
||||
*/
|
||||
define('CORE_TEST_CASES', CAKE . 'Test' . DS . 'Case');
|
||||
define('APP_TEST_CASES', TESTS . 'Case');
|
||||
|
||||
/**
|
||||
* Path to the test cases directory of the app.
|
||||
*/
|
||||
if (!defined('APP_TEST_CASES')) {
|
||||
define('APP_TEST_CASES', TESTS . 'Case');
|
||||
}
|
||||
|
||||
App::uses('CakeTestSuiteCommand', 'TestSuite');
|
||||
|
||||
|
@ -154,7 +170,9 @@ class CakeTestSuiteDispatcher {
|
|||
} elseif (is_file($vendor . DS . 'phpunit.phar')) {
|
||||
$backup = $GLOBALS['_SERVER']['SCRIPT_NAME'];
|
||||
$GLOBALS['_SERVER']['SCRIPT_NAME'] = '-';
|
||||
ob_start();
|
||||
$included = include_once $vendor . DS . 'phpunit.phar';
|
||||
ob_end_clean();
|
||||
$GLOBALS['_SERVER']['SCRIPT_NAME'] = $backup;
|
||||
return $included;
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
->will($this->returnValue($options['data']));
|
||||
}
|
||||
|
||||
$Dispatch = new ControllerTestDispatcher();
|
||||
$Dispatch = $this->_createDispatcher();
|
||||
foreach (Router::$routes as $route) {
|
||||
if ($route instanceof RedirectRoute) {
|
||||
$route->response = $this->getMock('CakeResponse', array('send'));
|
||||
|
@ -315,6 +315,15 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
return $this->{$options['return']};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the test dispatcher class
|
||||
*
|
||||
* @return Dispatcher
|
||||
*/
|
||||
protected function _createDispatcher() {
|
||||
return new ControllerTestDispatcher();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a mocked controller and mocks any classes passed to `$mocks`. By
|
||||
* default, `_stop()` is stubbed as is sending the response headers, so to not
|
||||
|
@ -418,4 +427,20 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
return $this->controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets some properties to free memory.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset(
|
||||
$this->contents,
|
||||
$this->controller,
|
||||
$this->headers,
|
||||
$this->result,
|
||||
$this->view,
|
||||
$this->vars
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,69 +30,24 @@ class CakeText {
|
|||
* @return string RFC 4122 UUID
|
||||
*/
|
||||
public static function uuid() {
|
||||
$node = env('SERVER_ADDR');
|
||||
|
||||
if (strpos($node, ':') !== false) {
|
||||
if (substr_count($node, '::')) {
|
||||
$node = str_replace(
|
||||
'::', str_repeat(':0000', 8 - substr_count($node, ':')) . ':', $node
|
||||
);
|
||||
}
|
||||
$node = explode(':', $node);
|
||||
$ipSix = '';
|
||||
|
||||
foreach ($node as $id) {
|
||||
$ipSix .= str_pad(base_convert($id, 16, 2), 16, 0, STR_PAD_LEFT);
|
||||
}
|
||||
$node = base_convert($ipSix, 2, 10);
|
||||
|
||||
if (strlen($node) < 38) {
|
||||
$node = null;
|
||||
} else {
|
||||
$node = crc32($node);
|
||||
}
|
||||
} elseif (empty($node)) {
|
||||
$host = env('HOSTNAME');
|
||||
|
||||
if (empty($host)) {
|
||||
$host = env('HOST');
|
||||
}
|
||||
|
||||
if (!empty($host)) {
|
||||
$ip = gethostbyname($host);
|
||||
|
||||
if ($ip === $host) {
|
||||
$node = crc32($host);
|
||||
} else {
|
||||
$node = ip2long($ip);
|
||||
}
|
||||
}
|
||||
} elseif ($node !== '127.0.0.1') {
|
||||
$node = ip2long($node);
|
||||
} else {
|
||||
$node = null;
|
||||
}
|
||||
|
||||
if (empty($node)) {
|
||||
$node = crc32(Configure::read('Security.salt'));
|
||||
}
|
||||
|
||||
if (function_exists('hphp_get_thread_id')) {
|
||||
$pid = hphp_get_thread_id();
|
||||
} elseif (function_exists('zend_thread_id')) {
|
||||
$pid = zend_thread_id();
|
||||
} else {
|
||||
$pid = getmypid();
|
||||
}
|
||||
|
||||
if (!$pid || $pid > 65535) {
|
||||
$pid = mt_rand(0, 0xfff) | 0x4000;
|
||||
}
|
||||
|
||||
list($timeMid, $timeLow) = explode(' ', microtime());
|
||||
$random = function_exists('random_int') ? 'random_int' : 'mt_rand';
|
||||
return sprintf(
|
||||
"%08x-%04x-%04x-%02x%02x-%04x%08x", (int)$timeLow, (int)substr($timeMid, 2) & 0xffff,
|
||||
mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3f) | 0x80, mt_rand(0, 0xff), $pid, $node
|
||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
// 32 bits for "time_low"
|
||||
$random(0, 65535),
|
||||
$random(0, 65535),
|
||||
// 16 bits for "time_mid"
|
||||
$random(0, 65535),
|
||||
// 12 bits before the 0100 of (version) 4 for "time_hi_and_version"
|
||||
$random(0, 4095) | 0x4000,
|
||||
// 16 bits, 8 bits for "clk_seq_hi_res",
|
||||
// 8 bits for "clk_seq_low",
|
||||
// two most significant bits holds zero and one for variant DCE1.1
|
||||
$random(0, 0x3fff) | 0x8000,
|
||||
// 48 bits for "node"
|
||||
$random(0, 65535),
|
||||
$random(0, 65535),
|
||||
$random(0, 65535)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue