Skip to content

Commit

Permalink
Fix: Cast model key to integer to improve query performance on Postgr…
Browse files Browse the repository at this point in the history
…eSQL (#524)
  • Loading branch information
BakhadyrovF authored Jul 15, 2024
1 parent fb04ace commit 3f57a4c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/PersonalAccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public static function findToken($token)

[$id, $token] = explode('|', $token, 2);

if ((new static())->getKeyType() === 'int') {

Check failure on line 66 in src/PersonalAccessToken.php

View workflow job for this annotation

GitHub Actions / tests / Static Analysis

Unsafe usage of new static().
$id = (int) $id;
}

if ($instance = static::find($id)) {
return hash_equals($instance->token, hash('sha256', $token)) ? $instance : null;
}
Expand Down

0 comments on commit 3f57a4c

Please sign in to comment.