r53710 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53709‎ | r53710 | r53711 >
Date:11:06, 24 July 2009
Author:nikerabbit
Status:reverted (Comments)
Tags:
Comment:
* Don't add 200 extra css/js requests when showing 100 diffs
* Allow suppressing "line 1" from the diffs, which can get quite annoying with many diffs
Modified paths:
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -30,6 +30,10 @@
3131 var $mCacheHit = false; // Was the diff fetched from cache?
3232 var $htmldiff;
3333
 34+ // If true, line X is not displayed when X is 1, for example to increase
 35+ // readability and conserve space with many small diffs.
 36+ protected $mReducedLineNumbers = false;
 37+
3438 protected $unhide = false;
3539 /**#@-*/
3640
@@ -80,6 +84,10 @@
8185 $this->unhide = $unhide;
8286 }
8387
 88+ function setReducedLineNumbers( $value = true ) {
 89+ $this->mReducedLineNumbers = $value;
 90+ }
 91+
8492 function getTitle() {
8593 return $this->mTitle;
8694 }
@@ -637,10 +645,16 @@
638646 */
639647 function showDiffStyle() {
640648 global $wgStylePath, $wgStyleVersion, $wgOut;
 649+
 650+ static $styleDone = false;
 651+ if ( $styleDone === $wgOut ) return;
 652+
641653 $wgOut->addStyle( 'common/diff.css' );
642654
643655 // JS is needed to detect old versions of Mozilla to work around an annoyance bug.
644656 $wgOut->addScript( "<script type=\"text/javascript\" src=\"$wgStylePath/common/diff.js?$wgStyleVersion\"></script>" );
 657+
 658+ $styleDone = $wgOut;
645659 }
646660
647661 /**
@@ -842,6 +856,7 @@
843857
844858 function localiseLineNumbersCb( $matches ) {
845859 global $wgLang;
 860+ if ( $matches[1] === '1' && $this->mReducedLineNumbers ) return '';
846861 return wfMsgExt( 'lineno', 'escape', $wgLang->formatNum( $matches[1] ) );
847862 }
848863

Follow-up revisions

RevisionCommit summaryAuthorDate
r55452Revert r53710 "* Allow suppressing "line 1" from the diffs, which can get qui...brion22:01, 21 August 2009
r55545Recommit r53710 without the hack for preventing style sheets being added mult...nikerabbit05:37, 24 August 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   22:01, 21 August 2009

Use of static variable here means that running multiple diffs during one request may mess things up. It should rather check if it's been added in $wgOut already.

#Comment by Nikerabbit (talk | contribs)   17:49, 22 August 2009

Is the reduced line numbers part okay?

#Comment by Brion VIBBER (talk | contribs)   19:21, 22 August 2009

sure :)

Status & tagging log