| @@ -20,8 +20,9 @@ | ||
| 20 | 20 | private $last_type; |
| 21 | 21 | private $last_time = 0; |
| 22 | 22 | private $themes = []; |
| 23 | 23 | private $plugins = []; |
| 24 | + private $composer = []; | |
| 24 | 25 | private $summary_list = []; |
| 25 | 26 | private $cx_buffer = []; |
| 26 | 27 | private $parsed_data = 0; |
| 27 | 28 | private $plugins_dir; |
| @@ -93,8 +94,9 @@ | ||
| 93 | 94 | $this->save_iostats(); |
| 94 | 95 | $this->save_connections(); |
| 95 | 96 | $this->save_data(); |
| 96 | 97 | $this->save_diskio(); |
| 98 | + $this->save_composer(); | |
| 97 | 99 | |
| 98 | 100 | code_profiler_log_info( sprintf( |
| 99 | 101 | __('Volume of code and data analyzed: %1$sMB (%2$s plugins and '. |
| 100 | 102 | '1 theme) in %4$ss - Memory used: %3$sMB', 'code-profiler'), |
| @@ -208,14 +210,8 @@ | ||
| 208 | 210 | $this->summary_list['items'] = $this->total_plugins + 1; // Add the theme |
| 209 | 211 | $this->summary_list['time'] = $this->convert_2_seconds( $this->summary_list['time'] ); |
| 210 | 212 | $this->summary_list['time'] = number_format( $this->summary_list['time'], 4 ); |
| 211 | 213 | |
| 212 | - // Re-run options | |
| 213 | - if (! empty( $s['rerun'] ) ) { | |
| 214 | - $this->summary_list['rerun'] = $s['rerun']; | |
| 215 | - $this->summary_list['rerun']['profile'] = $this->profile_name; | |
| 216 | - } | |
| 217 | - | |
| 218 | 214 | // Save Code Profiler, PHP and WordPress' versions |
| 219 | 215 | global $wp_version; |
| 220 | 216 | $this->summary_list['versions'] = [ |
| 221 | 217 | 'wp' => $wp_version, |
| @@ -223,8 +219,9 @@ | ||
| 223 | 219 | 'php' => PHP_VERSION |
| 224 | 220 | ]; |
| 225 | 221 | |
| 226 | 222 | file_put_contents( $summary_json, json_encode( $this->summary_list ) ); |
| 223 | + | |
| 227 | 224 | } |
| 228 | 225 | |
| 229 | 226 | |
| 230 | 227 | /** |
| @@ -388,8 +385,16 @@ | ||
| 388 | 385 | if (! isset( $this->plugins[ $slug['plugin'] ]['time'] ) ) { |
| 389 | 386 | $this->plugins[ $slug['plugin'] ]['time'] = 0; |
| 390 | 387 | } |
| 391 | 388 | } |
| 389 | + | |
| 390 | + // Look for multiple copies of composer and warn the user | |
| 391 | + if ( preg_match("`^{$this->plugins_dir}[\\\/](?:[^\\\/]+)[\\\/].+?[\\\/]composer[\\\/]autoload_real\.php`", $caller ) ) { | |
| 392 | + // Save the slug first, we'll fetch the name later | |
| 393 | + if (! isset( $this->composer[ $slug['plugin'] ] ) ) { | |
| 394 | + $this->composer[ $slug['plugin'] ] = ''; | |
| 395 | + } | |
| 396 | + } | |
| 392 | 397 | } |
| 393 | 398 | |
| 394 | 399 | // We don't have a slug: if there's an old record, update it |
| 395 | 400 | } else { |
| @@ -465,8 +470,27 @@ | ||
| 465 | 470 | CODE_PROFILER_UPLOAD_DIR ."/{$this->microtime}.{$this->profile_name}.diskio.profile" |
| 466 | 471 | ); |
| 467 | 472 | } |
| 468 | 473 | |
| 474 | + | |
| 475 | + /** | |
| 476 | + * Save list of plugins using composer | |
| 477 | + */ | |
| 478 | + private function save_composer() { | |
| 479 | + | |
| 480 | + if (! empty( $this->composer ) ) { | |
| 481 | + // Try to get the plugin's name | |
| 482 | + foreach( $this->composer as $slug => $v ) { | |
| 483 | + if ( isset( $this->plugins[ $slug ]['name'] ) ) { | |
| 484 | + $this->composer[ $slug ] = $this->plugins[ $slug ]['name']; | |
| 485 | + } | |
| 486 | + } | |
| 487 | + file_put_contents( | |
| 488 | + CODE_PROFILER_UPLOAD_DIR ."/{$this->microtime}.{$this->profile_name}.composer.profile", | |
| 489 | + json_encode( $this->composer ) | |
| 490 | + ); | |
| 491 | + } | |
| 492 | + } | |
| 469 | 493 | |
| 470 | 494 | /** |
| 471 | 495 | * External connections. |
| 472 | 496 | */ |