Merge "selenium: Remove "RunJobs" wait from specialrecentchanges test"
[lhc/web/wiklou.git] / includes / specials / SpecialVersion.php
index 5456ce7..6ad02f0 100644 (file)
@@ -31,13 +31,20 @@ use MediaWiki\MediaWikiServices;
  * @ingroup SpecialPage
  */
 class SpecialVersion extends SpecialPage {
+
+       /**
+        * @var bool
+        */
        protected $firstExtOpened = false;
 
        /**
-        * Stores the current rev id/SHA hash of MediaWiki core
+        * @var string The current rev id/SHA hash of MediaWiki core
         */
        protected $coreId = '';
 
+       /**
+        * @var string[]|false Lazy initialized key/value with message content
+        */
        protected static $extensionTypes = false;
 
        public function __construct() {
@@ -219,23 +226,26 @@ class SpecialVersion extends SpecialPage {
        }
 
        /**
-        * Returns wiki text showing the third party software versions (apache, php, mysql).
+        * @since 1.34
         *
-        * @return string
+        * @return array
         */
-       public static function softwareInformation() {
+       public static function getSoftwareInformation() {
                $dbr = wfGetDB( DB_REPLICA );
 
                // Put the software in an array of form 'name' => 'version'. All messages should
                // be loaded here, so feel free to use wfMessage in the 'name'. Raw HTML or
                // wikimarkup can be used.
-               $software = [];
-               $software['[https://www.mediawiki.org/ MediaWiki]'] = self::getVersionLinked();
+               $software = [
+                       '[https://www.mediawiki.org/ MediaWiki]' => self::getVersionLinked()
+               ];
+
                if ( wfIsHHVM() ) {
                        $software['[https://hhvm.com/ HHVM]'] = HHVM_VERSION . " (" . PHP_SAPI . ")";
                } else {
                        $software['[https://php.net/ PHP]'] = PHP_VERSION . " (" . PHP_SAPI . ")";
                }
+
                $software[$dbr->getSoftwareLink()] = $dbr->getServerInfo();
 
                if ( defined( 'INTL_ICU_VERSION' ) ) {
@@ -245,18 +255,27 @@ class SpecialVersion extends SpecialPage {
                // Allow a hook to add/remove items.
                Hooks::run( 'SoftwareInfo', [ &$software ] );
 
+               return $software;
+       }
+
+       /**
+        * Returns HTML showing the third party software versions (apache, php, mysql).
+        *
+        * @return string HTML table
+        */
+       public static function softwareInformation() {
                $out = Xml::element(
                                'h2',
                                [ 'id' => 'mw-version-software' ],
                                wfMessage( 'version-software' )->text()
                        ) .
-                               Xml::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ] ) .
-                               "<tr>
-                                       <th>" . wfMessage( 'version-software-product' )->text() . "</th>
-                                       <th>" . wfMessage( 'version-software-version' )->text() . "</th>
-                               </tr>\n";
+                       Xml::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ] ) .
+                       "<tr>
+                               <th>" . wfMessage( 'version-software-product' )->text() . "</th>
+                               <th>" . wfMessage( 'version-software-version' )->text() . "</th>
+                       </tr>\n";
 
-               foreach ( $software as $name => $version ) {
+               foreach ( self::getSoftwareInformation() as $name => $version ) {
                        $out .= "<tr>
                                        <td>" . $name . "</td>
                                        <td dir=\"ltr\">" . $version . "</td>
@@ -367,7 +386,7 @@ class SpecialVersion extends SpecialPage {
         *
         * @since 1.17
         *
-        * @return array
+        * @return string[]
         */
        public static function getExtensionTypes() {
                if ( self::$extensionTypes === false ) {
@@ -969,7 +988,27 @@ class SpecialVersion extends SpecialPage {
                $linkRenderer = $this->getLinkRenderer();
 
                $list = [];
-               foreach ( (array)$authors as $item ) {
+               $authors = (array)$authors;
+
+               // Special case: if the authors array has only one item and it is "...",
+               // it should not be rendered as the "version-poweredby-others" i18n msg,
+               // but rather as "version-poweredby-various" i18n msg instead.
+               if ( count( $authors ) === 1 && $authors[0] === '...' ) {
+                       // Link to the extension's or skin's AUTHORS or CREDITS file, if there is
+                       // such a file; otherwise just return the i18n msg as-is
+                       if ( $extName && $this->getExtAuthorsFileName( $extDir ) ) {
+                               return $linkRenderer->makeLink(
+                                       $this->getPageTitle( "Credits/$extName" ),
+                                       $this->msg( 'version-poweredby-various' )->text()
+                               );
+                       } else {
+                               return $this->msg( 'version-poweredby-various' )->escaped();
+                       }
+               }
+
+               // Otherwise, if we have an actual array that has more than one item,
+               // process each array item as usual
+               foreach ( $authors as $item ) {
                        if ( $item == '...' ) {
                                $hasOthers = true;