Skip to content

Commit

Permalink
Fix php 8.3 deprecation Accessing static trait property(#940)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed May 29, 2024
1 parent 5dd4036 commit 49001f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
7 changes: 0 additions & 7 deletions src/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ trait Audit
*/
protected $modified = [];

/**
* Is globally auditing disabled?
*
* @var bool
*/
public static $auditingDisabled = false;

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Auditable.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ protected function getRestoredEventAttributes(): array
*/
public function readyForAuditing(): bool
{
if (static::$auditingDisabled || Audit::$auditingDisabled) {
if (static::$auditingDisabled || Models\Audit::$auditingGloballyDisabled) {
return false;
}

Expand Down Expand Up @@ -526,7 +526,7 @@ public function getAuditEvents(): array
*/
public static function isAuditingDisabled(): bool
{
return static::$auditingDisabled || Audit::$auditingDisabled;
return static::$auditingDisabled || Models\Audit::$auditingGloballyDisabled;
}

/**
Expand Down Expand Up @@ -562,12 +562,12 @@ public static function withoutAuditing(callable $callback, bool $globally = fals
$auditingDisabled = static::$auditingDisabled;

static::disableAuditing();
Audit::$auditingDisabled = $globally;
Models\Audit::$auditingGloballyDisabled = $globally;

try {
return $callback();
} finally {
Audit::$auditingDisabled = false;
Models\Audit::$auditingGloballyDisabled = false;
static::$auditingDisabled = $auditingDisabled;
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/Models/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ class Audit extends Model implements \OwenIt\Auditing\Contracts\Audit
*/
protected $guarded = [];

/**
* Is globally auditing disabled?
*
* @var bool
*/
public static $auditingGloballyDisabled = false;

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 49001f7

Please sign in to comment.