Skip to content
This repository has been archived by the owner on Jan 29, 2021. It is now read-only.

Upgrading Laravel Framework #1071

Merged
merged 50 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
04b8d9b
Updating composer packages.
weerd Jul 8, 2020
15cbbba
Updating dependencies.
weerd Jul 9, 2020
2dc7b8d
Removing unused files and updating index.php
weerd Jul 9, 2020
2fc52a3
Updating .htaccess.
weerd Jul 9, 2020
a299bed
Removing bootstrap/autoload call.
weerd Jul 9, 2020
7fe7dfb
Updating TrustedProxy settings.
weerd Jul 9, 2020
0c77833
Removing mentions of Dusk in project since no longer used.
weerd Jul 9, 2020
8c0127f
Upadating Hashing config.
weerd Jul 13, 2020
05cc009
Updating Logging.
weerd Jul 13, 2020
c356a02
Updating logger method name.
weerd Jul 13, 2020
9ac1c52
Bringing rest of files up to date and in sync with 5.6 framework files.
weerd Jul 14, 2020
123258b
Reverting web routes file I was using for debugging.
weerd Jul 14, 2020
3198f2e
Figuring out issues with running tests.
weerd Jul 16, 2020
bb78b4c
Updating composer.
weerd Jul 20, 2020
8ada9ae
StyleCI fix.
weerd Jul 20, 2020
9f3865d
Updating dependencies for 5.7.
weerd Jul 20, 2020
4be7a98
Updating assets.
weerd Jul 20, 2020
c2af8ef
Updating authorization.
weerd Jul 20, 2020
ed89b54
Updating cache.
weerd Jul 20, 2020
96118e2
Updating tests.
weerd Jul 20, 2020
4a2da82
Removing overridden mock() method since the signature changed and Lar…
weerd Jul 21, 2020
19bafd9
Removing unused imported class.
weerd Jul 21, 2020
2b294d0
Removing CustomGate now that framework supports Guest User Gates.
weerd Jul 23, 2020
ee07c28
Fixing up broken tests.
weerd Jul 23, 2020
05e3b87
Composer lock update.
weerd Jul 23, 2020
c8453d4
Wrapping up miscellaneous updates from 5.6 to 5.7.
weerd Jul 23, 2020
f1a4250
Some miscellaneous updates from 5.7 to 5.8.
weerd Jul 23, 2020
8c10c8f
Updating dependencies and fixing API routes.
weerd Jul 23, 2020
51ced1d
Updating testing.
weerd Jul 23, 2020
72991e7
Updating notifications.
weerd Jul 25, 2020
cd60a80
Updating support.
weerd Jul 27, 2020
b0a30f4
Updating support with env() changes.
weerd Jul 27, 2020
8817e91
Updating env example vars.
weerd Jul 27, 2020
02324fa
Updates to env vars used and simplifying redis env settings.
weerd Jul 27, 2020
6a322f8
Fixing up Tag tests and errors with notifications.
weerd Jul 28, 2020
76f9d43
Updating cache config.
weerd Jul 28, 2020
a8896d2
Removing deleted_at from array since automatically converted after u…
weerd Jul 28, 2020
cf74c81
Changing tag so it does not trigger notification, if not point of test.
weerd Jul 28, 2020
83f6b85
Cleanup.
weerd Jul 28, 2020
fffa483
Fixing StyleCI issue.
weerd Jul 28, 2020
31d07f7
StyleCI fixes.
weerd Jul 28, 2020
99c0746
StyleCI fixes.
weerd Jul 28, 2020
8b1c4eb
Updating Trusted Proxies based on Heroku docs.
weerd Jul 29, 2020
88b74cd
Type-hinting the Authenticateable class works.
weerd Jul 29, 2020
f433f03
Updating redis options.
weerd Jul 29, 2020
cddadb2
Updating filesystems config and reivew app config.
weerd Jul 29, 2020
3e16a73
Adding note regarding a potential future update.
weerd Jul 29, 2020
c93b144
Restoring the Good Submission tag and setting empty string var for sl…
weerd Jul 29, 2020
94fae7f
Restoring old approach now that tests do not trigger notifications.
weerd Jul 29, 2020
0521749
Updaing AWS_* env variables.
weerd Jul 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@ root = true


[*]
indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

[*.php]
indent_style = space
indent_size = 4

[*.json]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.php]
indent_size = 4
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG=daily
APP_LOG_LEVEL=debug
APP_URL=http://rogue.test

LOG_CHANNEL=daily
LOG_SLACK_WEBHOOK_URL=

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
Expand All @@ -13,8 +14,8 @@ DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=redis
FILESYSTEM_DRIVER=public
SESSION_DRIVER=redis
STORAGE_DRIVER=public
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
Expand Down
18 changes: 8 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/vendor
/node_modules
/public/storage
/storage/debugbar
Homestead.yaml
Homestead.json
.DS_Store
.env
.env.dusk.local
.phpunit.result.cache

.DS_Store
vendor
node_modules
storage/debugbar
Homestead.yaml
Homestead.json

