Check that no MySQL-isms have snuck into the codebase.
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Wed, 30 Apr 2008 14:44:22 +0000 (14:44 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Wed, 30 Apr 2008 14:44:22 +0000 (14:44 +0000)
maintenance/postgres/compare_schemas.pl

index 2a74ae3..fd06502 100644 (file)
@@ -2,11 +2,14 @@
 
 ## Rough check that the base and postgres "tables.sql" are in sync
 ## Should be run from maintenance/postgres
+## Checks a few other things as well...
 
 use strict;
 use warnings;
 use Data::Dumper;
 
+check_includes_dir();
+
 my @old = ('../tables.sql');
 my $new = 'tables.sql';
 my @xfile;
@@ -453,6 +456,39 @@ for (sort keys %new) {
 } ## end each file to be parsed
 
 
+sub check_includes_dir {
+
+       ## Check for some common errors in the files in the includes directory
+
+       print "Checking files in includes directory...\n";
+       my $dir = "../../includes";
+       opendir my $dh, $dir or die qq{Could not opendir $dir: $!\n};
+       for my $file (grep { -f "$dir/$_" and /\.php$/ } readdir $dh) {
+               $file = "$dir/$file";
+               open my $fh, '<', $file or die qq{Could not open "$file": $!\n};
+               while (<$fh>) {
+                       if (/FORCE INDEX/ and $file !~ /Database.php/) {
+                               warn "Found FORCE INDEX string at line $. of $file\n";
+                       }
+                       if (/REPLACE INTO/ and $file !~ /Database/) {
+                               warn "Found REPLACE INTO string at line $. of $file\n";
+                       }
+                       if (/\bIF\s*\(/ and $file !~ /Database.php/) {
+                               warn "Found IF string at line $. of $file\n";
+                       }
+                       if (/\bCONCAT\b/ and $file !~ /Database.php/) {
+                               warn "Found CONCAT string at line $. of $file\n";
+                       }
+               }
+               close $fh or die qq{Could not close "$file": $!\n};
+       }
+       closedir $dh or die qq{Closedir failed?!\n};
+
+
+
+
+} ## end of check_includes_dir
+
 __DATA__
 ## Known exceptions
 OLD: searchindex          ## We use tsearch2 directly on the page table instead