PHP Compatibility Checker - Version 1.0.1

Version Description

  • Updated compatibility library with a few bugfixes
  • Added skip logic to prevent checker from hanging
Download this release

Release Info

Developer wpengine
Plugin Icon 128x128 PHP Compatibility Checker
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpengine, octalmage, stevenkword, taylor4484
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.0.1
5
  Tested up to: 4.5
6
- Stable tag: 1.0.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -69,8 +69,10 @@ Yes, this plugin can be used any ANY WordPress website on ANY host.
69
 
70
  Yes! While you cannot use this WordPress plugin to test your non-WordPress projects, you can use the [Open Source PHPCompatibility Library](https://github.com/wimg/PHPCompatibility) that this plugin is built on.
71
 
 
 
72
 
73
- 5) I found a bug, or have a suggestion, can I contribute back?
74
 
75
  Yes! WP Engine has a public GitHub repo where you can contribute back to this plugin. Please open an issue on the [Plugin GitHub](https://github.com/wpengine/phpcompat). We actively develop this plugin, and are always happy to receive pull requests.
76
 
@@ -83,6 +85,10 @@ The plugin was created by WP Engine to help the WordPress community increase ado
83
 
84
  == Changelog ==
85
 
 
 
 
 
86
  = 1.0.0 =
87
  - Major update to add PHP 7 checking support
88
  - Improved the UX of the progress bar
@@ -95,7 +101,6 @@ The plugin was created by WP Engine to help the WordPress community increase ado
95
 
96
  == Upgrade Notice ==
97
 
98
- = 1.0.0 =
99
- - Major update to add PHP 7 checking support
100
- - Improved the UX of the progress bar
101
- - Fixed bug with the way the plugin menu was registered
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.0.1
5
  Tested up to: 4.5
6
+ Stable tag: 1.0.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
69
 
70
  Yes! While you cannot use this WordPress plugin to test your non-WordPress projects, you can use the [Open Source PHPCompatibility Library](https://github.com/wimg/PHPCompatibility) that this plugin is built on.
71
 
72
+ 3) Why was my plugin/theme skipped?
73
+ Some servers have timeouts to prevent long running queries, this is commonly 60 seconds. This can prevent the checker from being able to process large themes or plugins. You should check with your host to see if this timeout can be temporarily removed. The best way around this timeout issues is to run this plugin on a [local copy](https://make.wordpress.org/core/handbook/tutorials/installing-a-local-server/) of your site.
74
 
75
+ 4) I found a bug, or have a suggestion, can I contribute back?
76
 
77
  Yes! WP Engine has a public GitHub repo where you can contribute back to this plugin. Please open an issue on the [Plugin GitHub](https://github.com/wpengine/phpcompat). We actively develop this plugin, and are always happy to receive pull requests.
78
 
85
 
86
  == Changelog ==
87
 
88
+ = 1.0.1 =
89
+ - Updated compatibility library with a few bugfixes
90
+ - Added skip logic to prevent checker from hanging
91
+
92
  = 1.0.0 =
93
  - Major update to add PHP 7 checking support
94
  - Improved the UX of the progress bar
101
 
102
  == Upgrade Notice ==
103
 
104
+ = 1.0.1 =
105
+ - Updated compatibility library with a few bugfixes
106
+ - Added skip logic to prevent checker from hanging
 
src/images/question.png ADDED
Binary file
src/js/run.js CHANGED
@@ -3,15 +3,6 @@ var test_version, only_active, timer;
3
 
4
  jQuery( document ).ready(function($) {
5
 
6
- // Handlebars if conditional.
7
- Handlebars.registerHelper('if', function( conditional, options ) {
8
- if ( conditional ) {
9
- return options.fn( this );
10
- } else {
11
- return options.inverse( this );
12
- }
13
- });
14
-
15
  $( '#developermode' ).change(function() {
16
  if ( $(this).is( ':checked' ) ) {
17
  $( '#developerMode' ).show();
@@ -159,6 +150,7 @@ function displayReport( response ) {
159
  var updateVersion;
160
  var updateAvailable = 0;
161
  var passed = 1;
 
162
  // Extract plugin/theme name.
163
  var name = plugins[x].substring( 0, plugins[x].indexOf( '\n' ) );
164
  // Extract results.
@@ -177,6 +169,10 @@ function displayReport( response ) {
177
  }
178
  // Trim whitespace and newlines from report.
179
  log = log.replace( /^\s+|\s+$/g, '' );
 
 
 
 
180
  // Use handlebars to build our template.
181
  var source = $( '#result-template' ).html();
182
  var template = Handlebars.compile( source );
@@ -186,6 +182,7 @@ function displayReport( response ) {
186
  errors: errors,
187
  logs: log,
188
  passed: passed,
 
189
  test_version: test_version,
190
  updateAvailable: updateAvailable
191
  };
3
 
4
  jQuery( document ).ready(function($) {
5
 
 
 
 
 
 
 
 
 
 
6
  $( '#developermode' ).change(function() {
7
  if ( $(this).is( ':checked' ) ) {
8
  $( '#developerMode' ).show();
150
  var updateVersion;
151
  var updateAvailable = 0;
152
  var passed = 1;
153
+ var skipped = 0;
154
  // Extract plugin/theme name.
155
  var name = plugins[x].substring( 0, plugins[x].indexOf( '\n' ) );
156
  // Extract results.
169
  }
170
  // Trim whitespace and newlines from report.
171
  log = log.replace( /^\s+|\s+$/g, '' );
172
+
173
+ if ( log.search('skipped') !== -1 ) {
174
+ skipped = 1;
175
+ }
176
  // Use handlebars to build our template.
177
  var source = $( '#result-template' ).html();
178
  var template = Handlebars.compile( source );
182
  errors: errors,
183
  logs: log,
184
  passed: passed,
185
+ skipped: skipped,
186
  test_version: test_version,
187
  updateAvailable: updateAvailable
188
  };
src/wpephpcompat.php CHANGED
@@ -147,13 +147,34 @@ class WPEPHPCompat {
147
  foreach ( $directories as $directory ) {
148
  $this->debug_log( 'Processing: ' . $directory->post_title );
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  $report = $this->process_file( $directory->post_content );
151
 
152
  if ( ! $report ) {
153
  $report = 'PHP ' . $this->test_version . ' compatible.';
154
  }
155
 
156
- $scan_results .= 'Name: ' . $directory->post_title . "\n\n" . $report . "\n";
157
 
158
  $update = get_post_meta( $directory->ID, 'update', true );
159
 
147
  foreach ( $directories as $directory ) {
148
  $this->debug_log( 'Processing: ' . $directory->post_title );
149
 
150
+ // Add the plugin/theme name to the results.
151
+ $scan_results .= 'Name: ' . $directory->post_title . "\n\n";
152
+
153
+ // Keep track of the number of times we've attempted to scan the plugin.
154
+ $count = get_post_meta( $directory->ID, 'count', true ) ?: 1;
155
+ $this->debug_log( 'Attempted scan count: ' . $count );
156
+
157
+ if ( $count > 2 ) { // If we've already tried twice, skip it.
158
+ $scan_results .= "The plugin/theme was skipped as it was too large to scan before the server killed the process.\n\n";
159
+ update_option( 'wpephpcompat.scan_results', $scan_results , false );
160
+ wp_delete_post( $directory->ID );
161
+ $count = 0;
162
+ $this->debug_log( 'Skipped: ' .$directory->post_title );
163
+ continue;
164
+ }
165
+
166
+ // Increment and save the count.
167
+ $count++;
168
+ update_post_meta( $directory->ID, 'count', $count );
169
+
170
+ // Start the scan.
171
  $report = $this->process_file( $directory->post_content );
172
 
173
  if ( ! $report ) {
174
  $report = 'PHP ' . $this->test_version . ' compatible.';
175
  }
176
 
177
+ $scan_results .= $report . "\n";
178
 
179
  $update = get_post_meta( $directory->ID, 'update', true );
180
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php CHANGED
@@ -53,7 +53,6 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends
53
  T_PRIVATE => '5.0',
54
  T_PROTECTED => '5.0',
55
  T_PUBLIC => '5.0',
56
- T_THROW => '5.0',
57
  T_TRAIT => '5.4',
58
  T_TRY => '5.0',
59
  T_NULL => '7.0',
53
  T_PRIVATE => '5.0',
54
  T_PROTECTED => '5.0',
55
  T_PUBLIC => '5.0',
 
56
  T_TRAIT => '5.4',
57
  T_TRY => '5.0',
58
  T_NULL => '7.0',
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php CHANGED
@@ -58,8 +58,12 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff
58
  $defaultToken = $stackPtr;
59
  $defaultCount = 0;
60
  if (isset($tokens[$stackPtr]['scope_closer'])) {
61
- while ($defaultToken = $phpcsFile->findNext(T_DEFAULT, $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
62
- $defaultCount++;
 
 
 
 
63
  }
64
 
65
  if ($defaultCount > 1) {
58
  $defaultToken = $stackPtr;
59
  $defaultCount = 0;
60
  if (isset($tokens[$stackPtr]['scope_closer'])) {
61
+ while ($defaultToken = $phpcsFile->findNext(array(T_DEFAULT, T_SWITCH), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
62
+ if ($tokens[$defaultToken]['type'] == 'T_SWITCH') {
63
+ $defaultToken = $tokens[$defaultToken]['scope_closer'];
64
+ } else {
65
+ $defaultCount++;
66
+ }
67
  }
68
 
69
  if ($defaultCount > 1) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php CHANGED
@@ -118,10 +118,32 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
118
 
119
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
120
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
 
 
 
 
 
 
 
 
121
 
122
  $nextComma = $stackPtr + 1;
123
  $cnt = 0;
124
  while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  if (isset($this->removedFunctionParameters[$function][$cnt])) {
126
  $this->addError($phpcsFile, $nextComma, $function, $cnt);
127
  }
118
 
119
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
120
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
121
+ $openParenthesis = $tokens[$closeParenthesis]['parenthesis_opener'];
122
+
123
+ $nextItem = $phpcsFile->findNext(array(), $openParenthesis + 1, $closeParenthesis, true);
124
+ if (isset($tokens[$nextItem]['nested_parenthesis'])) {
125
+ $parenthesisCount = count($tokens[$nextItem]['nested_parenthesis']);
126
+ } else {
127
+ $parenthesisCount = 0;
128
+ }
129
 
130
  $nextComma = $stackPtr + 1;
131
  $cnt = 0;
132
  while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
133
+ if (
134
+ $tokens[$nextComma]['type'] == 'T_COMMA'
135
+ &&
136
+ isset($tokens[$nextComma]['nested_parenthesis'])
137
+ &&
138
+ count($tokens[$nextComma]['nested_parenthesis']) != $parenthesisCount
139
+ ) {
140
+ continue;
141
+ }
142
+
143
+ if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
144
+ continue;
145
+ }
146
+
147
  if (isset($this->removedFunctionParameters[$function][$cnt])) {
148
  $this->addError($phpcsFile, $nextComma, $function, $cnt);
149
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php CHANGED
@@ -53,7 +53,6 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends
53
  T_PRIVATE => '5.0',
54
  T_PROTECTED => '5.0',
55
  T_PUBLIC => '5.0',
56
- T_THROW => '5.0',
57
  T_TRAIT => '5.4',
58
  T_TRY => '5.0',
59
  T_NULL => '7.0',
53
  T_PRIVATE => '5.0',
54
  T_PROTECTED => '5.0',
55
  T_PUBLIC => '5.0',
 
56
  T_TRAIT => '5.4',
57
  T_TRY => '5.0',
58
  T_NULL => '7.0',
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php CHANGED
@@ -58,8 +58,12 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff
58
  $defaultToken = $stackPtr;
59
  $defaultCount = 0;
60
  if (isset($tokens[$stackPtr]['scope_closer'])) {
61
- while ($defaultToken = $phpcsFile->findNext(T_DEFAULT, $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
62
- $defaultCount++;
 
 
 
 
63
  }
64
 
65
  if ($defaultCount > 1) {
58
  $defaultToken = $stackPtr;
59
  $defaultCount = 0;
60
  if (isset($tokens[$stackPtr]['scope_closer'])) {
61
+ while ($defaultToken = $phpcsFile->findNext(array(T_DEFAULT, T_SWITCH), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) {
62
+ if ($tokens[$defaultToken]['type'] == 'T_SWITCH') {
63
+ $defaultToken = $tokens[$defaultToken]['scope_closer'];
64
+ } else {
65
+ $defaultCount++;
66
+ }
67
  }
68
 
69
  if ($defaultCount > 1) {
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php CHANGED
@@ -118,10 +118,32 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
118
 
119
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
120
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
 
 
 
 
 
 
 
 
121
 
122
  $nextComma = $stackPtr + 1;
123
  $cnt = 0;
124
  while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  if (isset($this->removedFunctionParameters[$function][$cnt])) {
126
  $this->addError($phpcsFile, $nextComma, $function, $cnt);
127
  }
118
 
119
  if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
120
  $closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
121
+ $openParenthesis = $tokens[$closeParenthesis]['parenthesis_opener'];
122
+
123
+ $nextItem = $phpcsFile->findNext(array(), $openParenthesis + 1, $closeParenthesis, true);
124
+ if (isset($tokens[$nextItem]['nested_parenthesis'])) {
125
+ $parenthesisCount = count($tokens[$nextItem]['nested_parenthesis']);
126
+ } else {
127
+ $parenthesisCount = 0;
128
+ }
129
 
130
  $nextComma = $stackPtr + 1;
131
  $cnt = 0;
132
  while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS), $nextComma + 1, $closeParenthesis + 1)) {
133
+ if (
134
+ $tokens[$nextComma]['type'] == 'T_COMMA'
135
+ &&
136
+ isset($tokens[$nextComma]['nested_parenthesis'])
137
+ &&
138
+ count($tokens[$nextComma]['nested_parenthesis']) != $parenthesisCount
139
+ ) {
140
+ continue;
141
+ }
142
+
143
+ if ($tokens[$nextComma]['type'] == 'T_CLOSE_PARENTHESIS' && $nextComma != $closeParenthesis) {
144
+ continue;
145
+ }
146
+
147
  if (isset($this->removedFunctionParameters[$function][$cnt])) {
148
  $this->addError($phpcsFile, $nextComma, $function, $cnt);
149
  }
wpengine-phpcompat.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: PHP Compatibility Checker
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
- Version: 1.0.0
8
  Author URI: https://wpengine.com
9
  */
10
 
@@ -253,13 +253,13 @@ class WPEngine_PHPCompat {
253
 
254
  <!-- Results template -->
255
  <script id="result-template" type="text/x-handlebars-template">
256
- <div style="border-left-color: {{#if passed}}#038103{{else}}#e74c3c{{/if}};" class="wpe-results-card">
257
  <div class="inner-left">
258
- {{#if passed}}<img src="<?php echo esc_url( plugins_url( '/src/images/check.png', __FILE__ ) ); ?>">{{else}}<img src="<?php echo esc_url( plugins_url( '/src/images/x.png', __FILE__ ) ); ?>">{{/if}}
259
  </div>
260
  <div class="inner-right">
261
  <h3 style="margin: 0px;">{{plugin_name}}</h3>
262
- {{#if passed}}PHP {{test_version}} compatible.{{else}}<b>Not</b> PHP {{test_version}} compatible.{{/if}}<br>
263
  {{update}}<br>
264
  <textarea style="display: none; white-space: pre;">{{logs}}</textarea><a class="view-details">view details</a>
265
  </div>
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
+ Version: 1.0.1
8
  Author URI: https://wpengine.com
9
  */
10
 
253
 
254
  <!-- Results template -->
255
  <script id="result-template" type="text/x-handlebars-template">
256
+ <div style="border-left-color: {{#if skipped}}#999999{{else if passed}}#038103{{else}}#e74c3c{{/if}};" class="wpe-results-card">
257
  <div class="inner-left">
258
+ {{#if skipped}}<img src="<?php echo esc_url( plugins_url( '/src/images/question.png', __FILE__ ) ); ?>">{{else if passed}}<img src="<?php echo esc_url( plugins_url( '/src/images/check.png', __FILE__ ) ); ?>">{{else}}<img src="<?php echo esc_url( plugins_url( '/src/images/x.png', __FILE__ ) ); ?>">{{/if}}
259
  </div>
260
  <div class="inner-right">
261
  <h3 style="margin: 0px;">{{plugin_name}}</h3>
262
+ {{#if skipped}}Unknown{{else if passed}}PHP {{test_version}} compatible.{{else}}<b>Not</b> PHP {{test_version}} compatible.{{/if}}<br>
263
  {{update}}<br>
264
  <textarea style="display: none; white-space: pre;">{{logs}}</textarea><a class="view-details">view details</a>
265
  </div>