Merge "AjaxDispatcher: Use Config instead of globals"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 26 Aug 2014 14:56:27 +0000 (14:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 26 Aug 2014 14:56:27 +0000 (14:56 +0000)
23 files changed:
RELEASE-NOTES-1.24
includes/db/Database.php
includes/htmlform/HTMLCheckMatrix.php
includes/htmlform/HTMLForm.php
includes/installer/DatabaseInstaller.php
includes/installer/Installer.php
includes/installer/MssqlUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/i18n/en.json
includes/installer/i18n/qqq.json
includes/resourceloader/ResourceLoader.php
includes/specials/SpecialMIMEsearch.php
maintenance/archives/patch-fa_major_mime-chemical.sql [new file with mode: 0644]
maintenance/archives/patch-img_major_mime-chemical.sql [new file with mode: 0644]
maintenance/archives/patch-oi_major_mime-chemical.sql [new file with mode: 0644]
maintenance/mssql/archives/patch-fa_major_mime-chemical.sql [new file with mode: 0644]
maintenance/mssql/archives/patch-img_major_mime-chemical.sql [new file with mode: 0644]
maintenance/mssql/archives/patch-oi_major_mime-chemical.sql [new file with mode: 0644]
maintenance/mssql/tables.sql
maintenance/mssql/update-keys.sql [new file with mode: 0644]
maintenance/tables.sql
maintenance/update-keys.sql [new file with mode: 0644]
tests/phpunit/includes/config/GlobalVarConfigTest.php

index 7be3139..c2a1e2b 100644 (file)
@@ -355,6 +355,8 @@ changes to languages because of Bugzilla reports.
 * Removed EnhancedChangesList::arrow(), sideArrow(), downArrow(), spacerArrow().
 * Removed Xml::namespaceSelector(). (deprecated since 1.19)
 * Removed WikiPage::estimateRevisionCount(). (deprecated since 1.19)
+* MYSQL: Enum item added to "major MIME type" columns.
+  Running update.php on MySQL < v5.1 may result in heavy processing.
 
 ==== Renamed classes ====
 * CLDRPluralRuleConverter_Expression to CLDRPluralRuleConverterExpression
index 42c94f0..a46ee1c 100644 (file)
@@ -710,19 +710,42 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
        }
 
        /**
-        * Return a path to the DBMS-specific schema file, otherwise default to tables.sql
+        * Return a path to the DBMS-specific SQL file if it exists,
+        * otherwise default SQL file
         *
+        * @param string $filename
         * @return string
         */
