From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- includes/specials/SpecialVersion.php | 151 ++++++++++++++++++++++++----------- 1 file changed, 105 insertions(+), 46 deletions(-) (limited to 'includes/specials/SpecialVersion.php') diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index cb3fc118..c1a95939 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -109,12 +109,7 @@ class SpecialVersion extends SpecialPage { $file = $this->getExtLicenseFileName( dirname( $extNode['path'] ) ); if ( $file ) { $wikiText = file_get_contents( $file ); - if ( !isset( $extNode['license-name'] ) ) { - // If the developer did not explicitly set license-name they probably - // are unaware that we're now sucking this file in and thus it's probably - // not wikitext friendly. - $wikiText = "
$wikiText
"; - } + $wikiText = "
$wikiText
"; } } @@ -132,6 +127,7 @@ class SpecialVersion extends SpecialPage { $out->addHtml( $this->getSkinCredits() . $this->getExtensionCredits() . + $this->getExternalLibraries() . $this->getParserTags() . $this->getParserFunctionHooks() ); @@ -191,8 +187,8 @@ class SpecialVersion extends SpecialPage { 'Alexandre Emsenhuber', 'Siebrand Mazeland', 'Chad Horohoe', 'Roan Kattouw', 'Trevor Parscal', 'Bryan Tong Minh', 'Sam Reed', 'Victor Vasiliev', 'Rotem Liss', 'Platonides', 'Antoine Musso', - 'Timo Tijhof', 'Daniel Kinzler', 'Jeroen De Dauw', $othersLink, - $translatorsLink + 'Timo Tijhof', 'Daniel Kinzler', 'Jeroen De Dauw', 'Brad Jorsch', + $othersLink, $translatorsLink ); return wfMessage( 'version-poweredby-credits', MWTimestamp::getLocalInstance()->format( 'Y' ), @@ -220,7 +216,7 @@ class SpecialVersion extends SpecialPage { $software[$dbr->getSoftwareLink()] = $dbr->getServerInfo(); // Allow a hook to add/remove items. - wfRunHooks( 'SoftwareInfo', array( &$software ) ); + Hooks::run( 'SoftwareInfo', array( &$software ) ); $out = Xml::element( 'h2', @@ -251,7 +247,6 @@ class SpecialVersion extends SpecialPage { */ public static function getVersion( $flags = '' ) { global $wgVersion, $IP; - wfProfileIn( __METHOD__ ); $gitInfo = self::getGitHeadSha1( $IP ); $svnInfo = self::getSvnInfo( $IP ); @@ -275,8 +270,6 @@ class SpecialVersion extends SpecialPage { )->text(); } - wfProfileOut( __METHOD__ ); - return $version; } @@ -290,7 +283,6 @@ class SpecialVersion extends SpecialPage { */ public static function getVersionLinked() { global $wgVersion; - wfProfileIn( __METHOD__ ); $gitVersion = self::getVersionLinkedGit(); if ( $gitVersion ) { @@ -304,8 +296,6 @@ class SpecialVersion extends SpecialPage { } } - wfProfileOut( __METHOD__ ); - return $v; } @@ -341,7 +331,7 @@ class SpecialVersion extends SpecialPage { private static function getwgVersionLinked() { global $wgVersion; $versionUrl = ""; - if ( wfRunHooks( 'SpecialVersionVersionUrl', array( $wgVersion, &$versionUrl ) ) ) { + if ( Hooks::run( 'SpecialVersionVersionUrl', array( $wgVersion, &$versionUrl ) ) ) { $versionParts = array(); preg_match( "/^(\d+\.\d+)/", $wgVersion, $versionParts ); $versionUrl = "https://www.mediawiki.org/wiki/MediaWiki_{$versionParts[1]}"; @@ -402,7 +392,7 @@ class SpecialVersion extends SpecialPage { 'other' => wfMessage( 'version-other' )->text(), ); - wfRunHooks( 'ExtensionTypes', array( &self::$extensionTypes ) ); + Hooks::run( 'ExtensionTypes', array( &self::$extensionTypes ) ); } return self::$extensionTypes; @@ -503,6 +493,57 @@ class SpecialVersion extends SpecialPage { return $out; } + /** + * Generate an HTML table for external libraries that are installed + * + * @return string + */ + protected function getExternalLibraries() { + global $IP; + $path = "$IP/composer.lock"; + if ( !file_exists( $path ) ) { + // Maybe they're using mediawiki/vendor? + $path = "$IP/vendor/composer.lock"; + if ( !file_exists( $path ) ) { + return ''; + } + } + + $lock = new ComposerLock( $path ); + $out = Html::element( + 'h2', + array( 'id' => 'mw-version-libraries' ), + $this->msg( 'version-libraries' )->text() + ); + $out .= Html::openElement( + 'table', + array( 'class' => 'wikitable plainlinks', 'id' => 'sv-libraries' ) + ); + $out .= Html::openElement( 'tr' ) + . Html::element( 'th', array(), $this->msg( 'version-libraries-library' )->text() ) + . Html::element( 'th', array(), $this->msg( 'version-libraries-version' )->text() ) + . Html::closeElement( 'tr' ); + + foreach ( $lock->getInstalledDependencies() as $name => $info ) { + if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) { + // Skip any extensions or skins since they'll be listed + // in their proper section + continue; + } + $out .= Html::openElement( 'tr' ) + . Html::rawElement( + 'td', + array(), + Linker::makeExternalLink( "https://packagist.org/packages/$name", $name ) + ) + . Html::element( 'td', array(), $info['version'] ) + . Html::closeElement( 'tr' ); + } + $out .= Html::closeElement( 'table' ); + + return $out; + } + /** * Obtains a list of installed parser tags and the associated H2 header * @@ -516,7 +557,7 @@ class SpecialVersion extends SpecialPage { if ( count( $tags ) ) { $out = Html::rawElement( 'h2', - array( 'class' => 'mw-headline' ), + array( 'class' => 'mw-headline plainlinks' ), Linker::makeExternalLink( '//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Tag_extensions', $this->msg( 'version-parser-extensiontags' )->parse(), @@ -525,8 +566,17 @@ class SpecialVersion extends SpecialPage { ); array_walk( $tags, function ( &$value ) { - $value = '<' . htmlspecialchars( $value ) . '>'; + // Bidirectional isolation improves readability in RTL wikis + $value = Html::element( + 'bdi', + // Prevent < and > from slipping to another line + array( + 'style' => 'white-space: nowrap;', + ), + "<$value>" + ); } ); + $out .= $this->listToText( $tags ); } else { $out = ''; @@ -545,11 +595,15 @@ class SpecialVersion extends SpecialPage { $fhooks = $wgParser->getFunctionHooks(); if ( count( $fhooks ) ) { - $out = Html::rawElement( 'h2', array( 'class' => 'mw-headline' ), Linker::makeExternalLink( - '//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Parser_functions', - $this->msg( 'version-parser-function-hooks' )->parse(), - false /* msg()->parse() already escapes */ - ) ); + $out = Html::rawElement( + 'h2', + array( 'class' => 'mw-headline plainlinks' ), + Linker::makeExternalLink( + '//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Parser_functions', + $this->msg( 'version-parser-function-hooks' )->parse(), + false /* msg()->parse() already escapes */ + ) + ); $out .= $this->listToText( $fhooks ); } else { @@ -680,7 +734,7 @@ class SpecialVersion extends SpecialPage { list( $vcsVersion, $vcsLink, $vcsDate ) = $cache->get( $memcKey ); if ( !$vcsVersion ) { - wfDebug( "Getting VCS info for extension $extensionName" ); + wfDebug( "Getting VCS info for extension {$extension['name']}" ); $gitInfo = new GitInfo( $extensionPath ); $vcsVersion = $gitInfo->getHeadSHA1(); if ( $vcsVersion !== false ) { @@ -696,7 +750,7 @@ class SpecialVersion extends SpecialPage { } $cache->set( $memcKey, array( $vcsVersion, $vcsLink, $vcsDate ), 60 * 60 * 24 ); } else { - wfDebug( "Pulled VCS info for extension $extensionName from cache" ); + wfDebug( "Pulled VCS info for extension {$extension['name']} from cache" ); } } @@ -739,18 +793,23 @@ class SpecialVersion extends SpecialPage { // ... and license information; if a license file exists we // will link to it $licenseLink = ''; - if ( isset( $extension['license-name'] ) ) { - $licenseLink = Linker::link( - $this->getPageTitle( 'License/' . $extensionName ), - $out->parseInline( $extension['license-name'] ), - array( 'class' => 'mw-version-ext-license' ) - ); - } elseif ( $this->getExtLicenseFileName( $extensionPath ) ) { - $licenseLink = Linker::link( - $this->getPageTitle( 'License/' . $extensionName ), - $this->msg( 'version-ext-license' ), - array( 'class' => 'mw-version-ext-license' ) - ); + if ( isset( $extension['name'] ) ) { + $licenseName = null; + if ( isset( $extension['license-name'] ) ) { + $licenseName = $out->parseInline( $extension['license-name'] ); + } elseif ( $this->getExtLicenseFileName( $extensionPath ) ) { + $licenseName = $this->msg( 'version-ext-license' ); + } + if ( $licenseName !== null ) { + $licenseLink = Linker::link( + $this->getPageTitle( 'License/' . $extension['name'] ), + $licenseName, + array( + 'class' => 'mw-version-ext-license', + 'dir' => 'auto', + ) + ); + } } // ... and generate the description; which can be a parameterized l10n message @@ -778,12 +837,12 @@ class SpecialVersion extends SpecialPage { // ... now get the authors for this extension $authors = isset( $extension['author'] ) ? $extension['author'] : array(); - $authors = $this->listAuthors( $authors, $extensionName, $extensionPath ); + $authors = $this->listAuthors( $authors, $extension['name'], $extensionPath ); // Finally! Create the table $html = Html::openElement( 'tr', array( 'class' => 'mw-version-ext', - 'id' => "mw-version-ext-{$extensionName}" + 'id' => "mw-version-ext-{$extension['name']}" ) ); @@ -793,7 +852,7 @@ class SpecialVersion extends SpecialPage { $html .= Html::rawElement( 'td', array( 'class' => 'mw-version-ext-description' ), $description ); $html .= Html::rawElement( 'td', array( 'class' => 'mw-version-ext-authors' ), $authors ); - $html .= Html::closeElement( 'td' ); + $html .= Html::closeElement( 'tr' ); return $html; } @@ -916,10 +975,10 @@ class SpecialVersion extends SpecialPage { if ( $this->getExtAuthorsFileName( $extDir ) ) { $text = Linker::link( $this->getPageTitle( "Credits/$extName" ), - $this->msg( 'version-poweredby-others' )->text() + $this->msg( 'version-poweredby-others' )->escaped() ); } else { - $text = $this->msg( 'version-poweredby-others' )->text(); + $text = $this->msg( 'version-poweredby-others' )->escaped(); } $list[] = $text; } elseif ( substr( $item, -5 ) == ' ...]' ) { @@ -935,7 +994,7 @@ class SpecialVersion extends SpecialPage { if ( !$hasOthers && $this->getExtAuthorsFileName( $extDir ) ) { $list[] = $text = Linker::link( $this->getPageTitle( "Credits/$extName" ), - $this->msg( 'version-poweredby-others' )->text() + $this->msg( 'version-poweredby-others' )->escaped() ); } @@ -1024,7 +1083,7 @@ class SpecialVersion extends SpecialPage { * Convert an array or object to a string for display. * * @param mixed $list Will convert an array to string if given and return - * the paramater unaltered otherwise + * the parameter unaltered otherwise * * @return mixed */ @@ -1188,7 +1247,7 @@ class SpecialVersion extends SpecialPage { $language = $this->getLanguage(); $thAttribures = array( 'dir' => $language->getDir(), - 'lang' => $language->getCode() + 'lang' => $language->getHtmlCode() ); $out = Html::element( 'h2', -- cgit v1.2.3-54-g00ecf