From 336c750b7e65089e63277961a134e638b5700031 Mon Sep 17 00:00:00 2001 From: AD7six Date: Mon, 9 Jan 2012 23:38:32 +0100 Subject: [PATCH 1/7] Ensure the class has a constructor if there is no constructor (this means a model which does not inherit from Model) newInstance will throw an exception. --- lib/Cake/Utility/ClassRegistry.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index 89c6fd634..0284780ac 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -138,7 +138,11 @@ class ClassRegistry { if ($reflection->isAbstract() || $reflection->isInterface()) { throw new CakeException(__d('cake_dev', 'Cannot create instance of %s, as it is abstract or is an interface', $class)); } - $instance = $reflection->newInstance($settings); + if ($reflection->getConstructor()) { + $instance = $reflection->newInstance($settings); + } else { + $instance = $reflection->newInstance(); + } if ($strict) { $instance = ($instance instanceof Model) ? $instance : null; } From dbea15650bd67a1ecd0714156456fd010f4cd105 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 9 Jan 2012 21:33:13 -0500 Subject: [PATCH 2/7] Add iPad to the list of mobile clients. Fixes #2452 --- lib/Cake/Network/CakeRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 33a73d5ae..2b3e7ed75 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -104,7 +104,7 @@ class CakeRequest implements ArrayAccess { 'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'), 'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'), 'mobile' => array('env' => 'HTTP_USER_AGENT', 'options' => array( - 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', + 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' From aeda986745da388975de01330cc55146c03a4721 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 10 Jan 2012 21:01:03 -0500 Subject: [PATCH 3/7] Add additional empty() for tablePrefix. Fixes compatibility issues with plugins that worked correctly in previous point releases. Fixes #2462 --- lib/Cake/Model/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 2b2a55948..dca13e7ba 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -801,7 +801,7 @@ class Model extends Object { } if ($name === 'tablePrefix') { $this->setDataSource(); - if (property_exists($this, 'tablePrefix')) { + if (property_exists($this, 'tablePrefix') && !empty($this->tablePrefix)) { return $this->tablePrefix; } return $this->tablePrefix = null; From 32cb416ad7bf4118e85f6ffc10a20620cc0880f5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 11 Jan 2012 13:37:52 -0500 Subject: [PATCH 4/7] Replace smart quotes with ASCII equivalents. Fixes #2466 --- lib/Cake/Model/Model.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index dca13e7ba..fe5485cde 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -277,13 +277,13 @@ class Model extends Object { * ### Possible keys in association * * - `className`: the classname of the model being associated to the current model. - * If you’re defining a ‘Profile belongsTo User’ relationship, the className key should equal ‘User.’ + * If you're defining a 'Profile belongsTo User' relationship, the className key should equal 'User.' * - `foreignKey`: the name of the foreign key found in the current model. This is * especially handy if you need to define multiple belongsTo relationships. The default - * value for this key is the underscored, singular name of the other model, suffixed with ‘_id’. - * - `conditions`: An SQL fragment used to filter related model records. It’s good - * practice to use model names in SQL fragments: “User.active = 1” is always - * better than just “active = 1.” + * value for this key is the underscored, singular name of the other model, suffixed with '_id'. + * - `conditions`: An SQL fragment used to filter related model records. It's good + * practice to use model names in SQL fragments: 'User.active = 1' is always + * better than just 'active = 1.' * - `type`: the type of the join to use in the SQL query, default is LEFT which * may not fit your needs in all situations, INNER may be helpful when you want * everything from your main and associated models or nothing at all!(effective @@ -292,7 +292,7 @@ class Model extends Object { * fetched. Returns all fields by default. * - `order`: An SQL fragment that defines the sorting order for the returned associated rows. * - `counterCache`: If set to true the associated Model will automatically increase or - * decrease the “[singular_model_name]_count” field in the foreign table whenever you do + * decrease the "[singular_model_name]_count" field in the foreign table whenever you do * a save() or delete(). If its a string then its the field name to use. The value in the * counter field represents the number of related rows. * - `counterScope`: Optional conditions array to use for updating counter cache field. @@ -324,18 +324,18 @@ class Model extends Object { * ### Possible keys in association * * - `className`: the classname of the model being associated to the current model. - * If you’re defining a ‘User hasOne Profile’ relationship, the className key should equal ‘Profile.’ + * If you're defining a 'User hasOne Profile' relationship, the className key should equal 'Profile.' * - `foreignKey`: the name of the foreign key found in the other model. This is * especially handy if you need to define multiple hasOne relationships. * The default value for this key is the underscored, singular name of the - * current model, suffixed with ‘_id’. In the example above it would default to 'user_id'. - * - `conditions`: An SQL fragment used to filter related model records. It’s good - * practice to use model names in SQL fragments: “Profile.approved = 1” is - * always better than just “approved = 1.” + * current model, suffixed with '_id'. In the example above it would default to 'user_id'. + * - `conditions`: An SQL fragment used to filter related model records. It's good + * practice to use model names in SQL fragments: "Profile.approved = 1" is + * always better than just "approved = 1." * - `fields`: A list of fields to be retrieved when the associated model data is * fetched. Returns all fields by default. * - `order`: An SQL fragment that defines the sorting order for the returned associated rows. - * - `dependent`: When the dependent key is set to true, and the model’s delete() + * - `dependent`: When the dependent key is set to true, and the model's delete() * method is called with the cascade parameter set to true, associated model * records are also deleted. In this case we set it true so that deleting a * User will also delete her associated Profile. @@ -367,13 +367,13 @@ class Model extends Object { * ### Possible keys in association * * - `className`: the classname of the model being associated to the current model. - * If you’re defining a ‘User hasMany Comment’ relationship, the className key should equal ‘Comment.’ + * If you're defining a 'User hasMany Comment' relationship, the className key should equal 'Comment.' * - `foreignKey`: the name of the foreign key found in the other model. This is * especially handy if you need to define multiple hasMany relationships. The default - * value for this key is the underscored, singular name of the actual model, suffixed with ‘_id’. - * - `conditions`: An SQL fragment used to filter related model records. It’s good - * practice to use model names in SQL fragments: “Comment.status = 1” is always - * better than just “status = 1.” + * value for this key is the underscored, singular name of the actual model, suffixed with '_id'. + * - `conditions`: An SQL fragment used to filter related model records. It's good + * practice to use model names in SQL fragments: "Comment.status = 1" is always + * better than just "status = 1." * - `fields`: A list of fields to be retrieved when the associated model data is * fetched. Returns all fields by default. * - `order`: An SQL fragment that defines the sorting order for the returned associated rows. @@ -418,7 +418,7 @@ class Model extends Object { * ### Possible keys in association * * - `className`: the classname of the model being associated to the current model. - * If you're defining a ‘Recipe HABTM Tag' relationship, the className key should equal ‘Tag.' + * If you're defining a 'Recipe HABTM Tag' relationship, the className key should equal 'Tag.' * - `joinTable`: The name of the join table used in this association (if the * current table doesn't adhere to the naming convention for HABTM join tables). * - `with`: Defines the name of the model for the join table. By default CakePHP @@ -428,11 +428,11 @@ class Model extends Object { * - `foreignKey`: the name of the foreign key found in the current model. * This is especially handy if you need to define multiple HABTM relationships. * The default value for this key is the underscored, singular name of the - * current model, suffixed with ‘_id'. + * current model, suffixed with '_id'. * - `associationForeignKey`: the name of the foreign key found in the other model. * This is especially handy if you need to define multiple HABTM relationships. * The default value for this key is the underscored, singular name of the other - * model, suffixed with ‘_id'. + * model, suffixed with '_id'. * - `unique`: If true (default value) cake will first delete existing relationship * records in the foreign keys table before inserting new ones, when updating a * record. So existing associations need to be passed again when updating. From cf8c1cd93b33a5131e01df34dc4a419d4d99e0f2 Mon Sep 17 00:00:00 2001 From: Victor Yap Date: Wed, 11 Jan 2012 17:12:42 -0500 Subject: [PATCH 5/7] Return length 36 for uuid columns in Postgres.describe() When describing a Postgres native "uuid" column, the length 36 should be returned so that Model.save() will be able to correctly set $isUUID as "true" on that column. Fixes #2467 --- lib/Cake/Model/Datasource/Database/Postgres.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 3e47f52f2..73b0cd2b9 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -206,6 +206,8 @@ class Postgres extends DboSource { if ($c->type == 'character varying') { $length = null; $type = 'text'; + } else if ($c->type == 'uuid') { + $length = 36; } else { $length = intval($c->oct_length); } From 29cfdb4b41193b1cebf9aa8423e225890c98c565 Mon Sep 17 00:00:00 2001 From: Hans-Joachim Michl Date: Wed, 11 Jan 2012 15:41:21 +0100 Subject: [PATCH 6/7] Fixed wrong boundary marker for inline-files, inline-files should start new rel-boundaries, not (outer-)mixed-boundaries. Amavis spits out this error: X-Amavis-Alert: BAD HEADER MIME error: error: unexpected end of parts before epilogue --- lib/Cake/Network/Email/CakeEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 8ce813456..d34f5e0c9 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1288,7 +1288,7 @@ class CakeEmail { } $data = $this->_readFile($fileInfo['file']); - $msg[] = '--' . $this->_boundary; + $msg[] = '--rel-' . $this->_boundary; $msg[] = 'Content-Type: ' . $fileInfo['mimetype']; $msg[] = 'Content-Transfer-Encoding: base64'; $msg[] = 'Content-ID: <' . $fileInfo['contentId'] . '>'; From 4d73f4e6a10295de447c64c26bd951ac2a3b450d Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 11 Jan 2012 20:44:42 -0500 Subject: [PATCH 7/7] Fix boundaries used in multi-part messages. Inline attachments should use the multipart/related boundary. Otherwise sections will be incorrectly nested. Fixes #2413 --- lib/Cake/Network/Email/CakeEmail.php | 2 +- lib/Cake/Test/Case/Network/Email/CakeEmailTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index d34f5e0c9..bc36301cb 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1323,7 +1323,7 @@ class CakeEmail { $msg[] = '--' . $boundary; $msg[] = 'Content-Type: multipart/related; boundary="rel-' . $boundary . '"'; $msg[] = ''; - $relBoundary = 'rel-' . $boundary; + $relBoundary = $textBoundary = 'rel-' . $boundary; } if ($hasMultipleTypes) { diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 7479e1678..a3350efc2 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -865,7 +865,7 @@ class CakeEmailTest extends CakeTestCase { "\r\n" . "--alt-{$boundary}--\r\n" . "\r\n" . - "--$boundary\r\n" . + "--rel-$boundary\r\n" . "Content-Type: application/octet-stream\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-ID: \r\n" .