Always use the canonical extension name to link the license file
authorRicordisamoa <ricordisamoa@openmailbox.org>
Sat, 3 Jan 2015 14:16:39 +0000 (15:16 +0100)
committerRicordisamoa <ricordisamoa@openmailbox.org>
Sat, 3 Jan 2015 14:26:03 +0000 (15:26 +0100)
Items in $wgExtensionCredits can expose a 'namemsg' attribute,
but it should only be used for localized strings.
SpecialVersion->execute() correctly uses 'name', while commit
326f3f450ce56420090e3bb30eb9a9cccfe1816e inadvertently made
getCreditsForExtension() use 'namemsg'.

Also reduced code duplication.

Change-Id: I029ea17c55191d74bc6a803fad6cf092105f5b3c

includes/specials/SpecialVersion.php

index 3747e92..7df9efe 100644 (file)
@@ -788,24 +788,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',
-                                       'dir' => 'auto',
-                               )
-                       );
-               } elseif ( $this->getExtLicenseFileName( $extensionPath ) ) {
-                       $licenseLink = Linker::link(
-                               $this->getPageTitle( 'License/' . $extensionName ),
-                               $this->msg( 'version-ext-license' ),
-                               array(
-                                       'class' => 'mw-version-ext-license',
-                                       'dir' => 'auto',
-                               )
-                       );
+               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