From 818efc2e160aa56e8475219faed24542e80ee25d Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Thu, 8 Feb 2018 19:38:44 +0100 Subject: [PATCH] [5.6] Form method of hidden input '_method' is preserved on next request (#486) * Form method of hidden input '_method' is preserved on next request E.G. When you submitted data across a form with a 'PATCH' method and then in a second submit you use a form with a 'DELETE' method, the FormBuilder::getValueAttribute() method use the previous value of the hidden input '_method'. So the value is replaced by 'PATCH' instead of the 'DELETE' value. * Drop PHP 7.1 and add PHP 7.2 in Travis CI config Because Laravel 5.6 require at least PHP 7.1.3 * Fix PHP 7.2 Warning with count() Otherwise a PHP Warning is thrown: count(): Parameter must be an array or an object that implements Countable See http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.warn-on-non-countable-types * Bump Mockery version to support PHP 7.2 --- .travis.yml | 1 + composer.json | 2 +- src/FormBuilder.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index caba7c8..ccffcd9 100755 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: php php: - 7.1 + - 7.2 sudo: false diff --git a/composer.json b/composer.json index 6012ec0..119fce8 100755 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ }, "require-dev": { "illuminate/database": "5.6.*", - "mockery/mockery": "~0.9.4", + "mockery/mockery": "~1.0", "phpunit/phpunit": "~5.4" }, "autoload": { diff --git a/src/FormBuilder.php b/src/FormBuilder.php index 01a8d88..3cfc645 100644 --- a/src/FormBuilder.php +++ b/src/FormBuilder.php @@ -1184,7 +1184,7 @@ class FormBuilder } $request = $this->request($name); - if (! is_null($request)) { + if (! is_null($request) && $name != '_method') { return $request; } @@ -1268,7 +1268,7 @@ class FormBuilder */ public function oldInputIsEmpty() { - return (isset($this->session) && count($this->session->getOldInput()) === 0); + return (isset($this->session) && count((array) $this->session->getOldInput()) === 0); } /**