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

Commit

Permalink
All laravel upgrades (#1080)
Browse files Browse the repository at this point in the history
* Updating composer packages.

* Updating dependencies.

* Removing unused files and updating index.php

* Updating .htaccess.

* Removing bootstrap/autoload call.

* Updating TrustedProxy settings.

* Removing mentions of Dusk in project since no longer used.

* Upadating Hashing config.

* Updating Logging.

* Updating logger method name.

* Bringing rest of files up to date and in sync with 5.6 framework files.

* Reverting web routes file I was using for debugging.

* Figuring out issues with running tests.

* Updating composer.

* StyleCI fix.

* Updating dependencies for 5.7.

* Updating assets.

* Updating authorization.

* Updating cache.

* Updating tests.

* Removing overridden mock() method since the signature changed and Laravel provides same method.

* Removing unused imported class.

* Removing CustomGate now that framework supports Guest User Gates.

* Fixing up broken tests.

* Composer lock update.

* Wrapping up miscellaneous updates from 5.6 to 5.7.

* Some miscellaneous updates from 5.7 to 5.8.

* Updating dependencies and fixing API routes.

* Updating testing.

* Updating notifications.

* Updating support.

* Updating support with env() changes.

* Updating env example vars.

* Updates to env vars used and simplifying redis env settings.

* Fixing up Tag tests and errors with notifications.

* Updating cache config.

* Removing deleted_at from  array since automatically converted after upgrades.

* Changing tag so it does not trigger notification, if not point of test.

* Cleanup.

* StyleCI fixes.

* StyleCI fixes.

* Updating Trusted Proxies based on Heroku docs.

* Type-hinting the Authenticateable class works.

* Updating redis options.

* Updating filesystems config and reivew app config.

* Adding note regarding a potential future update.

* Restoring the Good Submission tag and setting empty string var for slack webhook in PHPUnit settings.

* Restoring old approach now that tests do not trigger notifications.

* Updaing AWS_* env variables.

* Updating editorconfig file.

* Upgrading Laravel Framework (#1071)

* Updating composer packages.

* Updating dependencies.

* Removing unused files and updating index.php

* Updating .htaccess.

* Removing bootstrap/autoload call.

* Updating TrustedProxy settings.

* Removing mentions of Dusk in project since no longer used.

* Upadating Hashing config.

* Updating Logging.

* Updating logger method name.

* Bringing rest of files up to date and in sync with 5.6 framework files.

* Reverting web routes file I was using for debugging.

* Figuring out issues with running tests.

* Updating composer.

* StyleCI fix.

* Updating dependencies for 5.7.

* Updating assets.

* Updating authorization.

* Updating cache.

* Updating tests.

* Removing overridden mock() method since the signature changed and Laravel provides same method.

* Removing unused imported class.

* Removing CustomGate now that framework supports Guest User Gates.

* Fixing up broken tests.

* Composer lock update.

* Wrapping up miscellaneous updates from 5.6 to 5.7.

* Some miscellaneous updates from 5.7 to 5.8.

* Updating dependencies and fixing API routes.

* Updating testing.

* Updating notifications.

* Updating support.

* Updating support with env() changes.

* Updating env example vars.

* Updates to env vars used and simplifying redis env settings.

* Fixing up Tag tests and errors with notifications.

* Updating cache config.

* Removing deleted_at from  array since automatically converted after upgrades.

* Changing tag so it does not trigger notification, if not point of test.

* Cleanup.

* Fixing StyleCI issue.

* StyleCI fixes.

* StyleCI fixes.

* Updating Trusted Proxies based on Heroku docs.

* Type-hinting the Authenticateable class works.

* Updating redis options.

* Updating filesystems config and reivew app config.

* Adding note regarding a potential future update.

* Restoring the Good Submission tag and setting empty string var for slack webhook in PHPUnit settings.

* Restoring old approach now that tests do not trigger notifications.

* Updaing AWS_* env variables.

* Restoring some items post rebase.

* StyleCI fix.

* Upgrading Laravel framework from 5.8 to 6.0 (#1081)

* Removing CustomGate now that framework supports Guest User Gates.

* Updating support.

* Rebase fixes.

* Rebase fixes.

* Upgrading Laravel Framework (#1071)

* Updating composer packages.

* Updating dependencies.

* Removing unused files and updating index.php

* Updating .htaccess.

* Removing bootstrap/autoload call.

* Updating TrustedProxy settings.

* Removing mentions of Dusk in project since no longer used.

* Upadating Hashing config.

* Updating Logging.

* Updating logger method name.

* Bringing rest of files up to date and in sync with 5.6 framework files.

* Reverting web routes file I was using for debugging.

* Figuring out issues with running tests.

* Updating composer.

* StyleCI fix.

* Updating dependencies for 5.7.

* Updating assets.

* Updating authorization.

* Updating cache.

* Updating tests.

* Removing overridden mock() method since the signature changed and Laravel provides same method.

* Removing unused imported class.

* Removing CustomGate now that framework supports Guest User Gates.

* Fixing up broken tests.

* Composer lock update.

* Wrapping up miscellaneous updates from 5.6 to 5.7.

* Some miscellaneous updates from 5.7 to 5.8.

* Updating dependencies and fixing API routes.

* Updating testing.

* Updating notifications.

* Updating support.

* Updating support with env() changes.

* Updating env example vars.

* Updates to env vars used and simplifying redis env settings.

* Fixing up Tag tests and errors with notifications.

* Updating cache config.

* Removing deleted_at from  array since automatically converted after upgrades.

* Changing tag so it does not trigger notification, if not point of test.

* Cleanup.

* Fixing StyleCI issue.

* StyleCI fixes.

* StyleCI fixes.

* Updating Trusted Proxies based on Heroku docs.

* Type-hinting the Authenticateable class works.

* Updating redis options.

* Updating filesystems config and reivew app config.

* Adding note regarding a potential future update.

* Restoring the Good Submission tag and setting empty string var for slack webhook in PHPUnit settings.

* Restoring old approach now that tests do not trigger notifications.

* Updaing AWS_* env variables.

* Miscellaneous updates.

* Updating miscellaneous.

* Composer dependency updates.

* Updating configuration.

* Updating PHPUnit and fixing test with previously deprecated method.

* Updating composer dependencies.

* Reordering.

* Cleanup.

* Prefixing the SQS Env vars with AWS_ for consistency.

* Post rebase cleanup

* Fixing straggling merge conflicts.

* Cleanup.

* Updating url and endpoint settings.
  • Loading branch information
weerd committed Aug 5, 2020
1 parent 3a68beb commit cee3103
Show file tree
Hide file tree
Showing 66 changed files with 2,920 additions and 1,759 deletions.
15 changes: 6 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ 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
trim_trailing_whitespace = true

[*.json]
indent_style = space
[*.js*]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
26 changes: 19 additions & 7 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,20 +14,31 @@ DB_USERNAME=homestead
DB_PASSWORD=secret

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

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_URL=redis://h:null@127.0.0.1:6379

# AWS
AWS_ACCESS_KEY_ID=
AWS_DEFAULT_REGION=us-east-1
AWS_SECRET_ACCESS_KEY=
AWS_S3_BUCKET=
AWS_S3_REGION=us-east-1
AWS_S3_URL=
AWS_SQS_PREFIX=
AWS_SQS_QUEUE=
AWS_SQS_REGION=us-east-1

# Northstar
NORTHSTAR_URL=https://identity-dev.dosomething.org
NORTHSTAR_AUTH_ID=dev-oauth
NORTHSTAR_AUTH_SECRET=
NORTHSTAR_CLIENT_ID=dev-machine
NORTHSTAR_CLIENT_SECRET=

# GraphQL
GRAPHQL_URL=https://graphql-dev.dosomething.org

# Algolia (only use if testing indexing):
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/assets/**
/public/dist
/public/storage
/storage/debugbar
Homestead.yaml
Homestead.json
.env
.env.dusk.local
/vendor

.DS_Store
.env
.env.backup
.phpunit.result.cache

public/assets/**
public/dist

Homestead.json
Homestead.yaml
npm-debug.log

/_book
27 changes: 0 additions & 27 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,8 @@
"NORTHSTAR_URL": {
"required": true
},
"ASHES_API_VERSION": {
"required": true
},
"ASHES_PASSWORD": {
"required": true
},
"ASHES_URI": {
"required": true
},
"ASHES_USERNAME": {
"required": true
},
"ROGUE_API_KEY": {
"required": true
},
"S3_BUCKET": {
"required": true
},
"S3_KEY": {
"required": true
},
"S3_REGION": {
"required": true
},
"S3_SECRET": {
"required": true
},
"S3_URL": {
"required": true
}
}
}
47 changes: 0 additions & 47 deletions app/Auth/CustomGate.php

This file was deleted.

30 changes: 16 additions & 14 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,41 @@ 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
*
* @throws \Exception
*/
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 \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
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
3 changes: 2 additions & 1 deletion app/Http/Controllers/CampaignsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Rogue\Http\Controllers;

use Rogue\Models\Campaign;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Rogue\Http\Transformers\CampaignTransformer;

Expand Down Expand Up @@ -65,7 +66,7 @@ public function index(Request $request)
}

// Experimental: Allow paginating by cursor (e.g. `?cursor[after]=OTAxNg==`):
if ($cursor = array_get($request->query('cursor'), 'after')) {
if ($cursor = Arr::get($request->query('cursor'), 'after')) {
$query->whereAfterCursor($cursor);

// Using 'cursor' implies cursor pagination:
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Rogue\Http\Controllers;

use Rogue\Models\Group;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Rogue\Http\Transformers\GroupTransformer;

Expand Down Expand Up @@ -44,7 +45,7 @@ public function index(Request $request)

$request->query->set('orderBy', 'name,asc');

if ($cursor = array_get($request->query('cursor'), 'after')) {
if ($cursor = Arr::get($request->query('cursor'), 'after')) {
$query->whereAfterCursor($cursor);
$this->useCursorPagination = true;
}
Expand Down
15 changes: 9 additions & 6 deletions app/Http/Controllers/PostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Rogue\Models\Post;
use Rogue\Models\Campaign;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Rogue\Managers\PostManager;
use Rogue\Managers\SignupManager;
Expand Down Expand Up @@ -87,11 +88,11 @@ public function index(Request $request)
$query = $query->withHiddenPosts();

// If tag param is passed, only return posts that have that tag.
if (array_has($filters, 'tag')) {
if (Arr::has($filters, 'tag')) {
$query = $query->withTag($filters['tag']);
}

if (array_has($filters, 'volunteer_credit')) {
if (Arr::has($filters, 'volunteer_credit')) {
if (filter_var($filters['volunteer_credit'], FILTER_VALIDATE_BOOLEAN)) {
$query = $query->withVolunteerCredit($filters['volunteer_credit']);
} else {
Expand All @@ -100,7 +101,7 @@ public function index(Request $request)
}

// If the northstar_id param is passed, only allow admins, staff, or owner to see anonymous posts.
if (array_has($filters, 'northstar_id')) {
if (Arr::has($filters, 'northstar_id')) {
$query = $query->withoutAnonymousPosts();
}

Expand All @@ -113,7 +114,7 @@ public function index(Request $request)
$request->query->set('orderBy', 'created_at,desc');

// Experimental: Allow paginating by cursor (e.g. `?cursor[after]=OTAxNg==`):
if ($cursor = array_get($request->query('cursor'), 'after')) {
if ($cursor = Arr::get($request->query('cursor'), 'after')) {
$query->whereAfterCursor($cursor);

// Using 'cursor' implies cursor pagination:
Expand Down Expand Up @@ -175,12 +176,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);

return $this->item($post);
}
Expand Down
8 changes: 5 additions & 3 deletions app/Http/Controllers/SignupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Rogue\Models\Signup;
use Rogue\Models\Campaign;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Rogue\Managers\SignupManager;
use Rogue\Http\Transformers\SignupTransformer;
Expand Down Expand Up @@ -93,7 +95,7 @@ public function index(Request $request)
$query = $this->filter($query, $filters, Signup::$indexes);

// Only allow an admin or the user who owns the signup to see the signup's unapproved posts.
if (starts_with($request->query('include'), 'posts')) {
if (Str::startsWith($request->query('include'), 'posts')) {
$types = (new \League\Fractal\Manager)
->parseIncludes($request->query('include'))
->getIncludeParams('posts');
Expand All @@ -107,7 +109,7 @@ public function index(Request $request)
$query = $this->orderBy($query, $orderBy, Signup::$sortable);

// Experimental: Allow paginating by cursor (e.g. `?cursor[after]=OTAxNg==`):
if ($cursor = array_get($request->query('cursor'), 'after')) {
if ($cursor = Arr::get($request->query('cursor'), 'after')) {
$query->whereAfterCursor($cursor);

// Using 'cursor' implies cursor pagination:
Expand All @@ -128,7 +130,7 @@ public function index(Request $request)
public function show(Request $request, Signup $signup)
{
// Only allow an admin or the user who owns the signup to see the signup's unapproved posts.
if (starts_with($request->query('include'), 'posts')) {
if (Str::startsWith($request->query('include'), 'posts')) {
$types = (new \League\Fractal\Manager)
->parseIncludes($request->query('include'))
->getIncludeParams('posts');
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/TagsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Rogue\Http\Controllers;

use Rogue\Models\Post;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Rogue\Repositories\PostRepository;
use Rogue\Http\Transformers\PostTransformer;
Expand Down Expand Up @@ -54,7 +55,7 @@ public function store(Post $post, Request $request)
// If a tag slug is sent in (dashed or lowercase), change to the tag name.
// @TODO: This controller/model should really deal in slugs...
$tag = $request->tag_name;
if (str_contains($tag, '-') || ctype_lower($tag)) {
if (Str::contains($tag, '-') || ctype_lower($tag)) {
$tag = ucwords(str_replace('-', ' ', $tag));
}

Expand Down

0 comments on commit cee3103

Please sign in to comment.