owen-it / laravel-auditing

Record the change log from models in Laravel
https://laravel-auditing.com
MIT License
3.01k stars 387 forks source link

Accessing static trait property OwenIt\Auditing\Audit::$auditingDisabled is deprecated #941

Closed Levivb closed 4 months ago

Levivb commented 4 months ago

PHP Version

8.3

Laravel Version

10.48

Package Version

13.6.6

Description

After a composer update the https://github.com/owen-it/laravel-auditing/releases/tag/v13.6.6 version is retrieved. Running laravel gives: DEPRECATED Accessing static trait property OwenIt\Auditing\Audit::$auditingDisabled is deprecated, it should only be accessed on a class using the trait in vendor/owen-it/laravel-auditing/src/Auditable.php on line 262.

See https://github.com/owen-it/laravel-auditing/compare/v13.6.5...v13.6.6

The new codechange:

-        if (static::$auditingDisabled) {
+        if (static::$auditingDisabled || Audit::$auditingDisabled) {

is valid php code - for now. But it's already deprecated. I suppose new code should not utilise deprecated code?

Steps To Reproduce

Mutate an entity with the Auditable trait to the database

Possible Solutions

Instead of placing the static property on a trait, it could be applied to an AuditState class containing the static property?

That way withoutAuditing can use that class to check if Audit is globally active

willpower232 commented 4 months ago

a fix is already underway #940

Levivb commented 4 months ago

Ah awesome! I missed that one, did check open issues though :)