getVal( 'action' ) === 'purge'; if ( $purge && $wgUser->isAllowed('purge') ) { $messageMemc->delete( $timekey ); $messageMemc->delete( $key ); } } /** * Check whether feeds can be used and that $type is a valid feed type * * @param $type String: feed type, as requested by the user * @return Boolean */ public static function checkFeedOutput( $type ) { global $wgOut, $wgFeed, $wgFeedClasses; if ( !$wgFeed ) { $wgOut->addWikiMsg( 'feed-unavailable' ); return false; } if( !isset( $wgFeedClasses[$type] ) ) { $wgOut->addWikiMsg( 'feed-invalid' ); return false; } return true; } /** * Format a diff for the newsfeed * * @param $row Object: row from the recentchanges table * @return String */ public static function formatDiff( $row ) { $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title ); $timestamp = wfTimestamp( TS_MW, $row->rc_timestamp ); $actiontext = ''; if( $row->rc_type == RC_LOG ) { $rcRow = (array)$row; // newFromRow() only accepts arrays for RC rows $actiontext = LogFormatter::newFromRow( $rcRow )->getActionText(); } return self::formatDiffRow( $titleObj, $row->rc_last_oldid, $row->rc_this_oldid, $timestamp, ($row->rc_deleted & Revision::DELETED_COMMENT) ? wfMessage('rev-deleted-comment')->escaped() : $row->rc_comment, $actiontext ); } /** * Really format a diff for the newsfeed * * @param $title Title object * @param $oldid Integer: old revision's id * @param $newid Integer: new revision's id * @param $timestamp Integer: new revision's timestamp * @param $comment String: new revision's comment * @param $actiontext String: text of the action; in case of log event * @return String */ public static function formatDiffRow( $title, $oldid, $newid, $timestamp, $comment, $actiontext='' ) { global $wgFeedDiffCutoff, $wgLang; wfProfileIn( __METHOD__ ); # log enties $completeText = '
' . implode( ' ', array_filter( array( $actiontext, Linker::formatComment( $comment ) ) ) ) . "
\n"; // NOTE: Check permissions for anonymous users, not current user. // No "privileged" version should end up in the cache. // Most feed readers will not log in anway. $anon = new User(); $accErrors = $title->getUserPermissionsErrors( 'read', $anon, true ); // Can't diff special pages, unreadable pages or pages with no new revision // to compare against: just return the text. if( $title->getNamespace() < 0 || $accErrors || !$newid ) { wfProfileOut( __METHOD__ ); return $completeText; } if( $oldid ) { wfProfileIn( __METHOD__."-dodiff" ); #$diffText = $de->getDiff( wfMessage( 'revisionasof', # $wgLang->timeanddate( $timestamp ), # $wgLang->date( $timestamp ), # $wgLang->time( $timestamp ) )->text(), # wfMessage( 'currentrev' )->text() ); $diffText = ''; // Don't bother generating the diff if we won't be able to show it if ( $wgFeedDiffCutoff > 0 ) { $de = new DifferenceEngine( $title, $oldid, $newid ); $diffText = $de->getDiff( wfMessage( 'previousrevision' )->text(), // hack wfMessage( 'revisionasof', $wgLang->timeanddate( $timestamp ), $wgLang->date( $timestamp ), $wgLang->time( $timestamp ) )->text() ); } if ( $wgFeedDiffCutoff <= 0 || ( strlen( $diffText ) > $wgFeedDiffCutoff ) ) { // Omit large diffs $diffText = self::getDiffLink( $title, $newid, $oldid ); } elseif ( $diffText === false ) { // Error in diff engine, probably a missing revision $diffText = "Can't load revision $newid
"; } else { // Diff output fine, clean up any illegal UTF-8 $diffText = UtfNormal::cleanUp( $diffText ); $diffText = self::applyDiffStyle( $diffText ); } wfProfileOut( __METHOD__."-dodiff" ); } else { $rev = Revision::newFromId( $newid ); if( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) { $newtext = ''; } else { $newtext = $rev->getText(); } if ( $wgFeedDiffCutoff <= 0 || strlen( $newtext ) > $wgFeedDiffCutoff ) { // Omit large new page diffs, bug 29110 $diffText = self::getDiffLink( $title, $newid ); } else { $diffText = '' . wfMessage( 'newpage' )->text() . '
' . '