Try to make POSTs as transactional as possible
[lhc/web/wiklou.git] / includes / specials / SpecialVersion.php
index 83fc636..e598f0b 100644 (file)
@@ -265,8 +265,8 @@ class SpecialVersion extends SpecialPage {
                        $version = $wgVersion . ' ' .
                                wfMessage(
                                        'version-svn-revision',
-                                       isset( $info['directory-rev'] ) ? $info['directory-rev'] : '',
-                                       $info['checkout-rev']
+                                       isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : '',
+                                       isset( $svnInfo['checkout-rev'] ) ? $svnInfo['checkout-rev'] : ''
                                )->text();
                }
 
@@ -515,10 +515,16 @@ class SpecialVersion extends SpecialPage {
                        array( 'id' => 'mw-version-libraries' ),
                        $this->msg( 'version-libraries' )->text()
                );
-               $out .= Html::openElement( 'table', array( 'class' => 'wikitable plainlinks', 'id' => 'sv-libraries' ) );
+               $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::element( 'th', array(), $this->msg( 'version-libraries-license' )->text() )
+                       . Html::element( 'th', array(), $this->msg( 'version-libraries-description' )->text() )
+                       . Html::element( 'th', array(), $this->msg( 'version-libraries-authors' )->text() )
                        . Html::closeElement( 'tr' );
 
                foreach ( $lock->getInstalledDependencies() as $name => $info ) {
@@ -527,9 +533,32 @@ class SpecialVersion extends SpecialPage {
                                // in their proper section
                                continue;
                        }
+                       $authors = array_map( function( $arr ) {
+                               // If a homepage is set, link to it
+                               if ( isset( $arr['homepage'] ) ) {
+                                       return "[{$arr['homepage']} {$arr['name']}]";
+                               }
+                               return $arr['name'];
+                       }, $info['authors'] );
+                       $authors = $this->listAuthors( $authors, false, "$IP/vendor/$name" );
+
+                       // We can safely assume that the libraries' names and descriptions
+                       // are written in English and aren't going to be translated,
+                       // so set appropriate lang and dir attributes
                        $out .= Html::openElement( 'tr' )
-                               . Html::rawElement( 'td', array(), Linker::makeExternalLink( "https://packagist.org/packages/$name", $name ) )
-                               . Html::element( 'td', array(), $info['version'] )
+                               . Html::rawElement(
+                                       'td',
+                                       array(),
+                                       Linker::makeExternalLink(
+                                               "https://packagist.org/packages/$name", $name,
+                                               true, '',
+                                               array( 'class' => 'mw-version-library-name' )
+                                       )
+                               )
+                               . Html::element( 'td', array( 'dir' => 'auto' ), $info['version'] )
+                               . Html::element( 'td', array( 'dir' => 'auto' ), $this->listToText( $info['licenses'] ) )
+                               . Html::element( 'td', array( 'lang' => 'en', 'dir' => 'ltr' ), $info['description'] )
+                               . Html::rawElement( 'td', array(), $authors )
                                . Html::closeElement( 'tr' );
                }
                $out .= Html::closeElement( 'table' );
@@ -550,7 +579,10 @@ class SpecialVersion extends SpecialPage {
                if ( count( $tags ) ) {
                        $out = Html::rawElement(
                                'h2',
-                               array( 'class' => 'mw-headline plainlinks' ),
+                               array(
+                                       'class' => 'mw-headline plainlinks',
+                                       'id' => 'mw-version-parser-extensiontags',
+                               ),
                                Linker::makeExternalLink(
                                        '//www.mediawiki.org/wiki/Special:MyLanguage/Manual:Tag_extensions',
                                        $this->msg( 'version-parser-extensiontags' )->parse(),
@@ -588,11 +620,18 @@ class SpecialVersion extends SpecialPage {
 
                $fhooks = $wgParser->getFunctionHooks();
                if ( count( $fhooks ) ) {
-                       $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 = Html::rawElement(
+                               'h2',
+                               array(
+                                       'class' => 'mw-headline plainlinks',
+                                       'id' => 'mw-version-parser-function-hooks',
+                               ),
+                               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 {
@@ -831,7 +870,7 @@ class SpecialVersion extends SpecialPage {
                // Finally! Create the table
                $html = Html::openElement( 'tr', array(
                                'class' => 'mw-version-ext',
-                               'id' => "mw-version-ext-{$extension['name']}"
+                               'id' => Sanitizer::escapeId( 'mw-version-ext-' . $extension['name'] )
                        )
                );
 
@@ -948,7 +987,8 @@ class SpecialVersion extends SpecialPage {
         *   'and others' will be added to the end of the credits.
         *
         * @param string|array $authors
-        * @param string $extName Name of the extension for link creation
+        * @param string|bool $extName Name of the extension for link creation,
+        *   false if no links should be created
         * @param string $extDir Path to the extension root directory
         *
         * @return string HTML fragment
@@ -961,13 +1001,13 @@ class SpecialVersion extends SpecialPage {
                        if ( $item == '...' ) {
                                $hasOthers = true;
 
-                               if ( $this->getExtAuthorsFileName( $extDir ) ) {
+                               if ( $extName && $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 ) == ' ...]' ) {
@@ -980,10 +1020,10 @@ class SpecialVersion extends SpecialPage {
                        }
                }
 
-               if ( !$hasOthers && $this->getExtAuthorsFileName( $extDir ) ) {
+               if ( $extName && !$hasOthers && $this->getExtAuthorsFileName( $extDir ) ) {
                        $list[] = $text = Linker::link(
                                $this->getPageTitle( "Credits/$extName" ),
-                               $this->msg( 'version-poweredby-others' )->text()
+                               $this->msg( 'version-poweredby-others' )->escaped()
                        );
                }
 
@@ -1135,9 +1175,9 @@ class SpecialVersion extends SpecialPage {
                        }
 
                        // SimpleXml whines about the xmlns...
-                       wfSuppressWarnings();
+                       MediaWiki\suppressWarnings();
                        $xml = simplexml_load_file( $entries );
-                       wfRestoreWarnings();
+                       MediaWiki\restoreWarnings();
 
                        if ( $xml ) {
                                foreach ( $xml->entry as $entry ) {