]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/SpecialRecentchanges.php
MediaWiki 1.5.8 (initial commit)
[autoinstallsdev/mediawiki.git] / includes / SpecialRecentchanges.php
1 <?php
2 /**
3  *
4  * @package MediaWiki
5  * @subpackage SpecialPage
6  */
7
8 /**
9  *
10  */
11 require_once( 'Feed.php' );
12 require_once( 'ChangesList.php' );
13 require_once( 'Revision.php' );
14
15 /**
16  * Constructor
17  */
18 function wfSpecialRecentchanges( $par, $specialPage ) {
19         global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgMemc, $wgDBname;
20         global $wgRequest, $wgSitename, $wgLanguageCode, $wgContLanguageCode;
21         global $wgFeedClasses, $wgUseRCPatrol;
22         global $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
23         global $wgLinkCache;
24         $fname = 'wfSpecialRecentchanges';
25
26         # Get query parameters
27         $feedFormat = $wgRequest->getVal( 'feed' );
28
29         $defaults = array(
30         /* int  */ 'days' => $wgUser->getDefaultOption('rcdays'),
31         /* int  */ 'limit' => $wgUser->getDefaultOption('rclimit'),
32         /* bool */ 'hideminor' => false,
33         /* bool */ 'hidebots' => true,
34         /* bool */ 'hideliu' => false,
35         /* bool */ 'hidepatrolled' => false,
36         /* bool */ 'hidemyself' => false,
37         /* text */ 'from' => '',
38         /* text */ 'namespace' => null,
39         /* bool */ 'invert' => false,
40         );
41
42         extract($defaults);
43         
44
45         $days = $wgUser->getOption( 'rcdays' );
46         if ( !$days ) { $days = $defaults['days']; }
47         $days = $wgRequest->getInt( 'days', $days );
48
49         $limit = $wgUser->getOption( 'rclimit' );
50         if ( !$limit ) { $limit = $defaults['limit']; }
51
52         #       list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
53         $limit = $wgRequest->getInt( 'limit', $limit );
54
55         /* order of selection: url > preferences > default */
56         $hideminor = $wgRequest->getBool( 'hideminor', $wgUser->getOption( 'hideminor') ? true : $defaults['hideminor'] );              
57         
58         # As a feed, use limited settings only
59         if( $feedFormat ) {
60                 global $wgFeedLimit;
61                 if( $limit > $wgFeedLimit ) {
62                         $options['limit'] = $wgFeedLimit;
63                 }
64
65         } else {
66
67                 $namespace = $wgRequest->getIntOrNull( 'namespace' );
68                 $invert = $wgRequest->getBool( 'invert', $defaults['invert'] );
69                 $hidebots = $wgRequest->getBool( 'hidebots', $defaults['hidebots'] );
70                 $hideliu = $wgRequest->getBool( 'hideliu', $defaults['hideliu'] );
71                 $hidepatrolled = $wgRequest->getBool( 'hidepatrolled', $defaults['hidepatrolled'] );
72                 $hidemyself = $wgRequest->getBool ( 'hidemyself', $defaults['hidemyself'] );
73                 $from = $wgRequest->getVal( 'from', $defaults['from'] );        
74
75                 # Get query parameters from path
76                 if( $par ) {
77                         $bits = preg_split( '/\s*,\s*/', trim( $par ) );
78                         foreach ( $bits as $bit ) {
79                                 if ( 'hidebots' == $bit ) $hidebots = 1;
80                                 if ( 'bots' == $bit ) $hidebots = 0;
81                                 if ( 'hideminor' == $bit ) $hideminor = 1;
82                                 if ( 'minor' == $bit ) $hideminor = 0;
83                                 if ( 'hideliu' == $bit ) $hideliu = 1;
84                                 if ( 'hidepatrolled' == $bit ) $hidepatrolled = 1;
85                                 if ( 'hidemyself' == $bit ) $hidemyself = 1;
86
87                                 if ( is_numeric( $bit ) ) {
88                                         $limit = $bit;
89                                 }
90
91                                 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
92                                         $limit = $m[1];
93                                 }
94
95                                 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
96                                         $days = $m[1];
97                                 }
98                         }
99                 }
100         }
101
102         if ( $limit < 0 || $limit > 5000 ) $limit = $defaults['limit'];
103
104
105         # Database connection and caching
106         $dbr =& wfGetDB( DB_SLAVE );
107         extract( $dbr->tableNames( 'recentchanges', 'watchlist' ) );
108
109         
110         $cutoff_unixtime = time() - ( $days * 86400 );
111         $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
112         $cutoff = $dbr->timestamp( $cutoff_unixtime );
113         if(preg_match('/^[0-9]{14}$/', $from) and $from > wfTimestamp(TS_MW,$cutoff)) {
114                 $cutoff = $dbr->timestamp($from);
115         } else {
116                 $from = $defaults['from'];
117         }
118                 
119         # 10 seconds server-side caching max
120         $wgOut->setSquidMaxage( 10 );
121
122         # Get last modified date, for client caching
123         # Don't use this if we are using the patrol feature, patrol changes don't update the timestamp
124         $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, $fname );
125         if ( $feedFormat || !$wgUseRCPatrol ) {
126                 if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){
127                         # Client cache fresh and headers sent, nothing more to do.
128                         return;
129                 }
130         }
131
132         $hidem  = $hideminor ? 'AND rc_minor=0' : '';
133         $hidem .= $hidebots ? ' AND rc_bot=0' : '';
134         $hidem .= ( $hideliu && !$hidemyself ) ? ' AND rc_user=0' : '';
135         $hidem .= $hidepatrolled ? ' AND rc_patrolled=0' : '';
136         $hidem .= $hidemyself  ? ' AND rc_user <> '.$wgUser->getID() : '';
137         $hidem .= is_null( $namespace ) ?  '' : ' AND rc_namespace' . ($invert ? '!=' : '=') . $namespace;
138
139         // This is the big thing!
140
141         $uid = $wgUser->getID();
142         $notifts = ($wgShowUpdatedMarker?",wl_notificationtimestamp":"");
143
144         // Perform query
145         $sql2 = "SELECT $recentchanges.*" . ($uid ? ",wl_user".$notifts : "") . " FROM $recentchanges " .
146           ($uid ? "LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") .
147           "WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
148           "ORDER BY rc_timestamp DESC LIMIT {$limit}";
149         $res = $dbr->query( $sql2, $fname );
150
151         // Fetch results, prepare a batch link existence check query
152         $rows = array();
153         $batch = new LinkBatch;
154         while( $row = $dbr->fetchObject( $res ) ){
155                 $rows[] = $row;
156                 // User page link
157                 $title = Title::makeTitleSafe( NS_USER, $row->rc_user_text );
158                 $batch->addObj( $title );
159
160                 // User talk
161                 $title = Title::makeTitleSafe( NS_USER_TALK, $row->rc_user_text );
162                 $batch->addObj( $title );
163
164         }
165         $dbr->freeResult( $res );
166
167         // Run existence checks
168         $batch->execute( $wgLinkCache );
169
170         if( $feedFormat ) {
171                 rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod );
172         } else {
173
174                 # Web output...
175
176                 // Output header
177                 if ( !$specialPage->including() ) {
178                         $wgOut->addWikiText( wfMsgForContent( "recentchangestext" ) );
179                 
180                         // Dump everything here
181                         $nondefaults = array();
182                 
183                         wfAppendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults);
184                         wfAppendToArrayIfNotDefault( 'limit', $limit , $defaults, $nondefaults);
185                         wfAppendToArrayIfNotDefault( 'hideminor', $hideminor, $defaults, $nondefaults);
186                         wfAppendToArrayIfNotDefault( 'hidebots', $hidebots, $defaults, $nondefaults);
187                         wfAppendToArrayIfNotDefault( 'hideliu', $hideliu, $defaults, $nondefaults);
188                         wfAppendToArrayIfNotDefault( 'hidepatrolled', $hidepatrolled, $defaults, $nondefaults);
189                         wfAppendToArrayIfNotDefault( 'hidemyself', $hidemyself, $defaults, $nondefaults);
190                         wfAppendToArrayIfNotDefault( 'from', $from, $defaults, $nondefaults);
191                         wfAppendToArrayIfNotDefault( 'namespace', $namespace, $defaults, $nondefaults);
192                         wfAppendToArrayIfNotDefault( 'invert', $invert, $defaults, $nondefaults);
193
194                         // Add end of the texts
195                         $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) );
196                         $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults) . '</div>');
197                 }
198
199                 // And now for the content
200                 $sk = $wgUser->getSkin();
201                 $wgOut->setSyndicated( true );
202                 $list =& new ChangesList( $sk );
203                 $s = $list->beginRecentChangesList();
204                 $counter = 1;
205                 foreach( $rows as $obj ){
206                         if( $limit == 0) {
207                                 break;
208                         }
209
210                         if ( ! ( $hideminor     && $obj->rc_minor     ) &&
211                              ! ( $hidepatrolled && $obj->rc_patrolled ) ) {
212                                 $rc = RecentChange::newFromRow( $obj );
213                                 $rc->counter = $counter++;
214
215                                 if ($wgShowUpdatedMarker
216                                         && !empty( $obj->wl_notificationtimestamp )
217                                         && ($obj->rc_timestamp >= $obj->wl_notificationtimestamp)) {
218                                                 $rc->notificationtimestamp = true;
219                                 } else {
220                                         $rc->notificationtimestamp = false;
221                                 }
222
223                                 if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
224                                         $sql3 = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_title='" . $dbr->strencode($obj->rc_title) ."' AND wl_namespace=$obj->rc_namespace" ;
225                                         $res3 = $dbr->query( $sql3, 'wfSpecialRecentChanges');
226                                         $x = $dbr->fetchObject( $res3 );
227                                         $rc->numberofWatchingusers = $x->n;
228                                 } else {
229                                         $rc->numberofWatchingusers = 0;
230                                 }
231                                 $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ) );
232                                 --$limit;
233                         }
234                 }
235                 $s .= $list->endRecentChangesList();
236                 $wgOut->addHTML( $s );
237         }
238 }
239
240 function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
241         global $messageMemc, $wgDBname, $wgFeedCacheTimeout;
242         global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
243         
244         if( !isset( $wgFeedClasses[$feedFormat] ) ) {
245                 wfHttpError( 500, "Internal Server Error", "Unsupported feed type." );
246                 return false;
247         }
248         
249         $timekey = "$wgDBname:rcfeed:$feedFormat:timestamp";
250         $key = "$wgDBname:rcfeed:$feedFormat:limit:$limit:minor:$hideminor";
251         
252         $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchanges' ) .
253                 ' [' . $wgContLanguageCode . ']';
254         $feed = new $wgFeedClasses[$feedFormat](
255                 $feedTitle,
256                 htmlspecialchars( wfMsgForContent( 'recentchangestext' ) ),
257                 $wgTitle->getFullUrl() );
258
259         /**
260          * Bumping around loading up diffs can be pretty slow, so where
261          * possible we want to cache the feed output so the next visitor
262          * gets it quick too.
263          */
264         $cachedFeed = false;
265         if( $feedLastmod = $messageMemc->get( $timekey ) ) {
266                 /**
267                  * If the cached feed was rendered very recently, we may
268                  * go ahead and use it even if there have been edits made
269                  * since it was rendered. This keeps a swarm of requests
270                  * from being too bad on a super-frequently edited wiki.
271                  */
272                 if( time() - wfTimestamp( TS_UNIX, $feedLastmod )
273                                 < $wgFeedCacheTimeout
274                         || wfTimestamp( TS_UNIX, $feedLastmod )
275                                 > wfTimestamp( TS_UNIX, $lastmod ) ) {
276                         wfDebug( "RC: loading feed from cache ($key; $feedLastmod; $lastmod)...\n" );
277                         $cachedFeed = $messageMemc->get( $key );
278                 } else {
279                         wfDebug( "RC: cached feed timestamp check failed ($feedLastmod; $lastmod)\n" );
280                 }
281         }
282         if( is_string( $cachedFeed ) ) {
283                 wfDebug( "RC: Outputting cached feed\n" );
284                 $feed->httpHeaders();
285                 echo $cachedFeed;
286         } else {
287                 wfDebug( "RC: rendering new feed and caching it\n" );
288                 ob_start();
289                 rcDoOutputFeed( $rows, $feed );
290                 $cachedFeed = ob_get_contents();
291                 ob_end_flush();
292                 
293                 $expire = 3600 * 24; # One day
294                 $messageMemc->set( $key, $cachedFeed );
295                 $messageMemc->set( $timekey, wfTimestamp( TS_MW ), $expire );
296         }
297         return true;
298 }
299
300 function rcDoOutputFeed( $rows, &$feed ) {
301         global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
302         
303         $feed->outHeader();
304         
305         # Merge adjacent edits by one user
306         $sorted = array();
307         $n = 0;
308         foreach( $rows as $obj ) {
309                 if( $n > 0 &&
310                         $obj->rc_namespace >= 0 &&
311                         $obj->rc_cur_id == $sorted[$n-1]->rc_cur_id &&
312                         $obj->rc_user_text == $sorted[$n-1]->rc_user_text ) {
313                         $sorted[$n-1]->rc_last_oldid = $obj->rc_last_oldid;
314                 } else {
315                         $sorted[$n] = $obj;
316                         $n++;
317                 }
318                 $first = false;
319         }
320         
321         foreach( $sorted as $obj ) {
322                 $title = Title::makeTitle( $obj->rc_namespace, $obj->rc_title );
323                 $talkpage = $title->getTalkPage();
324                 $item = new FeedItem(
325                         $title->getPrefixedText(),
326                         rcFormatDiff( $obj ),
327                         $title->getFullURL(),
328                         $obj->rc_timestamp,
329                         $obj->rc_user_text,
330                         $talkpage->getFullURL()
331                         );
332                 $feed->outItem( $item );
333         }
334         $feed->outFooter();
335 }
336
337 /**
338  *
339  */
340 function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) {
341         global $wgUser, $wgLang, $wgContLang;
342         $sk = $wgUser->getSkin();
343         $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
344           ($lim ? $wgLang->formatNum( "{$lim}" ) : wfMsg( 'recentchangesall' ) ), "{$more}" .
345           ($d ? "days={$d}&" : '') . 'limit='.$lim );
346         return $s;
347 }
348
349 /**
350  *
351  */
352 function rcDaysLink( $lim, $d, $page='Recentchanges', $more='' ) {
353         global $wgUser, $wgLang, $wgContLang;
354         $sk = $wgUser->getSkin();
355         $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
356           ($d ? $wgLang->formatNum( "{$d}" ) : wfMsg( 'recentchangesall' ) ), $more.'days='.$d .
357           ($lim ? '&limit='.$lim : '') );
358         return $s;
359 }
360
361 /**
362  * Used by Recentchangeslinked
363  */
364 function rcDayLimitLinks( $days, $limit, $page='Recentchanges', $more='', $doall = false, $minorLink = '',
365         $botLink = '', $liuLink = '', $patrLink = '', $myselfLink = '' ) {
366         if ($more != '') $more .= '&';
367         $cl = rcCountLink( 50, $days, $page, $more ) . ' | ' .
368           rcCountLink( 100, $days, $page, $more  ) . ' | ' .
369           rcCountLink( 250, $days, $page, $more  ) . ' | ' .
370           rcCountLink( 500, $days, $page, $more  ) .
371           ( $doall ? ( ' | ' . rcCountLink( 0, $days, $page, $more ) ) : '' );
372         $dl = rcDaysLink( $limit, 1, $page, $more  ) . ' | ' .
373           rcDaysLink( $limit, 3, $page, $more  ) . ' | ' .
374           rcDaysLink( $limit, 7, $page, $more  ) . ' | ' .
375           rcDaysLink( $limit, 14, $page, $more  ) . ' | ' .
376           rcDaysLink( $limit, 30, $page, $more  ) .
377           ( $doall ? ( ' | ' . rcDaysLink( $limit, 0, $page, $more ) ) : '' );
378         $shm = wfMsg( 'showhideminor', $minorLink, $botLink, $liuLink, $patrLink, $myselfLink );
379         $note = wfMsg( 'rclinks', $cl, $dl, $shm );
380         return $note;
381 }
382
383
384 /**
385  * Makes change an option link which carries all the other options
386  */
387 function makeOptionsLink( $title, $override, $options ) {
388         global $wgUser, $wgLang, $wgContLang;
389         $sk = $wgUser->getSkin();
390         return $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ),
391                 $title, wfArrayToCGI( $override, $options ) );
392 }
393
394 /**
395  * Creates the options panel
396  */
397 function rcOptionsPanel( $defaults, $nondefaults ) {
398         global $wgLang;
399
400         $options = $nondefaults + $defaults;
401
402         if( $options['from'] )
403                 $note = wfMsg( 'rcnotefrom', $wgLang->formatNum( $options['limit'] ), $wgLang->timeanddate( $options['from'], true ) );
404         else
405                 $note = wfMsg( 'rcnote', $wgLang->formatNum( $options['limit'] ), $wgLang->formatNum( $options['days'] ) );
406
407         // limit links
408         $cl = '';
409         $options_limit = array(50, 100, 250, 500);
410         $i = 0;
411         while ( $i+1 < count($options_limit) ) {
412                 $cl .=  makeOptionsLink( $options_limit[$i], array( 'limit' => $options_limit[$i] ), $nondefaults) . ' | ' ;
413                 $i++;
414         }
415         $cl .=  makeOptionsLink( $options_limit[$i], array( 'limit' => $options_limit[$i] ), $nondefaults) ;
416
417         // day links, reset 'from' to none
418         $dl = '';
419         $options_days = array(1, 3, 7, 14, 30);
420         $i = 0;
421         while ( $i+1 < count($options_days) ) {
422                 $dl .=  makeOptionsLink( $options_days[$i], array( 'days' => $options_days[$i], 'from' => '' ), $nondefaults) . ' | ' ;
423                 $i++;
424         }
425         $dl .=  makeOptionsLink( $options_days[$i], array( 'days' => $options_days[$i], 'from' => '' ), $nondefaults) ;
426
427         // show/hide links
428         $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ));
429         $minorLink = makeOptionsLink( $showhide[1-$options['hideminor']],
430                 array( 'hideminor' => 1-$options['hideminor'] ), $nondefaults);
431         $botLink = makeOptionsLink( $showhide[1-$options['hidebots']],
432                 array( 'hidebots' => 1-$options['hidebots'] ), $nondefaults);
433         $liuLink   = makeOptionsLink( $showhide[1-$options['hideliu']],
434                 array( 'hideliu' => 1-$options['hideliu'] ), $nondefaults);
435         $patrLink  = makeOptionsLink( $showhide[1-$options['hidepatrolled']],
436                 array( 'hidepatrolled' => 1-$options['hidepatrolled'] ), $nondefaults);
437         $myselfLink = makeOptionsLink( $showhide[1-$options['hidemyself']], 
438                 array( 'hidemyself' => 1-$options['hidemyself'] ), $nondefaults);
439         $hl = wfMsg( 'showhideminor', $minorLink, $botLink, $liuLink, $patrLink, $myselfLink );
440         
441         // show from this onward link
442         $now = $wgLang->timeanddate( wfTimestampNow(), true );
443         $tl =  makeOptionsLink( $now, array( 'from' => wfTimestampNow()), $nondefaults );
444         
445         $rclinks = wfMsg( 'rclinks', $cl, $dl, $hl );
446         $rclistfrom = wfMsg( 'rclistfrom', $tl );
447         return "$note<br />$rclinks<br />$rclistfrom";
448
449 }
450
451 /**<F2>
452  * Creates the choose namespace selection
453  *
454  * @access private
455  *
456  * @param mixed $namespace The key of the currently selected namespace, empty string
457  *              if there is none
458  * @param bool $invert Whether to invert the namespace selection
459  * @param array $nondefaults An array of non default options to be remembered
460  *
461  * @return string
462  */
463 function rcNamespaceForm ( $namespace, $invert, $nondefaults ) {
464         global $wgContLang, $wgScript;
465         $t = Title::makeTitle( NS_SPECIAL, 'Recentchanges' );
466
467         $namespaceselect = HTMLnamespaceselector($namespace, '');
468         $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . '" />';
469         $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ? ' checked="checked"' : '' ) . ' />';
470
471         $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
472
473         foreach ( $nondefaults as $key => $value ) {
474                 if ($key != 'namespace' && $key != 'invert')
475                         $out .= wfElement('input', array( 'type' => 'hidden', 'name' => $key, 'value' => $value));
476         }
477
478         $out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
479         $out .= "
480 <div id='nsselect' class='recentchanges'>
481         <label for='namespace'>" . wfMsgHtml('namespace') . "</label>
482         $namespaceselect $submitbutton $invertbox <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>
483 </div>";
484         $out .= '</form></div>';
485         return $out;
486 }
487
488
489 /**
490  * Format a diff for the newsfeed
491  */
492 function rcFormatDiff( $row ) {
493         $fname = 'rcFormatDiff';
494         wfProfileIn( $fname );
495         
496         require_once( 'DifferenceEngine.php' );
497         $comment = "<p>" . htmlspecialchars( $row->rc_comment ) . "</p>\n";
498         
499         if( $row->rc_namespace >= 0 ) {
500                 global $wgContLang;
501                 
502                 #$diff =& new DifferenceEngine( $row->rc_this_oldid, $row->rc_last_oldid, $row->rc_id );
503                 #$diff->showDiffPage();
504                 
505                 $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
506                 $dbr =& wfGetDB( DB_SLAVE );
507                 $newrev =& Revision::newFromTitle( $titleObj, $row->rc_this_oldid );
508                 if( $newrev ) {
509                         $newtext = $newrev->getText();
510                 } else {
511                         $diffText = "<p>Can't load revision $row->rc_this_oldid</p>";
512                         wfProfileOut( $fname );
513                         return $comment . $diffText;
514                 }
515
516                 if( $row->rc_last_oldid ) {
517                         wfProfileIn( "$fname-dodiff" );
518                         $oldrev =& Revision::newFromId( $row->rc_last_oldid );
519                         if( !$oldrev ) {
520                                 $diffText = "<p>Can't load old revision $row->rc_last_oldid</p>";
521                                 wfProfileOut( $fname );
522                                 return $comment . $diffText;
523                         }
524                         $oldtext = $oldrev->getText();
525                                 
526                         # Old entries may contain illegal characters
527                         # which will damage output
528                         $oldtext = UtfNormal::cleanUp( $oldtext );
529                         
530                         global $wgFeedDiffCutoff;
531                         if( strlen( $newtext ) > $wgFeedDiffCutoff ||
532                                 strlen( $oldtext ) > $wgFeedDiffCutoff ) {
533                                 $diffLink = $titleObj->escapeFullUrl(
534                                         'diff=' . $row->rc_this_oldid .
535                                         '&oldid=' . $row->rc_last_oldid );
536                                 $diffText = '<a href="' .
537                                         $diffLink .
538                                         '">' .
539                                         htmlspecialchars( wfMsgForContent( 'difference' ) ) .
540                                         '</a>';
541                         } else {
542                                 $diffText = DifferenceEngine::getDiff( $oldtext, $newtext,
543                                   wfMsg( 'revisionasof', $wgContLang->timeanddate( $row->rc_timestamp ) ),
544                                   wfMsg( 'currentrev' ) );
545                         }
546                         wfProfileOut( "$fname-dodiff" );
547                 } else {
548                         $rev = Revision::newFromId( $row->rc_this_oldid );
549                         if( is_null( $rev ) ) {
550                                 $newtext = '';
551                         } else {
552                                 $newtext = $rev->getText();
553                         }
554                         $diffText = '<p><b>' . wfMsg( 'newpage' ) . '</b></p>' .
555                                 '<div>' . nl2br( htmlspecialchars( $newtext ) ) . '</div>';
556                 }
557                 
558                 wfProfileOut( $fname );
559                 return $comment . $diffText;
560         }
561         
562         wfProfileOut( $fname );
563         return $comment;        
564 }
565
566 ?>