r87217 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87216‎ | r87217 | r87218 >
Date:21:28, 1 May 2011
Author:reedy
Status:ok
Tags:
Comment:
Refactor out common code
Modified paths:
  • /trunk/phase3/includes/specials/SpecialComparePages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialComparePages.php
@@ -100,29 +100,9 @@
101101 }
102102
103103 public static function showDiff( $data ){
 104+ $rev1 = self::revOrTitle( $data['Revision1'], $data['Page1'] );
 105+ $rev2 = self::revOrTitle( $data['Revision2'], $data['Page2'] );
104106
105 - if( $data['Revision1'] ){
106 - $rev1 = $data['Revision1'];
107 - } elseif( $data['Page1'] ) {
108 - $title = Title::newFromText( $data['Page1'] );
109 - if( $title instanceof Title ){
110 - $rev1 = $title->getLatestRevID();
111 - }
112 - } else {
113 - $rev1 = null;
114 - }
115 -
116 - if( $data['Revision2'] ){
117 - $rev2 = $data['Revision2'];
118 - } elseif( $data['Page2'] ) {
119 - $title = Title::newFromText( $data['Page2'] );
120 - if( $title instanceof Title ){
121 - $rev2 = $title->getLatestRevID();
122 - }
123 - } else {
124 - $rev2 = null;
125 - }
126 -
127107 if( $rev1 && $rev2 ) {
128108 $de = new DifferenceEngine( null,
129109 $rev1,
@@ -133,4 +113,16 @@
134114 $de->showDiffPage( true );
135115 }
136116 }
 117+
 118+ public static function revOrTitle( $revision, $title ) {
 119+ if( $revision ){
 120+ return $revision;
 121+ } elseif( $title ) {
 122+ $title = Title::newFromText( $title );
 123+ if( $title instanceof Title ){
 124+ return $title->getLatestRevID();
 125+ }
 126+ }
 127+ return null;
 128+ }
137129 }

Status & tagging log