33class PHPCS_Diff {
44
55 // PHPCS configuration.
6- private $ phpcs_command = 'phpcs ' ; // You might need to provde a path to phpcs.phar file.
7- private $ standards_location = '~/PHP_CodeSniffer/Standards ' ; // @todo: adjust the path to standards
6+ public $ phpcs_command = 'phpcs ' ; // You might need to provde a path to phpcs.phar file.
7+ public $ standards_location = '~/PHP_CodeSniffer/Standards ' ; // @todo: adjust the path to standards
88
9- private $ version_control ;
9+ public $ version_control ;
1010
1111 public $ allowed_extensions ;
1212
@@ -57,7 +57,7 @@ public function run( $oldest_rev, $newest_rev ) {
5757 $ cache_group = 'vip-phpcs ' ;
5858
5959 if ( true !== $ this ->nocache ) {
60- $ found_issues = wp_cache_get ( $ cache_key , $ cache_group );
60+ $ found_issues = false ; // wp_cache_get( $cache_key, $cache_group );
6161 if ( false !== $ found_issues ) {
6262 return $ found_issues ;
6363 }
@@ -72,10 +72,13 @@ public function run( $oldest_rev, $newest_rev ) {
7272 if ( false === $ this ->no_diff_to_big && strlen ( $ diff ) > 25000000 ) {
7373 $ error = new WP_Error ( 'diff-too-big ' , 'The Diff is too big to parse ' );
7474 if ( true !== $ this ->nocache ) {
75- wp_cache_set ( $ cache_key , $ error , $ cache_group , 3 *HOUR_IN_SECONDS );
75+ // wp_cache_set( $cache_key, $error, $cache_group, 3*HOUR_IN_SECONDS );
7676 }
7777 return $ error ;
7878 }
79+ if ( true === empty ( $ diff ) ) {
80+ return new WP_Error ( 'diff_parsing_error ' , 'Error parsing diff. ' );
81+ }
7982
8083 $ diff_info = $ this ->version_control ->parse_diff_for_info ( $ diff );
8184 $ file_diffs = $ diff_info ['file_diffs ' ];
@@ -103,7 +106,7 @@ public function run( $oldest_rev, $newest_rev ) {
103106 }
104107
105108 if ( true !== $ this ->nocache ) {
106- wp_cache_set ( $ cache_key , $ found_issues , $ cache_group , 3 *HOUR_IN_SECONDS );
109+ // wp_cache_set( $cache_key, $found_issues, $cache_group, 3*HOUR_IN_SECONDS );
107110 }
108111
109112 return $ found_issues ;
@@ -146,7 +149,7 @@ private function run_phpcs_for_file_revision( $filename, $revision ) {
146149 $ cache_key = 'phpcs_file_rev_ ' . md5 ( $ filename . $ revision . $ this ->phpcs_standard );
147150 $ cache_group = 'vip-phpcs ' ;
148151 if ( true !== $ this ->nocache ) {
149- $ result = wp_cache_get ( $ cache_key , $ cache_group );
152+ $ result = false ; // wp_cache_get( $cache_key, $cache_group );
150153 } else {
151154 $ result = false ;
152155 }
@@ -156,7 +159,7 @@ private function run_phpcs_for_file_revision( $filename, $revision ) {
156159 $ result = $ this ->version_control ->run_phpcs_for_file_at_revision ( $ filename , $ revision , $ this ->phpcs_command , $ this ->standards_location , $ this ->phpcs_standard );
157160
158161 if ( true !== $ this ->nocache ) {
159- wp_cache_set ( $ cache_key , $ result , $ cache_group , 6 *HOUR_IN_SECONDS );
162+ // wp_cache_set( $cache_key, $result, $cache_group, 6*HOUR_IN_SECONDS );
160163 }
161164 }
162165 return $ result ;
@@ -245,4 +248,4 @@ private function stop_the_insanity() {
245248 $ wp_object_cache ->__remoteset (); // important
246249 }
247250
248- }
251+ }
0 commit comments