Skip to content

AuditCustom Event does not respect audit.enabled = false config #1016

@jansgescheit

Description

@jansgescheit

PHP Version

8.4

Laravel Version

11.8

Package Version

13.6

Description

In our cicd pipeline we are testing with pest in parallel in this testing stage audits are disabled by environment AUDITING_ENABLED: false but we got several errors likes this:

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'url' at row 1 (Connection: mysql, SQL: insert into `audits` (`old_values`, `new_values`, `event`, `auditable_id`, `auditable_type`, `user_id`, `user_type`, `tags`, `url`, `updated_at`, `created_at`) values ({"foo":[]}, {"foo":[]}, sync-foo, 421345, foo, ?, ?, ?, /builds/exmple/src/vendor/pestphp/pest/bin/worker.php --status-file /tmp/worker_01_stdout_67ed8f864cb66_status --progress-file /tmp/worker_01_stdout_67ed8f864cb66_progress --unexpected-output-file /tmp/worker_01_stdout_67ed8f864cb66_unexpected_output --test-result-file /tmp/worker_01_stdout_67ed8f864cb66_test_result --result-cache-file /tmp/worker_01_stdout_67ed8f864cb66_result_cache --phpunit-argv a:9:{i:0;s:18:"vendor/bin/phpunit";i:1;s:17:"--cache-directory";i:2;s:63:"/builds/example/src/vendor/pestphp/pest/.temp";i:3;s:21:"--do-not-cache-result";i:4;s:12:"--no-logging";i:5;s:13:"--no-coverage";i:6;s:11:"--no-output";i:7;s:14:"--coverage-php";i:8;s:44:"/tmp/worker_01_stdout_67ed8f864cb66_coverage";}, 2025-04-02 19:28:09, 2025-04-02 19:28:09))

It is obvious that the URL field is too short. However, this is not the problem but that the error occurs because a custom audit event dispatched by Event::dispatch(AuditCustom::class, ...) is used here.

The listener that processes the event does not seem to look at the audit.enabled config. Furthermore, the audit.console config is also set to false, which is also not taken into account.

As a workaround I can read the config myself, but I think this should be done in the domain of the package.

Steps To Reproduce

set audit.enabled to false and dispatch a custom event

Possible Solutions

No response

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