}
/**
+ * @deprecated in 1.22
* @param $row
* @return RecentChange
*/
public static function newFromCurRow( $row ) {
+ wfDeprecated( __METHOD__, '1.22' );
$rc = new RecentChange;
$rc->loadFromCurRow( $row );
$rc->notificationtimestamp = false;
*
* @param array $conds of conditions
* @param $fname Mixed: override the method name in profiling/logs
+ * @param $options Array Query options
* @return RecentChange
*/
- public static function newFromConds( $conds, $fname = __METHOD__ ) {
+ public static function newFromConds( $conds, $fname = __METHOD__, $options = array() ) {
$dbr = wfGetDB( DB_SLAVE );
- $row = $dbr->selectRow( 'recentchanges', self::selectFields(), $conds, $fname );
+ $row = $dbr->selectRow( 'recentchanges', self::selectFields(), $conds, $fname, $options );
if ( $row !== false ) {
return self::newFromRow( $row );
} else {
* @return String
*/
public static function cleanupForIRC( $text ) {
- return Sanitizer::decodeCharReferences( str_replace( array( "\n", "\r" ), array( "", "" ), $text ) );
+ return Sanitizer::decodeCharReferences( str_replace( array( "\n", "\r" ), array( " ", "" ), $text ) );
}
/**
),
__METHOD__
);
+ // Invalidate the page cache after the page has been patrolled
+ // to make sure that the Patrol link isn't visible any longer!
+ $this->getTitle()->invalidateCache();
return $dbw->affectedRows();
}
/**
* Makes a pseudo-RC entry from a cur row
*
+ * @deprected in 1.22
* @param $row
*/
public function loadFromCurRow( $row ) {
+ wfDeprecated( __METHOD__, '1.22' );
$this->mAttribs = array(
'rc_timestamp' => wfTimestamp( TS_MW, $row->rev_timestamp ),
'rc_cur_time' => $row->rev_timestamp,
return ChangesList::showCharacterDifference( $old, $new );
}
+ /**
+ * Purge expired changes from the recentchanges table
+ * @since 1.22
+ */
+ public static function purgeExpiredChanges() {
+ if ( wfReadOnly() ) {
+ return;
+ }
+
+ $method = __METHOD__;
+ $dbw = wfGetDB( DB_MASTER );
+ $dbw->onTransactionIdle( function() use ( $dbw, $method ) {
+ global $wgRCMaxAge;
+
+ $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
+ $dbw->delete(
+ 'recentchanges',
+ array( 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ),
+ $method
+ );
+ } );
+ }
+
private static function checkIPAddress( $ip ) {
global $wgRequest;
if ( $ip ) {
}
return $ip;
}
+
+ /**
+ * Check whether the given timestamp is new enough to have a RC row with a given tolerance
+ * as the recentchanges table might not be cleared out regularly (so older entries might exist)
+ * or rows which will be deleted soon shouldn't be included.
+ *
+ * @param $timestamp mixed MWTimestamp compatible timestamp
+ * @param $tolerance integer Tolerance in seconds
+ * @return bool
+ */
+ public static function isInRCLifespan( $timestamp, $tolerance = 0 ) {
+ global $wgRCMaxAge;
+ return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge;
+ }
}