-
Notifications
You must be signed in to change notification settings - Fork 243
Upgrade to Laravel 12 and PHP 8.4 #8687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
7009039
407cdb8
af40a9a
4677567
861451d
d8adcdb
2b6bcc2
c57f6d1
1516f8e
5ed3c1a
400026c
578ebc7
e8ddfd9
d7e4830
48065d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,3 +51,4 @@ devhub/pm-font/dist | |
| test-db-snapshot.db | ||
| snapshot_*.db | ||
| storage/transitions | ||
| .envrc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,9 +181,10 @@ protected function getTableColumns(string $tableName): array | |
| */ | ||
| protected function getTables(): array | ||
| { | ||
| $database = \DB::connection()->getDatabaseName(); | ||
| $tables = array_map(function ($item) { | ||
| return $item['name']; | ||
| }, Schema::getTables()); | ||
| }, Schema::getTables($database)); | ||
|
|
||
| return $tables; | ||
| } | ||
|
|
@@ -193,9 +194,10 @@ protected function getTables(): array | |
| */ | ||
| protected function getViews(): array | ||
| { | ||
| $database = \DB::connection()->getDatabaseName(); | ||
| $views = array_map(function ($item) { | ||
| return $item['name']; | ||
| }, Schema::getViews()); | ||
| }, Schema::getViews($database)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getViews returns incompatible data structure breaking view logicHigh Severity The Additional Locations (2) |
||
|
|
||
| return $views; | ||
| } | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ public function getOauthClient(Request $request) | |
|
|
||
| if (!$client) { | ||
| $clientRepository = app('Laravel\Passport\ClientRepository'); | ||
| $client = $clientRepository->create(null, 'devlink', $redirectUri); | ||
| $client = $clientRepository->createAuthorizationCodeGrantClient('devlink', [$redirectUri]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DevLink client creation missing confidential parameterMedium Severity The |
||
| } | ||
|
|
||
| $query = http_build_query([ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,48 +3,39 @@ | |
| namespace ProcessMaker\Http\Controllers\Auth; | ||
|
|
||
| use Illuminate\Http\Request; | ||
| use Laravel\Passport\Http\Controllers\ClientController as PassportClientController; | ||
| use Illuminate\Http\Response; | ||
| use Laravel\Passport\ClientRepository; | ||
| use ProcessMaker\Events\AuthClientCreated; | ||
| use ProcessMaker\Events\AuthClientDeleted; | ||
| use ProcessMaker\Events\AuthClientUpdated; | ||
| use ProcessMaker\Http\Resources\AuthClient as AuthClientResource; | ||
|
|
||
| class ClientController extends PassportClientController | ||
| class ClientController | ||
| { | ||
| /** | ||
| * List auth clients | ||
| * | ||
| * @param \Illuminate\Http\Request $request | ||
| * @return array | ||
| */ | ||
| public function __construct( | ||
| protected ClientRepository $clients, | ||
| protected \Illuminate\Contracts\Validation\Factory $validation, | ||
| ) { | ||
| } | ||
|
|
||
| public function index(Request $request) | ||
| { | ||
| $clients = \Laravel\Passport\Client::where('revoked', false)->get(); | ||
|
|
||
| return AuthClientResource::collection($clients); | ||
| } | ||
|
|
||
| /** | ||
| * Get an individual auth client | ||
| * | ||
| * @param \Illuminate\Http\Request $request | ||
| * @param string $clientId | ||
| * @return array | ||
| */ | ||
| public function show(Request $request, $clientId) | ||
| { | ||
| // $client = $this->clients->find($clientId); | ||
| $client = parent::show($request, $clientId); | ||
| $client = $this->clients->findForUser($clientId, $request->user()); | ||
|
|
||
| if (!$client) { | ||
| return new Response('', 404); | ||
| } | ||
|
|
||
| return new AuthClientResource($client); | ||
| } | ||
|
|
||
| /** | ||
| * Store a new client. | ||
| * | ||
| * @param \Illuminate\Http\Request $request | ||
| * @return \Laravel\Passport\Client | ||
| */ | ||
| public function store(Request $request) | ||
| { | ||
| $this->validate($request); | ||
|
|
@@ -53,36 +44,42 @@ public function store(Request $request) | |
| $password = in_array('password_client', $request->types); | ||
| $redirect = in_array('authorization_code_grant', $request->types) ? $request->redirect : ''; | ||
|
|
||
| $client = $this->clients->create( | ||
| $request->user()->getKey(), | ||
| $request->name, | ||
| $redirect, | ||
| null, | ||
| $personalAccess, | ||
| $password | ||
| )->makeVisible('secret'); | ||
| // Use ClientRepository methods based on type | ||
| if ($personalAccess) { | ||
| $client = $this->clients->createPersonalAccessGrantClient( | ||
| $request->name | ||
| ); | ||
| } elseif ($password) { | ||
| $client = $this->clients->createPasswordGrantClient( | ||
| $request->name, | ||
| null, // provider | ||
| false // confidential | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OAuth clients not associated with user when createdHigh Severity When creating personal access or password grant clients via Additional Locations (2)There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Password grant client created as non-confidential breaks databaseHigh Severity The |
||
| } else { | ||
| // Authorization code grant | ||
| $client = $this->clients->createAuthorizationCodeGrantClient( | ||
| $request->name, | ||
| $redirect ? explode(',', $redirect) : [], | ||
| true, // confidential | ||
| $request->user() | ||
| ); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Store method silently ignores multiple selected client typesMedium Severity The |
||
|
|
||
| $client->makeVisible('secret'); | ||
| AuthClientCreated::dispatch($client->getAttributes()); | ||
|
|
||
| return new AuthClientResource($client); | ||
| } | ||
|
|
||
| /** | ||
| * Update the given client. | ||
| * | ||
| * @param \Illuminate\Http\Request $request | ||
| * @param string $clientId | ||
| * @return \Illuminate\Http\Response|\Laravel\Passport\Client | ||
| */ | ||
| public function update(Request $request, $clientId) | ||
| { | ||
| $client = $this->clients->find($clientId); | ||
| $client = $this->clients->findForUser($clientId, $request->user()); | ||
|
|
||
| if (!$client) { | ||
| return new Response('', 404); | ||
| } | ||
|
|
||
| $original_values = $client->getAttributes(); | ||
|
|
||
| $originalValues = $client->getAttributes(); | ||
| $this->validate($request); | ||
|
|
||
| $personalAccess = in_array('personal_access_client', $request->types); | ||
|
|
@@ -97,33 +94,26 @@ public function update(Request $request, $clientId) | |
| ]); | ||
|
|
||
| $original = array_intersect_key($client->getOriginal(), $client->getDirty()); | ||
|
|
||
| $client->save(); | ||
|
|
||
| AuthClientUpdated::dispatch($clientId, $original, $client->getChanges(), $request->name); | ||
|
|
||
| return new AuthClientResource($client); | ||
| } | ||
|
|
||
| /** | ||
| * Delete the given client. | ||
| * | ||
| * @param \Illuminate\Http\Request $request | ||
| * @param string $clientId | ||
| * @return null | ||
| */ | ||
| public function destroy(Request $request, $clientId) | ||
| { | ||
| $client = $this->clients->find($clientId); | ||
| $client = $this->clients->findForUser($clientId, $request->user()); | ||
|
|
||
| if (!$client) { | ||
| return new Response('', 404); | ||
| } | ||
|
|
||
| $attributes = $client->getAttributes(); | ||
| $this->clients->delete($client); | ||
| AuthClientDeleted::dispatch($client->getAttributes()); | ||
| AuthClientDeleted::dispatch($attributes); | ||
|
|
||
| return response('', 204); | ||
| return new Response('', 204); | ||
| } | ||
|
|
||
| private function validate($request) | ||
|
|
@@ -133,9 +123,11 @@ private function validate($request) | |
| 'types' => 'array|min:1|required', | ||
| 'types.*' => 'in:authorization_code_grant,password_client,personal_access_client', | ||
| ]; | ||
|
|
||
| if (is_array($request->types) && in_array('authorization_code_grant', $request->types)) { | ||
| $rules['redirect'] = 'required|url|max:2000'; | ||
| } | ||
|
|
||
| $this->validation->make($request->all(), $rules, [ | ||
| 'min' => __('The Auth-Client must have at least :min item chosen.'), | ||
| ])->validate(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schema methods don't accept database parameter
High Severity
Schema::getTables()andSchema::getViews()methods in Laravel 12 don't accept a database name parameter. The code passes$databaseto these methods, but they take no arguments. This would cause anArgumentCountErrorat runtime when theprocessmaker:create-data-lake-viewsartisan command is executed.Additional Locations (1)
ProcessMaker/Console/Commands/CreateDataLakeViews.php#L199-L200