-
Notifications
You must be signed in to change notification settings - Fork 243
Upgrade to Laravel 12 and PHP 8.5 #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
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 |
|---|---|---|
|
|
@@ -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,44 @@ 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->createPersonalAccessClient( | ||
| $request->user()->getKey(), | ||
| $request->name, | ||
| $redirect | ||
| ); | ||
| } elseif ($password) { | ||
| $client = $this->clients->createPasswordGrantClient( | ||
| $request->user()->getKey(), | ||
| $request->name, | ||
| $redirect | ||
| ); | ||
| } 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 +96,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 +125,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.
getViews returns incompatible data structure breaking view logic
High Severity
The
getViews()method now returns a numerically-indexed array of view name strings, but consumers expect an associative array keyed by view name with objects having agetSql()method. InshouldCreate(), the checkisset($views[$viewName])will always fail since the array uses numeric keys, causing views to always be recreated unnecessarily. In theup()method's foreach loop,$viewNamebecomes numeric indices (0, 1, 2...) instead of actual view names, breaking the dropped table detection logic entirely.Additional Locations (2)
ProcessMaker/Console/Commands/CreateDataLakeViews.php#L121-L136ProcessMaker/Console/Commands/CreateDataLakeViews.php#L87-L94