Fixed crash from broken plugin loaded hook input from global

Fixes #35
This commit is contained in:
Andrey Savchenko committed 2019-07-02 14:46:13 +03:00
1 parent e2f85f44d2
commit 54ba716ba8
2 files changed
+13 -3

No files matched your search

+3
View File
@@ -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
+10 -3
View File
@@ -32,15 +32,22 @@ class Plugin_Load_Collector implements Record_Collector_Interface {
*
* @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;
}
/**