public/assets/**
public/dist
public/storage

npm-debug.log

/_book
10 changes: 5 additions & 5 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@
"ASHES_USERNAME": {
"required": true
},
"ROGUE_API_KEY": {
"AWS_S3_BUCKET": {
"required": true
},
"AWS_S3_URL": {
weerd marked this conversation as resolved.
Show resolved Hide resolved
"required": true
},
"S3_BUCKET": {
"ROGUE_API_KEY": {
"required": true
},
"S3_KEY": {
Expand All @@ -91,9 +94,6 @@
},
"S3_SECRET": {
"required": true
},
"S3_URL": {
"required": true
}
}
}
47 changes: 0 additions & 47 deletions app/Auth/CustomGate.php

This file was deleted.

26 changes: 12 additions & 14 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,37 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @param \Exception $exceptionxception
* @return void
*/
public function report(Exception $e)
public function report(Exception $exception)
{
parent::report($e);
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
* @param \Exception $exception
* @return \Illuminate\Http\Response | \Symfony\Component\HttpFoundation\Response
*/
public function render($request, Exception $e)
public function render($request, Exception $exception)
{
// If Intervention can't parse a file (corrupted or wrong type), return 422.
// @TODO: Handle this with a validation rule on our v3 routes.
if ($e instanceof \Intervention\Image\Exception\NotReadableException) {
if ($exception instanceof \Intervention\Image\Exception\NotReadableException) {
abort(422, 'Invalid image provided.');
}

// Re-cast specific exceptions or uniquely render them:
if ($e instanceof GlideNotFoundException) {
$e = new NotFoundHttpException('That image could not be found.');
} elseif ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException('That resource could not be found.');
if ($exception instanceof GlideNotFoundException) {
$exception = new NotFoundHttpException('That image could not be found.');
} elseif ($exception instanceof ModelNotFoundException) {
$exception = new NotFoundHttpException('That resource could not be found.');
}

return parent::render($request, $e);
return parent::render($request, $exception);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/PostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ public function update(PostRequest $request, Post $post)
// Only allow an admin/staff or the user who owns the post to update.
$this->authorize('update', $post);

$validatedRequest = $request->validated();

// But don't allow user's to review their own posts.
if (! Gate::allows('review', $post)) {
unset($request['status']);
unset($validatedRequest['status']);
}

$this->posts->update($post, $request->validated());
$this->posts->update($post, $validatedRequest);
weerd marked this conversation as resolved.
Show resolved Hide resolved

return $this->item($post);
}
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Rogue\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\Rogue\Http\Middleware\TrustProxies::class,
Expand Down Expand Up @@ -58,8 +58,10 @@ class Kernel extends HttpKernel
'guard' => \DoSomething\Gateway\Server\Middleware\SetGuard::class,
'scopes' => \DoSomething\Gateway\Server\Middleware\RequireScope::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \Rogue\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'role' => \Rogue\Http\Middleware\CheckRole::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
Expand Down
17 changes: 17 additions & 0 deletions app/Http/Middleware/CheckForMaintenanceMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Rogue\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;

class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}
15 changes: 4 additions & 11 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application,
* sourced from 'config/trustedproxy.php'.
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;

/**
* The current proxy header mappings.
* The headers that should be used to detect proxies.
*
* @var array
* @var int
*/
protected $headers = [
Request::HEADER_FORWARDED => null, // Not set on AWS or Heroku.
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => null, // Not set on AWS or Heroku.
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
protected $headers = Request::HEADER_X_FORWARDED_ALL;
weerd marked this conversation as resolved.
Show resolved Hide resolved
}
3 changes: 2 additions & 1 deletion app/Policies/PostPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rogue\Policies;

use Rogue\Models\User;
use Rogue\Models\Post;
use Illuminate\Auth\Access\HandlesAuthorization;

Expand All @@ -28,7 +29,7 @@ public function viewAll($user, Post $post)
* @param Rogue\Models\Post $post
* @return bool
*/
public function show($user, Post $post)
public function show($user = null, Post $post)
weerd marked this conversation as resolved.
Show resolved Hide resolved
{
if ($post->status !== 'accepted') {
return is_staff_user() || is_owner($post);
Expand Down
9 changes: 1 addition & 8 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Closure;
use Hashids\Hashids;
use Rogue\Auth\CustomGate;
use InvalidArgumentException;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\View;
Expand All @@ -24,12 +23,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->app->singleton(GateContract::class, function ($app) {
return new CustomGate($app, function () use ($app) {
return call_user_func($app['auth']->userResolver());
});
});
weerd marked this conversation as resolved.
Show resolved Hide resolved

$this->app->singleton(Hashids::class, function ($app) {
return new Hashids(config('app.key'), 10);
});
Expand All @@ -56,7 +49,7 @@ public function boot()
}, 'The :attribute must be a valid ISO-3166-2 region code.');

// Attach the user & request ID to context for all log messages.
Log::getMonolog()->pushProcessor(function ($record) {
Log::getLogger()->pushProcessor(function ($record) {
weerd marked this conversation as resolved.
Show resolved Hide resolved
$record['extra']['user_id'] = auth()->id();
$record['extra']['client_id'] = token()->client();
$record['extra']['request_id'] = request()->header('X-Request-Id');
Expand Down
6 changes: 4 additions & 2 deletions artisan
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
Expand All @@ -13,7 +15,7 @@
|
*/

require __DIR__.'/bootstrap/autoload.php';
require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

Expand All @@ -40,7 +42,7 @@ $status = $kernel->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.
|
Expand Down
34 changes: 0 additions & 34 deletions bootstrap/autoload.php

This file was deleted.

Loading