From: jenkins-bot Date: Tue, 16 May 2017 09:02:00 +0000 (+0000) Subject: Merge "Resources.php: Add missing dependencies to module 'mediawiki.util'" X-Git-Tag: 1.31.0-rc.0~3243 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=0d7607db15a11a584ee143ade8d56b929dd12b46;hp=3ad01cdeccedd7a49f1c3491434041dde243c873;p=lhc%2Fweb%2Fwiklou.git Merge "Resources.php: Add missing dependencies to module 'mediawiki.util'" --- diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index 27acb8ac5f..d32db34cf1 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -66,6 +66,9 @@ changes to languages because of Phabricator reports. deprecated. There are no known callers. * File::getStreamHeaders() was deprecated. * MediaHandler::getStreamHeaders() was deprecated. +* The ExtractThumbParameters hook (deprecated in 1.21) was removed. +* The OutputPage::addParserOutputNoText and ::getHeadLinks methods (both + deprecated in 1.24) were removed. == Compatibility == MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for diff --git a/docs/extension.schema.v2.json b/docs/extension.schema.v2.json index 137dd519ca..d5a9b65215 100644 --- a/docs/extension.schema.v2.json +++ b/docs/extension.schema.v2.json @@ -2,6 +2,7 @@ "$schema": "http://json-schema.org/schema#", "description": "MediaWiki extension.json schema", "type": "object", + "additionalProperties": false, "properties": { "manifest_version": { "type": "integer", @@ -729,6 +730,20 @@ "type": "array", "description": "List of service wiring files to be loaded by the default instance of MediaWikiServices" }, + "attributes": { + "description":"Registration information for other extensions", + "type": "object", + "patternProperties": { + ".*": { + "type": "object", + "patternProperties": { + ".*": { + "type": ["array", "object"] + } + } + } + } + }, "load_composer_autoloader": { "type": "boolean", "description": "Load the composer autoloader for this extension, if one is present" diff --git a/docs/hooks.txt b/docs/hooks.txt index d95e39b986..62b22e153f 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1527,13 +1527,6 @@ $ip: The ip address of the user change the tables headers. &$extTypes: associative array of extensions types -'ExtractThumbParameters': DEPRECATED! Media handler should override -MediaHandler::parseParamString instead. -Called when extracting thumbnail parameters from a thumbnail file name. -$thumbname: the base name of the thumbnail file -&$params: the currently extracted params (has source name, temp or archived -zone) - 'FetchChangesList': When fetching the ChangesList derivative for a particular user. $user: User the list is being fetched for diff --git a/includes/EditPage.php b/includes/EditPage.php index b1f50f089d..098ffbf791 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2753,6 +2753,9 @@ class EditPage { $wgOut->addHTML( Html::hidden( 'format', $this->contentFormat ) ); $wgOut->addHTML( Html::hidden( 'model', $this->contentModel ) ); + // Preserve &ooui=1 / &ooui=0 from URL parameters after submitting the page for preview + $wgOut->addHTML( Html::hidden( 'ooui', $this->oouiEnabled ? '1' : '0' ) ); + // following functions will need OOUI, enable it only once; here. if ( $this->oouiEnabled ) { $wgOut->enableOOUI(); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 85610b9a5b..84a168b5e7 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1773,17 +1773,6 @@ class OutputPage extends ContextSource { $this->addParserOutput( $parserOutput ); } - /** - * Add a ParserOutput object, but without Html. - * - * @deprecated since 1.24, use addParserOutputMetadata() instead. - * @param ParserOutput $parserOutput - */ - public function addParserOutputNoText( $parserOutput ) { - wfDeprecated( __METHOD__, '1.24' ); - $this->addParserOutputMetadata( $parserOutput ); - } - /** * Add all metadata associated with a ParserOutput object, but without the actual HTML. This * includes categories, language links, ResourceLoader modules, effects of certain magic words, @@ -3560,16 +3549,6 @@ class OutputPage extends ContextSource { return $tags; } - /** - * @return string HTML tag links to be put in the header. - * @deprecated since 1.24 Use OutputPage::headElement or if you have to, - * OutputPage::getHeadLinksArray directly. - */ - public function getHeadLinks() { - wfDeprecated( __METHOD__, '1.24' ); - return implode( "\n", $this->getHeadLinksArray() ); - } - /** * Generate a "" for a feed. * diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index d4d104231d..d097414aff 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -493,6 +493,7 @@ class ParserOptions { * @return string|bool */ public function getWrapOutputClass() { + $this->optionUsed( 'wrapclass' ); return $this->wrapOutputClass; } @@ -943,6 +944,10 @@ class ParserOptions { $confstr .= '!printable=1'; } + if ( $this->wrapOutputClass !== 'mw-parser-output' && in_array( 'wrapclass', $forOptions ) ) { + $confstr .= '!wrapclass=' . $this->wrapOutputClass; + } + if ( $this->mExtraKey != '' ) { $confstr .= $this->mExtraKey; } diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 1212f9972c..d14be3ff8d 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -56,6 +56,16 @@ class ExtensionProcessor implements Processor { 'ValidSkinNames', ]; + /** + * Top-level attributes that come from MW core + * + * @var string[] + */ + protected static $coreAttributes = [ + 'SkinOOUIThemes', + 'TrackingCategories', + ]; + /** * Mapping of global settings to their specific merge strategies. * @@ -160,6 +170,14 @@ class ExtensionProcessor implements Processor { */ protected $attributes = []; + /** + * Extension attributes, keyed by name => + * settings. + * + * @var array + */ + protected $extAttributes = []; + /** * @param string $path * @param array $info @@ -186,14 +204,47 @@ class ExtensionProcessor implements Processor { $this->callbacks[$name] = $info['callback']; } + if ( $version === 2 ) { + $this->extractAttributes( $path, $info ); + } + foreach ( $info as $key => $val ) { + // If it's a global setting, if ( in_array( $key, self::$globalSettings ) ) { $this->storeToArray( $path, "wg$key", $val, $this->globals ); + continue; + } // Ignore anything that starts with a @ - } elseif ( $key[0] !== '@' && !in_array( $key, self::$notAttributes ) - && !in_array( $key, self::$creditsAttributes ) - ) { - $this->storeToArray( $path, $key, $val, $this->attributes ); + if ( $key[0] === '@' ) { + continue; + } + + if ( $version === 2 ) { + // Only whitelisted attributes are set + if ( in_array( $key, self::$coreAttributes ) ) { + $this->storeToArray( $path, $key, $val, $this->attributes ); + } + } else { + // version === 1 + if ( !in_array( $key, self::$notAttributes ) + && !in_array( $key, self::$creditsAttributes ) + ) { + // If it's not blacklisted, it's an attribute + $this->storeToArray( $path, $key, $val, $this->attributes ); + } + } + + } + } + + /** + * @param string $path + * @param array $info + */ + protected function extractAttributes( $path, array $info ) { + if ( isset( $info['attributes'] ) ) { + foreach ( $info['attributes'] as $extName => $value ) { + $this->storeToArray( $path, $extName, $value, $this->extAttributes ); } } } @@ -206,6 +257,22 @@ class ExtensionProcessor implements Processor { } } + // Merge $this->extAttributes into $this->attributes depending on what is loaded + foreach ( $this->extAttributes as $extName => $value ) { + // Only set the attribute if $extName is loaded (and hence present in credits) + if ( isset( $this->credits[$extName] ) ) { + foreach ( $value as $attrName => $attrValue ) { + $this->storeToArray( + '', // Don't provide a path since it's impossible to generate an error here + $extName . $attrName, + $attrValue, + $this->attributes + ); + } + unset( $this->extAttributes[$extName] ); + } + } + return [ 'globals' => $this->globals, 'defines' => $this->defines, diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index 344dd8f5c0..0423f71af5 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -31,7 +31,7 @@ class ExtensionRegistry { /** * Bump whenever the registration cache needs resetting */ - const CACHE_VERSION = 5; + const CACHE_VERSION = 6; /** * Special key that defines the merge strategy @@ -111,7 +111,7 @@ class ExtensionRegistry { * be loaded then). */ public function loadFromQueue() { - global $wgVersion; + global $wgVersion, $wgDevelopmentWarnings; if ( !$this->queued ) { return; } @@ -151,7 +151,10 @@ class ExtensionRegistry { // did that, but it should be cached $data['globals']['wgAutoloadClasses'] += $data['autoload']; unset( $data['autoload'] ); - $cache->set( $key, $data, 60 * 60 * 24 ); + if ( !( $data['warnings'] && $wgDevelopmentWarnings ) ) { + // If there were no warnings that were shown, cache it + $cache->set( $key, $data, 60 * 60 * 24 ); + } } $this->queued = []; } @@ -198,6 +201,7 @@ class ExtensionRegistry { $versionChecker = new VersionChecker( $wgVersion ); $extDependencies = []; $incompatible = []; + $warnings = false; foreach ( $queue as $path => $mtime ) { $json = file_get_contents( $path ); if ( $json === false ) { @@ -209,6 +213,11 @@ class ExtensionRegistry { } if ( !isset( $info['manifest_version'] ) ) { + wfDeprecated( + "{$info['name']}'s extension.json or skin.json does not have manifest_version", + '1.29' + ); + $warnings = true; // For backwards-compatability, assume a version of 1 $info['manifest_version'] = 1; } @@ -237,6 +246,7 @@ class ExtensionRegistry { $processor->extractInfo( $path, $info, $version ); } $data = $processor->getExtractedInfo(); + $data['warnings'] = $warnings; // check for incompatible extensions $incompatible = array_merge( diff --git a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.SavedQueriesModel.js b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.SavedQueriesModel.js index 04fb52b699..b8f2db5dda 100644 --- a/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.SavedQueriesModel.js +++ b/resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.SavedQueriesModel.js @@ -77,6 +77,16 @@ this.clearItems(); $.each( savedQueries.queries || {}, function ( id, obj ) { var normalizedData = $.extend( true, {}, baseState, obj.data ); + + // Backwards-compat fix: We stored the 'highlight' state with + // "1" and "0" instead of true/false; for already-stored states, + // we need to fix that. + // NOTE: Since this feature is only available in beta, we should + // not need this line when we release this to the general wikis. + // This method will automatically fix all saved queries anyways + // for existing users, who are only betalabs users at the moment. + normalizedData.highlights.highlight = !!Number( normalizedData.highlight ); + items.push( new mw.rcfilters.dm.SavedQueryItemModel( id, diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js index 4a9e780660..e9274f53b9 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js @@ -179,8 +179,8 @@ highlightedItems[ item.getName() ] = highlightEnabled ? item.getHighlightColor() : null; } ); - // Stored as a string '0' or '1' - highlightedItems.highlight = String( Number( this.filtersModel.isHighlightEnabled() ) ); + // These are filter states; highlight is stored as boolean + highlightedItems.highlight = this.filtersModel.isHighlightEnabled(); // Add item this.savedQueriesModel.addNewQuery( @@ -259,7 +259,7 @@ this.filtersModel.toggleFiltersSelected( data.filters ); // Update highlight state - this.filtersModel.toggleHighlight( !!highlights.highlight ); + this.filtersModel.toggleHighlight( !!Number( highlights.highlight ) ); this.filtersModel.getItems().forEach( function ( filterItem ) { var color = highlights[ filterItem.getName() ]; if ( color ) { @@ -482,7 +482,7 @@ ); // Update highlight state - this.filtersModel.toggleHighlight( !!parameters.highlight ); + this.filtersModel.toggleHighlight( !!Number( parameters.highlight ) ); this.filtersModel.getItems().forEach( function ( filterItem ) { var color = parameters[ filterItem.getName() + '_color' ]; if ( color ) { @@ -517,7 +517,7 @@ savedParams = this.filtersModel.getParametersFromFilters( data.filters || {} ); // Translate highlights to parameters - savedHighlights.highlight = queryHighlights.highlight; + savedHighlights.highlight = String( Number( queryHighlights.highlight ) ); $.each( queryHighlights, function ( filterName, color ) { if ( filterName !== 'highlights' ) { savedHighlights[ filterName + '_color' ] = color; diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php index d15725d2a4..ebe0bdede9 100644 --- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php @@ -447,6 +447,72 @@ class ExtensionProcessorTest extends MediaWikiTestCase { ]; } + /** + * Attributes under manifest_version 2 + * + * @covers ExtensionProcessor::extractAttributes + * @covers ExtensionProcessor::getExtractedInfo + */ + public function testExtractAttributes() { + $processor = new ExtensionProcessor(); + // Load FooBar extension + $processor->extractInfo( $this->dir, [ 'name' => 'FooBar' ], 2 ); + $processor->extractInfo( + $this->dir, + [ + 'name' => 'Baz', + 'attributes' => [ + // Loaded + 'FooBar' => [ + 'Plugins' => [ + 'ext.baz.foobar', + ], + ], + // Not loaded + 'FizzBuzz' => [ + 'MorePlugins' => [ + 'ext.baz.fizzbuzz', + ], + ], + ], + ], + 2 + ); + + $info = $processor->getExtractedInfo(); + $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] ); + $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] ); + $this->assertArrayNotHasKey( 'FizzBuzzMorePlugins', $info['attributes'] ); + } + + /** + * Attributes under manifest_version 1 + * + * @covers ExtensionProcessor::extractInfo + */ + public function testAttributes1() { + $processor = new ExtensionProcessor(); + $processor->extractInfo( + $this->dir, + [ + 'name' => 'FooBar', + 'FooBarPlugins' => [ + 'ext.baz.foobar', + ], + 'FizzBuzzMorePlugins' => [ + 'ext.baz.fizzbuzz', + ], + ], + 1 + ); + + $info = $processor->getExtractedInfo(); + $this->assertArrayHasKey( 'FooBarPlugins', $info['attributes'] ); + $this->assertSame( [ 'ext.baz.foobar' ], $info['attributes']['FooBarPlugins'] ); + $this->assertArrayHasKey( 'FizzBuzzMorePlugins', $info['attributes'] ); + $this->assertSame( [ 'ext.baz.fizzbuzz' ], $info['attributes']['FizzBuzzMorePlugins'] ); + } + public function testGlobalSettingsDocumentedInSchema() { global $IP; $globalSettings = TestingAccessWrapper::newFromClass( diff --git a/thumb.php b/thumb.php index d97f8e8eac..7c3e757241 100644 --- a/thumb.php +++ b/thumb.php @@ -530,15 +530,6 @@ function wfExtractThumbParams( $file, $params ) { $thumbname = $params['thumbName']; unset( $params['thumbName'] ); - // Do the hook first for older extensions that rely on it. - if ( !Hooks::run( 'ExtractThumbParameters', [ $thumbname, &$params ] ) ) { - // Check hooks if parameters can be extracted - // Hooks return false if they manage to *resolve* the parameters - // This hook should be considered deprecated - wfDeprecated( 'ExtractThumbParameters', '1.22' ); - return $params; // valid thumbnail URL (via extension or config) - } - // FIXME: Files in the temp zone don't set a MIME type, which means // they don't have a handler. Which means we can't parse the param // string. However, not a big issue as what good is a param string