+ if ( isset( $extension['path'] ) ) {
+ global $IP;
+ $extensionPath = dirname( $extension['path'] );
+ if ( $this->coreId == '' ) {
+ wfDebug( 'Looking up core head id' );
+ $coreHeadSHA1 = self::getGitHeadSha1( $IP );
+ if ( $coreHeadSHA1 ) {
+ $this->coreId = $coreHeadSHA1;
+ }
+ }
+ $cache = wfGetCache( CACHE_ANYTHING );
+ $memcKey = $cache->makeKey(
+ 'specialversion-ext-version-text', $extension['path'], $this->coreId
+ );
+ list( $vcsVersion, $vcsLink, $vcsDate ) = $cache->get( $memcKey );
+
+ if ( !$vcsVersion ) {
+ wfDebug( "Getting VCS info for extension {$extension['name']}" );
+ $gitInfo = new GitInfo( $extensionPath );
+ $vcsVersion = $gitInfo->getHeadSHA1();
+ if ( $vcsVersion !== false ) {
+ $vcsVersion = substr( $vcsVersion, 0, 7 );
+ $vcsLink = $gitInfo->getHeadViewUrl();
+ $vcsDate = $gitInfo->getHeadCommitDate();
+ }
+ $cache->set( $memcKey, [ $vcsVersion, $vcsLink, $vcsDate ], 60 * 60 * 24 );
+ } else {
+ wfDebug( "Pulled VCS info for extension {$extension['name']} from cache" );
+ }
+ }
+
+ $versionString = Html::rawElement(
+ 'span',
+ [ 'class' => 'mw-version-ext-version' ],
+ $canonicalVersion
+ );
+
+ if ( $vcsVersion ) {
+ if ( $vcsLink ) {
+ $vcsVerString = Linker::makeExternalLink(
+ $vcsLink,
+ $this->msg( 'version-version', $vcsVersion ),
+ true,
+ '',
+ [ 'class' => 'mw-version-ext-vcs-version' ]
+ );
+ } else {
+ $vcsVerString = Html::element( 'span',
+ [ 'class' => 'mw-version-ext-vcs-version' ],
+ "({$vcsVersion})"
+ );
+ }
+ $versionString .= " {$vcsVerString}";
+
+ if ( $vcsDate ) {
+ $vcsTimeString = Html::element( 'span',
+ [ 'class' => 'mw-version-ext-vcs-timestamp' ],
+ $this->getLanguage()->timeanddate( $vcsDate, true )
+ );
+ $versionString .= " {$vcsTimeString}";
+ }
+ $versionString = Html::rawElement( 'span',
+ [ 'class' => 'mw-version-ext-meta-version' ],
+ $versionString
+ );
+ }
+
+ // ... and license information; if a license file exists we
+ // will link to it
+ $licenseLink = '';
+ if ( isset( $extension['name'] ) ) {
+ $licenseName = null;
+ if ( isset( $extension['license-name'] ) ) {
+ $licenseName = new HtmlArmor( $out->parseInline( $extension['license-name'] ) );
+ } elseif ( $this->getExtLicenseFileName( $extensionPath ) ) {
+ $licenseName = $this->msg( 'version-ext-license' )->text();
+ }
+ if ( $licenseName !== null ) {
+ $licenseLink = $this->getLinkRenderer()->makeLink(
+ $this->getPageTitle( 'License/' . $extension['name'] ),
+ $licenseName,
+ [
+ 'class' => 'mw-version-ext-license',
+ 'dir' => 'auto',
+ ]
+ );
+ }