Skip to content

Commit

Permalink
Fixed crash from broken plugin loaded hook input from global
Browse files Browse the repository at this point in the history
Fixes #35
  • Loading branch information
Rarst committed Jul 2, 2019
1 parent e2f85f4 commit 54ba716
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions src/Record/Collector/Plugin_Load_Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 54ba716

Please sign in to comment.