Follow-up r81619: Add new message key to maintenance file
[lhc/web/wiklou.git] / maintenance / update.php
index 57ce9aa..9c42b44 100644 (file)
@@ -5,6 +5,21 @@
  * This is used when the database schema is modified and we need to apply patches.
  * It is kept compatible with php 4 parsing so that it can give out a meaningful error.
  *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @todo document
  * @ingroup Maintenance
@@ -31,9 +46,34 @@ class UpdateMediaWiki extends Maintenance {
        }
 
        function getDbType() {
+               /* If we used the class constant PHP4 would give a parser error here */
                return 2 /* Maintenance::DB_ADMIN */;
        }
 
+       private function compatChecks() {
+               $test = new PhpXmlBugTester();
+               if ( !$test->ok ) {
+                       $this->error(
+                               "Your system has a combination of PHP and libxml2 versions which is buggy\n" .
+                               "and can cause hidden data corruption in MediaWiki and other web apps.\n" .
+                               "Upgrade to PHP 5.2.9 or later and libxml2 2.7.3 or later!\n" .
+                               "ABORTING (see http://bugs.php.net/bug.php?id=45996).\n",
+                               true );
+               }
+
+               $test = new PhpRefCallBugTester;
+               $test->execute();
+               if ( !$test->ok ) {
+                       $ver = phpversion();
+                       $this->error(
+                               "PHP $ver is not compatible with MediaWiki due to a bug involving\n" .
+                               "reference parameters to __call. Upgrade to PHP 5.3.2 or higher, or \n" .
+                               "downgrade to PHP 5.3.0 to fix this.\n" .
+                               "ABORTING (see http://bugs.php.net/bug.php?id=50394 for details)\n",
+                               true );
+               }
+       }
+
        function execute() {
                global $wgVersion, $wgTitle, $wgLang;
 
@@ -43,7 +83,7 @@ class UpdateMediaWiki extends Maintenance {
                $this->output( "MediaWiki {$wgVersion} Updater\n\n" );
 
                if ( !$this->hasOption( 'skip-compat-checks' ) ) {
-                       install_version_checks();
+                       $this->compatChecks();
                } else {
                        $this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" );
                        wfCountdown( 5 );
@@ -64,7 +104,7 @@ class UpdateMediaWiki extends Maintenance {
                $shared = $this->hasOption( 'doshared' );
                $purge = !$this->hasOption( 'nopurge' );
 
-               $updater = DatabaseUpdater::newForDb( $db, $shared );
+               $updater = DatabaseUpdater::newForDb( $db, $shared, $this );
                $updater->doUpdates( $purge );
 
                foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
@@ -91,4 +131,4 @@ class UpdateMediaWiki extends Maintenance {
 }
 
 $maintClass = 'UpdateMediaWiki';
-require_once( DO_MAINTENANCE );
+require_once( RUN_MAINTENANCE_IF_MAIN );