summaryrefslogtreecommitdiff
path: root/includes/changes
diff options
context:
space:
mode:
Diffstat (limited to 'includes/changes')
-rw-r--r--includes/changes/ChangesFeed.php4
-rw-r--r--includes/changes/ChangesList.php6
-rw-r--r--includes/changes/EnhancedChangesList.php213
-rw-r--r--includes/changes/OldChangesList.php9
-rw-r--r--includes/changes/RecentChange.php39
5 files changed, 125 insertions, 146 deletions
diff --git a/includes/changes/ChangesFeed.php b/includes/changes/ChangesFeed.php
index 2d3b919d..28c2f7ed 100644
--- a/includes/changes/ChangesFeed.php
+++ b/includes/changes/ChangesFeed.php
@@ -167,14 +167,12 @@ class ChangesFeed {
* @param Feed $feed
*/
public static function generateFeed( $rows, &$feed ) {
- wfProfileIn( __METHOD__ );
$items = self::buildItems( $rows );
$feed->outHeader();
foreach ( $items as $item ) {
$feed->outItem( $item );
}
$feed->outFooter();
- wfProfileOut( __METHOD__ );
}
/**
@@ -183,7 +181,6 @@ class ChangesFeed {
* @return array
*/
public static function buildItems( $rows ) {
- wfProfileIn( __METHOD__ );
$items = array();
# Merge adjacent edits by one user
@@ -234,7 +231,6 @@ class ChangesFeed {
);
}
- wfProfileOut( __METHOD__ );
return $items;
}
}
diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php
index 03d1289f..932006d4 100644
--- a/includes/changes/ChangesList.php
+++ b/includes/changes/ChangesList.php
@@ -67,7 +67,7 @@ class ChangesList extends ContextSource {
$user = $context->getUser();
$sk = $context->getSkin();
$list = null;
- if ( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
+ if ( Hooks::run( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) {
$new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) );
return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context );
@@ -180,7 +180,7 @@ class ChangesList extends ContextSource {
* @param ResultWrapper|array $rows
*/
public function initChangesListRows( $rows ) {
- wfRunHooks( 'ChangesListInitRows', array( $this, $rows ) );
+ Hooks::run( 'ChangesListInitRows', array( $this, $rows ) );
}
/**
@@ -364,7 +364,7 @@ class ChangesList extends ContextSource {
# RTL/LTR marker
$articlelink .= $this->getLanguage()->getDirMark();
- wfRunHooks( 'ChangesListInsertArticleLink',
+ Hooks::run( 'ChangesListInsertArticleLink',
array( &$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched ) );
$s .= " $articlelink";
diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php
index 4ab77297..19277f10 100644
--- a/includes/changes/EnhancedChangesList.php
+++ b/includes/changes/EnhancedChangesList.php
@@ -34,6 +34,7 @@ class EnhancedChangesList extends ChangesList {
/**
* @param IContextSource|Skin $obj
+ * @throws MWException
*/
public function __construct( $obj ) {
if ( $obj instanceof Skin ) {
@@ -88,7 +89,6 @@ class EnhancedChangesList extends ChangesList {
* @return string
*/
public function recentChangesLine( &$baseRC, $watched = false ) {
- wfProfileIn( __METHOD__ );
$date = $this->getLanguage()->userDate(
$baseRC->mAttribs['rc_timestamp'],
@@ -109,8 +109,6 @@ class EnhancedChangesList extends ChangesList {
$cacheEntry = $this->cacheEntryFactory->newFromRecentChange( $baseRC, $watched );
$this->addCacheEntry( $cacheEntry );
- wfProfileOut( __METHOD__ );
-
return $ret;
}
@@ -160,7 +158,6 @@ class EnhancedChangesList extends ChangesList {
* @return string
*/
protected function recentChangesBlockGroup( $block ) {
- wfProfileIn( __METHOD__ );
# Add the namespace and title of the block as part of the class
$classes = array( 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' );
@@ -184,14 +181,12 @@ class EnhancedChangesList extends ChangesList {
$isnew = false;
$allBots = true;
$allMinors = true;
- $curId = $currentRevision = 0;
+ $curId = 0;
# Some catalyst variables...
$namehidden = true;
$allLogs = true;
- $oldid = '';
$RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
foreach ( $block as $rcObj ) {
- $oldid = $rcObj->mAttribs['rc_last_oldid'];
if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
$isnew = true;
}
@@ -215,9 +210,6 @@ class EnhancedChangesList extends ChangesList {
if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
$curId = $rcObj->mAttribs['rc_cur_id'];
}
- if ( !$currentRevision && $rcObj->mAttribs['rc_this_oldid'] ) {
- $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
- }
if ( !$rcObj->mAttribs['rc_bot'] ) {
$allBots = false;
@@ -278,87 +270,7 @@ class EnhancedChangesList extends ChangesList {
$queryParams['curid'] = $curId;
- # Changes message
- static $nchanges = array();
- static $sinceLastVisitMsg = array();
-
- $n = count( $block );
- if ( !isset( $nchanges[$n] ) ) {
- $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
- }
-
- $sinceLast = 0;
- $unvisitedOldid = null;
- /** @var $rcObj RCCacheEntry */
- foreach ( $block as $rcObj ) {
- // Same logic as below inside main foreach
- if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
- $sinceLast++;
- $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
- }
- }
- if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
- $sinceLastVisitMsg[$sinceLast] =
- $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
- }
-
- # Total change link
- $r .= ' ';
- $logtext = '';
- /** @var $block0 RecentChange */
- $block0 = $block[0];
- if ( !$allLogs ) {
- if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
- $logtext .= $nchanges[$n];
- } elseif ( $isnew ) {
- $logtext .= $nchanges[$n];
- } else {
- $logtext .= Linker::link(
- $block0->getTitle(),
- $nchanges[$n],
- array(),
- $queryParams + array(
- 'diff' => $currentRevision,
- 'oldid' => $oldid,
- ),
- array( 'known', 'noclasses' )
- );
- if ( $sinceLast > 0 && $sinceLast < $n ) {
- $logtext .= $this->message['pipe-separator'] . Linker::link(
- $block0->getTitle(),
- $sinceLastVisitMsg[$sinceLast],
- array(),
- $queryParams + array(
- 'diff' => $currentRevision,
- 'oldid' => $unvisitedOldid,
- ),
- array( 'known', 'noclasses' )
- );
- }
- }
- }
-
- # History
- if ( $allLogs ) {
- // don't show history link for logs
- } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
- $logtext .= $this->message['pipe-separator'] . $this->message['enhancedrc-history'];
- } else {
- $params = $queryParams;
- $params['action'] = 'history';
-
- $logtext .= $this->message['pipe-separator'] .
- Linker::linkKnown(
- $block0->getTitle(),
- $this->message['enhancedrc-history'],
- array(),
- $params
- );
- }
-
- if ( $logtext !== '' ) {
- $r .= $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
- }
+ $r .= $this->getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden );
$r .= ' <span class="mw-changeslist-separator">. .</span> ';
@@ -384,7 +296,7 @@ class EnhancedChangesList extends ChangesList {
}
$r .= $users;
- $r .= $this->numberofWatchingusers( $block0->numberofWatchingusers );
+ $r .= $this->numberofWatchingusers( $block[0]->numberofWatchingusers );
$r .= '</td></tr>';
# Sub-entries
@@ -468,19 +380,124 @@ class EnhancedChangesList extends ChangesList {
$this->rcCacheIndex++;
- wfProfileOut( __METHOD__ );
-
return $r;
}
/**
+ * Generates amount of changes (linking to diff ) & link to history.
+ *
+ * @param array $block
+ * @param array $queryParams
+ * @param bool $allLogs
+ * @param bool $isnew
+ * @param bool $namehidden
+ * @return string
+ */
+ protected function getLogText( $block, $queryParams, $allLogs, $isnew, $namehidden ) {
+ # Changes message
+ static $nchanges = array();
+ static $sinceLastVisitMsg = array();
+
+ $n = count( $block );
+ if ( !isset( $nchanges[$n] ) ) {
+ $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
+ }
+
+ $sinceLast = 0;
+ $unvisitedOldid = null;
+ /** @var $rcObj RCCacheEntry */
+ foreach ( $block as $rcObj ) {
+ // Same logic as below inside main foreach
+ if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
+ $sinceLast++;
+ $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
+ }
+ }
+ if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
+ $sinceLastVisitMsg[$sinceLast] =
+ $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
+ }
+
+ $currentRevision = 0;
+ foreach ( $block as $rcObj ) {
+ if ( !$currentRevision ) {
+ $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
+ }
+ }
+
+ # Total change link
+ $links = array();
+ /** @var $block0 RecentChange */
+ $block0 = $block[0];
+ $last = $block[count( $block ) - 1];
+ if ( !$allLogs ) {
+ if ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) {
+ $links['total-changes'] = $nchanges[$n];
+ } elseif ( $isnew ) {
+ $links['total-changes'] = $nchanges[$n];
+ } else {
+ $links['total-changes'] = Linker::link(
+ $block0->getTitle(),
+ $nchanges[$n],
+ array(),
+ $queryParams + array(
+ 'diff' => $currentRevision,
+ 'oldid' => $last->mAttribs['rc_last_oldid'],
+ ),
+ array( 'known', 'noclasses' )
+ );
+ if ( $sinceLast > 0 && $sinceLast < $n ) {
+ $links['total-changes-since-last'] = Linker::link(
+ $block0->getTitle(),
+ $sinceLastVisitMsg[$sinceLast],
+ array(),
+ $queryParams + array(
+ 'diff' => $currentRevision,
+ 'oldid' => $unvisitedOldid,
+ ),
+ array( 'known', 'noclasses' )
+ );
+ }
+ }
+ }
+
+ # History
+ if ( $allLogs ) {
+ // don't show history link for logs
+ } elseif ( $namehidden || !$block0->getTitle()->exists() ) {
+ $links['history'] = $this->message['enhancedrc-history'];
+ } else {
+ $params = $queryParams;
+ $params['action'] = 'history';
+
+ $links['history'] = Linker::linkKnown(
+ $block0->getTitle(),
+ $this->message['enhancedrc-history'],
+ array(),
+ $params
+ );
+ }
+
+ # Allow others to alter, remove or add to these links
+ Hooks::run( 'EnhancedChangesList::getLogText',
+ array( $this, &$links, $block ) );
+
+ if ( !$links ) {
+ return '';
+ }
+
+ $logtext = implode( $this->message['pipe-separator'], $links );
+ $logtext = $this->msg( 'parentheses' )->rawParams( $logtext )->escaped();
+ return ' ' . $logtext;
+ }
+
+ /**
* Enhanced RC ungrouped line.
*
* @param RecentChange|RCCacheEntry $rcObj
* @return string A HTML formatted line (generated using $r)
*/
protected function recentChangesBlockLine( $rcObj ) {
- wfProfileIn( __METHOD__ );
$query['curid'] = $rcObj->mAttribs['rc_cur_id'];
$type = $rcObj->mAttribs['rc_type'];
@@ -552,8 +569,6 @@ class EnhancedChangesList extends ChangesList {
$r .= "</td></tr></table>\n";
- wfProfileOut( __METHOD__ );
-
return $r;
}
@@ -568,8 +583,6 @@ class EnhancedChangesList extends ChangesList {
return '';
}
- wfProfileIn( __METHOD__ );
-
$blockOut = '';
foreach ( $this->rc_cache as $block ) {
if ( count( $block ) < 2 ) {
@@ -579,8 +592,6 @@ class EnhancedChangesList extends ChangesList {
}
}
- wfProfileOut( __METHOD__ );
-
return '<div>' . $blockOut . '</div>';
}
diff --git a/includes/changes/OldChangesList.php b/includes/changes/OldChangesList.php
index 4eed9262..4ce564d1 100644
--- a/includes/changes/OldChangesList.php
+++ b/includes/changes/OldChangesList.php
@@ -32,7 +32,6 @@ class OldChangesList extends ChangesList {
* @return string|bool
*/
public function recentChangesLine( &$rc, $watched = false, $linenumber = null ) {
- wfProfileIn( __METHOD__ );
$classes = array();
// use mw-line-even/mw-line-odd class only if linenumber is given (feature from bug 14468)
@@ -56,14 +55,10 @@ class OldChangesList extends ChangesList {
$rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
}
- if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$html, $rc, &$classes ) ) ) {
- wfProfileOut( __METHOD__ );
-
+ if ( !Hooks::run( 'OldChangesListRecentChangesLine', array( &$this, &$html, $rc, &$classes ) ) ) {
return false;
}
- wfProfileOut( __METHOD__ );
-
$dateheader = ''; // $html now contains only <li>...</li>, for hooks' convenience.
$this->insertDateHeader( $dateheader, $rc->mAttribs['rc_timestamp'] );
@@ -73,7 +68,7 @@ class OldChangesList extends ChangesList {
/**
* @param RecentChange $rc
* @param string[] &$classes
- * @param boolean $watched
+ * @param bool $watched
*
* @return string
*/
diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php
index e33274e8..b430bab9 100644
--- a/includes/changes/RecentChange.php
+++ b/includes/changes/RecentChange.php
@@ -257,7 +257,7 @@ class RecentChange {
public function getPerformer() {
if ( $this->mPerformer === false ) {
if ( $this->mAttribs['rc_user'] ) {
- $this->mPerformer = User::newFromID( $this->mAttribs['rc_user'] );
+ $this->mPerformer = User::newFromId( $this->mAttribs['rc_user'] );
} else {
$this->mPerformer = User::newFromName( $this->mAttribs['rc_user_text'], false );
}
@@ -283,7 +283,7 @@ class RecentChange {
}
# If our database is strict about IP addresses, use NULL instead of an empty string
- if ( $dbw->strictIPs() and $this->mAttribs['rc_ip'] == '' ) {
+ if ( $dbw->strictIPs() && $this->mAttribs['rc_ip'] == '' ) {
unset( $this->mAttribs['rc_ip'] );
}
@@ -298,7 +298,7 @@ class RecentChange {
$this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' );
## If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
- if ( $dbw->cascadingDeletes() and $this->mAttribs['rc_cur_id'] == 0 ) {
+ if ( $dbw->cascadingDeletes() && $this->mAttribs['rc_cur_id'] == 0 ) {
unset( $this->mAttribs['rc_cur_id'] );
}
@@ -309,7 +309,7 @@ class RecentChange {
$this->mAttribs['rc_id'] = $dbw->insertId();
# Notify extensions
- wfRunHooks( 'RecentChange_save', array( &$this ) );
+ Hooks::run( 'RecentChange_save', array( &$this ) );
# Notify external application via UDP
if ( !$noudp ) {
@@ -321,7 +321,7 @@ class RecentChange {
$editor = $this->getPerformer();
$title = $this->getTitle();
- if ( wfRunHooks( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) {
+ if ( Hooks::run( 'AbortEmailNotification', array( $editor, $title, $this ) ) ) {
# @todo FIXME: This would be better as an extension hook
$enotif = new EmailNotification();
$enotif->notifyOnPageChange( $editor, $title,
@@ -445,12 +445,12 @@ class RecentChange {
// Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
$right = $auto ? 'autopatrol' : 'patrol';
$errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
- if ( !wfRunHooks( 'MarkPatrolled', array( $this->getAttribute( 'rc_id' ), &$user, false ) ) ) {
+ if ( !Hooks::run( 'MarkPatrolled', array( $this->getAttribute( 'rc_id' ), &$user, false ) ) ) {
$errors[] = array( 'hookaborted' );
}
// Users without the 'autopatrol' right can't patrol their
// own revisions
- if ( $user->getName() == $this->getAttribute( 'rc_user_text' )
+ if ( $user->getName() === $this->getAttribute( 'rc_user_text' )
&& !$user->isAllowed( 'autopatrol' )
) {
$errors[] = array( 'markedaspatrollederror-noautopatrol' );
@@ -466,7 +466,7 @@ class RecentChange {
$this->reallyMarkPatrolled();
// Log this patrol event
PatrolLog::record( $this, $auto, $user );
- wfRunHooks( 'MarkPatrolledComplete', array( $this->getAttribute( 'rc_id' ), &$user, false ) );
+ Hooks::run( 'MarkPatrolledComplete', array( $this->getAttribute( 'rc_id' ), &$user, false ) );
return array();
}
@@ -796,29 +796,6 @@ class RecentChange {
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 ) {