From: jenkins-bot Date: Tue, 15 Sep 2015 23:25:38 +0000 (+0000) Subject: Merge "resourceloader: Don't call wfExpandUrl() on load.php urls" X-Git-Tag: 1.31.0-rc.0~10014 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=3a3c3e73e72f25e650480b7083b194d05d9e1bad;hp=b5e69c4ef621868787db4e6e1c648b594c3b71b4 Merge "resourceloader: Don't call wfExpandUrl() on load.php urls" --- diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index 8f5db0ee33..4463c7823e 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -139,6 +139,7 @@ changes to languages because of Phabricator reports. * ChangeTags::tagDescription() will return false if the interface message for the tag is disabled. * Added PageHistoryPager::doBatchLookups hook. +* Added $wikiId parameter to FormatAutocomments hook. * Added ParserCacheSaveComplete to ParserCache * supportsDirectEditing and supportsDirectApiEditing methods added to ContentHandler, to provide a way for ApiEditPage and EditPage to check diff --git a/autoload.php b/autoload.php index 4db3ec7ec7..5adfbe5104 100644 --- a/autoload.php +++ b/autoload.php @@ -768,6 +768,7 @@ $wgAutoloadLocalClasses = array( 'MediaWiki\\Tidy\\RaggettWrapper' => __DIR__ . '/includes/tidy/RaggettWrapper.php', 'MediaWiki\\Tidy\\TidyDriverBase' => __DIR__ . '/includes/tidy/TidyDriverBase.php', 'MediaWiki\\Widget\\ComplexNamespaceInputWidget' => __DIR__ . '/includes/widget/ComplexNamespaceInputWidget.php', + 'MediaWiki\\Widget\\ComplexTitleInputWidget' => __DIR__ . '/includes/widget/ComplexTitleInputWidget.php', 'MediaWiki\\Widget\\NamespaceInputWidget' => __DIR__ . '/includes/widget/NamespaceInputWidget.php', 'MediaWiki\\Widget\\TitleInputWidget' => __DIR__ . '/includes/widget/TitleInputWidget.php', 'MediaWiki\\Widget\\UserInputWidget' => __DIR__ . '/includes/widget/UserInputWidget.php', diff --git a/docs/hooks.txt b/docs/hooks.txt index 5e2269abb7..54ab46c171 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1376,6 +1376,9 @@ $auto: The extracted part of the parsed comment before the call to the hook. $post: Boolean, true if there is text after this autocomment $title: An optional title object used to links to sections. Can be null. $local: Boolean indicating whether section links should refer to local page. +$wikiId: String containing the ID (as used by WikiMap) of the wiki from which the + autocomment originated; null for the local wiki. Added in 1.26, should default + to null in handler functions, for backwards compatibility. 'GalleryGetModes': Get list of classes that can render different modes of a gallery. diff --git a/docs/uidesign/design.html b/docs/uidesign/design.html index 51c1b55204..6ab57d7d4f 100644 --- a/docs/uidesign/design.html +++ b/docs/uidesign/design.html @@ -2,6 +2,7 @@ + diff --git a/includes/Linker.php b/includes/Linker.php index db6f379d52..9b5ff27b3d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1276,9 +1276,11 @@ class Linker { * @param string $comment * @param Title|null $title Title object (to generate link to the section in autocomment) or null * @param bool $local Whether section links should refer to local page + * @param string|null $wikiId Id (as used by WikiMap) of the wiki to generate links to. For use with external changes. + * * @return mixed|string */ - public static function formatComment( $comment, $title = null, $local = false ) { + public static function formatComment( $comment, $title = null, $local = false, $wikiId = null ) { # Sanitize text a bit: $comment = str_replace( "\n", " ", $comment ); @@ -1286,8 +1288,8 @@ class Linker { $comment = Sanitizer::escapeHtmlAllowEntities( $comment ); # Render autocomments and make links: - $comment = self::formatAutocomments( $comment, $title, $local ); - $comment = self::formatLinksInComment( $comment, $title, $local ); + $comment = self::formatAutocomments( $comment, $title, $local, $wikiId ); + $comment = self::formatLinksInComment( $comment, $title, $local, $wikiId ); return $comment; } @@ -1304,9 +1306,11 @@ class Linker { * @param string $comment Comment text * @param Title|null $title An optional title object used to links to sections * @param bool $local Whether section links should refer to local page - * @return string Formatted comment + * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap. + * + * @return string Formatted comment (wikitext) */ - private static function formatAutocomments( $comment, $title = null, $local = false ) { + private static function formatAutocomments( $comment, $title = null, $local = false, $wikiId = null ) { // @todo $append here is something of a hack to preserve the status // quo. Someone who knows more about bidi and such should decide // (1) what sane rendering even *is* for an LTR edit summary on an RTL @@ -1320,7 +1324,7 @@ class Linker { // zero-width assertions optional, so wrap them in a non-capturing // group. '!(?:(?<=(.)))?/\*\s*(.*?)\s*\*/(?:(?=(.)))?!', - function ( $match ) use ( $title, $local, &$append ) { + function ( $match ) use ( $title, $local, $wikiId, &$append ) { global $wgLang; // Ensure all match positions are defined @@ -1330,7 +1334,7 @@ class Linker { $auto = $match[2]; $post = $match[3] !== ''; $comment = null; - Hooks::run( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local ) ); + Hooks::run( 'FormatAutocomments', array( &$comment, $pre, $auto, $post, $title, $local, $wikiId ) ); if ( $comment === null ) { $link = ''; if ( $title ) { @@ -1349,9 +1353,7 @@ class Linker { $title->getDBkey(), $section ); } if ( $sectionTitle ) { - $link = Linker::link( $sectionTitle, - $wgLang->getArrow(), array(), array(), - 'noclasses' ); + $link = Linker::makeCommentLink( $sectionTitle, $wgLang->getArrow(), $wikiId, 'noclasses' ); } else { $link = ''; } @@ -1384,7 +1386,7 @@ class Linker { * @param string $comment Text to format links in * @param Title|null $title An optional title object used to links to sections * @param bool $local Whether section links should refer to local page - * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap + * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap. * * @return string */ @@ -1459,22 +1461,9 @@ class Linker { $newTarget = clone ( $title ); $newTarget->setFragment( '#' . $target->getFragment() ); $target = $newTarget; - - } - - if ( $wikiId !== null ) { - $thelink = Linker::makeExternalLink( - WikiMap::getForeignURL( $wikiId, $target->getPrefixedText(), $target->getFragment() ), - $linkText . $inside, - /* escape = */ false // Already escaped - ) . $trail; - } else { - $thelink = Linker::link( - $target, - $linkText . $inside - ) . $trail; } + $thelink = Linker::makeCommentLink( $target, $linkText . $inside, $wikiId ) . $trail; } } if ( $thelink ) { @@ -1493,6 +1482,32 @@ class Linker { ); } + /** + * Generates a link to the given Title + * + * @note This is only public for technical reasons. It's not intended for use outside Linker. + * + * @param Title $title + * @param string $text + * @param string|null $wikiId Id of the wiki to link to (if not the local wiki), as used by WikiMap. + * @param string|string[] $options See the $options parameter in Linker::link. + * + * @return string HTML link + */ + public static function makeCommentLink( Title $title, $text, $wikiId = null, $options = array() ) { + if ( $wikiId !== null && !$title->isExternal() ) { + $link = Linker::makeExternalLink( + WikiMap::getForeignURL( $wikiId, $title->getPrefixedText(), $title->getFragment() ), + $text, + /* escape = */ false // Already escaped + ); + } else { + $link = Linker::link( $title, $text, array(), array(), $options ); + } + + return $link; + } + /** * @param Title $contextTitle * @param string $target @@ -1579,17 +1594,18 @@ class Linker { * @param string $comment * @param Title|null $title Title object (to generate link to section in autocomment) or null * @param bool $local Whether section links should refer to local page + * @param string|null $wikiId Id (as used by WikiMap) of the wiki to generate links to. For use with external changes. * * @return string */ - public static function commentBlock( $comment, $title = null, $local = false ) { + public static function commentBlock( $comment, $title = null, $local = false, $wikiId = null ) { // '*' used to be the comment inserted by the software way back // in antiquity in case none was provided, here for backwards // compatibility, acc. to brion -ævar if ( $comment == '' || $comment == '*' ) { return ''; } else { - $formatted = self::formatComment( $comment, $title, $local ); + $formatted = self::formatComment( $comment, $title, $local, $wikiId ); $formatted = wfMessage( 'parentheses' )->rawParams( $formatted )->escaped(); return " $formatted"; } @@ -2382,6 +2398,7 @@ class Linker { 'title' => $tooltip ) ); } + } /** diff --git a/includes/User.php b/includes/User.php index 605dab6834..dbcbe31fce 100644 --- a/includes/User.php +++ b/includes/User.php @@ -3709,14 +3709,6 @@ class User implements IDBAccessObject { Hooks::run( 'UserSaveSettings', array( $this ) ); $this->clearSharedCache(); $this->getUserPage()->invalidateCache(); - - // T95839: clear the cache again post-commit to reduce race conditions - // where stale values are written back to the cache by other threads. - // Note: this *still* doesn't deal with REPEATABLE-READ snapshot lag... - $that = $this; - $dbw->onTransactionIdle( function() use ( $that ) { - $that->clearSharedCache(); - } ); } /** diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 03410ccc9f..850f10103f 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -1324,14 +1324,6 @@ class FauxRequest extends WebRequest { $this->protocol = $protocol; } - /** - * @param string $method - * @throws MWException - */ - private function notImplemented( $method ) { - throw new MWException( "{$method}() not implemented" ); - } - /** * @param string $name * @param string $default @@ -1425,10 +1417,6 @@ class FauxRequest extends WebRequest { return $this->protocol; } - private function initHeaders() { - return; - } - /** * @param string $name * @param string $val diff --git a/includes/XmlSelect.php b/includes/XmlSelect.php index e765eedbc3..78f476452f 100644 --- a/includes/XmlSelect.php +++ b/includes/XmlSelect.php @@ -43,7 +43,7 @@ class XmlSelect { } /** - * @param string $default + * @param string|array $default */ public function setDefault( $default ) { $this->default = $default; @@ -95,7 +95,7 @@ class XmlSelect { * label => ( label => value, label => value ) * * @param array $options - * @param string $default + * @param string|array $default * @return string */ static function formatOptions( $options, $default = false ) { @@ -106,7 +106,11 @@ class XmlSelect { $contents = self::formatOptions( $value, $default ); $data .= Html::rawElement( 'optgroup', array( 'label' => $label ), $contents ) . "\n"; } else { - $data .= Xml::option( $label, $value, $value === $default ) . "\n"; + // If $default is an array, then the