From 9ba285a2ad66c9c6f57a2dc8253cb03713f680fb Mon Sep 17 00:00:00 2001 From: Authman Apatira Date: Sat, 13 Apr 2013 23:14:26 -0700 Subject: [PATCH 01/19] Return the status of $model->push(). --- laravel/database/eloquent/model.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 23d25b02..63ac9b56 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -335,7 +335,7 @@ public function has_many_and_belongs_to($model, $table = null, $foreign = null, */ public function push() { - $this->save(); + if (!$this->save()) return false; // To sync all of the relationships to the database, we will simply spin through // the relationships, calling the "push" method on each of the models in that @@ -349,9 +349,11 @@ public function push() foreach ($models as $model) { - $model->push(); + if (!$model->push()) return false; } } + + return true; } /** From 852937baf4ea1a4aedfe983b495d577e2e297ea7 Mon Sep 17 00:00:00 2001 From: dotramses Date: Sat, 4 May 2013 22:28:09 +0300 Subject: [PATCH 02/19] Update migrator.php when used in a setup task. The output created didn't add a line ending. --- laravel/cli/tasks/migrate/migrator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/cli/tasks/migrate/migrator.php b/laravel/cli/tasks/migrate/migrator.php index 5913b984..fe2ce7cb 100644 --- a/laravel/cli/tasks/migrate/migrator.php +++ b/laravel/cli/tasks/migrate/migrator.php @@ -200,7 +200,7 @@ public function install() $table->primary(array('bundle', 'name')); }); - echo "Migration table created successfully."; + echo "Migration table created successfully.".PHP_EOL; } /** @@ -275,4 +275,4 @@ protected function display($migration) return $migration['bundle'].'/'.$migration['name']; } -} \ No newline at end of file +} From 3d533f03e6b10dd5809333341548b9890a79a3a5 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 4 May 2013 19:25:53 -0500 Subject: [PATCH 03/19] Fix method override. --- laravel/core.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/laravel/core.php b/laravel/core.php index 784f65d9..74e0689a 100644 --- a/laravel/core.php +++ b/laravel/core.php @@ -154,8 +154,12 @@ use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation; +RequestFoundation::enableHttpMethodParameterOverride(); + Request::$foundation = RequestFoundation::createFromGlobals(); + + /* |-------------------------------------------------------------------------- | Determine The Application Environment From 76db206551622be1560fb68349da819807350a1b Mon Sep 17 00:00:00 2001 From: fpirsch Date: Sun, 5 May 2013 15:00:23 +0300 Subject: [PATCH 04/19] fix incorrect padding with multi-byte strings As far as encrypting and paddings are concerned, we are talking about **bytes** and not **characters**. So basic strlen/substr functions must be used instead of their mbstring version. --- laravel/crypter.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/laravel/crypter.php b/laravel/crypter.php index 5cbf1101..705d939b 100644 --- a/laravel/crypter.php +++ b/laravel/crypter.php @@ -116,7 +116,7 @@ protected static function iv_size() */ protected static function pad($value) { - $pad = static::$block - (Str::length($value) % static::$block); + $pad = static::$block - (strlen($value) % static::$block); return $value .= str_repeat(chr($pad), $pad); } @@ -129,14 +129,7 @@ protected static function pad($value) */ protected static function unpad($value) { - if (MB_STRING) - { - $pad = ord(mb_substr($value, -1, 1, Config::get('application.encoding'))); - } - else - { - $pad = ord(substr($value, -1)); - } + $pad = ord(substr($value, -1)); if ($pad and $pad <= static::$block) { @@ -145,12 +138,7 @@ protected static function unpad($value) // as the padding appears to have been changed. if (preg_match('/'.chr($pad).'{'.$pad.'}$/', $value)) { - if (MB_STRING) - { - return mb_substr($value, 0, Str::length($value) - $pad, Config::get('application.encoding')); - } - - return substr($value, 0, Str::length($value) - $pad); + return substr($value, 0, strlen($value) - $pad); } // If the padding characters do not match the expected padding From bd6289b1188049b0c6644b23346540ba85eefe77 Mon Sep 17 00:00:00 2001 From: Evgeny Kovalev Date: Sun, 5 May 2013 23:51:46 +0400 Subject: [PATCH 05/19] Fixes error messages. Validation allows max number. Fix for both Russian and English. NB The bug is fixed for English version V4 already. No language files for other languages for V4. Signed-off-by: Evgeny Kovalev --- application/language/en/validation.php | 6 +++--- application/language/ru/validation.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/application/language/en/validation.php b/application/language/en/validation.php index c07e4a0d..0d053c73 100644 --- a/application/language/en/validation.php +++ b/application/language/en/validation.php @@ -46,9 +46,9 @@ "ip" => "The :attribute must be a valid IP address.", "match" => "The :attribute format is invalid.", "max" => array( - "numeric" => "The :attribute must be less than :max.", - "file" => "The :attribute must be less than :max kilobytes.", - "string" => "The :attribute must be less than :max characters.", + "numeric" => "The :attribute may not be greater than :max.", + "file" => "The :attribute may not be greater than :max kilobytes.", + "string" => "The :attribute may not be greater than :max characters.", ), "mimes" => "The :attribute must be a file of type: :values.", "min" => array( diff --git a/application/language/ru/validation.php b/application/language/ru/validation.php index 8fd15f5c..dc6a37f1 100644 --- a/application/language/ru/validation.php +++ b/application/language/ru/validation.php @@ -45,9 +45,9 @@ "ip" => "Поле :attribute должно быть полным IP-адресом.", "match" => "Поле :attribute имеет неверный формат.", "max" => array( - "numeric" => "Поле :attribute должно быть меньше :max.", - "file" => "Поле :attribute должно быть меньше :max Килобайт.", - "string" => "Поле :attribute должно быть короче :max символов.", + "numeric" => "Поле :attribute должно быть не больше :max.", + "file" => "Поле :attribute должно быть не больше :max Килобайт.", + "string" => "Поле :attribute должно быть длиннее :max символов.", ), "mimes" => "Поле :attribute должно быть файлом одного из типов: :values.", "min" => array( @@ -101,4 +101,4 @@ 'attributes' => array(), -); \ No newline at end of file +); From accbcabfcf9050b9a45960589892cda3779e66d5 Mon Sep 17 00:00:00 2001 From: Evgeny Kovalev Date: Mon, 6 May 2013 00:01:57 +0400 Subject: [PATCH 06/19] Fixes 'greater' to 'not greater'. Signed-off-by: Evgeny Kovalev --- application/language/ru/validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/language/ru/validation.php b/application/language/ru/validation.php index dc6a37f1..4be4e1a9 100644 --- a/application/language/ru/validation.php +++ b/application/language/ru/validation.php @@ -47,7 +47,7 @@ "max" => array( "numeric" => "Поле :attribute должно быть не больше :max.", "file" => "Поле :attribute должно быть не больше :max Килобайт.", - "string" => "Поле :attribute должно быть длиннее :max символов.", + "string" => "Поле :attribute должно быть не длиннее :max символов.", ), "mimes" => "Поле :attribute должно быть файлом одного из типов: :values.", "min" => array( From 96e44d908cd261d47a936e9a38b76391fa8a6bb9 Mon Sep 17 00:00:00 2001 From: Jason Funk Date: Tue, 7 May 2013 09:16:13 -0500 Subject: [PATCH 07/19] Allow the developer to set the Content-Disposition header in Response::download() --- laravel/response.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/laravel/response.php b/laravel/response.php index f3508358..ece2c354 100644 --- a/laravel/response.php +++ b/laravel/response.php @@ -202,9 +202,14 @@ public static function download($path, $name = null, $headers = array()) // off to the HttpFoundation and let it create the header text. $response = new static(File::get($path), 200, $headers); - $d = $response->disposition($name); + // If the Content-Disposition header has already been set by the + // merge above, then do not override it with out generated one. + if (!isset($headers['Content-Disposition'])) { + $d = $response->disposition($name); + $response = $response->header('Content-Disposition', $d); + } - return $response->header('Content-Disposition', $d); + return $response; } /** From 641ac8d69c91063d684555852badc45717db91bf Mon Sep 17 00:00:00 2001 From: Pavel Puchkin Date: Wed, 8 May 2013 11:39:51 +1100 Subject: [PATCH 08/19] Access foreign property in Belongs_To through a getter --- laravel/database/eloquent/relationships/belongs_to.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/database/eloquent/relationships/belongs_to.php b/laravel/database/eloquent/relationships/belongs_to.php index 0336025f..ebaca978 100644 --- a/laravel/database/eloquent/relationships/belongs_to.php +++ b/laravel/database/eloquent/relationships/belongs_to.php @@ -110,7 +110,7 @@ public function match($relationship, &$children, $parents) */ public function foreign_value() { - return $this->base->get_attribute($this->foreign); + return $this->base->{$this->foreign}; } /** @@ -126,4 +126,4 @@ public function bind($id) return $this->base; } -} \ No newline at end of file +} From 3a46721eca6562f518c65a8ecc00af8816e14da3 Mon Sep 17 00:00:00 2001 From: Pavel Puchkin Date: Wed, 8 May 2013 18:19:27 +1100 Subject: [PATCH 09/19] Even more fluent eloquent model via magic setters Now it is possible to use Eloquent's magic setters in chains. For example: $model->set_foo('foo')->take(10)->set_bar(some_function()); // ...even though setters 'foo' and 'bar' are not defined on the model --- laravel/database/eloquent/model.php | 1 + laravel/tests/cases/eloquent.test.php | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 23d25b02..b35fb1a2 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -770,6 +770,7 @@ public function __call($method, $parameters) elseif (starts_with($method, 'set_')) { $this->set_attribute(substr($method, 4), $parameters[0]); + return $this; } // Finally we will assume that the method is actually the beginning of a diff --git a/laravel/tests/cases/eloquent.test.php b/laravel/tests/cases/eloquent.test.php index ec08ed0f..6111eb46 100644 --- a/laravel/tests/cases/eloquent.test.php +++ b/laravel/tests/cases/eloquent.test.php @@ -133,6 +133,19 @@ public function testAttributeMagicSetterMethodChangesAttribute() Model::$accessible = null; } + /** + * Test the Model::__set method allows chaining. + * + * @group laravel + */ + public function testAttributeMagicSetterMethodAllowsChaining() + { + $model = new Model; + $this->assertInstanceOf('Model', $model->set_foo('foo')); + $model->set_bar('bar')->set_baz('baz'); + $this->assertEquals(array('foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz'), $model->to_array()); + } + /** * Test the Model::__get method. * @@ -288,4 +301,4 @@ public function testConvertingToArray() } -} \ No newline at end of file +} From f2f1d4d17301cde3cb62ea1f5b4cbf6ba8172f10 Mon Sep 17 00:00:00 2001 From: Pavel Puchkin Date: Wed, 8 May 2013 20:11:44 +1000 Subject: [PATCH 10/19] Return `$this` in `set_attribute` --- laravel/database/eloquent/model.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index b35fb1a2..6c0ef483 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -441,7 +441,7 @@ public function timestamp() } /** - *Updates the timestamp on the model and immediately saves it. + * Updates the timestamp on the model and immediately saves it. * * @return void */ @@ -562,11 +562,12 @@ public function get_attribute($key) * * @param string $key * @param mixed $value - * @return void + * @return Model */ public function set_attribute($key, $value) { $this->attributes[$key] = $value; + return $this; } /** @@ -769,8 +770,7 @@ public function __call($method, $parameters) } elseif (starts_with($method, 'set_')) { - $this->set_attribute(substr($method, 4), $parameters[0]); - return $this; + return $this->set_attribute(substr($method, 4), $parameters[0]); } // Finally we will assume that the method is actually the beginning of a From ae61b601b6451f7ad6a3ae6333c1c0d583d5cd57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Czy=C5=BCewski?= Date: Sat, 11 May 2013 14:16:41 +0300 Subject: [PATCH 11/19] Update .htaccess Change link in comment. (2.2 -> current) --- public/.htaccess | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/.htaccess b/public/.htaccess index 6e89138e..f6299414 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,9 +1,9 @@ # Apache configuration file -# http://httpd.apache.org/docs/2.2/mod/quickreference.html +# http://httpd.apache.org/docs/current/mod/quickreference.html # Note: ".htaccess" files are an overhead for each request. This logic should # be placed in your Apache config whenever possible. -# http://httpd.apache.org/docs/2.2/howto/htaccess.html +# http://httpd.apache.org/docs/current/howto/htaccess.html # Turning on the rewrite engine is necessary for the following rules and # features. "+FollowSymLinks" must be enabled for this to work symbolically. @@ -20,4 +20,4 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] - \ No newline at end of file + From b894cde4babc70295182f0e310811e357707041f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20van=20Dijk?= Date: Mon, 13 May 2013 12:00:09 +0200 Subject: [PATCH 12/19] Added Dutch translations for validation rules "date_format" and "required_with". --- application/language/nl/validation.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/language/nl/validation.php b/application/language/nl/validation.php index 3017d8fa..95f5f2a9 100644 --- a/application/language/nl/validation.php +++ b/application/language/nl/validation.php @@ -27,6 +27,7 @@ "countbetween" => ":attribute moet tussen :min en :max geselecteerde elementen bevatten.", "countmax" => ":attribute moet minder dan :max geselecteerde elementen bevatten.", "countmin" => ":attribute moet minimaal :min geselecteerde elementen bevatten.", + "date_format" => ":attribute moet een geldige datum formaat bevatten.", "different" => ":attribute en :other moeten verschillend zijn.", "email" => ":attribute is geen geldig e-mailadres.", "exists" => ":attribute bestaat niet.", @@ -49,6 +50,7 @@ "not_in" => "Het formaat van :attribute is ongeldig.", "numeric" => ":attribute moet een nummer zijn.", "required" => ":attribute is verplicht.", + "required_with" => ":attribute is verplicht i.c.m. :field", "same" => ":attribute en :other moeten overeenkomen.", "size" => array( "numeric" => ":attribute moet :size zijn.", From 727b69494b4938f38c9f8dad0f83920e2cc2303b Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 14 May 2013 00:41:39 -0500 Subject: [PATCH 13/19] Check arrays on Input::had. Closes #1988. --- laravel/input.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/laravel/input.php b/laravel/input.php index 84424570..7ddb1b02 100644 --- a/laravel/input.php +++ b/laravel/input.php @@ -160,6 +160,8 @@ public static function except($keys) */ public static function had($key) { + if (is_array(static::old($key))) return true; + return trim((string) static::old($key)) !== ''; } From 5d63d5ad524688fdbf55b926e256c967e50d660e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 14 May 2013 00:51:05 -0500 Subject: [PATCH 14/19] Consider protocoless URLs as valid. Closes. #1966. --- laravel/url.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/laravel/url.php b/laravel/url.php index b8fb1f46..1e006a94 100644 --- a/laravel/url.php +++ b/laravel/url.php @@ -355,6 +355,8 @@ public static function transpose($uri, $parameters) */ public static function valid($url) { + if (starts_with($url, '//')) return true; + return filter_var($url, FILTER_VALIDATE_URL) !== false; } From d1ae2324fdffc96004d8c3471accd9f98f4e1f33 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 14 May 2013 00:55:23 -0500 Subject: [PATCH 15/19] Fix returning check for Postgres. --- laravel/database/connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/database/connection.php b/laravel/database/connection.php index ec1ae884..5d2c2e11 100644 --- a/laravel/database/connection.php +++ b/laravel/database/connection.php @@ -197,7 +197,7 @@ public function query($sql, $bindings = array()) // For insert statements that use the "returning" clause, which is allowed // by database systems such as Postgres, we need to actually return the // real query result so the consumer can get the ID. - elseif (stripos($sql, 'insert') === 0 and stripos($sql, 'returning') !== false) + elseif (stripos($sql, 'insert') === 0 and stripos($sql, ') returning') !== false) { return $this->fetch($statement, Config::get('database.fetch')); } From 678b92ef85ce0258eb9a6ac57bb26fca9480e430 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 14 May 2013 01:15:47 -0500 Subject: [PATCH 16/19] putenv in test runner. --- laravel/cli/tasks/test/runner.php | 1 + 1 file changed, 1 insertion(+) diff --git a/laravel/cli/tasks/test/runner.php b/laravel/cli/tasks/test/runner.php index eb1a8625..7b18b845 100644 --- a/laravel/cli/tasks/test/runner.php +++ b/laravel/cli/tasks/test/runner.php @@ -88,6 +88,7 @@ protected function test() // strings with spaces inside should be wrapped in quotes. $esc_path = escapeshellarg($path); + putenv('LARAVEL_ENV='.Request::env()); passthru('LARAVEL_ENV='.Request::env().' phpunit --configuration '.$esc_path, $status); @unlink($path); From 82686af96f1434341edbfff2dd9f74e8eb0f9e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20van=20Dijk?= Date: Tue, 14 May 2013 08:59:59 +0200 Subject: [PATCH 17/19] Language line correction Indentation before '=>' and 'geldig' instead of 'geldige'. --- application/language/nl/validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/language/nl/validation.php b/application/language/nl/validation.php index 95f5f2a9..eedac482 100644 --- a/application/language/nl/validation.php +++ b/application/language/nl/validation.php @@ -27,7 +27,7 @@ "countbetween" => ":attribute moet tussen :min en :max geselecteerde elementen bevatten.", "countmax" => ":attribute moet minder dan :max geselecteerde elementen bevatten.", "countmin" => ":attribute moet minimaal :min geselecteerde elementen bevatten.", - "date_format" => ":attribute moet een geldige datum formaat bevatten.", + "date_format" => ":attribute moet een geldig datum formaat bevatten.", "different" => ":attribute en :other moeten verschillend zijn.", "email" => ":attribute is geen geldig e-mailadres.", "exists" => ":attribute bestaat niet.", From bee0153e3b3fd4202d8c19d0fa4d98b003428d40 Mon Sep 17 00:00:00 2001 From: Pavel Puchkin Date: Wed, 15 May 2013 18:04:47 +1200 Subject: [PATCH 18/19] Fix russian translation for 'exists' validation rule --- application/language/ru/validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/language/ru/validation.php b/application/language/ru/validation.php index 4be4e1a9..7f375023 100644 --- a/application/language/ru/validation.php +++ b/application/language/ru/validation.php @@ -38,7 +38,7 @@ "countmin" => "The :attribute must have at least :min selected elements.", "different" => "Поля :attribute и :other должны различаться.", "email" => "Поле :attribute имеет неверный формат.", - "exists" => "Выбранное значение для :attribute уже существует.", + "exists" => "Выбранное значение для :attribute не верно.", "image" => "Поле :attribute должно быть картинкой.", "in" => "Выбранное значение для :attribute не верно.", "integer" => "Поле :attribute должно быть целым числом.", From cfcd82e04aaf035476bd52fab8c5bc02ecb20a3b Mon Sep 17 00:00:00 2001 From: aeberhardo Date: Wed, 15 May 2013 19:05:04 +0200 Subject: [PATCH 19/19] Fixes variable export for Windows. Issue: https://github.com/laravel/laravel/issues/1870 Fix in commit https://github.com/laravel/laravel/commit/678b92ef85ce0258eb9a6ac57bb26fca9480e430 does not work. Signed-off-by: aeberhardo --- laravel/cli/tasks/test/runner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/cli/tasks/test/runner.php b/laravel/cli/tasks/test/runner.php index 7b18b845..60575bf5 100644 --- a/laravel/cli/tasks/test/runner.php +++ b/laravel/cli/tasks/test/runner.php @@ -89,7 +89,7 @@ protected function test() $esc_path = escapeshellarg($path); putenv('LARAVEL_ENV='.Request::env()); - passthru('LARAVEL_ENV='.Request::env().' phpunit --configuration '.$esc_path, $status); + passthru('phpunit --configuration '.$esc_path, $status); @unlink($path);