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