summaryrefslogtreecommitdiff
path: root/maintenance/checkSyntax.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /maintenance/checkSyntax.php
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'maintenance/checkSyntax.php')
-rw-r--r--maintenance/checkSyntax.php20
1 files changed, 18 insertions, 2 deletions
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";