-       public function getSchemaPath() {
+       private function getSqlFilePath( $filename ) {
                global $IP;
-               if ( file_exists( "$IP/maintenance/" . $this->getType() . "/tables.sql" ) ) {
-                       return "$IP/maintenance/" . $this->getType() . "/tables.sql";
+               $dbmsSpecificFilePath = "$IP/maintenance/" . $this->getType() . "/$filename";
+               if ( file_exists( $dbmsSpecificFilePath ) ) {
+                       return $dbmsSpecificFilePath;
                } else {
-                       return "$IP/maintenance/tables.sql";
+                       return "$IP/maintenance/$filename";
                }
        }
 
+       /**
+        * Return a path to the DBMS-specific schema file,
+        * otherwise default to tables.sql
+        *
+        * @return string
+        */
+       public function getSchemaPath() {
+               return $this->getSqlFilePath( 'tables.sql' );
+       }
+
+       /**
+        * Return a path to the DBMS-specific update key file,
+        * otherwise default to update-keys.sql
+        *
+        * @return string
+        */
+       public function getUpdateKeysPath() {
+               return $this->getSqlFilePath( 'update-keys.sql' );
+       }
+
 # ------------------------------------------------------------------------------
 # Other functions
 # ------------------------------------------------------------------------------
index 8255526..6c538fd 100644 (file)
@@ -80,8 +80,6 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
         * @return string
         */
        function getInputHTML( $value ) {
-               global $wgUseMediaWikiUIEverywhere;
-
                $html = '';
                $tableContents = '';
                $rows = $this->mParams['rows'];
@@ -129,7 +127,7 @@ class HTMLCheckMatrix extends HTMLFormField implements HTMLNestedFilterable {
                                        $thisAttribs['disabled'] = 1;
                                }
                                $chkBox = Xml::check( "{$this->mName}[]", $checked, $attribs + $thisAttribs );
-                               if ( $wgUseMediaWikiUIEverywhere ) {
+                               if ( $this->mParent->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
                                        $chkBox = Html::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
                                                $chkBox .
                                                Html::element( 'label', array( 'for' => $thisId ) ) .
index 6501890..3a455ab 100644 (file)
@@ -300,9 +300,8 @@ class HTMLForm extends ContextSource {
         * @return string
         */
        public function getDisplayFormat() {
-               global $wgHTMLFormAllowTableFormat;
                $format = $this->displayFormat;
-               if ( !$wgHTMLFormAllowTableFormat && $format === 'table' ) {
+               if ( !$this->getConfig()->get( 'HTMLFormAllowTableFormat' ) && $format === 'table' ) {
                        $format = 'div';
                }
                return $format;
@@ -845,8 +844,6 @@ class HTMLForm extends ContextSource {
         * @return string HTML.
         */
        function getHiddenFields() {
-               global $wgArticlePath;
-
                $html = '';
                if ( $this->getMethod() == 'post' ) {
                        $html .= Html::hidden(
@@ -857,7 +854,8 @@ class HTMLForm extends ContextSource {
                        $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n";
                }
 
-               if ( strpos( $wgArticlePath, '?' ) !== false && $this->getMethod() == 'get' ) {
+               $articlePath = $this->getConfig()->get( 'ArticlePath' );
+               if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() == 'get' ) {
                        $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n";
                }
 
@@ -874,8 +872,8 @@ class HTMLForm extends ContextSource {
         * @return string HTML.
         */
        function getButtons() {
-               global $wgUseMediaWikiUIEverywhere;
                $buttons = '';
+               $useMediaWikiUIEverywhere = $this->getConfig()->get( 'UseMediaWikiUIEverywhere' );
 
                if ( $this->mShowSubmit ) {
                        $attribs = array();
@@ -894,7 +892,7 @@ class HTMLForm extends ContextSource {
 
                        $attribs['class'] = array( 'mw-htmlform-submit' );
 
-                       if ( $this->isVForm() || $wgUseMediaWikiUIEverywhere ) {
+                       if ( $this->isVForm() || $useMediaWikiUIEverywhere ) {
                                array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' );
                        }
 
@@ -937,7 +935,7 @@ class HTMLForm extends ContextSource {
                                $attrs['id'] = $button['id'];
                        }
 
-                       if ( $wgUseMediaWikiUIEverywhere ) {
+                       if ( $useMediaWikiUIEverywhere ) {
                                if ( isset( $attrs['class' ] ) ) {
                                        $attrs['class'] .= ' mw-ui-button';
                                } else {
@@ -1438,20 +1436,19 @@ class HTMLForm extends ContextSource {
         * @return string
         */
        public function getAction() {
-               global $wgScript, $wgArticlePath;
-
                // If an action is alredy provided, return it
                if ( $this->mAction !== false ) {
                        return $this->mAction;
                }
 
-               // Check whether we are in GET mode and $wgArticlePath contains a "?"
+               $articlePath = $this->getConfig()->get( 'ArticlePath' );
+               // Check whether we are in GET mode and the ArticlePath contains a "?"
                // meaning that getLocalURL() would return something like "index.php?title=...".
                // As browser remove the query string before submitting GET forms,
-               // it means that the title would be lost. In such case use $wgScript instead
+               // it means that the title would be lost. In such case use wfScript() instead
                // and put title in an hidden field (see getHiddenFields()).
-               if ( strpos( $wgArticlePath, '?' ) !== false && $this->getMethod() === 'get' ) {
-                       return $wgScript;
+               if ( strpos( $articlePath, '?' ) !== false && $this->getMethod() === 'get' ) {
+                       return wfScript();
                }
 
                return $this->getTitle()->getLocalURL();
index 8a01b32..31b93c8 100644 (file)
@@ -163,19 +163,26 @@ abstract class DatabaseInstaller {
        }
 
        /**
-        * Create database tables from scratch.
+        * Apply a SQL source file to the database as part of running an installation step.
         *
+        * @param string $sourceFileMethod
+        * @param string $stepName
+        * @param string $archiveTableMustNotExist
         * @return Status
         */
-       public function createTables() {
+       private function stepApplySourceFile(
+               $sourceFileMethod,
+               $stepName,
+               $archiveTableMustNotExist = false
+       ) {
                $status = $this->getConnection();
                if ( !$status->isOK() ) {
                        return $status;
                }
                $this->db->selectDB( $this->getVar( 'wgDBname' ) );
 
-               if ( $this->db->tableExists( 'archive', __METHOD__ ) ) {
-                       $status->warning( 'config-install-tables-exist' );
+               if ( $archiveTableMustNotExist && $this->db->tableExists( 'archive', __METHOD__ ) ) {
+                       $status->warning( "config-$stepName-tables-exist" );
                        $this->enableLB();
 
                        return $status;
@@ -184,11 +191,13 @@ abstract class DatabaseInstaller {
                $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
                $this->db->begin( __METHOD__ );
 
-               $error = $this->db->sourceFile( $this->db->getSchemaPath() );
+               $error = $this->db->sourceFile(
+                       call_user_func( array( $this->db, $sourceFileMethod ) )
+               );
                if ( $error !== true ) {
                        $this->db->reportQueryError( $error, 0, '', __METHOD__ );
                        $this->db->rollback( __METHOD__ );
-                       $status->fatal( 'config-install-tables-failed', $error );
+                       $status->fatal( "config-$stepName-tables-failed", $error );
                } else {
                        $this->db->commit( __METHOD__ );
                }
@@ -200,6 +209,24 @@ abstract class DatabaseInstaller {
                return $status;
        }
 
+       /**
+        * Create database tables from scratch.
+        *
+        * @return Status
+        */
+       public function createTables() {
+               return $this->stepApplySourceFile( 'getSchemaPath', 'install', true );
+       }
+
+       /**
+        * Insert update keys into table to prevent running unneded updates.
+        *
+        * @return Status
+        */
+       public function insertUpdateKeys() {
+               return $this->stepApplySourceFile( 'getUpdateKeysPath', 'updates', false );
+       }
+
        /**
         * Create the tables for each extension the user enabled
         * @return Status
index 33b091b..aca3119 100644 (file)
@@ -1520,6 +1520,7 @@ abstract class Installer {
                        array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
                        array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
                        array( 'name' => 'keys', 'callback' => array( $this, 'generateKeys' ) ),
+                       array( 'name' => 'updates', 'callback' => array( $installer, 'insertUpdateKeys' ) ),
                        array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
                        array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
                );
index 4d86d11..ed11f8b 100644 (file)
@@ -52,6 +52,13 @@ class MssqlUpdater extends DatabaseUpdater {
                        array( 'updateConstraints', 'media_type', 'image', 'img_media_type' ),
                        array( 'updateConstraints', 'media_type', 'uploadstash', 'us_media_type' ),
                        // END: Constraint updates
+
+                       array( 'modifyField', 'image', 'img_major_mime',
+                               'patch-img_major_mime-chemical.sql' ),
+                       array( 'modifyField', 'oldimage', 'oi_major_mime',
+                               'patch-oi_major_mime-chemical.sql' ),
+                       array( 'modifyField', 'filearchive', 'fa_major_mime',
+                               'patch-fa_major_mime-chemical.sql' ),
                );
        }
 
index dcf37b6..990b5b0 100644 (file)
@@ -254,11 +254,18 @@ class MysqlUpdater extends DatabaseUpdater {
                        // 1.24
                        array( 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ),
                        array( 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ),
-                       array( 'addIndex', 'watchlist', 'wl_user_notificationtimestamp', 'patch-watchlist-user-notificationtimestamp-index.sql' ),
+                       array( 'addIndex', 'watchlist', 'wl_user_notificationtimestamp',
+                               'patch-watchlist-user-notificationtimestamp-index.sql' ),
                        array( 'addField', 'page', 'page_lang', 'patch-page_lang.sql' ),
                        array( 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ),
                        array( 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ),
                        array( 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ),
+                       array( 'modifyField', 'image', 'img_major_mime',
+                               'patch-img_major_mime-chemical.sql' ),
+                       array( 'modifyField', 'oldimage', 'oi_major_mime',
+                               'patch-oi_major_mime-chemical.sql' ),
+                       array( 'modifyField', 'filearchive', 'fa_major_mime',
+                               'patch-fa_major_mime-chemical.sql' ),
                );
        }
 
index bd76ada..ca328cf 100644 (file)
        "config-install-stats": "Initializing statistics",
        "config-install-keys": "Generating secret keys",
        "config-insecure-keys": "<strong>Warning:</strong> {{PLURAL:$2|A secure key|Secure keys}} ($1) generated during installation {{PLURAL:$2|is|are}} not completely safe. Consider changing {{PLURAL:$2|it|them}} manually.",
+       "config-install-updates": "Prevent running unneeded updates",
+       "config-install-updates-failed": "<strong>Error:</strong> Inserting update keys into tables failed with the following error: $1",
        "config-install-sysop": "Creating administrator user account",
        "config-install-subscribe-fail": "Unable to subscribe to mediawiki-announce: $1",
        "config-install-subscribe-notpossible": "cURL is not installed and <code>allow_url_fopen</code> is not available.",
index 8d9aac2..410b1d5 100644 (file)
        "config-install-stats": "*{{msg-mw|Config-install-database}}\n*{{msg-mw|Config-install-tables}}\n*{{msg-mw|Config-install-schema}}\n*{{msg-mw|Config-install-user}}\n*{{msg-mw|Config-install-interwiki}}\n*{{msg-mw|Config-install-stats}}\n*{{msg-mw|Config-install-keys}}\n*{{msg-mw|Config-install-sysop}}\n*{{msg-mw|Config-install-mainpage}}",
        "config-install-keys": "*{{msg-mw|Config-install-database}}\n*{{msg-mw|Config-install-tables}}\n*{{msg-mw|Config-install-schema}}\n*{{msg-mw|Config-install-user}}\n*{{msg-mw|Config-install-interwiki}}\n*{{msg-mw|Config-install-stats}}\n*{{msg-mw|Config-install-keys}}\n*{{msg-mw|Config-install-sysop}}\n*{{msg-mw|Config-install-mainpage}}",
        "config-insecure-keys": "Parameters:\n* $1 - A list of names of the secret keys that were generated.\n* $2 - the number of items in the list $1, to be used with PLURAL.",
+       "config-install-updates": "Message indicating that the updatelog table is filled with keys of updates that won't be run when running database updates.",
+       "config-install-updates-failed": "Used as error message. Parameters:\n* $1 - detailed error message",
        "config-install-sysop": "Message indicates that the administrator user account is being created\n\nSee also:\n*{{msg-mw|Config-install-database}}\n*{{msg-mw|Config-install-tables}}\n*{{msg-mw|Config-install-schema}}\n*{{msg-mw|Config-install-user}}\n*{{msg-mw|Config-install-interwiki}}\n*{{msg-mw|Config-install-stats}}\n*{{msg-mw|Config-install-keys}}\n*{{msg-mw|Config-install-sysop}}\n*{{msg-mw|Config-install-mainpage}}",
        "config-install-subscribe-fail": "{{doc-important|\"[[m:mail:mediawiki-announce|mediawiki-announce]]\" is the name of a mailing list and should not be translated.}}\nA message displayed if the MediaWiki installer encounters an error making a request to lists.wikimedia.org which hosts the mailing list.\n* $1 - the HTTP error encountered, reproduced as is (English string)",
        "config-install-subscribe-notpossible": "Error shown when automatically subscribing to the MediaWiki announcements mailing list fails.",
index 08340c9..60fd783 100644 (file)
@@ -1181,11 +1181,13 @@ class ResourceLoader {
         * Returns JS code which calls mw.loader.register with the given
         * parameters. Has three calling conventions:
         *
-        *   - ResourceLoader::makeLoaderRegisterScript( $name, $version, $dependencies, $group, $source, $skip ):
-        *       Register a single module.
+        *   - ResourceLoader::makeLoaderRegisterScript( $name, $version,
+        *        $dependencies, $group, $source, $skip
+        *     ):
+        *        Register a single module.
         *
         *   - ResourceLoader::makeLoaderRegisterScript( array( $name1, $name2 ) ):
-        *       Register modules with the given names.
+        *        Register modules with the given names.
         *
         *   - ResourceLoader::makeLoaderRegisterScript( array(
         *        array( $name1, $version1, $dependencies1, $group1, $source1, $skip1 ),
index 3215778..5bd69e0 100644 (file)
@@ -184,7 +184,8 @@ class MIMEsearchPage extends QueryPage {
                        'video',
                        'message',
                        'model',
-                       'multipart'
+                       'multipart',
+                       'chemical'
                );
 
                return in_array( $type, $types );
diff --git a/maintenance/archives/patch-fa_major_mime-chemical.sql b/maintenance/archives/patch-fa_major_mime-chemical.sql
new file mode 100644 (file)
index 0000000..be9b0ff
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE /*$wgDBprefix*/filearchive
+  CHANGE  fa_major_mime fa_major_mime ENUM('unknown','application','audio','image','text','video','message','model','multipart','chemical');
+
diff --git a/maintenance/archives/patch-img_major_mime-chemical.sql b/maintenance/archives/patch-img_major_mime-chemical.sql
new file mode 100644 (file)
index 0000000..4bde446
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE /*$wgDBprefix*/image
+  CHANGE  img_major_mime img_major_mime ENUM('unknown','application','audio','image','text','video','message','model','multipart','chemical');
+
diff --git a/maintenance/archives/patch-oi_major_mime-chemical.sql b/maintenance/archives/patch-oi_major_mime-chemical.sql
new file mode 100644 (file)
index 0000000..e3b4552
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE /*$wgDBprefix*/oldimage
+  CHANGE  oi_major_mime oi_major_mime ENUM('unknown','application','audio','image','text','video','message','model','multipart','chemical');
+
diff --git a/maintenance/mssql/archives/patch-fa_major_mime-chemical.sql b/maintenance/mssql/archives/patch-fa_major_mime-chemical.sql
new file mode 100644 (file)
index 0000000..1836808
--- /dev/null
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/filearchive
+DROP CONSTRAINT fa_major_mime_ckc;
+ALTER TABLE /*_*/filearchive
+WITH NOCHECK ADD CONSTRAINT fa_major_mime_ckc CHECK (fa_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical'));
\ No newline at end of file
diff --git a/maintenance/mssql/archives/patch-img_major_mime-chemical.sql b/maintenance/mssql/archives/patch-img_major_mime-chemical.sql
new file mode 100644 (file)
index 0000000..eed0786
--- /dev/null
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/image
+DROP CONSTRAINT img_major_mime_ckc;
+ALTER TABLE /*_*/image
+WITH NOCHECK ADD CONSTRAINT img_major_mime_ckc CHECK (img_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical'));
\ No newline at end of file
diff --git a/maintenance/mssql/archives/patch-oi_major_mime-chemical.sql b/maintenance/mssql/archives/patch-oi_major_mime-chemical.sql
new file mode 100644 (file)
index 0000000..35482ed
--- /dev/null
@@ -0,0 +1,4 @@
+ALTER TABLE /*_*/oldimage
+DROP CONSTRAINT oi_major_mime_ckc;
+ALTER TABLE /*_*/oldimage
+WITH NOCHECK ADD CONSTRAINT oi_major_mime_ckc CHECK (oi_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical'));
\ No newline at end of file
index daaa81e..b9cd715 100644 (file)
@@ -594,7 +594,7 @@ CREATE TABLE /*_*/image (
   -- SHA-1 content hash in base-36
   img_sha1 nvarchar(32) NOT NULL default '',
 
-  CONSTRAINT img_major_mime_ckc check (img_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart')),
+  CONSTRAINT img_major_mime_ckc check (img_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical')),
   CONSTRAINT img_media_type_ckc check (img_media_type in('UNKNOWN', 'BITMAP', 'DRAWING', 'AUDIO', 'VIDEO', 'MULTIMEDIA', 'OFFICE', 'TEXT', 'EXECUTABLE', 'ARCHIVE'))
 );
 
@@ -639,7 +639,7 @@ CREATE TABLE /*_*/oldimage (
   oi_deleted tinyint NOT NULL default 0,
   oi_sha1 nvarchar(32) NOT NULL default '',
 
-  CONSTRAINT oi_major_mime_ckc check (oi_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart')),
+  CONSTRAINT oi_major_mime_ckc check (oi_major_mime IN('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical')),
   CONSTRAINT oi_media_type_ckc check (oi_media_type IN('UNKNOWN', 'BITMAP', 'DRAWING', 'AUDIO', 'VIDEO', 'MULTIMEDIA', 'OFFICE', 'TEXT', 'EXECUTABLE', 'ARCHIVE'))
 );
 
@@ -700,7 +700,7 @@ CREATE TABLE /*_*/filearchive (
   -- sha1 hash of file content
   fa_sha1 nvarchar(32) NOT NULL default '',
 
-  CONSTRAINT fa_major_mime_ckc check (fa_major_mime in('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart')),
+  CONSTRAINT fa_major_mime_ckc check (fa_major_mime in('unknown', 'application', 'audio', 'image', 'text', 'video', 'message', 'model', 'multipart', 'chemical')),
   CONSTRAINT fa_media_type_ckc check (fa_media_type in('UNKNOWN', 'BITMAP', 'DRAWING', 'AUDIO', 'VIDEO', 'MULTIMEDIA', 'OFFICE', 'TEXT', 'EXECUTABLE', 'ARCHIVE'))
 );
 
diff --git a/maintenance/mssql/update-keys.sql b/maintenance/mssql/update-keys.sql
new file mode 100644 (file)
index 0000000..4d2c1c1
--- /dev/null
@@ -0,0 +1,31 @@
+-- Update keys for Microsoft SQL Server
+-- SQL to insert update keys into the initial tables after a
+-- fresh installation of MediaWiki's database.
+-- This is read and executed by the install script; you should
+-- not have to run it by itself unless doing a manual install.
+-- Insert keys here if either the unnecessary would cause heavy
+-- processing or could potentially cause trouble by lowering field
+-- sizes, adding constraints, etc.
+-- When adjusting field sizes, it is recommended removing old
+-- patches but to play safe, update keys should also inserted here.
+
+--
+-- The /*_*/ comments in this and other files are
+-- replaced with the defined table prefix by the installer
+-- and updater scripts. If you are installing or running
+-- updates manually, you will need to manually insert the
+-- table prefix if any when running these scripts.
+--
+
+INSERT INTO /*_*/updatelog
+       SELECT 'filearchive-fa_major_mime-patch-fa_major_mime-chemical.sql' AS ul_key, null as ul_value
+       UNION SELECT 'image-img_major_mime-patch-img_major_mime-chemical.sql', null
+       UNION SELECT 'oldimage-oi_major_mime-patch-oi_major_mime-chemical.sql', null
+       UNION SELECT 'cl_type-category_types-ck', null
+       UNION SELECT 'fa_major_mime-major_mime-ck', null
+       UNION SELECT 'fa_media_type-media_type-ck', null
+       UNION SELECT 'img_major_mime-major_mime-ck', null
+       UNION SELECT 'img_media_type-media_type-ck', null
+       UNION SELECT 'oi_major_mime-major_mime-ck', null
+       UNION SELECT 'oi_media_type-media_type-ck', null
+       UNION SELECT 'us_media_type-media_type-ck', null;
\ No newline at end of file
index f181e0f..0228684 100644 (file)
@@ -847,7 +847,8 @@ CREATE TABLE /*_*/image (
 
   -- major part of a MIME media type as defined by IANA
   -- see http://www.iana.org/assignments/media-types/
-  img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown",
+  -- for "chemical" cf. http://dx.doi.org/10.1021/ci9803233 by the ACS
+  img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
 
   -- minor part of a MIME media type as defined by IANA
   -- the minor parts are not required to adher to any standard
@@ -906,7 +907,7 @@ CREATE TABLE /*_*/oldimage (
 
   oi_metadata mediumblob NOT NULL,
   oi_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
-  oi_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown",
+  oi_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
   oi_minor_mime varbinary(100) NOT NULL default "unknown",
   oi_deleted tinyint unsigned NOT NULL default 0,
   oi_sha1 varbinary(32) NOT NULL default ''
@@ -956,7 +957,7 @@ CREATE TABLE /*_*/filearchive (
   fa_metadata mediumblob,
   fa_bits int default 0,
   fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
-  fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") default "unknown",
+  fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
   fa_minor_mime varbinary(100) default "unknown",
   fa_description tinyblob,
   fa_user int unsigned default 0,
diff --git a/maintenance/update-keys.sql b/maintenance/update-keys.sql
new file mode 100644 (file)
index 0000000..d5ef924
--- /dev/null
@@ -0,0 +1,29 @@
+-- SQL to insert update keys into the initial tables after a
+-- fresh installation of MediaWiki's database.
+-- This is read and executed by the install script; you should
+-- not have to run it by itself unless doing a manual install.
+-- Insert keys here if either the unnecessary would cause heavy
+-- processing or could potentially cause trouble by lowering field
+-- sizes, adding constraints, etc.
+-- When adjusting field sizes, it is recommended removing old
+-- patches but to play safe, update keys should also inserted here.
+
+-- This is a shared file used for both MySQL and SQLite installs.
+-- Therefore inserting multiple values is not possible using the
+-- INSERT INTO VALUES syntax.
+--
+--
+-- The /*_*/ comments in this and other files are
+-- replaced with the defined table prefix by the installer
+-- and updater scripts. If you are installing or running
+-- updates manually, you will need to manually insert the
+-- table prefix if any when running these scripts.
+--
+
+INSERT INTO /*_*/updatelog
+       SELECT 'filearchive-fa_major_mime-patch-fa_major_mime-chemical.sql' AS ul_key, null as ul_value
+       UNION SELECT 'image-img_major_mime-patch-img_major_mime-chemical.sql', null
+       UNION SELECT 'oldimage-oi_major_mime-patch-oi_major_mime-chemical.sql', null
+       UNION SELECT 'user_groups-ug_group-patch-ug_group-length-increase-255.sql', null
+       UNION SELECT 'user_former_groups-ufg_group-patch-ufg_group-length-increase-255.sql', null
+       UNION SELECT 'user_properties-up_property-patch-up_property.sql', null;
\ No newline at end of file
index 662f268..a999081 100644 (file)
@@ -8,6 +8,34 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
        public function testNewInstance() {
                $config = GlobalVarConfig::newInstance();
                $this->assertInstanceOf( 'GlobalVarConfig', $config );
+               $this->maybeStashGlobal( 'wgBaz' );
+               $GLOBALS['wgBaz'] = 'somevalue';
+               // Check prefix is set to 'wg'
+               $this->assertEquals( 'somevalue', $config->get( 'Baz' ) );
+       }
+
+       /**
+        * @covers GlobalVarConfig::__construct
+        * @dataProvider provideConstructor
+        */
+       public function testConstructor( $prefix ) {
+               $var = $prefix . 'GlobalVarConfigTest';
+               $rand = wfRandomString();
+               $this->maybeStashGlobal( $var );
+               $GLOBALS[$var] = $rand;
+               $config = new GlobalVarConfig( $prefix );
+               $this->assertInstanceOf( 'GlobalVarConfig', $config );
+               $this->assertEquals( $rand, $config->get( 'GlobalVarConfigTest' ) );
+       }
+
+       public static function provideConstructor() {
+               return array(
+                       array( 'wg' ),
+                       array( 'ef' ),
+                       array( 'smw' ),
+                       array( 'blahblahblahblah' ),
+                       array( '' ),
+               );
        }
 
        public function provideGet() {
@@ -27,6 +55,7 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
                        array( 'Foo', 'wg', 'default2' ),
                        array( 'Variable', 'ef', 'default3' ),
                        array( 'BAR', '', 'default4' ),
+                       array( 'ThisGlobalWasNotSetAbove', 'wg', false )
                );
        }
 
@@ -40,6 +69,9 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
         */
        public function testGet( $name, $prefix, $expected ) {
                $config = new GlobalVarConfig( $prefix );
+               if ( $expected === false ) {
+                       $this->setExpectedException( 'ConfigException', 'GlobalVarConfig::getWithPrefix: undefined variable:' );
+               }
                $this->assertEquals( $config->get( $name ), $expected );
        }
 
@@ -52,16 +84,20 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
                );
        }
 
+       private function maybeStashGlobal( $var ) {
+               if ( array_key_exists( $var, $GLOBALS ) ) {
+                       // Will be reset after this test is over
+                       $this->stashMwGlobals( $var );
+               }
+       }
+
        /**
         * @dataProvider provideSet
         * @covers GlobalVarConfig::set
         * @covers GlobalVarConfig::setWithPrefix
         */
        public function testSet( $name, $prefix, $var ) {
-               if ( array_key_exists( $var, $GLOBALS ) ) {
-                       // Will be reset after this test is over
-                       $this->stashMwGlobals( $var );
-               }
+               $this->maybeStashGlobal( $var );
                $config = new GlobalVarConfig( $prefix );
                $random = wfRandomString();
                $config->set( $name, $random );