From ca32f08966f1b51fcb19460f0996bb0c4048e6fe Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 3 Dec 2011 13:29:22 +0100 Subject: Update to MediaWiki 1.18.0 * also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing --- maintenance/checkSyntax.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'maintenance/checkSyntax.php') diff --git a/maintenance/checkSyntax.php b/maintenance/checkSyntax.php index 396cac5f..83f73be5 100644 --- a/maintenance/checkSyntax.php +++ b/maintenance/checkSyntax.php @@ -101,7 +101,9 @@ class CheckSyntax extends Maintenance { return; // process only this path } elseif ( $this->hasOption( 'list-file' ) ) { $file = $this->getOption( 'list-file' ); - $f = @fopen( $file, 'r' ); + wfSuppressWarnings(); + $f = fopen( $file, 'r' ); + wfRestoreWarnings(); if ( !$f ) { $this->error( "Can't open file $file\n", true ); } @@ -137,7 +139,7 @@ class CheckSyntax extends Maintenance { // Don't just put $IP, because the recursive dir thingie goes into all subdirs $dirs = array( $IP . '/includes', - $IP . '/config', + $IP . '/mw-config', $IP . '/languages', $IP . '/maintenance', $IP . '/skins', @@ -275,7 +277,9 @@ class CheckSyntax extends Maintenance { } $text = file_get_contents( $file ); + $tokens = token_get_all( $text ); + $this->checkEvilToken( $file, $tokens, '@', 'Error supression operator (@)'); $this->checkRegex( $file, $text, '/^[\s\r\n]+<\?/', 'leading whitespace' ); $this->checkRegex( $file, $text, '/\?>[\s\r\n]*$/', 'trailing ?>' ); $this->checkRegex( $file, $text, '/^[\xFF\xFE\xEF]/', 'byte-order mark' ); @@ -292,6 +296,18 @@ class CheckSyntax extends Maintenance { $this->mWarnings[$file][] = $desc; $this->output( "Warning in file $file: $desc found.\n" ); } + + private function checkEvilToken( $file, $tokens, $evilToken, $desc ) { + if ( !in_array( $evilToken, $tokens ) ) { + return; + } + + if ( !isset( $this->mWarnings[$file] ) ) { + $this->mWarnings[$file] = array(); + } + $this->mWarnings[$file][] = $desc; + $this->output( "Warning in file $file: $desc found.\n" ); + } } $maintClass = "CheckSyntax"; -- cgit v1.2.2