Skip to content

Commit

Permalink
Prevent storage of WP_Hook snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher committed Dec 19, 2024
1 parent 20a8c7b commit 7d0dc03
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions inc/backtrace/class-frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace AI_Logger\Backtrace;

use Spatie\Backtrace\Frame as SpatieFrame;
use WP_Hook;

/**
* Frame extension class.
Expand Down Expand Up @@ -56,6 +57,16 @@ public static function from_base( SpatieFrame $frame ): self {
* @param int $line_count Number of lines to load.
*/
public function load_snippet( int $line_count ): void {
// Prevent snippet from being loaded for specific internal frames which
// don't make sense to store (such as do_action).
if ( WP_Hook::class === $this->class ) {
return;
}

if ( ! $this->class && in_array( $this->method, [ 'do_action', 'do_action_ref_array', 'apply_filters', 'apply_filters_ref_array' ], true ) ) {
return;
}

$this->snippet = $this->getSnippet( $line_count );
}
}

0 comments on commit 7d0dc03

Please sign in to comment.