jenkins-bot has submitted this change and it was merged.
Change subject: Cache VCS commit id/date text on Special:Version
......................................................................
Cache VCS commit id/date text on Special:Version
So Special:Version works on beta.wmflabs.org again
Bug: 53335
Change-Id: I5a5b23a73974aba2322bf69f534e8aa8b60741db
---
M includes/specials/SpecialVersion.php
1 file changed, 40 insertions(+), 12 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/specials/SpecialVersion.php
b/includes/specials/SpecialVersion.php
index c8add01..5c3f509 100644
--- a/includes/specials/SpecialVersion.php
+++ b/includes/specials/SpecialVersion.php
@@ -31,6 +31,11 @@
class SpecialVersion extends SpecialPage {
protected $firstExtOpened = false;
+ /**
+ * Stores the current rev id/SHA hash of MediaWiki core
+ */
+ protected $coreId = '';
+
protected static $extensionTypes = false;
protected static $viewvcUrls = array(
@@ -616,20 +621,43 @@
}
if ( isset( $extension['path'] ) ) {
- $extensionPath = dirname( $extension['path'] );
- $gitInfo = new GitInfo( $extensionPath );
- $vcsVersion = $gitInfo->getHeadSHA1();
- if ( $vcsVersion !== false ) {
- $vcsVersion = substr( $vcsVersion, 0, 7 );
- $vcsLink = $gitInfo->getHeadViewUrl();
- $vcsDate = $gitInfo->getHeadCommitDate();
- } else {
- $svnInfo = self::getSvnInfo( $extensionPath );
- if ( $svnInfo !== false ) {
- $vcsVersion = $this->msg(
'version-svn-revision', $svnInfo['checkout-rev'] )->text();
- $vcsLink = isset(
$svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
+ global $IP;
+ if ( $this->coreId == '' ) {
+ wfDebug( 'Looking up core head id' );
+ $coreHeadSHA1 = self::getGitHeadSha1( $IP );
+ if ( $coreHeadSHA1 ) {
+ $this->coreId = $coreHeadSHA1;
+ } else {
+ $svnInfo = self::getSvnInfo( $IP );
+ if ( $svnInfo !== false ) {
+ $this->coreId =
$svnInfo['checkout-rev'];
+ }
}
}
+ $cache = wfGetCache( CACHE_ANYTHING );
+ $memcKey = wfMemcKey(
'specialversion-ext-version-text', $extension['path'], $this->coreId );
+ list( $vcsVersion, $vcsLink, $vcsDate ) = $cache->get(
$memcKey );
+
+ if ( !$vcsVersion ) {
+ wfDebug( "Getting VCS info for extension
$extensionName" );
+ $extensionPath = dirname( $extension['path'] );
+ $gitInfo = new GitInfo( $extensionPath );
+ $vcsVersion = $gitInfo->getHeadSHA1();
+ if ( $vcsVersion !== false ) {
+ $vcsVersion = substr( $vcsVersion, 0, 7
);
+ $vcsLink = $gitInfo->getHeadViewUrl();
+ $vcsDate =
$gitInfo->getHeadCommitDate();
+ } else {
+ $svnInfo = self::getSvnInfo(
$extensionPath );
+ if ( $svnInfo !== false ) {
+ $vcsVersion = $this->msg(
'version-svn-revision', $svnInfo['checkout-rev'] )->text();
+ $vcsLink = isset(
$svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
+ }
+ }
+ $cache->set( $memcKey, array( $vcsVersion,
$vcsLink, $vcsDate ), 60 * 60 * 24 );
+ } else {
+ wfDebug( "Pulled VCS info for extension
$extensionName from cache" );
+ }
}
$versionString = Html::rawElement(
--
To view, visit https://gerrit.wikimedia.org/r/95878
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5a5b23a73974aba2322bf69f534e8aa8b60741db
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: PleaseStand <[email protected]>
Gerrit-Reviewer: Wikinaut <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits