Skip to content

Commit 128210c

Browse files
committed
Avoid passing null to substr
1 parent 84a7e9d commit 128210c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Profiler.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ function () {
9999
}
100100
}
101101
);
102-
if ( 'hook' === $this->type
103-
&& ':before' === substr( $this->focus, -7, 7 ) ) {
102+
if (
103+
'hook' === $this->type &&
104+
$this->focus &&
105+
':before' === substr( $this->focus, -7, 7 )
106+
) {
104107
$stage_hooks = array();
105108
foreach ( $this->stage_hooks as $hooks ) {
106109
$stage_hooks = array_merge( $stage_hooks, $hooks );
@@ -114,8 +117,11 @@ function () {
114117
WP_CLI::add_hook( 'after_wp_config_load', array( $this, 'wp_tick_profile_begin' ) );
115118
}
116119
WP_CLI::add_wp_hook( $end_hook, array( $this, 'wp_tick_profile_end' ), -9999 );
117-
} elseif ( 'hook' === $this->type
118-
&& ':after' === substr( $this->focus, -6, 6 ) ) {
120+
} elseif (
121+
'hook' === $this->type &&
122+
$this->focus &&
123+
':after' === substr( $this->focus, -6, 6 )
124+
) {
119125
$start_hook = substr( $this->focus, 0, -6 );
120126
WP_CLI::add_wp_hook( $start_hook, array( $this, 'wp_tick_profile_begin' ), 9999 );
121127
} else {

0 commit comments

Comments
 (0)