diff --git a/app/Console/cake.php b/app/Console/cake.php index ec6ee33c5..9c2751028 100644 --- a/app/Console/cake.php +++ b/app/Console/cake.php @@ -29,7 +29,7 @@ if (function_exists('ini_set')) { ini_set('include_path', $root . $ds . 'lib' . PATH_SEPARATOR . ini_get('include_path')); } -if (!include($dispatcher)) { +if (!include ($dispatcher)) { trigger_error('Could not locate CakePHP core files.', E_USER_ERROR); } unset($paths, $path, $dispatcher, $root, $ds); diff --git a/app/View/Pages/home.ctp b/app/View/Pages/home.ctp index 98533322a..d6b365a62 100644 --- a/app/View/Pages/home.ctp +++ b/app/View/Pages/home.ctp @@ -3,23 +3,15 @@ * * PHP 5 * - * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) - * Copyright (c) Cake Software Foundation, Inc. (http://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 * @package app.View.Pages * @since CakePHP(tm) v 0.10.0.1076 - * @license http://www.opensource.org/licenses/mit-license.php MIT License */ if (!Configure::read('debug')): throw new NotFoundException(); endif; + App::uses('Debugger', 'Utility'); ?>
@@ -31,11 +23,17 @@ if (Configure::read('debug') > 0): Debugger::checkSecurityKeys(); endif; ?> +1) Help me configure it 2) I don't / can't use URL rewriting
+
=')):
@@ -67,11 +65,11 @@ endif;
$settings = Cache::settings();
if (!empty($settings)):
echo '';
- echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit APP/Config/core.php ', '' . $settings['engine'] . 'Engine');
+ echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', ''. $settings['engine'] . 'Engine', 'APP/Config/core.php');
echo '';
else:
echo '';
- echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in APP/Config/core.php');
+ echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php');
echo '';
endif;
?>
@@ -88,7 +86,7 @@ endif;
echo '';
echo __d('cake_dev', 'Your database configuration file is NOT present.');
echo '
';
- echo __d('cake_dev', 'Rename APP/Config/database.php.default to APP/Config/database.php');
+ echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php');
echo '';
endif;
?>
@@ -155,9 +153,10 @@ if (isset($filePresent)):
-To change its layout, edit: APP/View/Layouts/default.ctp.
-You can also add some CSS styles for your pages at: APP/webroot/css.');
+echo __d('cake_dev', 'To change the content of this page, edit: %s.
+To change its layout, edit: %s.
+You can also add some CSS styles for your pages at: %s.',
+ 'APP/View/Pages/home.ctp', 'APP/View/Layouts/default.ctp', 'APP/webroot/css');
?>
1) Help me configure it 2) I don't / can't use URL rewriting
+
=')):
@@ -93,12 +99,12 @@ if (isset($filePresent)):
} catch (Exception $connectionError) {
$connected = false;
$errorMsg = $connectionError->getMessage();
- if (method_exists($connectionError, 'getAttributes')) {
+ if (method_exists($connectionError, 'getAttributes')):
$attributes = $connectionError->getAttributes();
- if (isset($errorMsg['message'])) {
+ if (isset($errorMsg['message'])):
$errorMsg .= '
' . $attributes['message'];
- }
- }
+ endif;
+ endif;
}
?>
@@ -119,13 +125,13 @@ if (isset($filePresent)):
';
echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.');
echo '
';
- echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding %s when configuring', '--enable-unicode-properties
');
+ echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding --enable-unicode-properties
when configuring');
echo '
diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php
index fd90a6d9e..da8c2243f 100644
--- a/lib/Cake/Controller/Component/RequestHandlerComponent.php
+++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php
@@ -518,6 +518,9 @@ class RequestHandlerComponent extends Component {
}
list($contentType) = explode(';', env('CONTENT_TYPE'));
+ if ($contentType === '') {
+ list($contentType) = explode(';', CakeRequest::header('CONTENT_TYPE'));
+ }
if (!$type) {
return $this->mapType($contentType);
}
diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php
index f414f2d65..670b71a6d 100644
--- a/lib/Cake/Model/Model.php
+++ b/lib/Cake/Model/Model.php
@@ -3499,25 +3499,23 @@ class Model extends Object implements CakeEventListener {
* @return boolean true on delete
*/
protected function _clearCache($type = null) {
- if ($type === null) {
- if (Configure::read('Cache.check') === true) {
- $assoc[] = strtolower(Inflector::pluralize($this->alias));
- $assoc[] = strtolower(Inflector::underscore(Inflector::pluralize($this->alias)));
- foreach ($this->_associations as $key => $association) {
- foreach ($this->$association as $key => $className) {
- $check = strtolower(Inflector::pluralize($className['className']));
- if (!in_array($check, $assoc)) {
- $assoc[] = strtolower(Inflector::pluralize($className['className']));
- $assoc[] = strtolower(Inflector::underscore(Inflector::pluralize($className['className'])));
- }
- }
- }
- clearCache($assoc);
- return true;
- }
- } else {
- //Will use for query cache deleting
+ if ($type !== null || Configure::read('Cache.check') !== true) {
+ return;
}
+ $assoc[] = strtolower(Inflector::pluralize($this->alias));
+ $assoc[] = Inflector::underscore(Inflector::pluralize($this->alias));
+ foreach ($this->_associations as $association) {
+ foreach ($this->$association as $className) {
+ $pluralized = strtolower(Inflector::pluralize($className['className']));
+ if (!in_array($pluralized, $assoc)) {
+ $assoc[] = $pluralized;
+ $assoc[] = Inflector::underscore(Inflector::pluralize($className['className']));
+ }
+ }
+ }
+ $assoc = array_unique($assoc);
+ clearCache($assoc);
+ return true;
}
/**
diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php
index 574985754..1a14cbc08 100644
--- a/lib/Cake/Network/CakeRequest.php
+++ b/lib/Cake/Network/CakeRequest.php
@@ -788,7 +788,10 @@ class CakeRequest implements ArrayAccess {
}
/**
- * Parse Accept* headers with qualifier options
+ * Parse Accept* headers with qualifier options.
+ *
+ * Only qualifiers will be extracted, any other accept extensions will be
+ * discarded as they are not frequently used.
*
* @param string $header
* @return array
@@ -797,14 +800,21 @@ class CakeRequest implements ArrayAccess {
$accept = array();
$header = explode(',', $header);
foreach (array_filter($header) as $value) {
- $prefPos = strpos($value, ';');
- if ($prefPos !== false) {
- $prefValue = substr($value, strpos($value, '=') + 1);
- $value = trim(substr($value, 0, $prefPos));
- } else {
- $prefValue = '1.0';
- $value = trim($value);
+ $prefValue = '1.0';
+ $value = trim($value);
+
+ $semiPos = strpos($value, ';');
+ if ($semiPos !== false) {
+ $params = explode(';', $value);
+ $value = trim($params[0]);
+ foreach ($params as $param) {
+ $qPos = strpos($param, 'q=');
+ if ($qPos !== false) {
+ $prefValue = substr($param, $qPos + 2);
+ }
+ }
}
+
if (!isset($accept[$prefValue])) {
$accept[$prefValue] = array();
}
diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php
index 3db176327..f6a0ed2e5 100644
--- a/lib/Cake/Network/CakeResponse.php
+++ b/lib/Cake/Network/CakeResponse.php
@@ -250,9 +250,9 @@ class CakeResponse {
'f4b' => 'audio/mp4',
'gif' => 'image/gif',
'ief' => 'image/ief',
- 'jpe' => 'image/jpeg',
- 'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
'pbm' => 'image/x-portable-bitmap',
'pgm' => 'image/x-portable-graymap',
'png' => 'image/png',
diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php
index 63ced76f3..96631e335 100644
--- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php
+++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php
@@ -279,6 +279,19 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->assertNull($this->RequestHandler->ext);
}
+/**
+ * Test that the headers sent by firefox are not treated as XML requests.
+ *
+ * @return void
+ */
+ public function testInititalizeFirefoxHeaderNotXml() {
+ $_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8';
+ Router::parseExtensions('xml', 'json');
+
+ $this->RequestHandler->initialize($this->Controller);
+ $this->assertNull($this->RequestHandler->ext);
+ }
+
/**
* Test that a type mismatch doesn't incorrectly set the ext
*
@@ -603,6 +616,16 @@ class RequestHandlerComponentTest extends CakeTestCase {
$result = $this->RequestHandler->requestedWith(array('rss', 'atom'));
$this->assertFalse($result);
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ unset($_SERVER['CONTENT_TYPE']);
+ $_SERVER['HTTP_CONTENT_TYPE'] = 'application/json';
+
+ $result = $this->RequestHandler->requestedWith(array('json', 'xml'));
+ $this->assertEquals('json', $result);
+
+ $result = $this->RequestHandler->requestedWith(array('rss', 'atom'));
+ $this->assertFalse($result);
+
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*';
$this->assertTrue($this->RequestHandler->isXml());
$this->assertFalse($this->RequestHandler->isAtom());
diff --git a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php
index 8f5e684d8..79461305e 100644
--- a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php
+++ b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php
@@ -68,7 +68,7 @@ class CakeEventTestListener {
*
* @package Cake.Test.Case.Event
*/
-class CustomTestEventListerner extends CakeEventTestListener implements CakeEventListener {
+class CustomTestEventListener extends CakeEventTestListener implements CakeEventListener {
public function implementedEvents() {
return array(
@@ -325,7 +325,7 @@ class CakeEventManagerTest extends CakeTestCase {
*/
public function testAttachSubscriber() {
$manager = new CakeEventManager;
- $listener = $this->getMock('CustomTestEventListerner', array('secondListenerFunction'));
+ $listener = $this->getMock('CustomTestEventListener', array('secondListenerFunction'));
$manager->attach($listener);
$event = new CakeEvent('fake.event');
@@ -339,7 +339,7 @@ class CakeEventManagerTest extends CakeTestCase {
$manager->dispatch($event);
$manager = new CakeEventManager;
- $listener = $this->getMock('CustomTestEventListerner', array('listenerFunction', 'thirdListenerFunction'));
+ $listener = $this->getMock('CustomTestEventListener', array('listenerFunction', 'thirdListenerFunction'));
$manager->attach($listener);
$event = new CakeEvent('multiple.handlers');
$listener->expects($this->once())->method('listenerFunction')->with($event);
@@ -354,7 +354,7 @@ class CakeEventManagerTest extends CakeTestCase {
*/
public function testDetachSubscriber() {
$manager = new CakeEventManager;
- $listener = $this->getMock('CustomTestEventListerner', array('secondListenerFunction'));
+ $listener = $this->getMock('CustomTestEventListener', array('secondListenerFunction'));
$manager->attach($listener);
$expected = array(
array('callable' => array($listener, 'secondListenerFunction'), 'passParams' => true)
diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php
index fe45ed922..c1760d293 100644
--- a/lib/Cake/Test/Case/Network/CakeRequestTest.php
+++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php
@@ -1164,6 +1164,41 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
+/**
+ * Test parsing accept ignores index param
+ *
+ * @return void
+ */
+ public function testParseAcceptIgnoreAcceptExtensions() {
+ $_SERVER['HTTP_ACCEPT'] = 'application/json;level=1, text/plain, */*';
+
+ $request = new CakeRequest('/', false);
+ $result = $request->parseAccept();
+ $expected = array(
+ '1.0' => array('application/json', 'text/plain', '*/*'),
+ );
+ $this->assertEquals($expected, $result);
+ }
+
+/**
+ * Test that parsing accept headers with invalid syntax works.
+ *
+ * The header used is missing a q value for application/xml.
+ *
+ * @return void
+ */
+ public function testParseAcceptInvalidSyntax() {
+ $_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8';
+ $request = new CakeRequest('/', false);
+ $result = $request->parseAccept();
+ $expected = array(
+ '1.0' => array('text/html', 'application/xhtml+xml', 'application/xml', 'image/jpeg'),
+ '0.9' => array('image/*'),
+ '0.8' => array('*/*'),
+ );
+ $this->assertEquals($expected, $result);
+ }
+
/**
* Test baseUrl and webroot with ModRewrite
*
diff --git a/lib/Cake/Test/Case/Utility/StringTest.php b/lib/Cake/Test/Case/Utility/StringTest.php
index efe89f033..1d54775ca 100644
--- a/lib/Cake/Test/Case/Utility/StringTest.php
+++ b/lib/Cake/Test/Case/Utility/StringTest.php
@@ -314,6 +314,67 @@ class StringTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
+/**
+ * test that wordWrap() works the same as built-in wordwrap function
+ *
+ * @dataProvider wordWrapProvider
+ * @return void
+ */
+ public function testWordWrap($text, $width, $break = "\n", $cut = false) {
+ $result = String::wordWrap($text, $width, $break, $cut);
+ $expected = wordwrap($text, $width, $break, $cut);
+ $this->assertTextEquals($expected, $result, 'Text not wrapped same as built-in function.');
+ }
+
+/**
+ * data provider for testWordWrap method
+ *
+ * @return array
+ */
+ public function wordWrapProvider() {
+ return array(
+ array(
+ 'The quick brown fox jumped over the lazy dog.',
+ 33
+ ),
+ array(
+ 'A very long woooooooooooord.',
+ 8
+ ),
+ array(
+ 'A very long woooooooooooord. Right.',
+ 8
+ ),
+ );
+ }
+
+/**
+ * test that wordWrap() properly handle unicode strings.
+ *
+ * @return void
+ */
+ public function testWordWrapUnicodeAware() {
+ $text = 'Но вим омниюм факёльиси элыктрам, мюнырэ лэгыры векж ыт. Выльёт квюандо нюмквуам ты кюм. Зыд эю рыбюм.';
+ $result = String::wordWrap($text, 33, "\n", true);
+ $expected = <<