Brian Wolff has uploaded a new change for review.
https://gerrit.wikimedia.org/r/273608
Change subject: Show unpatrolled "!" on history pages
......................................................................
Show unpatrolled "!" on history pages
This also adds a class so that users can add the yellow highlighting
if they wish. I didn't put that in by default, since that highlighting
is not used for example in RecentChanges, which seems closest to this
use case.
This modifies the file upload code to use a consistent timestamp
for both the null edit, and for RC entry. This allows us to look
up the patrol status of file uploads, without doing any schema
changes. Previously, the timestamps may have differed by about
a second.
Bug: T31611
Change-Id: Idaf093e17e9b9e4d1d644eea38e34939b9a4358e
---
M includes/Revision.php
M includes/actions/HistoryAction.php
M includes/filerepo/file/LocalFile.php
M includes/page/WikiPage.php
4 files changed, 69 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/08/273608/1
diff --git a/includes/Revision.php b/includes/Revision.php
index 3db3744..e979928 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -1620,9 +1620,10 @@
* @param string $summary Revision's summary
* @param bool $minor Whether the revision should be considered as minor
* @param User|null $user User object to use or null for $wgUser
+ * @param String|null $timestamp Timestamp, or null for current time
* @return Revision|null Revision or null on error
*/
- public static function newNullRevision( $dbw, $pageId, $summary,
$minor, $user = null ) {
+ public static function newNullRevision( $dbw, $pageId, $summary,
$minor, $user = null, $timestamp = null ) {
global $wgContentHandlerUseDB, $wgContLang;
$fields = [ 'page_latest', 'page_namespace', 'page_title',
@@ -1662,7 +1663,8 @@
'text_id' => $current->rev_text_id,
'parent_id' => $current->page_latest,
'len' => $current->rev_len,
- 'sha1' => $current->rev_sha1
+ 'sha1' => $current->rev_sha1,
+ 'timestamp' => $timestamp ?: wfTimestampNow()
];
if ( $wgContentHandlerUseDB ) {
diff --git a/includes/actions/HistoryAction.php
b/includes/actions/HistoryAction.php
index 073b3ca..0238845 100644
--- a/includes/actions/HistoryAction.php
+++ b/includes/actions/HistoryAction.php
@@ -370,6 +370,10 @@
*/
protected $parentLens;
+ /** @var array Associative array, where the keys are unpatrolled
revision ids */
+ protected $unpatrolledRevs;
+
+
/** @var bool Whether to show the tag editing UI */
protected $showTagEditUI;
@@ -462,6 +466,7 @@
$this->mResult->seek( 0 );
$batch = new LinkBatch();
$revIds = [];
+ $potentialUnpatrolledRevs = [];
foreach ( $this->mResult as $row ) {
if ( $row->rev_parent_id ) {
$revIds[] = $row->rev_parent_id;
@@ -473,10 +478,45 @@
$batch->add( NS_USER, $row->rev_user_text );
$batch->add( NS_USER_TALK, $row->rev_user_text
);
}
+ if ( RecentChange::isInRCLifespan( $row->rev_timestamp,
21600 ) ) {
+ $potentialUnpatrolledRevs[] =
$this->mDb->makeList( [
+ "rc_this_oldid" => $row->rev_id,
+ "rc_timestamp" => $row->rev_timestamp
+ ], LIST_AND );
+ }
}
$this->parentLens = Revision::getParentLengths( $this->mDb,
$revIds );
+ $this->unpatrolledRevs = $this->getUnpatrolled(
$potentialUnpatrolledRevs );
$batch->execute();
$this->mResult->seek( 0 );
+ }
+
+ /**
+ * Find revisions not yet patrolled
+ *
+ * @param $potentialUnpatrolledRevs Array Conditions to check in RC
table
+ * @return Array List of revision ids that are not patrolled (as array
keys)
+ * or empty array if rc patrol disabled or user does not have
permission.
+ */
+ protected function getUnpatrolled( array $potentialUnpatrolledRevs ) {
+ $user = $this->getContext()->getUser();
+ if ( !$user->useRCPatrol() || !$potentialUnpatrolledRevs ) {
+ return [];
+ }
+
+ // This is assuming that the most relavent index is
+ // on rc_timestamp, and there are not very many
+ // rc entries happening within a 1 second interval
+ return array_flip( $this->mDb->selectFieldValues(
+ 'recentchanges',
+ 'rc_this_oldid',
+ [
+ 'rc_patrolled' => 0,
+ 'rc_type' => [ RC_NEW, RC_EDIT, RC_LOG ],
+ $this->mDb->makeList(
$potentialUnpatrolledRevs, LIST_OR )
+ ],
+ __METHOD__
+ ) );
}
/**
@@ -676,8 +716,20 @@
Linker::revUserTools( $rev, true ) . "</span>";
$s .= $dirmark;
+ $flags = '';
if ( $rev->isMinor() ) {
- $s .= ' ' . ChangesList::flag( 'minor' );
+ $flags .= ChangesList::flag( 'minor' );
+ }
+
+ if ( isset( $this->unpatrolledRevs[$rev->getId()] ) ) {
+ // Note: if user does not have rights or $wgUseRCPatrol
+ // is false, then $this->unpatrolledRevs will be empty.
+ $flags .= ChangesList::flag( 'unpatrolled' );
+ $classes[] = 'mw-history-unpatrolled';
+ }
+
+ if ( $flags !== '' ) {
+ $s .= ' ' . $flags;
}
# Sometimes rev_len isn't populated
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index c232d82..1f3b784 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1389,7 +1389,8 @@
$descId,
$editSummary,
false,
- $user
+ $user,
+ $timestamp
);
if ( $nullRevision ) {
$nullRevision->insertOn( $dbw );
@@ -1432,7 +1433,10 @@
$comment,
EDIT_NEW | EDIT_SUPPRESS_RC,
false,
- $user
+ $user,
+ null, /* serial format */
+ null, /* tags */
+ $this->timestamp
);
if ( isset( $status->value['revision'] ) ) {
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index 3308890..42e64a9 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -1639,6 +1639,7 @@
* @param array|null $tags Change tags to apply to this edit
* Callers are responsible for permission checks
* (with ChangeTags::canAddTagsAccompanyingChange)
+ * @param string|null $timestamp Override the edit timestamp
*
* @throws MWException
* @return Status Possible errors:
@@ -1660,7 +1661,7 @@
*/
public function doEditContent(
Content $content, $summary, $flags = 0, $baseRevId = false,
- User $user = null, $serialFormat = null, $tags = null
+ User $user = null, $serialFormat = null, $tags = null,
$timestamp = null
) {
global $wgUser, $wgUseAutomaticEditSummaries;
@@ -1723,7 +1724,8 @@
'oldId' => $this->getLatest(),
'oldIsRedirect' => $this->isRedirect(),
'oldCountable' => $this->isCountable(),
- 'tags' => ( $tags !== null ) ? (array)$tags : []
+ 'tags' => ( $tags !== null ) ? (array)$tags : [],
+ 'timestamp' => $timestamp ?: wfTimestampNow()
];
// Actually create the revision and create/update the page
@@ -1763,7 +1765,7 @@
$status = Status::newGood( [ 'new' => false, 'revision' => null
] );
// Convenience variables
- $now = wfTimestampNow();
+ $now = $meta['timestamp'];
$oldid = $meta['oldId'];
/** @var $oldContent Content|null */
$oldContent = $meta['oldContent'];
@@ -1928,7 +1930,7 @@
$status = Status::newGood( [ 'new' => true, 'revision' => null
] );
- $now = wfTimestampNow();
+ $now = $meta['timestamp'];
$newsize = $content->getSize();
$prepStatus = $content->prepareSave( $this, $flags,
$meta['oldId'], $user );
$status->merge( $prepStatus );
--
To view, visit https://gerrit.wikimedia.org/r/273608
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idaf093e17e9b9e4d1d644eea38e34939b9a4358e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits