Checking images for syntax errors can yield funky results:)
authorMax Semenik <maxsem@users.mediawiki.org>
Wed, 18 Nov 2009 17:57:32 +0000 (17:57 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Wed, 18 Nov 2009 17:57:32 +0000 (17:57 +0000)
maintenance/syntaxChecker.php

index 8710e2d..86d7827 100644 (file)
@@ -95,7 +95,11 @@ class SyntaxChecker extends Maintenance {
                        }
 
                        preg_match_all( '/^\s*[AM]\s+(.*?)\r?$/m', $output, $matches );
-                       $this->mFiles = array_merge( $this->mFiles, $matches[1] );
+                       foreach ( $matches[1] as $file ) {
+                               if ( self::isSuitableFile( $file ) && !is_dir( $file ) ) {
+                                       $this->mFiles[] = $file;
+                               }
+                       }
                        return;
                }
 
@@ -128,6 +132,14 @@ class SyntaxChecker extends Maintenance {
 
                $this->output( "done.\n" );
        }
+       
+       /**
+        * Returns true if $file is of a type we can check
+        */
+       private static function isSuitableFile( $file ) {
+               $ext = pathinfo( $file, PATHINFO_EXTENSION );
+               return $ext == 'php' || $ext == 'inc' || $ext == 'php5';
+       }
 
        /**
         * Add given path to file list, searching it in include path if needed
@@ -162,8 +174,7 @@ class SyntaxChecker extends Maintenance {
                        RecursiveIteratorIterator::SELF_FIRST
                );
                foreach ( $iterator as $file ) {
-                       $ext = pathinfo( $file->getFilename(), PATHINFO_EXTENSION );
-                       if ( $ext == 'php' || $ext == 'inc' || $ext == 'php5' ) {
+                       if ( self::isSuitableFile( $file->getRealPath() ) ) {
                                $this->mFiles[] = $file->getRealPath();
                        }
                }