Skip to content

Undefined $client_id causes Fatal SQL error in post/user handlers when no client context #1272

@prefectford40

Description

@prefectford40

Version: 83e15e9
Description:
After the recent update, multiple pages that access assets, documents and other entities without a specific client context cause a PHP Fatal Error due to $client_id being undefined.
Error:
PHP Warning: Undefined variable $client_id in post/user/asset.php on line 982
PHP Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the right syntax
to use near ' log_user_id = 13, log_entity_id = 0'
Steps to reproduce:

Go to Assets page without selecting a specific client
Try to export assets to CSV
Fatal error occurs, page returns 500

Fix applied locally:
Added $client_id = $client_id ?? 0; at the top of all affected post/user handler files including asset.php, document.php and 22 others.
Affected files:
All files in /post/user/ that call logAction() with $client_id

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions