* 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
}
/**
- * 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
# ------------------------------------------------------------------------------
* @return string
*/
function getInputHTML( $value ) {
- global $wgUseMediaWikiUIEverywhere;
-
$html = '';
$tableContents = '';
$rows = $this->mParams['rows'];
$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 ) ) .
* @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;
* @return string HTML.
*/
function getHiddenFields() {
- global $wgArticlePath;
-
$html = '';
if ( $this->getMethod() == 'post' ) {
$html .= Html::hidden(
$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";
}
* @return string HTML.
*/
function getButtons() {
- global $wgUseMediaWikiUIEverywhere;
$buttons = '';
+ $useMediaWikiUIEverywhere = $this->getConfig()->get( 'UseMediaWikiUIEverywhere' );
if ( $this->mShowSubmit ) {
$attribs = array();
$attribs['class'] = array( 'mw-htmlform-submit' );
- if ( $this->isVForm() || $wgUseMediaWikiUIEverywhere ) {
+ if ( $this->isVForm() || $useMediaWikiUIEverywhere ) {
array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' );
}
$attrs['id'] = $button['id'];
}
- if ( $wgUseMediaWikiUIEverywhere ) {
+ if ( $useMediaWikiUIEverywhere ) {
if ( isset( $attrs['class' ] ) ) {
$attrs['class'] .= ' mw-ui-button';
} else {
* @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();
}
/**
- * 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;
$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__ );
}
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
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' ) ),
);
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' ),
);
}
// 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' ),
);
}
"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.",
"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.",
* 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 ),
'video',
'message',
'model',
- 'multipart'
+ 'multipart',
+ 'chemical'
);
return in_array( $type, $types );
--- /dev/null
+ALTER TABLE /*$wgDBprefix*/filearchive
+ CHANGE fa_major_mime fa_major_mime ENUM('unknown','application','audio','image','text','video','message','model','multipart','chemical');
+
--- /dev/null
+ALTER TABLE /*$wgDBprefix*/image
+ CHANGE img_major_mime img_major_mime ENUM('unknown','application','audio','image','text','video','message','model','multipart','chemical');
+
--- /dev/null
+ALTER TABLE /*$wgDBprefix*/oldimage
+ CHANGE oi_major_mime oi_major_mime ENUM('unknown','application','audio','image','text','video','message','model','multipart','chemical');
+
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
-- 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'))
);
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'))
);
-- 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'))
);
--- /dev/null
+-- 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
-- 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
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 ''
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,
--- /dev/null
+-- 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
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() {
array( 'Foo', 'wg', 'default2' ),
array( 'Variable', 'ef', 'default3' ),
array( 'BAR', '', 'default4' ),
+ array( 'ThisGlobalWasNotSetAbove', 'wg', false )
);
}
*/
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 );
}
);
}
+ 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 );