From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/installer/CliInstaller.php | 21 ++- includes/installer/DatabaseInstaller.php | 38 +++- includes/installer/DatabaseUpdater.php | 127 +++++++++---- includes/installer/Ibm_db2Installer.php | 17 +- includes/installer/Ibm_db2Updater.php | 25 ++- includes/installer/InstallDocFormatter.php | 20 +++ includes/installer/Installer.i18n.php | 7 +- includes/installer/Installer.php | 98 +++++++--- includes/installer/LocalSettingsGenerator.php | 34 +++- includes/installer/MysqlInstaller.php | 33 +++- includes/installer/MysqlUpdater.php | 115 +++++------- includes/installer/OracleInstaller.php | 20 ++- includes/installer/OracleUpdater.php | 59 +++--- includes/installer/PostgresInstaller.php | 57 +++--- includes/installer/PostgresUpdater.php | 248 ++++++++++++++++++-------- includes/installer/SqliteInstaller.php | 17 +- includes/installer/SqliteUpdater.php | 33 +++- includes/installer/WebInstaller.php | 57 +++--- includes/installer/WebInstallerOutput.php | 26 ++- includes/installer/WebInstallerPage.php | 101 +++++++---- 20 files changed, 793 insertions(+), 360 deletions(-) (limited to 'includes/installer') diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index f9afbb20..38b4a824 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -2,6 +2,21 @@ /** * Core installer command line interface. * + * 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 * @ingroup Deployment */ @@ -117,7 +132,7 @@ class CliInstaller extends Installer { * @param $path String Full path to write LocalSettings.php to */ public function writeConfigurationFile( $path ) { - $ls = new LocalSettingsGenerator( $this ); + $ls = InstallerOverrides::getLocalSettingsGenerator( $this ); $ls->writeFile( "$path/LocalSettings.php" ); } @@ -148,7 +163,7 @@ class CliInstaller extends Installer { protected function getMessageText( $params ) { $msg = array_shift( $params ); - $text = wfMsgExt( $msg, array( 'parseinline' ), $params ); + $text = wfMessage( $msg, $params )->parse(); $text = preg_replace( '/(.*?)<\/a>/', '$2 <$1>', $text ); return html_entity_decode( strip_tags( $text ), ENT_QUOTES ); @@ -172,7 +187,7 @@ class CliInstaller extends Installer { if ( !$status->isOk() ) { echo "\n"; - exit; + exit( 1 ); } } diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index ab77e2d3..de59b2d6 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -2,6 +2,21 @@ /** * DBMS-specific installation helper. * + * 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 * @ingroup Deployment */ @@ -50,7 +65,7 @@ abstract class DatabaseInstaller { public abstract function getName(); /** - * @return true if the client library is compiled in. + * @return bool Returns true if the client library is compiled in. */ public abstract function isCompiled(); @@ -88,6 +103,7 @@ abstract class DatabaseInstaller { * $this->parent can be assumed to be a WebInstaller. * If the DB type has no settings beyond those already configured with * getConnectForm(), this should return false. + * @return bool */ public function getSettingsForm() { return false; @@ -140,7 +156,7 @@ abstract class DatabaseInstaller { $this->db = $status->value; // Enable autocommit $this->db->clearFlag( DBO_TRX ); - $this->db->commit(); + $this->db->commit( __METHOD__ ); } return $status; } @@ -207,6 +223,7 @@ abstract class DatabaseInstaller { /** * Override this to provide DBMS-specific schema variables, to be * substituted into tables.sql and other schema files. + * @return array */ public function getSchemaVars() { return array(); @@ -256,7 +273,7 @@ abstract class DatabaseInstaller { $up = DatabaseUpdater::newForDB( $this->db ); $up->doUpdates(); } catch ( MWException $e ) { - echo "\nAn error occured:\n"; + echo "\nAn error occurred:\n"; echo $e->getText(); $ret = false; } @@ -282,6 +299,7 @@ abstract class DatabaseInstaller { /** * Get an array of MW configuration globals that will be configured by this class. + * @return array */ public function getGlobalNames() { return $this->globalNames; @@ -313,14 +331,16 @@ abstract class DatabaseInstaller { /** * Get the internationalised name for this DBMS. + * @return String */ public function getReadableName() { - return wfMsg( 'config-type-' . $this->getName() ); + return wfMessage( 'config-type-' . $this->getName() )->text(); } /** * Get a name=>value map of MW configuration globals that overrides. * DefaultSettings.php + * @return array */ public function getGlobalDefaults() { return array(); @@ -328,6 +348,7 @@ abstract class DatabaseInstaller { /** * Get a name=>value map of internal variables used during installation. + * @return array */ public function getInternalDefaults() { return $this->internalDefaults; @@ -439,6 +460,7 @@ abstract class DatabaseInstaller { * values: List of allowed values (required) * itemAttribs Array of attribute arrays, outer key is the value name (optional) * + * @return string */ public function getRadioSet( $params ) { $params['controlName'] = $this->getName() . '_' . $params['var']; @@ -451,6 +473,7 @@ abstract class DatabaseInstaller { * Assumes that variables containing "password" in the name are (potentially * fake) passwords. * @param $varNames Array + * @return array */ public function setVarsFromRequest( $varNames ) { return $this->parent->setVarsFromRequest( $varNames, $this->getName() . '_' ); @@ -486,7 +509,7 @@ abstract class DatabaseInstaller { public function getInstallUserBox() { return Html::openElement( 'fieldset' ) . - Html::element( 'legend', array(), wfMsg( 'config-db-install-account' ) ) . + Html::element( 'legend', array(), wfMessage( 'config-db-install-account' )->text() ) . $this->getTextBox( '_InstallUser', 'config-db-username', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-install-username' ) ) . $this->getPasswordBox( '_InstallPassword', 'config-db-password', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-install-password' ) ) . Html::closeElement( 'fieldset' ); @@ -494,6 +517,7 @@ abstract class DatabaseInstaller { /** * Submit a standard install user fieldset. + * @return Status */ public function submitInstallUserBox() { $this->setVarsFromRequest( array( '_InstallUser', '_InstallPassword' ) ); @@ -510,7 +534,7 @@ abstract class DatabaseInstaller { public function getWebUserBox( $noCreateMsg = false ) { $wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : ''; $s = Html::openElement( 'fieldset' ) . - Html::element( 'legend', array(), wfMsg( 'config-db-web-account' ) ) . + Html::element( 'legend', array(), wfMessage( 'config-db-web-account' )->text() ) . $this->getCheckBox( '_SameAccount', 'config-db-web-account-same', array( 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' ) @@ -520,7 +544,7 @@ abstract class DatabaseInstaller { $this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) . $this->parent->getHelpBox( 'config-db-web-help' ); if ( $noCreateMsg ) { - $s .= $this->parent->getWarningBox( wfMsgNoTrans( $noCreateMsg ) ); + $s .= $this->parent->getWarningBox( wfMessage( $noCreateMsg )->plain() ); } else { $s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' ); } diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index f2e36aec..ff0a99e9 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -2,11 +2,26 @@ /** * DBMS-specific updater helper. * + * 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 * @ingroup Deployment */ -require_once( dirname(__FILE__) . '/../../maintenance/Maintenance.php' ); +require_once( __DIR__ . '/../../maintenance/Maintenance.php' ); /** * Class for handling database updates. Roughly based off of updaters.inc, with @@ -202,11 +217,45 @@ abstract class DatabaseUpdater { $this->extensionUpdates[] = array( 'addField', $tableName, $columnName, $sqlPath, true ); } + /** + * + * @since 1.20 + * + * @param $tableName string + * @param $columnName string + * @param $sqlPath string + */ + public function dropExtensionField( $tableName, $columnName, $sqlPath ) { + $this->extensionUpdates[] = array( 'dropField', $tableName, $columnName, $sqlPath, true ); + } + + /** + * + * @since 1.20 + * + * @param $tableName string + * @param $sqlPath string + */ + public function dropExtensionTable( $tableName, $sqlPath ) { + $this->extensionUpdates[] = array( 'dropTable', $tableName, $sqlPath, true ); + } + + /** + * + * @since 1.20 + * + * @param $tableName string + * @return bool + */ + public function tableExists( $tableName ) { + return ( $this->db->tableExists( $tableName, __METHOD__ ) ); + } + /** * Add a maintenance script to be run after the database updates are complete. - * + * * @since 1.19 - * + * * @param $class string Name of a Maintenance subclass */ public function addPostDatabaseUpdateMaintenance( $class ) { @@ -224,7 +273,7 @@ abstract class DatabaseUpdater { /** * @since 1.17 - * + * * @return array */ public function getPostDatabaseUpdateMaintenance() { @@ -239,6 +288,7 @@ abstract class DatabaseUpdater { public function doUpdates( $what = array( 'core', 'extensions', 'purge', 'stats' ) ) { global $wgLocalisationCacheConf, $wgVersion; + $this->db->begin( __METHOD__ ); $what = array_flip( $what ); if ( isset( $what['core'] ) ) { $this->runUpdates( $this->getCoreUpdateList(), false ); @@ -261,6 +311,7 @@ abstract class DatabaseUpdater { $this->rebuildLocalisationCache(); } } + $this->db->commit( __METHOD__ ); } /** @@ -412,13 +463,20 @@ abstract class DatabaseUpdater { * Applies a SQL patch * @param $path String Path to the patch file * @param $isFullPath Boolean Whether to treat $path as a relative or not + * @param $msg String Description of the patch */ - protected function applyPatch( $path, $isFullPath = false ) { - if ( $isFullPath ) { - $this->db->sourceFile( $path ); - } else { - $this->db->sourceFile( $this->db->patchPath( $path ) ); + protected function applyPatch( $path, $isFullPath = false, $msg = null ) { + if ( $msg === null ) { + $msg = "Applying $path patch"; } + + if ( !$isFullPath ) { + $path = $this->db->patchPath( $path ); + } + + $this->output( "$msg ..." ); + $this->db->sourceFile( $path ); + $this->output( "done.\n" ); } /** @@ -431,9 +489,7 @@ abstract class DatabaseUpdater { if ( $this->db->tableExists( $name, __METHOD__ ) ) { $this->output( "...$name table already exists.\n" ); } else { - $this->output( "Creating $name table..." ); - $this->applyPatch( $patch, $fullpath ); - $this->output( "done.\n" ); + $this->applyPatch( $patch, $fullpath, "Creating $name table" ); } } @@ -450,9 +506,7 @@ abstract class DatabaseUpdater { } elseif ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) { $this->output( "...have $field field in $table table.\n" ); } else { - $this->output( "Adding $field field to table $table..." ); - $this->applyPatch( $patch, $fullpath ); - $this->output( "done.\n" ); + $this->applyPatch( $patch, $fullpath, "Adding $field field to table $table" ); } } @@ -467,9 +521,7 @@ abstract class DatabaseUpdater { if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) { $this->output( "...index $index already set on $table table.\n" ); } else { - $this->output( "Adding index $index to table $table... " ); - $this->applyPatch( $patch, $fullpath ); - $this->output( "done.\n" ); + $this->applyPatch( $patch, $fullpath, "Adding index $index to table $table" ); } } @@ -483,9 +535,7 @@ abstract class DatabaseUpdater { */ protected function dropField( $table, $field, $patch, $fullpath = false ) { if ( $this->db->fieldExists( $table, $field, __METHOD__ ) ) { - $this->output( "Table $table contains $field field. Dropping... " ); - $this->applyPatch( $patch, $fullpath ); - $this->output( "done.\n" ); + $this->applyPatch( $patch, $fullpath, "Table $table contains $field field. Dropping" ); } else { $this->output( "...$table table does not contain $field field.\n" ); } @@ -501,24 +551,35 @@ abstract class DatabaseUpdater { */ protected function dropIndex( $table, $index, $patch, $fullpath = false ) { if ( $this->db->indexExists( $table, $index, __METHOD__ ) ) { - $this->output( "Dropping $index index from table $table... " ); - $this->applyPatch( $patch, $fullpath ); - $this->output( "done.\n" ); + $this->applyPatch( $patch, $fullpath, "Dropping $index index from table $table" ); } else { $this->output( "...$index key doesn't exist.\n" ); } } /** + * If the specified table exists, drop it, or execute the + * patch if one is provided. + * + * Public @since 1.20 + * * @param $table string - * @param $patch string + * @param $patch string|false * @param $fullpath bool */ - protected function dropTable( $table, $patch, $fullpath = false ) { + public function dropTable( $table, $patch = false, $fullpath = false ) { if ( $this->db->tableExists( $table, __METHOD__ ) ) { - $this->output( "Dropping table $table... " ); - $this->applyPatch( $patch, $fullpath ); - $this->output( "done.\n" ); + $msg = "Dropping table $table"; + + if ( $patch === false ) { + $this->output( "$msg ..." ); + $this->db->dropTable( $table, __METHOD__ ); + $this->output( "done.\n" ); + } + else { + $this->applyPatch( $patch, $fullpath, $msg ); + } + } else { $this->output( "...$table doesn't exist.\n" ); } @@ -541,10 +602,8 @@ abstract class DatabaseUpdater { } elseif( $this->updateRowExists( $updateKey ) ) { $this->output( "...$field in table $table already modified by patch $patch.\n" ); } else { - $this->output( "Modifying $field field of table $table..." ); - $this->applyPatch( $patch, $fullpath ); + $this->applyPatch( $patch, $fullpath, "Modifying $field field of table $table" ); $this->insertUpdateRow( $updateKey ); - $this->output( "done.\n" ); } } @@ -637,9 +696,7 @@ abstract class DatabaseUpdater { return; } - $this->output( "Converting tc_time from UNIX epoch to MediaWiki timestamp... " ); - $this->applyPatch( 'patch-tc-timestamp.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-tc-timestamp.sql', false, "Converting tc_time from UNIX epoch to MediaWiki timestamp" ); } /** diff --git a/includes/installer/Ibm_db2Installer.php b/includes/installer/Ibm_db2Installer.php index a6c4fd65..ca9bdf4b 100644 --- a/includes/installer/Ibm_db2Installer.php +++ b/includes/installer/Ibm_db2Installer.php @@ -2,6 +2,21 @@ /** * IBM_DB2-specific installer. * + * 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 * @ingroup Deployment */ @@ -53,7 +68,7 @@ class Ibm_db2Installer extends DatabaseInstaller { $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) . $this->getTextBox( 'wgDBport', 'config-db-port', array(), $this->parent->getHelpBox( 'config-db-port' ) ) . Html::openElement( 'fieldset' ) . - Html::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) . + Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) . $this->getTextBox( 'wgDBname', 'config-db-name', array(), $this->parent->getHelpBox( 'config-db-name-help' ) ) . $this->getTextBox( 'wgDBmwschema', 'config-db-schema', array(), $this->parent->getHelpBox( 'config-db-schema-help' ) ) . Html::closeElement( 'fieldset' ) . diff --git a/includes/installer/Ibm_db2Updater.php b/includes/installer/Ibm_db2Updater.php index 03540bb0..9daba9c2 100644 --- a/includes/installer/Ibm_db2Updater.php +++ b/includes/installer/Ibm_db2Updater.php @@ -2,6 +2,21 @@ /** * IBM_DB2-specific updater. * + * 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 * @ingroup Deployment */ @@ -55,20 +70,22 @@ class Ibm_db2Updater extends DatabaseUpdater { array( 'addField', 'categorylinks', 'cl_sortkey_prefix', 'patch-cl_sortkey_prefix-field.sql' ), array( 'addField', 'categorylinks', 'cl_collation', 'patch-cl_collation-field.sql' ), array( 'addField', 'categorylinks', 'cl_type', 'patch-cl_type-field.sql' ), - + //1.18 array( 'doUserNewTalkTimestampNotNull' ), array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ), array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql'), - array( 'doRebuildLocalisationCache' ), - + array( 'doRebuildLocalisationCache' ), + // 1.19 array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'), array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ), array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ), - array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ) + array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ), + + // 1.20 ); } } diff --git a/includes/installer/InstallDocFormatter.php b/includes/installer/InstallDocFormatter.php index 5801f26d..9a389dd8 100644 --- a/includes/installer/InstallDocFormatter.php +++ b/includes/installer/InstallDocFormatter.php @@ -1,4 +1,24 @@ 'Download LocalSettings.php', 'config-help' => 'help', + 'config-nofile' => 'File "$1" could not be found. Has it been deleted?', 'mainpagetext' => "'''MediaWiki has been successfully installed.'''", 'mainpagedocfooter' => "Consult the [//meta.wikimedia.org/wiki/Help:Contents User's Guide] for information on using the wiki software. @@ -4484,7 +4485,7 @@ Esta no es la contraseña para la cuenta de MediaWiki; esta es la contraseña pa 'config-db-wiki-help' => 'Introduce el nombre de usuario y la contraseña que serán usados para acceder a la base de datos durante la operación normal del wiki. Si esta cuenta no existe y la cuenta de instalación tiene suficientes privilegios, se creará esta cuenta de usuario con los privilegios mínimos necesarios para la operación normal del wiki.', 'config-db-prefix' => 'Prefijo para las tablas de la base de datos:', - 'config-db-prefix-help' => 'Si necesita compartir una base de datos entre múltiples wikis, o entre MediaWiki y otra aplicación web, puede optar por agregar un prefijo a todos los nombres de tabla para evitar conflictos. + 'config-db-prefix-help' => 'Si necesita compartir una base de datos entre múltiples wikis, o entre MediaWiki y otra aplicación web, puede optar por agregar un prefijo a todos los nombres de tabla para evitar conflictos. No utilice espacios. Normalmente se deja este campo vacío.', @@ -14228,7 +14229,7 @@ Jeśli korzystasz ze współdzielonego hostingu, dostawca usługi hostingowej mo Możesz utworzyć konto użytkownika bazy danych podczas instalacji MediaWiki. Wówczas należy podać nazwę i hasło użytkownika z rolą SYSDBA w celu użycia go przez instalator do utworzenia nowe konta użytkownika, z którego korzystać będzie MediaWiki. -Możesz również skorzystać z konta użytkownika bazy danych utworzonego bezpośrednio w Oracle i wówczas wystarczy podać tylko nazwę i hasło tego użytkownika. Konto z rolą SYSDBA nie będzie potrzebne, jednak konto użytkownika powinno mieć uprawnienia do utworzenia obiektów w schemacie bazy danych. Możesz też podać dwa konta - konto dla instalatora, z pomocą którego zostaną obiekty w schemacie bazy danych i drugie konto, z którego będzie MediaWiki korzystać będzie do pracy. +Możesz również skorzystać z konta użytkownika bazy danych utworzonego bezpośrednio w Oracle i wówczas wystarczy podać tylko nazwę i hasło tego użytkownika. Konto z rolą SYSDBA nie będzie potrzebne, jednak konto użytkownika powinno mieć uprawnienia do utworzenia obiektów w schemacie bazy danych. Możesz też podać dwa konta - konto dla instalatora, z pomocą którego zostaną obiekty w schemacie bazy danych i drugie konto, z którego będzie MediaWiki korzystać będzie do pracy. W podkatalogu "maintenance/oracle" znajduje się skrypt do tworzenia konta użytkownika. Korzystanie z konta użytkownika z ograniczonymi uprawnieniami spowoduje wyłączenie funkcji związanych z aktualizacją oprogramowania MediaWiki.', 'config-db-install-account' => 'Konto użytkownika dla instalatora', @@ -17765,7 +17766,7 @@ Ang mas masasalimuot na mga kaayusan ng mga karapatan ng tagagamit ay makukuha p 'config-license-gfdl' => 'Lisensiyang 1.3 ng Malayang Dokumentasyon ng GNU o mas lalong huli', 'config-license-pd' => 'Nasasakupan ng Madla', 'config-license-cc-choose' => 'Pumili ng isang pasadyang Lisensiya ng Malikhaing mga Pangkaraniwan', - 'config-license-help' => "Maraming mga pangmadlang wiki ang naglalagay ng lahat ng mga ambag sa ilalim ng [http://freedomdefined.org/Definition lisensiyang malaya]. + 'config-license-help' => "Maraming mga pangmadlang wiki ang naglalagay ng lahat ng mga ambag sa ilalim ng [http://freedomdefined.org/Definition lisensiyang malaya]. Nakakatulong ito sa paglikha ng isang diwa ng pagmamay-ari ng pamayanan at nakapanghihikayat ng ambag na pangmahabang panahon. Sa pangkalahatan, hindi kailangan ang isang wiking pribado o pangsamahan. diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 990d4449..ac5dbd74 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -2,6 +2,21 @@ /** * Base code for MediaWiki installer. * + * 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 * @ingroup Deployment */ @@ -24,7 +39,7 @@ abstract class Installer { // This is the absolute minimum PHP version we can support - const MINIMUM_PHP_VERSION = '5.2.3'; + const MINIMUM_PHP_VERSION = '5.3.2'; /** * @var array @@ -293,7 +308,7 @@ abstract class Installer { /** * UI interface for displaying a short message - * The parameters are like parameters to wfMsg(). + * The parameters are like parameters to wfMessage(). * The messages will be in wikitext format, which will be converted to an * output format such as HTML or text before being sent to the user. * @param $msg @@ -324,7 +339,7 @@ abstract class Installer { // Load the installer's i18n file. $wgExtensionMessagesFiles['MediawikiInstaller'] = - dirname( __FILE__ ) . '/Installer.i18n.php'; + __DIR__ . '/Installer.i18n.php'; // Having a user with id = 0 safeguards us from DB access via User::loadOptions(). $wgUser = User::newFromId( 0 ); @@ -543,7 +558,7 @@ abstract class Installer { * write your messages. This appears to work well enough. Basic formatting and * external links work just fine. * - * But in case a translator decides to throw in a #ifexist or internal link or + * But in case a translator decides to throw in a "#ifexist" or internal link or * whatever, this function is guarded to catch the attempted DB access and to present * some fallback text. * @@ -630,7 +645,7 @@ abstract class Installer { $allNames = array(); foreach ( self::getDBTypes() as $name ) { - $allNames[] = wfMsg( "config-type-$name" ); + $allNames[] = wfMessage( "config-type-$name" )->text(); } // cache initially available databases to make sure that everything will be displayed correctly @@ -659,6 +674,7 @@ abstract class Installer { return false; } $this->setVar( '_CompiledDBs', $databases ); + return true; } /** @@ -672,6 +688,7 @@ abstract class Installer { /** * Some versions of libxml+PHP break < and > encoding horribly + * @return bool */ protected function envCheckBrokenXML() { $test = new PhpXmlBugTester(); @@ -679,11 +696,13 @@ abstract class Installer { $this->showError( 'config-brokenlibxml' ); return false; } + return true; } /** * Test PHP (probably 5.3.1, but it could regress again) to make sure that * reference parameters to __call() are not converted to null + * @return bool */ protected function envCheckPHP531() { $test = new PhpRefCallBugTester; @@ -692,66 +711,79 @@ abstract class Installer { $this->showError( 'config-using531', phpversion() ); return false; } + return true; } /** * Environment check for magic_quotes_runtime. + * @return bool */ protected function envCheckMagicQuotes() { if( wfIniGetBool( "magic_quotes_runtime" ) ) { $this->showError( 'config-magic-quotes-runtime' ); return false; } + return true; } /** * Environment check for magic_quotes_sybase. + * @return bool */ protected function envCheckMagicSybase() { if ( wfIniGetBool( 'magic_quotes_sybase' ) ) { $this->showError( 'config-magic-quotes-sybase' ); return false; } + return true; } /** * Environment check for mbstring.func_overload. + * @return bool */ protected function envCheckMbstring() { if ( wfIniGetBool( 'mbstring.func_overload' ) ) { $this->showError( 'config-mbstring' ); return false; } + return true; } /** * Environment check for zend.ze1_compatibility_mode. + * @return bool */ protected function envCheckZE1() { if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) { $this->showError( 'config-ze1' ); return false; } + return true; } /** * Environment check for safe_mode. + * @return bool */ protected function envCheckSafeMode() { if ( wfIniGetBool( 'safe_mode' ) ) { $this->setVar( '_SafeMode', true ); $this->showMessage( 'config-safe-mode' ); } + return true; } /** * Environment check for the XML module. + * @return bool */ protected function envCheckXML() { if ( !function_exists( "utf8_encode" ) ) { $this->showError( 'config-xml-bad' ); return false; } + return true; } /** @@ -779,10 +811,12 @@ abstract class Installer { $this->showError( 'config-pcre-no-utf8' ); return false; } + return true; } /** * Environment check for available memory. + * @return bool */ protected function envCheckMemory() { $limit = ini_get( 'memory_limit' ); @@ -802,9 +836,8 @@ abstract class Installer { $this->showMessage( 'config-memory-raised', $limit, $newLimit ); $this->setVar( '_RaiseMemory', true ); } - } else { - return true; } + return true; } /** @@ -830,15 +863,18 @@ abstract class Installer { /** * Scare user to death if they have mod_security + * @return bool */ protected function envCheckModSecurity() { if ( self::apacheModulePresent( 'mod_security' ) ) { $this->showMessage( 'config-mod-security' ); } + return true; } /** * Search for GNU diff3. + * @return bool */ protected function envCheckDiff3() { $names = array( "gdiff3", "diff3", "diff3.exe" ); @@ -852,10 +888,12 @@ abstract class Installer { $this->setVar( 'wgDiff3', false ); $this->showMessage( 'config-diff3-bad' ); } + return true; } /** * Environment check for ImageMagick and GD. + * @return bool */ protected function envCheckGraphics() { $names = array( wfIsWindows() ? 'convert.exe' : 'convert' ); @@ -868,10 +906,11 @@ abstract class Installer { return true; } elseif ( function_exists( 'imagejpeg' ) ) { $this->showMessage( 'config-gd' ); - return true; + } else { $this->showMessage( 'config-no-scaling' ); } + return true; } /** @@ -881,6 +920,7 @@ abstract class Installer { $server = $this->envGetDefaultServer(); $this->showMessage( 'config-using-server', $server ); $this->setVar( 'wgServer', $server ); + return true; } /** @@ -895,7 +935,7 @@ abstract class Installer { */ protected function envCheckPath() { global $IP; - $IP = dirname( dirname( dirname( __FILE__ ) ) ); + $IP = dirname( dirname( __DIR__ ) ); $this->setVar( 'IP', $IP ); $this->showMessage( 'config-using-uri', $this->getVar( 'wgServer' ), $this->getVar( 'wgScriptPath' ) ); @@ -913,6 +953,7 @@ abstract class Installer { $ext = 'php'; } $this->setVar( 'wgScriptExtension', ".$ext" ); + return true; } /** @@ -991,6 +1032,7 @@ abstract class Installer { /** * TODO: document + * @return bool */ protected function envCheckUploadsDirectory() { global $IP; @@ -999,17 +1041,17 @@ abstract class Installer { $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/'; $safe = !$this->dirIsExecutable( $dir, $url ); - if ( $safe ) { - return true; - } else { + if ( !$safe ) { $this->showMessage( 'config-uploads-not-safe', $dir ); } + return true; } /** * Checks if suhosin.get.max_value_length is set, and if so, sets * $wgResourceLoaderMaxQueryLength to that value in the generated * LocalSettings file + * @return bool */ protected function envCheckSuhosinMaxValueLength() { $maxValueLength = ini_get( 'suhosin.get.max_value_length' ); @@ -1022,6 +1064,7 @@ abstract class Installer { $maxValueLength = -1; } $this->setVar( 'wgResourceLoaderMaxQueryLength', $maxValueLength ); + return true; } /** @@ -1075,12 +1118,16 @@ abstract class Installer { if( $utf8 ) { $useNormalizer = 'utf8'; $utf8 = utf8_normalize( $not_normal_c, UtfNormal::UNORM_NFC ); - if ( $utf8 !== $normal_c ) $needsUpdate = true; + if ( $utf8 !== $normal_c ) { + $needsUpdate = true; + } } if( $intl ) { $useNormalizer = 'intl'; $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C ); - if ( $intl !== $normal_c ) $needsUpdate = true; + if ( $intl !== $normal_c ) { + $needsUpdate = true; + } } // Uses messages 'config-unicode-using-php', 'config-unicode-using-utf8', 'config-unicode-using-intl' @@ -1094,11 +1141,15 @@ abstract class Installer { } } + /** + * @return bool + */ protected function envCheckCtype() { if ( !function_exists( 'ctype_digit' ) ) { $this->showError( 'config-ctype' ); return false; } + return true; } /** @@ -1131,6 +1182,7 @@ abstract class Installer { * * If $versionInfo is not false, only executables with a version * matching $versionInfo[1] will be returned. + * @return bool|string */ public static function locateExecutable( $path, $names, $versionInfo = false ) { if ( !is_array( $names ) ) { @@ -1179,6 +1231,9 @@ abstract class Installer { * Checks if scripts located in the given directory can be executed via the given URL. * * Used only by environment checks. + * @param $dir string + * @param $url string + * @return bool|int|string */ public function dirIsExecutable( $dir, $url ) { $scriptTypes = array( @@ -1539,12 +1594,13 @@ abstract class Installer { $status = Status::newGood(); try { $page = WikiPage::factory( Title::newMainPage() ); - $page->doEdit( wfMsgForContent( 'mainpagetext' ) . "\n\n" . - wfMsgForContent( 'mainpagedocfooter' ), - '', - EDIT_NEW, - false, - User::newFromName( 'MediaWiki default' ) ); + $page->doEdit( wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" . + wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text(), + '', + EDIT_NEW, + false, + User::newFromName( 'MediaWiki default' ) + ); } catch (MWException $e) { //using raw, because $wgShowExceptionDetails can not be set yet $status->fatal( 'config-install-mainpage-failed', $e->getMessage() ); @@ -1561,6 +1617,8 @@ abstract class Installer { // Don't access the database $GLOBALS['wgUseDatabaseMessages'] = false; + // Don't cache langconv tables + $GLOBALS['wgLanguageConverterCacheType'] = CACHE_NONE; // Debug-friendly $GLOBALS['wgShowExceptionDetails'] = true; // Don't break forms diff --git a/includes/installer/LocalSettingsGenerator.php b/includes/installer/LocalSettingsGenerator.php index 89154e58..bbc6b64e 100644 --- a/includes/installer/LocalSettingsGenerator.php +++ b/includes/installer/LocalSettingsGenerator.php @@ -2,6 +2,21 @@ /** * Generator for LocalSettings.php file. * + * 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 * @ingroup Deployment */ @@ -14,16 +29,16 @@ */ class LocalSettingsGenerator { - private $extensions = array(); - private $values = array(); - private $groupPermissions = array(); - private $dbSettings = ''; - private $safeMode = false; + protected $extensions = array(); + protected $values = array(); + protected $groupPermissions = array(); + protected $dbSettings = ''; + protected $safeMode = false; /** * @var Installer */ - private $installer; + protected $installer; /** * Constructor. @@ -151,7 +166,7 @@ class LocalSettingsGenerator { /** * @return String */ - private function buildMemcachedServerList() { + protected function buildMemcachedServerList() { $servers = $this->values['_MemCachedServers']; if( !$servers ) { @@ -172,7 +187,7 @@ class LocalSettingsGenerator { /** * @return String */ - private function getDefaultText() { + protected function getDefaultText() { if( !$this->values['wgImageMagickConvertCommand'] ) { $this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert'; $magic = '#'; @@ -244,7 +259,8 @@ if ( !defined( 'MEDIAWIKI' ) ) { {$metaNamespace} ## The URL base path to the directory containing the wiki; ## defaults for all runtime URL paths are based off of this. -## For more information on customizing the URLs please see: +## For more information on customizing the URLs +## (like /w/index.php/Page_title to /wiki/Page_title) please see: ## http://www.mediawiki.org/wiki/Manual:Short_URL \$wgScriptPath = \"{$this->values['wgScriptPath']}\"; \$wgScriptExtension = \"{$this->values['wgScriptExtension']}\"; diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 7585fe7a..f66f15f2 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -2,6 +2,21 @@ /** * MySQL-specific installer. * + * 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 * @ingroup Deployment */ @@ -74,7 +89,7 @@ class MysqlInstaller extends DatabaseInstaller { return $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) . Html::openElement( 'fieldset' ) . - Html::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) . + Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) . $this->getTextBox( 'wgDBname', 'config-db-name', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-name-help' ) ) . $this->getTextBox( 'wgDBprefix', 'config-db-prefix', array( 'dir' => 'ltr' ), $this->parent->getHelpBox( 'config-db-prefix-help' ) ) . Html::closeElement( 'fieldset' ) . @@ -336,7 +351,7 @@ class MysqlInstaller extends DatabaseInstaller { $s .= Xml::openElement( 'div', array( 'id' => 'dbMyisamWarning' )); - $s .= $this->parent->getWarningBox( wfMsg( 'config-mysql-myisam-dep' ) ); + $s .= $this->parent->getWarningBox( wfMessage( 'config-mysql-myisam-dep' )->text() ); $s .= Xml::closeElement( 'div' ); if( $this->getVar( '_MysqlEngine' ) != 'MyISAM' ) { @@ -514,21 +529,21 @@ class MysqlInstaller extends DatabaseInstaller { $fullName = $this->buildFullUserName( $dbUser, $host ); if( !$this->userDefinitelyExists( $dbUser, $host ) ) { try{ - $this->db->begin(); + $this->db->begin( __METHOD__ ); $this->db->query( "CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ ); - $this->db->commit(); + $this->db->commit( __METHOD__ ); $grantableNames[] = $fullName; } catch( DBQueryError $dqe ) { if( $this->db->lastErrno() == 1396 /* ER_CANNOT_USER */ ) { // User (probably) already exists - $this->db->rollback(); + $this->db->rollback( __METHOD__ ); $status->warning( 'config-install-user-alreadyexists', $dbUser ); $grantableNames[] = $fullName; break; } else { // If we couldn't create for some bizzare reason and the // user probably doesn't exist, skip the grant - $this->db->rollback(); + $this->db->rollback( __METHOD__ ); $status->warning( 'config-install-user-create-failed', $dbUser, $dqe->getText() ); } } @@ -544,11 +559,11 @@ class MysqlInstaller extends DatabaseInstaller { $dbAllTables = $this->db->addIdentifierQuotes( $dbName ) . '.*'; foreach( $grantableNames as $name ) { try { - $this->db->begin(); + $this->db->begin( __METHOD__ ); $this->db->query( "GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ ); - $this->db->commit(); + $this->db->commit( __METHOD__ ); } catch( DBQueryError $dqe ) { - $this->db->rollback(); + $this->db->rollback( __METHOD__ ); $status->fatal( 'config-install-user-grant-failed', $dbUser, $dqe->getText() ); } } diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 9e7869ec..49dff805 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -2,6 +2,21 @@ /** * MySQL-specific updater. * + * 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 * @ingroup Deployment */ @@ -192,6 +207,12 @@ class MysqlUpdater extends DatabaseUpdater { array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ), array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ), array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase.sql' ), + + // 1.20 + array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ), + array( 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ), + array( 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ), + array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ), ); } @@ -211,9 +232,7 @@ class MysqlUpdater extends DatabaseUpdater { if ( in_array( 'binary', $flags ) ) { $this->output( "...$table table has correct $field encoding.\n" ); } else { - $this->output( "Fixing $field encoding on $table table... " ); - $this->applyPatch( $patchFile ); - $this->output( "done.\n" ); + $this->applyPatch( $patchFile, false, "Fixing $field encoding on $table table" ); } } @@ -250,12 +269,8 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( 'Creating interwiki table...' ); - $this->applyPatch( 'patch-interwiki.sql' ); - $this->output( "done.\n" ); - $this->output( 'Adding default interwiki definitions...' ); - $this->applyPatch( "$IP/maintenance/interwiki.sql", true ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-interwiki.sql', false, 'Creating interwiki table' ); + $this->applyPatch( "$IP/maintenance/interwiki.sql", true, 'Adding default interwiki definitions' ); } /** @@ -271,9 +286,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Updating indexes to 20031107..." ); - $this->applyPatch( 'patch-indexes.sql', true ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-indexes.sql', true, "Updating indexes to 20031107" ); } protected function doOldLinksUpdate() { @@ -288,10 +301,9 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Fixing ancient broken imagelinks table.\n" ); - $this->output( "NOTE: you will have to run maintenance/refreshLinks.php after this.\n" ); - $this->applyPatch( 'patch-fix-il_from.sql' ); - $this->output( "done.\n" ); + if( $this->applyPatch( 'patch-fix-il_from.sql', false, "Fixing ancient broken imagelinks table." ) ) { + $this->output("NOTE: you will have to run maintenance/refreshLinks.php after this." ); + } } /** @@ -513,9 +525,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Converting links and brokenlinks tables to pagelinks... " ); - $this->applyPatch( 'patch-pagelinks.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-pagelinks.sql', false, "Converting links and brokenlinks tables to pagelinks" ); global $wgContLang; foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) { @@ -551,9 +561,7 @@ class MysqlUpdater extends DatabaseUpdater { if ( !$duper->clearDupes() ) { $this->output( "WARNING: This next step will probably fail due to unfixed duplicates...\n" ); } - $this->output( "Adding unique index on user_name... " ); - $this->applyPatch( 'patch-user_nameindex.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-user_nameindex.sql', false, "Adding unique index on user_name" ); } protected function doUserGroupsUpdate() { @@ -566,9 +574,7 @@ class MysqlUpdater extends DatabaseUpdater { $this->db->query( "ALTER TABLE $oldug RENAME TO $newug", __METHOD__ ); $this->output( "done.\n" ); - $this->output( "Re-adding fresh user_groups table... " ); - $this->applyPatch( 'patch-user_groups.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-user_groups.sql', false, "Re-adding fresh user_groups table" ); $this->output( "***\n" ); $this->output( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" ); @@ -580,15 +586,11 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Adding user_groups table... " ); - $this->applyPatch( 'patch-user_groups.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-user_groups.sql', false, "Adding user_groups table" ); if ( !$this->db->tableExists( 'user_rights', __METHOD__ ) ) { if ( $this->db->fieldExists( 'user', 'user_rights', __METHOD__ ) ) { - $this->output( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." ); - $this->db->applyPatch( 'patch-user_rights.sql' ); - $this->output( "done.\n" ); + $this->db->applyPatch( 'patch-user_rights.sql', false, "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion" ); } else { $this->output( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" ); $this->output( "*** You may need to manually configure some sysops by manipulating\n" ); @@ -630,9 +632,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Making wl_notificationtimestamp nullable... " ); - $this->applyPatch( 'patch-watchlist-null.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-watchlist-null.sql', false, "Making wl_notificationtimestamp nullable" ); } /** @@ -658,8 +658,8 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Creating templatelinks table...\n" ); - $this->applyPatch( 'patch-templatelinks.sql' ); + $this->applyPatch( 'patch-templatelinks.sql', false, "Creating templatelinks table" ); + $this->output( "Populating...\n" ); if ( wfGetLB()->getServerCount() > 1 ) { // Slow, replication-friendly update @@ -700,8 +700,7 @@ class MysqlUpdater extends DatabaseUpdater { !$this->indexHasField( 'templatelinks', 'tl_namespace', 'tl_from' ) || !$this->indexHasField( 'imagelinks', 'il_to', 'il_from' ) ) { - $this->applyPatch( 'patch-backlinkindexes.sql' ); - $this->output( "...backlinking indices updated\n" ); + $this->applyPatch( 'patch-backlinkindexes.sql', false, "Updating backlinking indices" ); } } @@ -716,9 +715,8 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Creating page_restrictions table..." ); - $this->applyPatch( 'patch-page_restrictions.sql' ); - $this->applyPatch( 'patch-page_restrictions_sortkey.sql' ); + $this->applyPatch( 'patch-page_restrictions.sql', false, "Creating page_restrictions table (1/2)" ); + $this->applyPatch( 'patch-page_restrictions_sortkey.sql', false, "Creating page_restrictions table (2/2)" ); $this->output( "done.\n" ); $this->output( "Migrating old restrictions to new table...\n" ); @@ -728,8 +726,7 @@ class MysqlUpdater extends DatabaseUpdater { protected function doCategorylinksIndicesUpdate() { if ( !$this->indexHasField( 'categorylinks', 'cl_sortkey', 'cl_from' ) ) { - $this->applyPatch( 'patch-categorylinksindex.sql' ); - $this->output( "...categorylinks indices updated\n" ); + $this->applyPatch( 'patch-categorylinksindex.sql', false, "Updating categorylinks Indices" ); } } @@ -768,18 +765,14 @@ class MysqlUpdater extends DatabaseUpdater { } elseif ( $this->db->fieldExists( 'profiling', 'pf_memory', __METHOD__ ) ) { $this->output( "...profiling table has pf_memory field.\n" ); } else { - $this->output( "Adding pf_memory field to table profiling..." ); - $this->applyPatch( 'patch-profiling-memory.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-profiling-memory.sql', false, "Adding pf_memory field to table profiling" ); } } protected function doFilearchiveIndicesUpdate() { $info = $this->db->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ ); if ( !$info ) { - $this->output( "Updating filearchive indices..." ); - $this->applyPatch( 'patch-filearchive-user-index.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-filearchive-user-index.sql', false, "Updating filearchive indices" ); } } @@ -790,9 +783,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Making pl_namespace, tl_namespace and il_to indices UNIQUE... " ); - $this->applyPatch( 'patch-pl-tl-il-unique.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-pl-tl-il-unique.sql', false, "Making pl_namespace, tl_namespace and il_to indices UNIQUE" ); } protected function renameEuWikiId() { @@ -801,9 +792,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Renaming eu_wiki_id -> eu_local_id... " ); - $this->applyPatch( 'patch-eu_local_id.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-eu_local_id.sql', false, "Renaming eu_wiki_id -> eu_local_id" ); } protected function doUpdateMimeMinorField() { @@ -812,9 +801,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Altering all *_mime_minor fields to 100 bytes in size ... " ); - $this->applyPatch( 'patch-mime_minor_length.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-mime_minor_length.sql', false, "Altering all *_mime_minor fields to 100 bytes in size" ); } protected function doClFieldsUpdate() { @@ -823,9 +810,7 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( 'Updating categorylinks (again)...' ); - $this->applyPatch( 'patch-categorylinks-better-collation2.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-categorylinks-better-collation2.sql', false, 'Updating categorylinks (again)' ); } protected function doLangLinksLengthUpdate() { @@ -834,9 +819,7 @@ class MysqlUpdater extends DatabaseUpdater { $row = $this->db->fetchObject( $res ); if ( $row && $row->Type == "varbinary(10)" ) { - $this->output( 'Updating length of ll_lang in langlinks...' ); - $this->applyPatch( 'patch-langlinks-ll_lang-20.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-langlinks-ll_lang-20.sql', false, 'Updating length of ll_lang in langlinks' ); } else { $this->output( "...ll_lang is up-to-date.\n" ); } @@ -849,8 +832,6 @@ class MysqlUpdater extends DatabaseUpdater { return; } - $this->output( "Making user_last_timestamp nullable... " ); - $this->applyPatch( 'patch-user-newtalk-timestamp-null.sql' ); - $this->output( "done.\n" ); + $this->applyPatch( 'patch-user-newtalk-timestamp-null.sql', false, "Making user_last_timestamp nullable" ); } } diff --git a/includes/installer/OracleInstaller.php b/includes/installer/OracleInstaller.php index 51e6d4a2..72ec800d 100644 --- a/includes/installer/OracleInstaller.php +++ b/includes/installer/OracleInstaller.php @@ -2,6 +2,21 @@ /** * Oracle-specific installer. * + * 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 * @ingroup Deployment */ @@ -47,12 +62,12 @@ class OracleInstaller extends DatabaseInstaller { return $this->getTextBox( 'wgDBserver', 'config-db-host-oracle', array(), $this->parent->getHelpBox( 'config-db-host-oracle-help' ) ) . Html::openElement( 'fieldset' ) . - Html::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) . + Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) . $this->getTextBox( 'wgDBprefix', 'config-db-prefix' ) . $this->getTextBox( '_OracleDefTS', 'config-oracle-def-ts' ) . $this->getTextBox( '_OracleTempTS', 'config-oracle-temp-ts', array(), $this->parent->getHelpBox( 'config-db-oracle-help' ) ) . Html::closeElement( 'fieldset' ) . - $this->parent->getWarningBox( wfMsg( 'config-db-account-oracle-warn' ) ). + $this->parent->getWarningBox( wfMessage( 'config-db-account-oracle-warn' )->text() ). $this->getInstallUserBox(). $this->getWebUserBox(); } @@ -243,6 +258,7 @@ class OracleInstaller extends DatabaseInstaller { /** * Overload: after this action field info table has to be rebuilt + * @return Status */ public function createTables() { $this->setupSchemaVars(); diff --git a/includes/installer/OracleUpdater.php b/includes/installer/OracleUpdater.php index 93c2726b..e71c26fe 100644 --- a/includes/installer/OracleUpdater.php +++ b/includes/installer/OracleUpdater.php @@ -2,6 +2,21 @@ /** * Oracle-specific updater. * + * 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 * @ingroup Deployment */ @@ -51,6 +66,10 @@ class OracleUpdater extends DatabaseUpdater { array( 'doPageRestrictionsPKUKFix' ), array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase.sql' ), + //1.20 + array( 'addIndex', 'ipblocks', 'i05', 'patch-ipblocks_i05_index.sql' ), + array( 'addIndex', 'revision', 'i05', 'patch-revision_i05_index.sql' ), + // KEEP THIS AT THE BOTTOM!! array( 'doRebuildDuplicateFunction' ), @@ -63,40 +82,32 @@ class OracleUpdater extends DatabaseUpdater { * Oracle inserts NULL, so namespace fields should have a default value */ protected function doNamespaceDefaults() { - $this->output( "Altering namespace fields with default value ... " ); $meta = $this->db->fieldInfo( 'page', 'page_namespace' ); if ( $meta->defaultValue() != null ) { - $this->output( "defaults seem to present on namespace fields\n" ); return; } - $this->applyPatch( 'patch_namespace_defaults.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_namespace_defaults.sql', false, "Altering namespace fields with default value" ); } /** * Uniform FK names + deferrable state */ protected function doFKRenameDeferr() { - $this->output( "Altering foreign keys ... " ); $meta = $this->db->query( 'SELECT COUNT(*) cnt FROM user_constraints WHERE constraint_type = \'R\' AND deferrable = \'DEFERRABLE\'' ); $row = $meta->fetchRow(); if ( $row && $row['cnt'] > 0 ) { - $this->output( "at least one FK is deferrable, considering up to date\n" ); return; } - $this->applyPatch( 'patch_fk_rename_deferred.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_fk_rename_deferred.sql', false, "Altering foreign keys ... " ); } /** * Recreate functions to 17 schema layout */ protected function doFunctions17() { - $this->output( "Recreating functions ... " ); - $this->applyPatch( 'patch_create_17_functions.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_create_17_functions.sql', false, "Recreating functions" ); } /** @@ -104,14 +115,11 @@ class OracleUpdater extends DatabaseUpdater { * there are no incremental patches prior to this */ protected function doSchemaUpgrade17() { - $this->output( "Updating schema to 17 ... " ); // check if iwlinks table exists which was added in 1.17 if ( $this->db->tableExists( 'iwlinks' ) ) { - $this->output( "schema seem to be up to date.\n" ); return; } - $this->applyPatch( 'patch_16_17_schema_changes.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_16_17_schema_changes.sql', false, "Updating schema to 17" ); } /** @@ -140,24 +148,19 @@ class OracleUpdater extends DatabaseUpdater { * converted to NULL in Oracle */ protected function doRemoveNotNullEmptyDefaults() { - $this->output( "Removing not null empty constraints ... " ); $meta = $this->db->fieldInfo( 'categorylinks' , 'cl_sortkey_prefix' ); if ( $meta->isNullable() ) { - $this->output( "constraints seem to be removed\n" ); return; } - $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false, "Removing not null empty constraints" ); } + protected function doRemoveNotNullEmptyDefaults2() { - $this->output( "Removing not null empty constraints ... " ); $meta = $this->db->fieldInfo( 'ipblocks' , 'ipb_by_text' ); if ( $meta->isNullable() ) { - $this->output( "constraints seem to be removed\n" ); return; } - $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_remove_not_null_empty_defs2.sql', false, "Removing not null empty constraints" ); } /** @@ -165,17 +168,13 @@ class OracleUpdater extends DatabaseUpdater { * cascading taken in account in the deleting function */ protected function doRecentchangesFK2Cascade() { - $this->output( "Altering RECENTCHANGES_FK2 ... " ); - $meta = $this->db->query( 'SELECT 1 FROM all_constraints WHERE owner = \''.strtoupper($this->db->getDBname()).'\' AND constraint_name = \''.$this->db->tablePrefix().'RECENTCHANGES_FK2\' AND delete_rule = \'CASCADE\'' ); $row = $meta->fetchRow(); if ( $row ) { - $this->output( "FK up to date\n" ); return; } - $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_recentchanges_fk2_cascade.sql', false, "Altering RECENTCHANGES_FK2" ); } /** @@ -199,9 +198,7 @@ class OracleUpdater extends DatabaseUpdater { * rebuilding of the function that duplicates tables for tests */ protected function doRebuildDuplicateFunction() { - $this->output( "Rebuilding duplicate function ... " ); - $this->applyPatch( 'patch_rebuild_dupfunc.sql', false ); - $this->output( "ok\n" ); + $this->applyPatch( 'patch_rebuild_dupfunc.sql', false, "Rebuilding duplicate function" ); } /** diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index fea012e2..3ac2b3a8 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -2,6 +2,21 @@ /** * PostgreSQL-specific installer. * + * 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 * @ingroup Deployment */ @@ -45,7 +60,7 @@ class PostgresInstaller extends DatabaseInstaller { $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) . $this->getTextBox( 'wgDBport', 'config-db-port' ) . Html::openElement( 'fieldset' ) . - Html::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) . + Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) . $this->getTextBox( 'wgDBname', 'config-db-name', array(), $this->parent->getHelpBox( 'config-db-name-help' ) ) . $this->getTextBox( 'wgDBmwschema', 'config-db-schema', array(), $this->parent->getHelpBox( 'config-db-schema-help' ) ) . Html::closeElement( 'fieldset' ) . @@ -110,9 +125,9 @@ class PostgresInstaller extends DatabaseInstaller { /** * Open a PG connection with given parameters - * @param $user User name - * @param $password Password - * @param $dbName Database name + * @param $user string User name + * @param $password string Password + * @param $dbName string Database name * @return Status */ protected function openConnectionWithParams( $user, $password, $dbName ) { @@ -147,7 +162,7 @@ class PostgresInstaller extends DatabaseInstaller { */ $conn = $status->value; $conn->clearFlag( DBO_TRX ); - $conn->commit(); + $conn->commit( __METHOD__ ); $this->pgConns[$type] = $conn; } return $status; @@ -168,14 +183,14 @@ class PostgresInstaller extends DatabaseInstaller { * separate connection for this allows us to avoid accidental cross-module * dependencies. * - * @param $type The type of connection to get: + * @param $type string The type of connection to get: * - create-db: A connection for creating DBs, suitable for pre- * installation. * - create-schema: A connection to the new DB, for creating schemas and * other similar objects in the new DB. * - create-tables: A connection with a role suitable for creating tables. * - * @return A Status object. On success, a connection object will be in the + * @return Status object. On success, a connection object will be in the * value member. */ protected function openPgConnection( $type ) { @@ -344,6 +359,7 @@ class PostgresInstaller extends DatabaseInstaller { /** * Returns true if the install user is able to create objects owned * by the web user, false otherwise. + * @return bool */ protected function canCreateObjectsForWebUser() { if ( $this->isSuperUser() ) { @@ -365,10 +381,11 @@ class PostgresInstaller extends DatabaseInstaller { /** * Recursive helper for canCreateObjectsForWebUser(). - * @param $conn Database object - * @param $targetMember Role ID of the member to look for - * @param $group Role ID of the group to look for - * @param $maxDepth Maximum recursive search depth + * @param $conn DatabaseBase object + * @param $targetMember int Role ID of the member to look for + * @param $group int Role ID of the group to look for + * @param $maxDepth int Maximum recursive search depth + * @return bool */ protected function isRoleMember( $conn, $targetMember, $group, $maxDepth ) { if ( $targetMember === $group ) { @@ -429,10 +446,6 @@ class PostgresInstaller extends DatabaseInstaller { $conn = $status->value; $dbName = $this->getVar( 'wgDBname' ); - //$schema = $this->getVar( 'wgDBmwschema' ); - //$user = $this->getVar( 'wgDBuser' ); - //$safeschema = $conn->addIdentifierQuotes( $schema ); - //$safeuser = $conn->addIdentifierQuotes( $user ); $exists = $conn->selectField( '"pg_catalog"."pg_database"', '1', array( 'datname' => $dbName ), __METHOD__ ); @@ -464,19 +477,13 @@ class PostgresInstaller extends DatabaseInstaller { } } - // If we created a user, alter it now to search the new schema by default - if ( $this->getVar( '_CreateDBAccount' ) ) { - $conn->query( "ALTER ROLE $safeuser SET search_path = $safeschema, public", - __METHOD__ ); - } - // Select the new schema in the current connection - $conn->query( "SET search_path = $safeschema" ); + $conn->determineCoreSchema( $schema ); return Status::newGood(); } function commitChanges() { - $this->db->commit(); + $this->db->commit( __METHOD__ ); return Status::newGood(); } @@ -491,10 +498,8 @@ class PostgresInstaller extends DatabaseInstaller { } $conn = $status->value; - //$schema = $this->getVar( 'wgDBmwschema' ); $safeuser = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) ); $safepass = $conn->addQuotes( $this->getVar( 'wgDBpassword' ) ); - //$safeschema = $conn->addIdentifierQuotes( $schema ); // Check if the user already exists $userExists = $conn->roleExists( $this->getVar( 'wgDBuser' ) ); @@ -551,7 +556,7 @@ class PostgresInstaller extends DatabaseInstaller { */ $conn = $status->value; - if( $conn->tableExists( 'user' ) ) { + if( $conn->tableExists( 'archive' ) ) { $status->warning( 'config-install-tables-exist' ); $this->enableLB(); return $status; diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 023cb300..6cffe84a 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -2,6 +2,21 @@ /** * PostgreSQL-specific updater. * + * 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 * @ingroup Deployment */ @@ -23,28 +38,35 @@ class PostgresUpdater extends DatabaseUpdater { /** * @todo FIXME: Postgres should use sequential updates like Mysql, Sqlite * and everybody else. It never got refactored like it should've. + * @return array */ protected function getCoreUpdateList() { return array( # rename tables 1.7.3 # r15791 Change reserved word table names "user" and "text" - array( 'renameTable', 'user', 'mwuser'), - array( 'renameTable', 'text', 'pagecontent'), - - # new sequences - array( 'addSequence', 'logging_log_id_seq' ), - array( 'addSequence', 'page_restrictions_pr_id_seq' ), + array( 'renameTable', 'user', 'mwuser' ), + array( 'renameTable', 'text', 'pagecontent' ), + array( 'renameIndex', 'mwuser', 'user_pkey', 'mwuser_pkey'), + array( 'renameIndex', 'mwuser', 'user_user_name_key', 'mwuser_user_name_key' ), + array( 'renameIndex', 'pagecontent','text_pkey', 'pagecontent_pkey' ), # renamed sequences array( 'renameSequence', 'ipblocks_ipb_id_val', 'ipblocks_ipb_id_seq' ), array( 'renameSequence', 'rev_rev_id_val', 'revision_rev_id_seq' ), array( 'renameSequence', 'text_old_id_val', 'text_old_id_seq' ), - array( 'renameSequence', 'category_id_seq', 'category_cat_id_seq' ), array( 'renameSequence', 'rc_rc_id_seq', 'recentchanges_rc_id_seq' ), array( 'renameSequence', 'log_log_id_seq', 'logging_log_id_seq' ), array( 'renameSequence', 'pr_id_val', 'page_restrictions_pr_id_seq' ), array( 'renameSequence', 'us_id_seq', 'uploadstash_us_id_seq' ), + # since r58263 + array( 'renameSequence', 'category_id_seq', 'category_cat_id_seq'), + + # new sequences if not renamed above + array( 'addSequence', 'logging', false, 'logging_log_id_seq' ), + array( 'addSequence', 'page_restrictions', false, 'page_restrictions_pr_id_seq' ), + array( 'addSequence', 'filearchive', 'fa_id', 'filearchive_fa_id_seq' ), + # new tables array( 'addTable', 'category', 'patch-category.sql' ), array( 'addTable', 'page', 'patch-page.sql' ), @@ -67,11 +89,13 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addTable', 'module_deps', 'patch-module_deps.sql' ), array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ), array( 'addTable', 'user_former_groups','patch-user_former_groups.sql' ), + array( 'addTable', 'external_user', 'patch-external_user.sql' ), # Needed before new field array( 'convertArchive2' ), # new fields + array( 'addPgField', 'updatelog', 'ul_value', 'TEXT' ), array( 'addPgField', 'archive', 'ar_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'archive', 'ar_len', 'INTEGER' ), array( 'addPgField', 'archive', 'ar_page_id', 'INTEGER' ), @@ -87,6 +111,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'ipblocks', 'ipb_create_account', 'SMALLINT NOT NULL DEFAULT 1' ), array( 'addPgField', 'ipblocks', 'ipb_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'ipblocks', 'ipb_enable_autoblock', 'SMALLINT NOT NULL DEFAULT 1' ), + array( 'addPgField', 'ipblocks', 'ipb_parent_block_id', 'INTEGER DEFAULT NULL REFERENCES ipblocks(ipb_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED' ), array( 'addPgField', 'filearchive', 'fa_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'logging', 'log_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'logging', 'log_id', "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq')" ), @@ -138,7 +163,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'changeField', 'image', 'img_size', 'integer', '' ), array( 'changeField', 'image', 'img_width', 'integer', '' ), array( 'changeField', 'image', 'img_height', 'integer', '' ), - array( 'changeField', 'interwiki', 'iw_local', 'smallint', 'iw_local::smallint DEFAULT 0' ), + array( 'changeField', 'interwiki', 'iw_local', 'smallint', 'iw_local::smallint' ), array( 'changeField', 'interwiki', 'iw_trans', 'smallint', 'iw_trans::smallint DEFAULT 0' ), array( 'changeField', 'ipblocks', 'ipb_auto', 'smallint', 'ipb_auto::smallint DEFAULT 0' ), array( 'changeField', 'ipblocks', 'ipb_anon_only', 'smallint', "CASE WHEN ipb_anon_only=' ' THEN 0 ELSE ipb_anon_only::smallint END DEFAULT 0" ), @@ -168,18 +193,23 @@ class PostgresUpdater extends DatabaseUpdater { array( 'changeField', 'revision', 'rev_minor_edit', 'smallint', 'rev_minor_edit::smallint DEFAULT 0' ), array( 'changeField', 'templatelinks', 'tl_namespace', 'smallint', 'tl_namespace::smallint' ), array( 'changeField', 'user_newtalk', 'user_ip', 'text', 'host(user_ip)' ), + array( 'changeField', 'uploadstash', 'us_image_bits', 'smallint', '' ), # null changes array( 'changeNullableField', 'oldimage', 'oi_bits', 'NULL' ), array( 'changeNullableField', 'oldimage', 'oi_timestamp', 'NULL' ), array( 'changeNullableField', 'oldimage', 'oi_major_mime', 'NULL' ), array( 'changeNullableField', 'oldimage', 'oi_minor_mime', 'NULL' ), + array( 'changeNullableField', 'image', 'img_metadata', 'NOT NULL'), + array( 'changeNullableField', 'filearchive', 'fa_metadata', 'NOT NULL'), + array( 'changeNullableField', 'recentchanges', 'rc_cur_id', 'NULL' ), array( 'checkOiDeleted' ), # New indexes array( 'addPgIndex', 'archive', 'archive_user_text', '(ar_user_text)' ), array( 'addPgIndex', 'image', 'img_sha1', '(img_sha1)' ), + array( 'addPgIndex', 'ipblocks', 'ipb_parent_block_id', '(ipb_parent_block_id)' ), array( 'addPgIndex', 'oldimage', 'oi_sha1', '(oi_sha1)' ), array( 'addPgIndex', 'page', 'page_mediawiki_title', '(page_title) WHERE page_namespace = 8' ), array( 'addPgIndex', 'pagelinks', 'pagelinks_title', '(pl_title)' ), @@ -192,12 +222,78 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgIndex', 'iwlinks', 'iwl_prefix_title_from', '(iwl_prefix, iwl_title, iwl_from)' ), array( 'addPgIndex', 'job', 'job_timestamp_idx', '(job_timestamp)' ), + array( 'checkIndex', 'pagelink_unique', array( + array('pl_from', 'int4_ops', 'btree', 0), + array('pl_namespace', 'int2_ops', 'btree', 0), + array('pl_title', 'text_ops', 'btree', 0), + ), + 'CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)' ), + array( 'checkIndex', 'cl_sortkey', array( + array('cl_to', 'text_ops', 'btree', 0), + array('cl_sortkey', 'text_ops', 'btree', 0), + array('cl_from', 'int4_ops', 'btree', 0), + ), + 'CREATE INDEX cl_sortkey ON "categorylinks" USING "btree" ("cl_to", "cl_sortkey", "cl_from")' ), + array( 'checkIndex', 'logging_times', array( + array('log_timestamp', 'timestamptz_ops', 'btree', 0), + ), + 'CREATE INDEX "logging_times" ON "logging" USING "btree" ("log_timestamp")' ), + array( 'dropIndex', 'oldimage', 'oi_name' ), + array( 'checkIndex', 'oi_name_archive_name', array( + array('oi_name', 'text_ops', 'btree', 0), + array('oi_archive_name', 'text_ops', 'btree', 0), + ), + 'CREATE INDEX "oi_name_archive_name" ON "oldimage" USING "btree" ("oi_name", "oi_archive_name")' ), + array( 'checkIndex', 'oi_name_timestamp', array( + array('oi_name', 'text_ops', 'btree', 0), + array('oi_timestamp', 'timestamptz_ops', 'btree', 0), + ), + 'CREATE INDEX "oi_name_timestamp" ON "oldimage" USING "btree" ("oi_name", "oi_timestamp")' ), + array( 'checkIndex', 'page_main_title', array( + array('page_title', 'text_pattern_ops', 'btree', 0), + ), + 'CREATE INDEX "page_main_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 0)' ), + array( 'checkIndex', 'page_mediawiki_title', array( + array('page_title', 'text_pattern_ops', 'btree', 0), + ), + 'CREATE INDEX "page_mediawiki_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 8)' ), + array( 'checkIndex', 'page_project_title', array( + array('page_title', 'text_pattern_ops', 'btree', 0), + ), + 'CREATE INDEX "page_project_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 4)' ), + array( 'checkIndex', 'page_talk_title', array( + array('page_title', 'text_pattern_ops', 'btree', 0), + ), + 'CREATE INDEX "page_talk_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 1)' ), + array( 'checkIndex', 'page_user_title', array( + array('page_title', 'text_pattern_ops', 'btree', 0), + ), + 'CREATE INDEX "page_user_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 2)' ), + array( 'checkIndex', 'page_utalk_title', array( + array('page_title', 'text_pattern_ops', 'btree', 0), + ), + 'CREATE INDEX "page_utalk_title" ON "page" USING "btree" ("page_title" "text_pattern_ops") WHERE ("page_namespace" = 3)' ), + array( 'checkIndex', 'ts2_page_text', array( + array('textvector', 'tsvector_ops', 'gist', 0), + ), + 'CREATE INDEX "ts2_page_text" ON "pagecontent" USING "gist" ("textvector")' ), + array( 'checkIndex', 'ts2_page_title', array( + array('titlevector', 'tsvector_ops', 'gist', 0), + ), + 'CREATE INDEX "ts2_page_title" ON "page" USING "gist" ("titlevector")' ), + array( 'checkOiNameConstraint' ), array( 'checkPageDeletedTrigger' ), - array( 'checkRcCurIdNullable' ), - array( 'checkPagelinkUniqueIndex' ), array( 'checkRevUserFkey' ), - array( 'checkIpbAdress' ), + array( 'dropIndex', 'ipblocks', 'ipb_address'), + array( 'checkIndex', 'ipb_address_unique', array( + array('ipb_address', 'text_ops', 'btree', 0), + array('ipb_user', 'int4_ops', 'btree', 0), + array('ipb_auto', 'int2_ops', 'btree', 0), + array('ipb_anon_only', 'int2_ops', 'btree', 0), + ), + 'CREATE UNIQUE INDEX ipb_address_unique ON ipblocks (ipb_address,ipb_user,ipb_auto,ipb_anon_only)' ), + array( 'checkIwlPrefix' ), # All FK columns should be deferred @@ -210,6 +306,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'changeFkeyDeferrable', 'imagelinks', 'il_from', 'page(page_id) ON DELETE CASCADE' ), array( 'changeFkeyDeferrable', 'ipblocks', 'ipb_by', 'mwuser(user_id) ON DELETE CASCADE' ), array( 'changeFkeyDeferrable', 'ipblocks', 'ipb_user', 'mwuser(user_id) ON DELETE SET NULL' ), + array( 'changeFkeyDeferrable', 'ipblocks', 'ipb_parent_block_id', 'ipblocks(ipb_id) ON DELETE SET NULL' ), array( 'changeFkeyDeferrable', 'langlinks', 'll_from', 'page(page_id) ON DELETE CASCADE' ), array( 'changeFkeyDeferrable', 'logging', 'log_user', 'mwuser(user_id) ON DELETE SET NULL' ), array( 'changeFkeyDeferrable', 'oldimage', 'oi_name', 'image(img_name) ON DELETE CASCADE ON UPDATE CASCADE' ), @@ -229,6 +326,8 @@ class PostgresUpdater extends DatabaseUpdater { array( 'changeFkeyDeferrable', 'user_properties', 'up_user', 'mwuser(user_id) ON DELETE CASCADE' ), array( 'changeFkeyDeferrable', 'watchlist', 'wl_user', 'mwuser(user_id) ON DELETE CASCADE' ), + # r81574 + array( 'addInterwikiType' ), # end array( 'tsearchFixes' ), ); @@ -274,7 +373,6 @@ class PostgresUpdater extends DatabaseUpdater { } protected function describeTable( $table ) { - global $wgDBmwschema; $q = <<db->query( sprintf( $q, $this->db->addQuotes( $table ), - $this->db->addQuotes( $wgDBmwschema ) ) ); + $this->db->addQuotes( $this->db->getCoreSchema() ) ) ); if ( !$res ) { return null; } @@ -299,8 +397,6 @@ END; } function describeIndex( $idx ) { - global $wgDBmwschema; - // first fetch the key (which is a list of columns ords) and // the table the index applies to (an oid) $q = <<db->query( sprintf( $q, - $this->db->addQuotes( $wgDBmwschema ), + $this->db->addQuotes( $this->db->getCoreSchema() ), $this->db->addQuotes( $idx ) ) ); @@ -350,7 +446,6 @@ END; } function fkeyDeltype( $fkey ) { - global $wgDBmwschema; $q = <<db->query( sprintf( $q, - $this->db->addQuotes( $wgDBmwschema ), + $this->db->addQuotes( $this->db->getCoreSchema() ), $this->db->addQuotes( $fkey ) ) ); @@ -371,7 +466,6 @@ END; } function ruleDef( $table, $rule ) { - global $wgDBmwschema; $q = <<db->query( sprintf( $q, - $this->db->addQuotes( $wgDBmwschema ), + $this->db->addQuotes( $this->db->getCoreSchema() ), $this->db->addQuotes( $table ), $this->db->addQuotes( $rule ) ) @@ -394,10 +488,13 @@ END; return $d; } - protected function addSequence( $ns ) { + protected function addSequence( $table, $pkey, $ns ) { if ( !$this->db->sequenceExists( $ns ) ) { $this->output( "Creating sequence $ns\n" ); $this->db->query( "CREATE SEQUENCE $ns" ); + if( $pkey !== false ) { + $this->setDefault( $table, $pkey, '"nextval"(\'"' . $ns . '"\'::"regclass")' ); + } } } @@ -412,12 +509,22 @@ END; } } - protected function renameTable( $old, $new ) { + protected function renameTable( $old, $new, $patch = false ) { if ( $this->db->tableExists( $old ) ) { $this->output( "Renaming table $old to $new\n" ); $old = $this->db->realTableName( $old, "quoted" ); $new = $this->db->realTableName( $new, "quoted" ); $this->db->query( "ALTER TABLE $old RENAME TO $new" ); + if( $patch !== false ) { + $this->applyPatch( $patch ); + } + } + } + + protected function renameIndex( $table, $old, $new ) { + if ( $this->db->indexExists( $table, $old ) ) { + $this->output( "Renaming index $old to $new\n" ); + $this->db->query( "ALTER INDEX $old RENAME TO $new" ); } } @@ -453,13 +560,20 @@ END; } $sql .= " USING $default"; } - $this->db->begin( __METHOD__ ); $this->db->query( $sql ); - $this->db->commit( __METHOD__ ); } } - protected function changeNullableField( $table, $field, $null ) { + protected function setDefault( $table, $field, $default ) { + + $info = $this->db->fieldInfo( $table, $field ); + if ( $info->defaultValue() !== $default ) { + $this->output( "Changing '$table.$field' default value\n" ); + $this->db->query( "ALTER TABLE $table ALTER $field SET DEFAULT " . $default ); + } + } + + protected function changeNullableField( $table, $field, $null) { $fi = $this->db->fieldInfo( $table, $field ); if ( is_null( $fi ) ) { $this->output( "...ERROR: expected column $table.$field to exist\n" ); @@ -498,11 +612,11 @@ END; if ( $this->db->indexExists( $table, $index ) ) { $this->output( "...index '$index' on table '$table' already exists\n" ); } else { - $this->output( "Creating index '$index' on table '$table'\n" ); if ( preg_match( '/^\(/', $type ) ) { + $this->output( "Creating index '$index' on table '$table'\n" ); $this->db->query( "CREATE INDEX $index ON $table $type" ); } else { - $this->applyPatch( $type, true ); + $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" ); } } } @@ -518,15 +632,20 @@ END; } $this->output( "Altering column '$table.$field' to be DEFERRABLE INITIALLY DEFERRED\n" ); $conname = $fi->conname(); - $command = "ALTER TABLE $table DROP CONSTRAINT $conname"; - $this->db->query( $command ); - $command = "ALTER TABLE $table ADD CONSTRAINT $conname FOREIGN KEY ($field) REFERENCES $clause DEFERRABLE INITIALLY DEFERRED"; + if ( $fi->conname() ) { + $conclause = "CONSTRAINT \"$conname\""; + $command = "ALTER TABLE $table DROP CONSTRAINT $conname"; + $this->db->query( $command ); + } else { + $this->output( "Column '$table.$field' does not have a foreign key constraint, will be added\n" ); + $conclause = ""; + } + $command = "ALTER TABLE $table ADD $conclause FOREIGN KEY ($field) REFERENCES $clause DEFERRABLE INITIALLY DEFERRED"; $this->db->query( $command ); } protected function convertArchive2() { if ( $this->db->tableExists( "archive2" ) ) { - $this->output( "Converting 'archive2' back to normal archive table\n" ); if ( $this->db->ruleExists( 'archive', 'archive_insert' ) ) { $this->output( "Dropping rule 'archive_insert'\n" ); $this->db->query( 'DROP RULE archive_insert ON archive' ); @@ -535,7 +654,7 @@ END; $this->output( "Dropping rule 'archive_delete'\n" ); $this->db->query( 'DROP RULE archive_delete ON archive' ); } - $this->applyPatch( 'patch-remove-archive2.sql' ); + $this->applyPatch( 'patch-remove-archive2.sql', false, "Converting 'archive2' back to normal archive table" ); } else { $this->output( "...obsolete table 'archive2' does not exist\n" ); } @@ -570,38 +689,34 @@ END; protected function checkPageDeletedTrigger() { if ( !$this->db->triggerExists( 'page', 'page_deleted' ) ) { - $this->output( "Adding function and trigger 'page_deleted' to table 'page'\n" ); - $this->applyPatch( 'patch-page_deleted.sql' ); + $this->applyPatch( 'patch-page_deleted.sql', false, "Adding function and trigger 'page_deleted' to table 'page'" ); } else { $this->output( "...table 'page' has 'page_deleted' trigger\n" ); } } - protected function checkRcCurIdNullable(){ - $fi = $this->db->fieldInfo( 'recentchanges', 'rc_cur_id' ); - if ( !$fi->isNullable() ) { - $this->output( "Removing NOT NULL constraint from 'recentchanges.rc_cur_id'\n" ); - $this->applyPatch( 'patch-rc_cur_id-not-null.sql' ); - } else { - $this->output( "...column 'recentchanges.rc_cur_id' has a NOT NULL constraint\n" ); + protected function dropIndex( $table, $index, $patch = '', $fullpath = false ) { + if ( $this->db->indexExists( $table, $index ) ) { + $this->output( "Dropping obsolete index '$index'\n" ); + $this->db->query( "DROP INDEX \"". $index ."\"" ); } } - protected function checkPagelinkUniqueIndex() { - $pu = $this->describeIndex( 'pagelink_unique' ); - if ( !is_null( $pu ) && ( $pu[0] != 'pl_from' || $pu[1] != 'pl_namespace' || $pu[2] != 'pl_title' ) ) { - $this->output( "Dropping obsolete version of index 'pagelink_unique index'\n" ); - $this->db->query( 'DROP INDEX pagelink_unique' ); - $pu = null; + protected function checkIndex( $index, $should_be, $good_def ) { + $pu = $this->db->indexAttributes( $index ); + if ( !empty( $pu ) && $pu != $should_be ) { + $this->output( "Dropping obsolete version of index '$index'\n" ); + $this->db->query( "DROP INDEX \"". $index ."\"" ); + $pu = array(); } else { - $this->output( "...obsolete version of index 'pagelink_unique index' does not exist\n" ); + $this->output( "...no need to drop index '$index'\n" ); } - if ( is_null( $pu ) ) { - $this->output( "Creating index 'pagelink_unique index'\n" ); - $this->db->query( 'CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title)' ); + if ( empty( $pu ) ) { + $this->output( "Creating index '$index'\n" ); + $this->db->query( $good_def ); } else { - $this->output( "...index 'pagelink_unique_index' already exists\n" ); + $this->output( "...index '$index' exists\n" ); } } @@ -609,43 +724,30 @@ END; if ( $this->fkeyDeltype( 'revision_rev_user_fkey' ) == 'r' ) { $this->output( "...constraint 'revision_rev_user_fkey' is ON DELETE RESTRICT\n" ); } else { - $this->output( "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT\n" ); - $this->applyPatch( 'patch-revision_rev_user_fkey.sql' ); - } - } - - protected function checkIpbAdress() { - if ( $this->db->indexExists( 'ipblocks', 'ipb_address' ) ) { - $this->output( "Removing deprecated index 'ipb_address'...\n" ); - $this->db->query( 'DROP INDEX ipb_address' ); - } - if ( $this->db->indexExists( 'ipblocks', 'ipb_address_unique' ) ) { - $this->output( "...have ipb_address_unique\n" ); - } else { - $this->output( "Adding ipb_address_unique index\n" ); - $this->applyPatch( 'patch-ipb_address_unique.sql' ); + $this->applyPatch( 'patch-revision_rev_user_fkey.sql', false, "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT" ); } } protected function checkIwlPrefix() { if ( $this->db->indexExists( 'iwlinks', 'iwl_prefix' ) ) { - $this->output( "Replacing index 'iwl_prefix' with 'iwl_prefix_from_title'...\n" ); - $this->applyPatch( 'patch-rename-iwl_prefix.sql' ); + $this->applyPatch( 'patch-rename-iwl_prefix.sql', false, "Replacing index 'iwl_prefix' with 'iwl_prefix_from_title'" ); } } + protected function addInterwikiType() { + $this->applyPatch( 'patch-add_interwiki.sql', false, "Refreshing add_interwiki()" ); + } + protected function tsearchFixes() { # Tweak the page_title tsearch2 trigger to filter out slashes # This is create or replace, so harmless to call if not needed - $this->output( "Refreshing ts2_page_title()...\n" ); - $this->applyPatch( 'patch-ts2pagetitle.sql' ); + $this->applyPatch( 'patch-ts2pagetitle.sql', false, "Refreshing ts2_page_title()" ); # If the server is 8.3 or higher, rewrite the tsearch2 triggers # in case they have the old 'default' versions # Gather version numbers in case we need them if ( $this->db->getServerVersion() >= 8.3 ) { - $this->output( "Rewriting tsearch2 triggers...\n" ); - $this->applyPatch( 'patch-tsearch2funcs.sql' ); + $this->applyPatch( 'patch-tsearch2funcs.sql', false, "Rewriting tsearch2 triggers" ); } } } diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index 658a3b16..6e1a74f6 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -2,6 +2,21 @@ /** * Sqlite-specific installer. * + * 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 * @ingroup Deployment */ @@ -207,7 +222,7 @@ class SqliteInstaller extends DatabaseInstaller { } /** - * @return Staus + * @return Status */ public function createTables() { $status = parent::createTables(); diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index e1bc2926..12a310af 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -2,6 +2,21 @@ /** * Sqlite-specific updater. * + * 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 * @ingroup Deployment */ @@ -71,6 +86,12 @@ class SqliteUpdater extends DatabaseUpdater { array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ), array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ), array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ug_group-length-increase.sql' ), + + // 1.20 + array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ), + array( 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ), + array( 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ), + array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ), ); } @@ -80,22 +101,16 @@ class SqliteUpdater extends DatabaseUpdater { $this->output( "...have initial indexes\n" ); return; } - $this->output( "Adding initial indexes..." ); - $this->applyPatch( 'initial-indexes.sql' ); - $this->output( "done\n" ); + $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" ); } protected function sqliteSetupSearchindex() { $module = DatabaseSqlite::getFulltextSearchModule(); $fts3tTable = $this->updateRowExists( 'fts3' ); if ( $fts3tTable && !$module ) { - $this->output( '...PHP is missing FTS3 support, downgrading tables...' ); - $this->applyPatch( 'searchindex-no-fts.sql' ); - $this->output( "done\n" ); + $this->applyPatch( 'searchindex-no-fts.sql', false, 'PHP is missing FTS3 support, downgrading tables' ); } elseif ( !$fts3tTable && $module == 'FTS3' ) { - $this->output( '...adding FTS3 search capabilities...' ); - $this->applyPatch( 'searchindex-fts3.sql' ); - $this->output( "done\n" ); + $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" ); } else { $this->output( "...fulltext search table appears to be in order.\n" ); } diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index 1ff77db7..2f46ff0b 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -2,6 +2,21 @@ /** * Core installer web interface. * + * 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 * @ingroup Deployment */ @@ -146,7 +161,7 @@ class WebInstaller extends Installer { 'Content-Disposition: attachment; filename="LocalSettings.php"' ); - $ls = new LocalSettingsGenerator( $this ); + $ls = InstallerOverrides::getLocalSettingsGenerator( $this ); $rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )]; foreach( $rightsProfile as $group => $rightsArr ) { $ls->setGroupRights( $group, $rightsArr ); @@ -347,21 +362,21 @@ class WebInstaller extends Installer { $url = $m[1]; } return md5( serialize( array( - 'local path' => dirname( dirname( __FILE__ ) ), + 'local path' => dirname( __DIR__ ), 'url' => $url, 'version' => $GLOBALS['wgVersion'] ) ) ); } /** - * Show an error message in a box. Parameters are like wfMsg(). + * Show an error message in a box. Parameters are like wfMessage(). * @param $msg */ public function showError( $msg /*...*/ ) { $args = func_get_args(); array_shift( $args ); $args = array_map( 'htmlspecialchars', $args ); - $msg = wfMsgReal( $msg, $args, false, false, false ); + $msg = wfMessage( $msg, $args )->useDatabase( false )->plain(); $this->output->addHTML( $this->getErrorBox( $msg ) ); } @@ -433,6 +448,7 @@ class WebInstaller extends Installer { * * @param $name String * @param $default + * @return null */ public function getSession( $name, $default = null ) { if ( !isset( $this->session[$name] ) ) { @@ -484,7 +500,7 @@ class WebInstaller extends Installer { public function getAcceptLanguage() { global $wgLanguageCode, $wgRequest; - $mwLanguages = Language::getLanguageNames(); + $mwLanguages = Language::fetchLanguageNames(); $headerLanguages = array_keys( $wgRequest->getAcceptLang() ); foreach ( $headerLanguages as $lang ) { @@ -524,7 +540,7 @@ class WebInstaller extends Installer { $s .= $this->getPageListItem( 'Restart', true, $currentPageName ); $s .= "\n"; // end list pane $s .= Html::element( 'h2', array(), - wfMsg( 'config-page-' . strtolower( $currentPageName ) ) ); + wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() ); $this->output->addHTMLNoFlush( $s ); } @@ -540,7 +556,7 @@ class WebInstaller extends Installer { */ private function getPageListItem( $pageName, $enabled, $currentPageName ) { $s = "
  • "; - $name = wfMsg( 'config-page-' . strtolower( $pageName ) ); + $name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text(); if ( $enabled ) { $query = array( 'page' => $pageName ); @@ -593,7 +609,7 @@ class WebInstaller extends Installer { /** * Get HTML for an error box with an icon. * - * @param $text String: wikitext, get this with wfMsgNoTrans() + * @param $text String: wikitext, get this with wfMessage()->plain() * * @return string */ @@ -604,7 +620,7 @@ class WebInstaller extends Installer { /** * Get HTML for a warning box with an icon. * - * @param $text String: wikitext, get this with wfMsgNoTrans() + * @param $text String: wikitext, get this with wfMessage()->plain() * * @return string */ @@ -615,7 +631,7 @@ class WebInstaller extends Installer { /** * Get HTML for an info box with an icon. * - * @param $text String: wikitext, get this with wfMsgNoTrans() + * @param $text String: wikitext, get this with wfMessage()->plain() * @param $icon String: icon name, file in skins/common/images * @param $class String: additional class name to add to the wrapper div * @@ -624,13 +640,13 @@ class WebInstaller extends Installer { public function getInfoBox( $text, $icon = false, $class = false ) { $text = $this->parse( $text, true ); $icon = ( $icon == false ) ? '../skins/common/images/info-32.png' : '../skins/common/images/'.$icon; - $alt = wfMsg( 'config-information' ); + $alt = wfMessage( 'config-information' )->text(); return Html::infoBox( $text, $icon, $alt, $class, false ); } /** * Get small text indented help for a preceding form field. - * Parameters like wfMsg(). + * Parameters like wfMessage(). * * @param $msg * @return string @@ -639,18 +655,19 @@ class WebInstaller extends Installer { $args = func_get_args(); array_shift( $args ); $args = array_map( 'htmlspecialchars', $args ); - $text = wfMsgReal( $msg, $args, false, false, false ); + $text = wfMessage( $msg, $args )->useDatabase( false )->plain(); $html = $this->parse( $text, true ); return "
    \n" . - "" . wfMsgHtml( 'config-help' ) . "\n" . + "" . wfMessage( 'config-help' )->escaped() . + "\n" . "" . $html . "\n" . "
    \n"; } /** * Output a help box. - * @param $msg String key for wfMsg() + * @param $msg String key for wfMessage() */ public function showHelpBox( $msg /*, ... */ ) { $args = func_get_args(); @@ -668,7 +685,7 @@ class WebInstaller extends Installer { $args = func_get_args(); array_shift( $args ); $html = '
    ' . - $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) . + $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) . "
    \n"; $this->output->addHTML( $html ); } @@ -697,7 +714,7 @@ class WebInstaller extends Installer { if ( strval( $msg ) == '' ) { $labelText = ' '; } else { - $labelText = wfMsgHtml( $msg ); + $labelText = wfMessage( $msg )->escaped(); } $attributes = array( 'class' => 'config-label' ); @@ -877,7 +894,7 @@ class WebInstaller extends Installer { if( isset( $params['rawtext'] ) ) { $labelText = $params['rawtext']; } else { - $labelText = $this->parse( wfMsg( $params['label'] ) ); + $labelText = $this->parse( wfMessage( $params['label'] )->text() ); } return @@ -953,7 +970,7 @@ class WebInstaller extends Installer { Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) . ' ' . Xml::tags( 'label', array( 'for' => $id ), $this->parse( - wfMsgNoTrans( $params['itemLabelPrefix'] . strtolower( $value ) ) + wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain() ) ) . "
  • \n"; } @@ -1061,7 +1078,7 @@ class WebInstaller extends Installer { ) ); $anchor = Html::rawElement( 'a', array( 'href' => $this->getURL( array( 'localsettings' => 1 ) ) ), - $img . ' ' . wfMsgHtml( 'config-download-localsettings' ) ); + $img . ' ' . wfMessage( 'config-download-localsettings' )->escaped() ); return Html::rawElement( 'div', array( 'class' => 'config-download-link' ), $anchor ); } diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index c6c8a4c2..f3166c25 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -2,6 +2,21 @@ /** * Output handler for the web installer. * + * 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 * @ingroup Deployment */ @@ -93,7 +108,7 @@ class WebInstallerOutput { * @return String */ public function getCSS( $dir ) { - $skinDir = dirname( dirname( dirname( __FILE__ ) ) ) . '/skins'; + $skinDir = dirname( dirname( __DIR__ ) ) . '/skins'; // All these files will be concatenated in sequence and loaded // as one file. @@ -103,6 +118,7 @@ class WebInstallerOutput { $cssFileNames = array( // Basically the "skins.vector" ResourceLoader module styles + 'common/shared.css', 'common/commonElements.css', 'common/commonContent.css', 'common/commonInterface.css', @@ -133,11 +149,12 @@ class WebInstallerOutput { if( $dir == 'rtl' ) { $css = CSSJanus::transform( $css, true ); } + return $css; } /** - * to index.php?css=foobar for the + * "" to index.php?css=foobar for the "" * @return String */ private function getCssUrl( ) { @@ -221,7 +238,6 @@ class WebInstallerOutput { <?php $this->outputTitle(); ?> - getCssUrl() . "\n"; ?> getJQuery() . "\n"; ?> @@ -258,7 +274,7 @@ class WebInstallerOutput {
    parent->parse( wfMsgNoTrans( 'config-sidebar' ), true ); + echo $this->parent->parse( wfMessage( 'config-sidebar' )->plain(), true ); ?>
    @@ -286,7 +302,7 @@ class WebInstallerOutput { public function outputTitle() { global $wgVersion; - echo htmlspecialchars( wfMsg( 'config-title', $wgVersion ) ); + echo wfMessage( 'config-title', $wgVersion )->escaped(); } public function getJQuery() { diff --git a/includes/installer/WebInstallerPage.php b/includes/installer/WebInstallerPage.php index ff8185a1..a193afb7 100644 --- a/includes/installer/WebInstallerPage.php +++ b/includes/installer/WebInstallerPage.php @@ -2,6 +2,21 @@ /** * Base code for web installer pages. * + * 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 * @ingroup Deployment */ @@ -36,6 +51,7 @@ abstract class WebInstallerPage { * Is this a slow-running page in the installer? If so, WebInstaller will * set_time_limit(0) before calling execute(). Right now this only applies * to Install and Upgrade pages + * @return bool */ public function isSlow() { return false; @@ -68,13 +84,13 @@ abstract class WebInstallerPage { if ( $continue ) { // Fake submit button for enter keypress (bug 26267) - $s .= Xml::submitButton( wfMsg( "config-$continue" ), + $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(), array( 'name' => "enter-$continue", 'style' => 'visibility:hidden;overflow:hidden;width:1px;margin:0' ) ) . "\n"; } if ( $back ) { - $s .= Xml::submitButton( wfMsg( "config-$back" ), + $s .= Xml::submitButton( wfMessage( "config-$back" )->text(), array( 'name' => "submit-$back", 'tabindex' => $this->parent->nextTabIndex() @@ -82,7 +98,7 @@ abstract class WebInstallerPage { } if ( $continue ) { - $s .= Xml::submitButton( wfMsg( "config-$continue" ), + $s .= Xml::submitButton( wfMessage( "config-$continue" )->text(), array( 'name' => "submit-$continue", 'tabindex' => $this->parent->nextTabIndex(), @@ -117,7 +133,7 @@ abstract class WebInstallerPage { * @return string */ protected function getFieldsetStart( $legend ) { - return "\n
    " . wfMsgHtml( $legend ) . "\n"; + return "\n
    " . wfMessage( $legend )->escaped() . "\n"; } /** @@ -161,7 +177,7 @@ class WebInstaller_Language extends WebInstallerPage { $userLang = $r->getVal( 'uselang' ); $contLang = $r->getVal( 'ContLang' ); - $languages = Language::getLanguageNames(); + $languages = Language::fetchLanguageNames(); $lifetime = intval( ini_get( 'session.gc_maxlifetime' ) ); if ( !$lifetime ) { $lifetime = 1440; // PHP default @@ -216,7 +232,7 @@ class WebInstaller_Language extends WebInstallerPage { } /** - * Get a " for selecting languages. * * @param $name * @param $label @@ -232,7 +248,7 @@ class WebInstaller_Language extends WebInstallerPage { $s .= Html::openElement( 'select', array( 'id' => $name, 'name' => $name, 'tabindex' => $this->parent->nextTabIndex() ) ) . "\n"; - $languages = Language::getLanguageNames(); + $languages = Language::fetchLanguageNames(); ksort( $languages ); foreach ( $languages as $code => $lang ) { if ( isset( $wgDummyLanguageCodes[$code] ) ) continue; @@ -279,8 +295,8 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { } $this->startForm(); $this->addHTML( $this->parent->getInfoBox( - wfMsgNoTrans( 'config-upgrade-key-missing', - "
    \$wgUpgradeKey = '" . $this->getVar( 'wgUpgradeKey' ) . "';
    " ) + wfMessage( 'config-upgrade-key-missing', "
    \$wgUpgradeKey = '" .
    +					$this->getVar( 'wgUpgradeKey' ) . "';
    " )->plain() ) ); $this->endForm( 'continue' ); return 'output'; @@ -317,7 +333,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { protected function showKeyForm() { $this->startForm(); $this->addHTML( - $this->parent->getInfoBox( wfMsgNoTrans( 'config-localsettings-upgrade' ) ). + $this->parent->getInfoBox( wfMessage( 'config-localsettings-upgrade' )->plain() ). '
    ' . $this->parent->getTextBox( array( 'var' => 'wgUpgradeKey', @@ -341,7 +357,7 @@ class WebInstaller_ExistingWiki extends WebInstallerPage { /** * Initiate an upgrade of the existing database - * @param $vars Variables from LocalSettings.php and AdminSettings.php + * @param $vars array Variables from LocalSettings.php and AdminSettings.php * @return Status */ protected function handleExistingUpgrade( $vars ) { @@ -394,13 +410,13 @@ class WebInstaller_Welcome extends WebInstallerPage { return 'continue'; } } - $this->parent->output->addWikiText( wfMsgNoTrans( 'config-welcome' ) ); + $this->parent->output->addWikiText( wfMessage( 'config-welcome' )->plain() ); $status = $this->parent->doEnvironmentChecks(); if ( $status->isGood() ) { $this->parent->output->addHTML( '' . - wfMsgHtml( 'config-env-good' ) . '' ); - $this->parent->output->addWikiText( wfMsgNoTrans( 'config-copyright', - SpecialVersion::getCopyrightAndAuthorList() ) ); + wfMessage( 'config-env-good' )->escaped() . '' ); + $this->parent->output->addWikiText( wfMessage( 'config-copyright', + SpecialVersion::getCopyrightAndAuthorList() )->plain() ); $this->startForm(); $this->endForm(); } else { @@ -438,10 +454,10 @@ class WebInstaller_DBConnect extends WebInstallerPage { $dbSupport = ''; foreach( $this->parent->getDBTypes() as $type ) { $link = DatabaseBase::factory( $type )->getSoftwareLink(); - $dbSupport .= wfMsgNoTrans( "config-support-$type", $link ) . "\n"; + $dbSupport .= wfMessage( "config-support-$type", $link )->plain() . "\n"; } $this->addHTML( $this->parent->getInfoBox( - wfMsg( 'config-support-info', $dbSupport ) ) ); + wfMessage( 'config-support-info', trim( $dbSupport ) )->text() ) ); foreach ( $this->parent->getVar( '_CompiledDBs' ) as $type ) { $installer = $this->parent->getDBInstaller( $type ); @@ -460,7 +476,7 @@ class WebInstaller_DBConnect extends WebInstallerPage { $settings .= Html::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) . - Html::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) . + Html::element( 'h3', array(), wfMessage( 'config-header-' . $type )->text() ) . $installer->getConnectForm() . "\n"; } @@ -539,7 +555,7 @@ class WebInstaller_Upgrade extends WebInstallerPage { $this->startForm(); $this->addHTML( $this->parent->getInfoBox( - wfMsgNoTrans( 'config-can-upgrade', $GLOBALS['wgVersion'] ) ) ); + wfMessage( 'config-can-upgrade', $GLOBALS['wgVersion'] )->plain() ) ); $this->endForm(); } @@ -554,11 +570,11 @@ class WebInstaller_Upgrade extends WebInstallerPage { $this->parent->disableLinkPopups(); $this->addHTML( $this->parent->getInfoBox( - wfMsgNoTrans( $msg, + wfMessage( $msg, $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/index' . $this->getVar( 'wgScriptExtension' ) - ), 'tick-32.png' + )->plain(), 'tick-32.png' ) ); $this->parent->restoreLinkPopups(); @@ -619,7 +635,10 @@ class WebInstaller_Name extends WebInstallerPage { // Set wgMetaNamespace to something valid before we show the form. // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki' $metaNS = $this->getVar( 'wgMetaNamespace' ); - $this->setVar( 'wgMetaNamespace', wfMsgForContent( 'config-ns-other-default' ) ); + $this->setVar( + 'wgMetaNamespace', + wfMessage( 'config-ns-other-default' )->inContentLanguage()->text() + ); $this->addHTML( $this->parent->getTextBox( array( @@ -667,7 +686,7 @@ class WebInstaller_Name extends WebInstallerPage { 'help' => $this->parent->getHelpBox( 'config-subscribe-help' ) ) ) . $this->getFieldSetEnd() . - $this->parent->getInfoBox( wfMsg( 'config-almost-done' ) ) . + $this->parent->getInfoBox( wfMessage( 'config-almost-done' )->text() ) . $this->parent->getRadioSet( array( 'var' => '_SkipOptional', 'itemLabelPrefix' => 'config-optional-', @@ -705,7 +724,7 @@ class WebInstaller_Name extends WebInstallerPage { $name = preg_replace( '/__+/', '_', $name ); $name = ucfirst( trim( $name, '_' ) ); } elseif ( $nsType == 'generic' ) { - $name = wfMsg( 'config-ns-generic' ); + $name = wfMessage( 'config-ns-generic' )->text(); } else { // other $name = $this->getVar( 'wgMetaNamespace' ); } @@ -817,7 +836,7 @@ class WebInstaller_Options extends WebInstallerPage { 'itemLabelPrefix' => 'config-profile-', 'values' => array_keys( $this->parent->rightsProfiles ), ) ) . - $this->parent->getInfoBox( wfMsgNoTrans( 'config-profile-help' ) ) . + $this->parent->getInfoBox( wfMessage( 'config-profile-help' )->plain() ) . # Licensing $this->parent->getRadioSet( array( @@ -1030,7 +1049,7 @@ class WebInstaller_Options extends WebInstallerPage { 'href' => $this->getCCPartnerUrl(), 'onclick' => $expandJs, ), - wfMsg( 'config-cc-again' ) + wfMessage( 'config-cc-again' )->text() ) . "

    \n" . "