P3 (Plugin Performance Profiler) - Version 1.5.2

Version Description

Fixed a race condition in the error detection logic. Now P3 will auto deactivate 60 seconds after an error if it is not cleared.

Download this release

Release Info

Developer StarfieldTech
Plugin Icon wp plugin P3 (Plugin Performance Profiler)
Version 1.5.2
Comparing to
See all releases

Code changes from version 1.5.1 to 1.5.2

classes/class.p3-profiler-plugin.php CHANGED
@@ -75,9 +75,6 @@ class P3_Profiler_Plugin {
75
  $opts['debug'] = false;
76
  update_option( 'p3-profiler_options', $opts );
77
  update_option( 'p3-profiler_debug_log', array() );
78
- if ( !empty( $p3_profiler ) ) {
79
- remove_action( 'shutdown', array( $p3_profiler, 'shutdown_handler' ) );
80
- }
81
 
82
  // Remove mu-plugin
83
  if ( file_exists( WPMU_PLUGIN_DIR . '/p3-profiler.php' ) ) {
75
  $opts['debug'] = false;
76
  update_option( 'p3-profiler_options', $opts );
77
  update_option( 'p3-profiler_debug_log', array() );
 
 
 
78
 
79
  // Remove mu-plugin
80
  if ( file_exists( WPMU_PLUGIN_DIR . '/p3-profiler.php' ) ) {
classes/class.p3-profiler-reader.php CHANGED
@@ -226,7 +226,7 @@ if ( !defined('P3_PATH') )
226
  $tmp = $this->plugin_times;
227
  $this->plugin_times = array();
228
  foreach ( $tmp as $k => $v ) {
229
- $k = $this->_get_plugin_name( $k );
230
  $this->plugin_times[$k] = $v / $this->visits;
231
  }
232
 
@@ -291,7 +291,7 @@ if ( !defined('P3_PATH') )
291
  'breakdown' => array()
292
  );
293
  foreach ( $o->runtime->breakdown as $k => $v ) {
294
- $name = $this->_get_plugin_name( $k );
295
  if ( !array_key_exists( $name, $tmp['breakdown'] ) ) {
296
  $tmp['breakdown'][$name] = 0;
297
  }
@@ -302,13 +302,27 @@ if ( !defined('P3_PATH') )
302
  return $ret;
303
  }
304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  /**
306
  * Translate a plugin name
307
  * Uses get_plugin_data if available.
308
  * @param string $plugin Plugin name (possible paths will be guessed)
309
  * @return string
310
  */
311
- private function _get_plugin_name( $plugin ) {
312
  if ( function_exists( 'get_plugin_data' ) ) {
313
  $plugin_info = array();
314
  $possible_paths = array(
226
  $tmp = $this->plugin_times;
227
  $this->plugin_times = array();
228
  foreach ( $tmp as $k => $v ) {
229
+ $k = $this->get_plugin_name( $k );
230
  $this->plugin_times[$k] = $v / $this->visits;
231
  }
232
 
291
  'breakdown' => array()
292
  );
293
  foreach ( $o->runtime->breakdown as $k => $v ) {
294
+ $name = $this->get_plugin_name( $k );
295
  if ( !array_key_exists( $name, $tmp['breakdown'] ) ) {
296
  $tmp['breakdown'][$name] = 0;
297
  }
302
  return $ret;
303
  }
304
 
305
+ /**
306
+ * Get a raw list (slugs only) of the detected plugins
307
+ * @return array
308
+ */
309
+ public function get_raw_plugin_list() {
310
+ $tmp = array();
311
+ foreach ( $this->_data as $o ) {
312
+ foreach( $o->runtime->breakdown as $k => $v ) {
313
+ $tmp[] = $k;
314
+ }
315
+ }
316
+ return array_unique( $tmp );
317
+ }
318
+
319
  /**
320
  * Translate a plugin name
321
  * Uses get_plugin_data if available.
322
  * @param string $plugin Plugin name (possible paths will be guessed)
323
  * @return string
324
  */
325
+ public function get_plugin_name( $plugin ) {
326
  if ( function_exists( 'get_plugin_data' ) ) {
327
  $plugin_info = array();
328
  $possible_paths = array(
classes/class.p3-profiler.php CHANGED
@@ -168,23 +168,27 @@ class P3_Profiler {
168
  return $this;
169
  }
170
 
 
 
 
171
  // Error detection
172
  $flag = get_option( 'p3_profiler-error_detection' );
173
- if ( !empty( $flag ) ) {
174
  p3_profiler_disable();
175
- delete_option( 'p3_profiler-error_detection' );
176
  return $this;
177
  }
178
 
 
 
 
 
 
179
  // Kludge memory limit / time limit
180
  if ( (int) @ini_get( 'memory_limit' ) < 256 ) {
181
  @ini_set( 'memory_limit', '256M' );
182
  }
183
  @set_time_limit( 90 );
184
 
185
- // Set the error detection flag
186
- update_option( 'p3_profiler-error_detection', time() );
187
-
188
  // Set the profile file
189
  $this->_profile_filename = $opts['profiling_enabled']['name'] . '.json';
190
 
@@ -236,7 +240,6 @@ class P3_Profiler {
236
  // Monitor all function-calls
237
  declare( ticks = 1 );
238
  register_tick_function( array( $this, 'tick_handler' ) );
239
- add_action( 'shutdown', array( $this, 'shutdown_handler' ) );
240
  }
241
 
242
  /**
168
  return $this;
169
  }
170
 
171
+ // Hook shutdown
172
+ register_shutdown_function( array( $this, 'shutdown_handler' ) );
173
+
174
  // Error detection
175
  $flag = get_option( 'p3_profiler-error_detection' );
176
+ if ( !empty( $flag ) && $flag > time() + 60 ) {
177
  p3_profiler_disable();
 
178
  return $this;
179
  }
180
 
181
+ // Set the error detection flag
182
+ if ( empty( $flag ) ) {
183
+ update_option( 'p3_profiler-error_detection', time() );
184
+ }
185
+
186
  // Kludge memory limit / time limit
187
  if ( (int) @ini_get( 'memory_limit' ) < 256 ) {
188
  @ini_set( 'memory_limit', '256M' );
189
  }
190
  @set_time_limit( 90 );
191
 
 
 
 
192
  // Set the profile file
193
  $this->_profile_filename = $opts['profiling_enabled']['name'] . '.json';
194
 
240
  // Monitor all function-calls
241
  declare( ticks = 1 );
242
  register_tick_function( array( $this, 'tick_handler' ) );
 
243
  }
244
 
245
  /**
p3-profiler.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: P3 (Plugin Performance Profiler)
4
  Plugin URI: http://support.godaddy.com/godaddy/wordpress-p3-plugin/
5
  Description: See which plugins are slowing down your site. Create a profile of your WordPress site's plugins' performance by measuring their impact on your site's load time.
6
  Author: GoDaddy.com
7
- Version: 1.5.1
8
  Author URI: http://www.godaddy.com/
9
  Text Domain: p3-profiler
10
  Domain Path: /languages
@@ -80,6 +80,27 @@ if ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) {
80
  add_action( 'admin_notices', array( 'P3_Profiler_Plugin_Admin', 'show_notices' ) );
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  // Remove the admin bar when in profiling mode
84
  } elseif ( defined( 'WPP_PROFILING_STARTED' ) || isset( $_GET['P3_HIDE_ADMIN_BAR'] ) ) {
85
  add_action( 'plugins_loaded', array( 'P3_Profiler_Plugin_Admin', 'remove_admin_bar' ) );
4
  Plugin URI: http://support.godaddy.com/godaddy/wordpress-p3-plugin/
5
  Description: See which plugins are slowing down your site. Create a profile of your WordPress site's plugins' performance by measuring their impact on your site's load time.
6
  Author: GoDaddy.com
7
+ Version: 1.5.2
8
  Author URI: http://www.godaddy.com/
9
  Text Domain: p3-profiler
10
  Domain Path: /languages
80
  add_action( 'admin_notices', array( 'P3_Profiler_Plugin_Admin', 'show_notices' ) );
81
  }
82
 
83
+ function p3_plugin_disclaimers( $profile ) {
84
+ $disclaimed_plugins = array(
85
+ 'jetpack',
86
+ 'wordpress-seo',
87
+ );
88
+
89
+ if ( $detected = array_intersect( $disclaimed_plugins, $profile->get_raw_plugin_list() ) ) {
90
+ ?>
91
+ <div class="updated inline">
92
+ <p><?php printf( __( 'Some plugins may show artificially high results. <a href="%s">More info</a>', 'p3-profiler' ), admin_url( 'tools.php?page=p3-profiler&p3_action=help#q17' ) ); ?></p>
93
+ <ul style="list-style: initial; margin-left: 1.5em;">
94
+ <?php foreach ( $detected as $plugin ) : ?>
95
+ <li><?php echo $profile->get_plugin_name( $plugin ); ?></li>
96
+ <?php endforeach; ?>
97
+ </ul>
98
+ </div>
99
+ <?php
100
+ }
101
+ }
102
+ add_action( 'p3_runtime_by_plugin_notifications', 'p3_plugin_disclaimers' );
103
+
104
  // Remove the admin bar when in profiling mode
105
  } elseif ( defined( 'WPP_PROFILING_STARTED' ) || isset( $_GET['P3_HIDE_ADMIN_BAR'] ) ) {
106
  add_action( 'plugins_loaded', array( 'P3_Profiler_Plugin_Admin', 'remove_admin_bar' ) );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Godaddy, StarfieldTech, kurtpayne
3
  Tags: debug, debugging, developer, development, performance, plugin, profiler, speed
4
  Requires at least: 3.3
5
  Tested up to: 4.0
6
- Stable tag: 1.5.1
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -47,6 +47,9 @@ Manual installation:
47
 
48
  == Upgrade Notice ==
49
 
 
 
 
50
  = 1.5.1 =
51
  Fix a bug which broke debug mode and caused scanning to not work properly for some users.
52
 
@@ -85,10 +88,6 @@ This version addresses a path disclosure issue. Users are encouraged to upgrade
85
 
86
  == Frequently Asked Questions ==
87
 
88
- = Why are Jetpack and Yoast SEO slowing my site down so much? =
89
-
90
- They're really not. P3 measures your site's performance while you're logged in. This activates extra features on these plugins for administrators that will not be visible to your users. The teams behind these plugins have put a lot of work on optimizing their plugins for performance and you should feel safe leaving these plugins installed and active.
91
-
92
  = I installed P3, what now? =
93
 
94
  Open the **Tools** menu, then open **P3 Plugin Profiler** then click **Scan Now**.
@@ -147,6 +146,10 @@ add_filter( 'p3_automatic_scan_urls', 'my_p3_auto_scan_pages' );
147
 
148
  == Changelog ==
149
 
 
 
 
 
150
  = 1.5.1 =
151
  * Fix a bug which broke debug mode and caused scanning to not work properly for some users.
152
 
3
  Tags: debug, debugging, developer, development, performance, plugin, profiler, speed
4
  Requires at least: 3.3
5
  Tested up to: 4.0
6
+ Stable tag: 1.5.2
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
47
 
48
  == Upgrade Notice ==
49
 
50
+ = 1.5.2 =
51
+ Fixed a race condition in the error detection logic. Now P3 will auto deactivate 60 seconds after an error if it is not cleared.
52
+
53
  = 1.5.1 =
54
  Fix a bug which broke debug mode and caused scanning to not work properly for some users.
55
 
88
 
89
  == Frequently Asked Questions ==
90
 
 
 
 
 
91
  = I installed P3, what now? =
92
 
93
  Open the **Tools** menu, then open **P3 Plugin Profiler** then click **Scan Now**.
146
 
147
  == Changelog ==
148
 
149
+ = 1.5.2 =
150
+ * Fix a race condition in the error detection logic
151
+ * Add a notice about WordPress SEO and Jetpack
152
+
153
  = 1.5.1 =
154
  * Fix a bug which broke debug mode and caused scanning to not work properly for some users.
155
 
start-profile.php CHANGED
@@ -49,8 +49,11 @@ function p3_profiler_disable() {
49
  if ( false === $transient ) {
50
  $transient = '';
51
  }
52
- file_put_contents( $path, $transient );
 
 
53
  delete_option( 'p3_scan_' . $opts['profiling_enabled']['name'], $transient );
 
54
  $opts['profiling_enabled'] = false;
55
  update_option( 'p3-profiler_options', $opts );
56
  }
49
  if ( false === $transient ) {
50
  $transient = '';
51
  }
52
+ if ( !empty( $opts ) && array_key_exists( 'profiling_enabled', $opts ) && !empty( $opts['profiling_enabled']['name'] ) ) {
53
+ file_put_contents( $path, $transient );
54
+ }
55
  delete_option( 'p3_scan_' . $opts['profiling_enabled']['name'], $transient );
56
+ delete_option( 'p3_profiler-error_detection' );
57
  $opts['profiling_enabled'] = false;
58
  update_option( 'p3-profiler_options', $opts );
59
  }
templates/help.php CHANGED
@@ -439,6 +439,13 @@ After you've tuned your site up as much as possible, if you're still not happy w
439
  </blockquote>
440
  </div>
441
 
 
 
 
 
 
 
 
442
  <div class="p3-question">
443
  <h2 class="p3-help-question q-glossary" style="border-bottom-width: 0px !important;"><?php _e( 'Glossary', 'p3-profiler' ); ?></h2>
444
  <blockquote class="q-glossary-data">
439
  </blockquote>
440
  </div>
441
 
442
+ <div class="p3-question">
443
+ <h2 class="p3-help-question q-jetpack"><?php _e( "Why do some plugins show artificially high results?", 'p3-profiler' ); ?></h2>
444
+ <blockquote class="q-specfic-data">
445
+ <?php _e( "P3 scans your site as a logged in user. Some plugins enable more functionality when you are logged in. When P3 detects a plugin which could be a false positive, such as Jetpack, you'll see a notice. The authors of these plugins have put a focus on performance and you should feel safe leaving them enabled on your site if you need the functionality they provide.", 'p3-profiler' ); ?>
446
+ </blockquote>
447
+ </div>
448
+
449
  <div class="p3-question">
450
  <h2 class="p3-help-question q-glossary" style="border-bottom-width: 0px !important;"><?php _e( 'Glossary', 'p3-profiler' ); ?></h2>
451
  <blockquote class="q-glossary-data">
templates/view-scan.php CHANGED
@@ -1079,4 +1079,6 @@ $plugin_list
1079
  <div id="p3-detailed-series-toggle" class="p3-dialog">
1080
 
1081
  </div>
1082
- </div>
 
 
1079
  <div id="p3-detailed-series-toggle" class="p3-dialog">
1080
 
1081
  </div>
1082
+ </div>
1083
+
1084
+ <?php do_action( 'p3_runtime_by_plugin_notifications', self::$profile ); ?>