From 875ecb33aaf06f9bc26cff03151588ddb7947af7 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Tue, 26 Sep 2017 13:22:15 -0400 Subject: [PATCH] Pull in mergeable upstream laravel updates --- app/Console/Kernel.php | 4 ++- app/Exceptions/Handler.php | 36 +++++++------------ .../Controllers/Auth/RegisterController.php | 8 ++--- app/Http/Kernel.php | 1 + app/Http/Middleware/EncryptCookies.php | 4 +-- app/Http/Middleware/TrimStrings.php | 4 +-- app/Http/Middleware/TrustProxies.php | 29 +++++++++++++++ app/Http/Middleware/VerifyCsrfToken.php | 4 +-- app/Providers/EventServiceProvider.php | 2 +- artisan | 6 ++-- bootstrap/autoload.php | 34 ------------------ config/database.php | 12 +++++++ config/filesystems.php | 4 +-- config/mail.php | 13 +++++++ .../{ModelFactory.php => UserFactory.php} | 11 +++--- phpunit.xml | 6 ++-- public/.htaccess | 5 +-- public/index.php | 6 ++-- resources/lang/en/validation.php | 4 ++- storage/framework/testing/.gitignore | 2 ++ tests/Feature/ExampleTest.php | 4 +-- tests/Unit/ExampleTest.php | 3 +- 22 files changed, 110 insertions(+), 92 deletions(-) create mode 100644 app/Http/Middleware/TrustProxies.php delete mode 100644 bootstrap/autoload.php rename database/factories/{ModelFactory.php => UserFactory.php} (55%) create mode 100644 storage/framework/testing/.gitignore diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 622e774..a8c5158 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -29,12 +29,14 @@ class Kernel extends ConsoleKernel } /** - * Register the Closure based commands for the application. + * Register the commands for the application. * * @return void */ protected function commands() { + $this->load(__DIR__.'/Commands'); + require base_path('routes/console.php'); } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 21c9784..7e2563a 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,23 +3,27 @@ namespace App\Exceptions; use Exception; -use Illuminate\Auth\AuthenticationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler { /** - * A list of the exception types that should not be reported. + * A list of the exception types that are not reported. * * @var array */ protected $dontReport = [ - \Illuminate\Auth\AuthenticationException::class, - \Illuminate\Auth\Access\AuthorizationException::class, - \Symfony\Component\HttpKernel\Exception\HttpException::class, - \Illuminate\Database\Eloquent\ModelNotFoundException::class, - \Illuminate\Session\TokenMismatchException::class, - \Illuminate\Validation\ValidationException::class, + // + ]; + + /** + * A list of the inputs that are never flashed for validation exceptions. + * + * @var array + */ + protected $dontFlash = [ + 'password', + 'password_confirmation', ]; /** @@ -46,20 +50,4 @@ class Handler extends ExceptionHandler { return parent::render($request, $exception); } - - /** - * Convert an authentication exception into an unauthenticated response. - * - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Auth\AuthenticationException $exception - * @return \Illuminate\Http\Response - */ - protected function unauthenticated($request, AuthenticationException $exception) - { - if ($request->expectsJson()) { - return response()->json(['error' => 'Unauthenticated.'], 401); - } - - return redirect()->guest('login'); - } } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 716d1e9..7714498 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -48,9 +48,9 @@ class RegisterController extends Controller protected function validator(array $data) { return Validator::make($data, [ - 'name' => 'required|max:255', - 'email' => 'required|email|max:255|unique:users', - 'password' => 'required|min:6|confirmed', + 'name' => 'required|string|max:255', + 'email' => 'required|string|email|max:255|unique:users', + 'password' => 'required|string|min:6|confirmed', ]); } @@ -58,7 +58,7 @@ class RegisterController extends Controller * Create a new user instance after a valid registration. * * @param array $data - * @return User + * @return \App\User */ protected function create(array $data) { diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 66d34c3..93bf68b 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -18,6 +18,7 @@ class Kernel extends HttpKernel \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + \App\Http\Middleware\TrustProxies::class, ]; /** diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index 3aa15f8..033136a 100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php @@ -2,9 +2,9 @@ namespace App\Http\Middleware; -use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter; +use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; -class EncryptCookies extends BaseEncrypter +class EncryptCookies extends Middleware { /** * The names of the cookies that should not be encrypted. diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php index 943e9a4..5a50e7b 100644 --- a/app/Http/Middleware/TrimStrings.php +++ b/app/Http/Middleware/TrimStrings.php @@ -2,9 +2,9 @@ namespace App\Http\Middleware; -use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer; +use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; -class TrimStrings extends BaseTrimmer +class TrimStrings extends Middleware { /** * The names of the attributes that should not be trimmed. diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php new file mode 100644 index 0000000..ef1c00d --- /dev/null +++ b/app/Http/Middleware/TrustProxies.php @@ -0,0 +1,29 @@ + 'FORWARDED', + Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', + Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', + Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', + Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', + ]; +} diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index a2c3541..0c13b85 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -2,9 +2,9 @@ namespace App\Http\Middleware; -use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; +use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; -class VerifyCsrfToken extends BaseVerifier +class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index a182657..fca6152 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -13,7 +13,7 @@ class EventServiceProvider extends ServiceProvider * @var array */ protected $listen = [ - 'App\Events\SomeEvent' => [ + 'App\Events\Event' => [ 'App\Listeners\EventListener', ], ]; diff --git a/artisan b/artisan index df630d0..5c23e2e 100755 --- a/artisan +++ b/artisan @@ -1,6 +1,8 @@ #!/usr/bin/env php handle( | Shutdown The Application |-------------------------------------------------------------------------- | -| Once Artisan has finished running. We will fire off the shutdown events +| Once Artisan has finished running, we will fire off the shutdown events | so that any final work may be done by the application before we shut | down the process. This is the last thing to happen to the request. | diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php deleted file mode 100644 index 3830137..0000000 --- a/bootstrap/autoload.php +++ /dev/null @@ -1,34 +0,0 @@ - env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', @@ -66,6 +67,17 @@ return [ 'sslmode' => 'prefer', ], + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + ], + ], /* diff --git a/config/filesystems.php b/config/filesystems.php index f59cf9e..4544f60 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -13,7 +13,7 @@ return [ | */ - 'default' => 'local', + 'default' => env('FILESYSTEM_DRIVER', 'local'), /* |-------------------------------------------------------------------------- @@ -26,7 +26,7 @@ return [ | */ - 'cloud' => 's3', + 'cloud' => env('FILESYSTEM_CLOUD', 's3'), /* |-------------------------------------------------------------------------- diff --git a/config/mail.php b/config/mail.php index cde91b7..1a35c95 100644 --- a/config/mail.php +++ b/config/mail.php @@ -88,6 +88,19 @@ return [ 'password' => env('MAIL_PASSWORD'), + /* + |-------------------------------------------------------------------------- + | Sendmail System Path + |-------------------------------------------------------------------------- + | + | When using the "sendmail" driver to send e-mails, we will need to know + | the path to where Sendmail lives on this server. A default path has + | been provided here, which will work well on most of your systems. + | + */ + + 'sendmail' => '/usr/sbin/sendmail -bs', + /* |-------------------------------------------------------------------------- | Markdown Mail Settings diff --git a/database/factories/ModelFactory.php b/database/factories/UserFactory.php similarity index 55% rename from database/factories/ModelFactory.php rename to database/factories/UserFactory.php index 7926c79..061d75a 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/UserFactory.php @@ -1,18 +1,19 @@ define(App\User::class, function (Faker\Generator $faker) { +$factory->define(App\User::class, function (Faker $faker) { static $password; return [ diff --git a/phpunit.xml b/phpunit.xml index a2c496e..bb9c4a7 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,7 @@ - + ./tests/Feature - + ./tests/Unit diff --git a/public/.htaccess b/public/.htaccess index 903f639..bd88a4f 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,13 +1,14 @@ - Options -MultiViews + Options -MultiViews -Indexes RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d - RewriteRule ^(.*)/$ /$1 [L,R=301] + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d diff --git a/public/index.php b/public/index.php index 716731f..4584cbc 100644 --- a/public/index.php +++ b/public/index.php @@ -7,6 +7,8 @@ * @author Taylor Otwell */ +define('LARAVEL_START', microtime(true)); + /* |-------------------------------------------------------------------------- | Register The Auto Loader @@ -15,11 +17,11 @@ | Composer provides a convenient, automatically generated class loader for | our application. We just need to utilize it! We'll simply require it | into the script here so that we don't have to worry about manual -| loading any of our classes later on. It feels nice to relax. +| loading any of our classes later on. It feels great to relax. | */ -require __DIR__.'/../bootstrap/autoload.php'; +require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 9608bc2..edc036d 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -41,12 +41,14 @@ return [ 'email' => 'The :attribute must be a valid email address.', 'exists' => 'The selected :attribute is invalid.', 'file' => 'The :attribute must be a file.', - 'filled' => 'The :attribute field is required.', + 'filled' => 'The :attribute field must have a value.', 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', 'in_array' => 'The :attribute field does not exist in :other.', 'integer' => 'The :attribute must be an integer.', 'ip' => 'The :attribute must be a valid IP address.', + 'ipv4' => 'The :attribute must be a valid IPv4 address.', + 'ipv6' => 'The :attribute must be a valid IPv6 address.', 'json' => 'The :attribute must be a valid JSON string.', 'max' => [ 'numeric' => 'The :attribute may not be greater than :max.', diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/storage/framework/testing/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 486dc27..f31e495 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -3,9 +3,7 @@ namespace Tests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; class ExampleTest extends TestCase { diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 5663bb4..e9fe19c 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -3,8 +3,7 @@ namespace Tests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; class ExampleTest extends TestCase {