From 4e5edd8c9f6e7abe8c2c6d269d8aa8cd158824bb Mon Sep 17 00:00:00 2001 From: erikn69 Date: Tue, 28 May 2024 15:18:49 -0500 Subject: [PATCH 1/2] Fix php 8.3 deprecation warning --- src/Audit.php | 7 ------- src/Auditable.php | 8 ++++---- src/Models/Audit.php | 7 +++++++ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Audit.php b/src/Audit.php index 33e5d4b0..8cb4596a 100644 --- a/src/Audit.php +++ b/src/Audit.php @@ -34,13 +34,6 @@ trait Audit */ protected $modified = []; - /** - * Is globally auditing disabled? - * - * @var bool - */ - public static $auditingDisabled = false; - /** * {@inheritdoc} */ diff --git a/src/Auditable.php b/src/Auditable.php index ac258dd3..0aed7acf 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -259,7 +259,7 @@ protected function getRestoredEventAttributes(): array */ public function readyForAuditing(): bool { - if (static::$auditingDisabled || Audit::$auditingDisabled) { + if (static::$auditingDisabled || Models\Audit::$auditingDisabled) { return false; } @@ -526,7 +526,7 @@ public function getAuditEvents(): array */ public static function isAuditingDisabled(): bool { - return static::$auditingDisabled || Audit::$auditingDisabled; + return static::$auditingDisabled || Models\Audit::$auditingDisabled; } /** @@ -562,12 +562,12 @@ public static function withoutAuditing(callable $callback, bool $globally = fals $auditingDisabled = static::$auditingDisabled; static::disableAuditing(); - Audit::$auditingDisabled = $globally; + Models\Audit::$auditingDisabled = $globally; try { return $callback(); } finally { - Audit::$auditingDisabled = false; + Models\Audit::$auditingDisabled = false; static::$auditingDisabled = $auditingDisabled; } } diff --git a/src/Models/Audit.php b/src/Models/Audit.php index 62ac6cd3..63e366d2 100644 --- a/src/Models/Audit.php +++ b/src/Models/Audit.php @@ -21,6 +21,13 @@ class Audit extends Model implements \OwenIt\Auditing\Contracts\Audit */ protected $guarded = []; + /** + * Is globally auditing disabled? + * + * @var bool + */ + public static $auditingDisabled = false; + /** * {@inheritdoc} */ From f4deed25f8cb39a649ebd68c91b58aa4d4434d01 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Wed, 29 May 2024 08:53:53 -0500 Subject: [PATCH 2/2] More descriptive property --- src/Auditable.php | 8 ++++---- src/Models/Audit.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Auditable.php b/src/Auditable.php index 0aed7acf..8b954090 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -259,7 +259,7 @@ protected function getRestoredEventAttributes(): array */ public function readyForAuditing(): bool { - if (static::$auditingDisabled || Models\Audit::$auditingDisabled) { + if (static::$auditingDisabled || Models\Audit::$auditingGloballyDisabled) { return false; } @@ -526,7 +526,7 @@ public function getAuditEvents(): array */ public static function isAuditingDisabled(): bool { - return static::$auditingDisabled || Models\Audit::$auditingDisabled; + return static::$auditingDisabled || Models\Audit::$auditingGloballyDisabled; } /** @@ -562,12 +562,12 @@ public static function withoutAuditing(callable $callback, bool $globally = fals $auditingDisabled = static::$auditingDisabled; static::disableAuditing(); - Models\Audit::$auditingDisabled = $globally; + Models\Audit::$auditingGloballyDisabled = $globally; try { return $callback(); } finally { - Models\Audit::$auditingDisabled = false; + Models\Audit::$auditingGloballyDisabled = false; static::$auditingDisabled = $auditingDisabled; } } diff --git a/src/Models/Audit.php b/src/Models/Audit.php index 63e366d2..187b01b9 100644 --- a/src/Models/Audit.php +++ b/src/Models/Audit.php @@ -26,7 +26,7 @@ class Audit extends Model implements \OwenIt\Auditing\Contracts\Audit * * @var bool */ - public static $auditingDisabled = false; + public static $auditingGloballyDisabled = false; /** * {@inheritdoc}