diff --git a/CHANGELOG.md b/CHANGELOG.md index 5690eb2..7655220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +### Fixed +- crash from broken plugin loaded hook input from global + ## 3.3 - 2019-03-27 ### Added diff --git a/src/Record/Collector/Plugin_Load_Collector.php b/src/Record/Collector/Plugin_Load_Collector.php index 60fca42..22f8d95 100644 --- a/src/Record/Collector/Plugin_Load_Collector.php +++ b/src/Record/Collector/Plugin_Load_Collector.php @@ -32,15 +32,22 @@ public function __construct() { * * @param string $plugin Plugin file path. */ - public function plugin_loaded( string $plugin ): void { + public function plugin_loaded( $plugin ): void { + + $time = microtime( true ); + + if ( ! is_string( $plugin ) ) { // Broken hook input from global. + $this->last = $time; + + return; + } - $time = microtime( true ); $this->entries[] = [ 'name' => $plugin, 'origin' => $this->last, 'duration' => $time - $this->last, ]; - $this->last = $time; + $this->last = $time; } /**