diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index acf88baa9..d6289b2aa 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -211,7 +211,7 @@ class App { * * @param string $type type of path * @param string $plugin name of plugin - * @return string array + * @return array * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::path */ public static function path($type, $plugin = null) { @@ -386,7 +386,7 @@ class App { * `App::core('Cache/Engine'); will return the full path to the cache engines package` * * @param string $type - * @return string full path to package + * @return array full path to package * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::core */ public static function core($type) { @@ -598,7 +598,7 @@ class App { * based on Inflector::underscore($name) . ".$ext"; * @param array $search paths to search for files, array('path 1', 'path 2', 'path 3'); * @param string $file full name of the file to search for including extension - * @param boolean $return, return the loaded file, the file must have a return + * @param boolean $return Return the loaded file, the file must have a return * statement in it to work: return $variable; * @return boolean true if Class is already in memory or if file is found and loaded, false if not */ diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 6b62df43b..bc72c8e8e 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -369,7 +369,10 @@ class TranslateBehavior extends ModelBehavior { /** * Bind translation for fields, optionally with hasMany association for - * fake field + * fake field. + * + * *Note* You should avoid binding translations that overlap existing model properties. + * This can cause un-expected and un-desirable behavior. * * @param Model $model instance of model * @param string|array $fields string with field or array(field1, field2=>AssocName, field3) @@ -392,6 +395,11 @@ class TranslateBehavior extends ModelBehavior { $field = $key; $association = $value; } + if ($association === 'name') { + throw new CakeException( + __d('cake_dev', 'You cannot bind a translation named "name".') + ); + } if (array_key_exists($field, $this->settings[$model->alias])) { unset($this->settings[$model->alias][$field]); diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 55fda4e13..66376525e 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -107,7 +107,7 @@ class CakeRequest implements ArrayAccess { 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', - 'webOS', 'Windows CE', 'Xiino' + 'webOS', 'Windows CE', 'Windows Phone OS', t'Xiino' )), 'requested' => array('param' => 'requested', 'value' => 1) ); diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index 8c342a5e4..89fa6a864 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -868,4 +868,16 @@ class TranslateBehaviorTest extends CakeTestCase { $this->assertFalse($result); } + +/** + * Test that an exception is raised when you try to over-write the name attribute. + * + * @expectedException CakeException + * @return void + */ + public function testExceptionOnNameTranslation() { + $this->loadFixtures('Translate', 'TranslatedItem'); + $TestModel = new TranslatedItem(); + $TestModel->bindTranslation(array('name' => 'name')); + } } diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index a1f04698e..bb825c784 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -636,6 +636,10 @@ class CakeRequestTest extends CakeTestCase { $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 5.1; rv:2.0b6pre) Gecko/20100902 Firefox/4.0b6pre Fennec/2.0b1pre'; $this->assertTrue($request->is('mobile')); $this->assertTrue($request->isMobile()); + + $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; OMNIA7)'; + $this->assertTrue($request->is('mobile')); + $this->assertTrue($request->isMobile()); } /**