diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-06 20:10:23 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-06 20:10:23 +0100 |
| commit | 487b42fa1c2d871f06dfb95f41387774852dbb7f (patch) | |
| tree | 62cbf5d1224df6b22c4547a3ca874f7c9d33e74a | |
| parent | 63a2a4a41b4b25c2e582480d6a971a1206acc64b (diff) | |
| download | protector-487b42fa1c2d871f06dfb95f41387774852dbb7f.tar.gz protector-487b42fa1c2d871f06dfb95f41387774852dbb7f.tar.bz2 protector-487b42fa1c2d871f06dfb95f41387774852dbb7f.zip | |
protector: guard empty roles with ?: [-1] to prevent Firebird IN() error
For anonymous users getRoles() returns an empty array, producing IN()
with no values — invalid Firebird SQL (-104 Token unknown).
Apply the standard guard so anonymous requests get IN(-1) instead,
matching the anonymous role_id. Affects both protector_content_list()
and protector_content_load().
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rwxr-xr-x | includes/classes/LibertyProtector.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/includes/classes/LibertyProtector.php b/includes/classes/LibertyProtector.php index 249f76b..eb37666 100755 --- a/includes/classes/LibertyProtector.php +++ b/includes/classes/LibertyProtector.php @@ -83,7 +83,7 @@ class LibertyProtector extends LibertyBase { function protector_content_list() { global $gBitUser; $userId = $gBitUser->mUserId ?? 0; - $roles = \array_keys($gBitUser->getRoles( $userId ?? 0, true )); + $roles = \array_keys($gBitUser->getRoles( $userId ?? 0, true )) ?: [-1]; $ret = [ 'join_sql' => " LEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_role_map` lcrm ON ( lc.`content_id`=lcrm.`content_id` ) LEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_roles_map` purm ON ( purm.`user_id` = " . $userId . " ) AND ( purm.`role_id`=lcrm.`role_id` ) ", 'where_sql' => " AND (lcrm.`content_id` IS null OR lcrm.`role_id` IN(" . implode( ',', array_fill( 0, count( $roles ), '?' ) ) . " ) OR purm.`user_id` = ? ) ", @@ -100,7 +100,7 @@ function protector_content_list() { function protector_content_load( $pContent = null ) { global $gBitUser; $userId = $gBitUser->mUserId ?? -1; - $roles = \array_keys($gBitUser->getRoles( $userId, true )); + $roles = \array_keys($gBitUser->getRoles( $userId, true )) ?: [-1]; protector_content_verify_access( $pContent, $roles ); $ret = [ 'join_sql' => " LEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_role_map` lcrm ON ( lc.`content_id`=lcrm.`content_id` ) LEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_roles_map` purm ON ( purm.`role_id`=lcrm.`role_id` ) ", |
