mirror of
https://hk.gh-proxy.com/https://github.com/wp-cli/profile-command.git
synced 2025-08-18 06:11:20 +08:00
Merge pull request #190 from wp-cli/fix/186
Fix deprecation warnings on PHP 8.2
This commit is contained in:
commit
ab3b9d18df
2 changed files with 39 additions and 17 deletions
|
@ -4,18 +4,16 @@ namespace WP_CLI\Profile;
|
|||
|
||||
class Logger {
|
||||
|
||||
public $time = 0;
|
||||
public $query_count = 0;
|
||||
public $query_time = 0;
|
||||
public $cache_hits = 0;
|
||||
public $cache_misses = 0;
|
||||
public $cache_ratio = null;
|
||||
public $hook_count = 0;
|
||||
public $hook_time = 0;
|
||||
public $request_count = 0;
|
||||
public $request_time = 0;
|
||||
public $callback_count = 0;
|
||||
|
||||
public $time = 0;
|
||||
public $query_count = 0;
|
||||
public $query_time = 0;
|
||||
public $cache_hits = 0;
|
||||
public $cache_misses = 0;
|
||||
public $cache_ratio = null;
|
||||
public $hook_count = 0;
|
||||
public $hook_time = 0;
|
||||
public $request_count = 0;
|
||||
public $request_time = 0;
|
||||
private $start_time = null;
|
||||
private $query_offset = null;
|
||||
private $cache_hit_offset = null;
|
||||
|
@ -24,14 +22,32 @@ class Logger {
|
|||
private $hook_depth = 0;
|
||||
private $request_start_time = null;
|
||||
|
||||
private $definitions = array();
|
||||
|
||||
public static $active_loggers = array();
|
||||
|
||||
public function __construct( $definition = array() ) {
|
||||
foreach ( $definition as $k => $v ) {
|
||||
$this->$k = $v;
|
||||
$this->definitions[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
public function __get( $key ) {
|
||||
if ( isset( $this->definitions[ $key ] ) ) {
|
||||
return $this->definitions[ $key ];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function __set( $key, $value ) {
|
||||
$this->definitions[ $key ] = $value;
|
||||
}
|
||||
|
||||
public function __isset( $key ) {
|
||||
return isset( $this->definitions[ $key ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Start this logger
|
||||
*/
|
||||
|
|
|
@ -99,8 +99,11 @@ class Profiler {
|
|||
}
|
||||
}
|
||||
);
|
||||
if ( 'hook' === $this->type
|
||||
&& ':before' === substr( $this->focus, -7, 7 ) ) {
|
||||
if (
|
||||
'hook' === $this->type &&
|
||||
$this->focus &&
|
||||
':before' === substr( $this->focus, -7, 7 )
|
||||
) {
|
||||
$stage_hooks = array();
|
||||
foreach ( $this->stage_hooks as $hooks ) {
|
||||
$stage_hooks = array_merge( $stage_hooks, $hooks );
|
||||
|
@ -114,8 +117,11 @@ class Profiler {
|
|||
WP_CLI::add_hook( 'after_wp_config_load', array( $this, 'wp_tick_profile_begin' ) );
|
||||
}
|
||||
WP_CLI::add_wp_hook( $end_hook, array( $this, 'wp_tick_profile_end' ), -9999 );
|
||||
} elseif ( 'hook' === $this->type
|
||||
&& ':after' === substr( $this->focus, -6, 6 ) ) {
|
||||
} elseif (
|
||||
'hook' === $this->type &&
|
||||
$this->focus &&
|
||||
':after' === substr( $this->focus, -6, 6 )
|
||||
) {
|
||||
$start_hook = substr( $this->focus, 0, -6 );
|
||||
WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 );
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue