r40877 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40876‎ | r40877 | r40878 >
Date:20:11, 15 September 2008
Author:brion
Status:old
Tags:
Comment:
Code review tweaks
* quickie memcache cache of svn diffs
* bug #123
Modified paths:
  • /trunk/extensions/CodeReview/CodeRepository.php (modified) (history)
  • /trunk/extensions/CodeReview/SpecialCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRepository.php
@@ -102,7 +102,20 @@
103103 }
104104
105105 function getDiff( $rev ) {
106 - $svn = SubversionAdaptor::newFromRepo( $this->mPath );
107 - return $svn->getDiff( '', $rev - 1, $rev );
 106+ global $wgMemc;
 107+
 108+ $rev1 = $rev - 1;
 109+ $rev2 = $rev;
 110+
 111+ $key = wfMemcKey( 'svn', md5( $this->mPath ), 'diff', $rev1, $rev2 );
 112+ $data = $wgMemc->get( $key );
 113+
 114+ if( !$data ) {
 115+ $svn = SubversionAdaptor::newFromRepo( $this->mPath );
 116+ $data = $svn->getDiff( '', $rev1, $rev2 );
 117+ $wgMemc->add( $key, $data, 86400 );
 118+ }
 119+
 120+ return $data;
108121 }
109122 }
Index: trunk/extensions/CodeReview/SpecialCode.php
@@ -73,7 +73,7 @@
7474 function formatMessage( $value ){
7575 $value = nl2br( htmlspecialchars( $value ) );
7676 $value = preg_replace_callback( '/\br(\d+)\b/', array( $this, 'messageRevLink' ), $value );
77 - $value = preg_replace_callback( '/\bbug (\d+)\b/i', array( $this, 'messageBugLink' ), $value );
 77+ $value = preg_replace_callback( '/\bbug #?(\d+)\b/i', array( $this, 'messageBugLink' ), $value );
7878 return $value;
7979 }
8080

Status & tagging log