Umherirrender has uploaded a new change for review.
https://gerrit.wikimedia.org/r/130096
Change subject: Add $user param to Revision::newNullRevision
......................................................................
Add $user param to Revision::newNullRevision
This avoids the use of $wgUser in Revision constructor and makes the
dependency on the global visible.
Change-Id: Ib67bd706a3c4ef081f475406e9aa1094c42222ef
---
M includes/Revision.php
M includes/Title.php
M includes/WikiPage.php
M includes/filerepo/file/LocalFile.php
M includes/specials/SpecialImport.php
5 files changed, 17 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/96/130096/1
diff --git a/includes/Revision.php b/includes/Revision.php
index 7b30540..afbd3ac 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -1566,9 +1566,10 @@
* @param int $pageId: ID number of the page to read from
* @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
* @return Revision|null Revision or null on error
*/
- public static function newNullRevision( $dbw, $pageId, $summary, $minor
) {
+ public static function newNullRevision( $dbw, $pageId, $summary,
$minor, $user = null ) {
global $wgContentHandlerUseDB;
wfProfileIn( __METHOD__ );
@@ -1591,8 +1592,15 @@
__METHOD__ );
if ( $current ) {
+ if ( !$user ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
+
$row = array(
'page' => $pageId,
+ 'user_text' => $user->getName(),
+ 'user' => $user->getId(),
'comment' => $summary,
'minor_edit' => $minor,
'text_id' => $current->rev_text_id,
diff --git a/includes/Title.php b/includes/Title.php
index 4dc0372..eec4dd6 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -3859,7 +3859,7 @@
}
# Save a null revision in the page's history notifying of the
move
- $nullRevision = Revision::newNullRevision( $dbw, $oldid,
$comment, true );
+ $nullRevision = Revision::newNullRevision( $dbw, $oldid,
$comment, true, $wgUser );
if ( !is_object( $nullRevision ) ) {
throw new MWException( 'No valid null revision produced
in ' . __METHOD__ );
}
diff --git a/includes/WikiPage.php b/includes/WikiPage.php
index 8e15ac9..161125d 100644
--- a/includes/WikiPage.php
+++ b/includes/WikiPage.php
@@ -2407,7 +2407,7 @@
// insert null revision to identify the page protection
change as edit summary
$latest = $this->getLatest();
- $nullRevision = $this->insertProtectNullRevision(
$revCommentMsg, $limit, $expiry, $cascade, $reason );
+ $nullRevision = $this->insertProtectNullRevision(
$revCommentMsg, $limit, $expiry, $cascade, $reason, $user );
if ( $nullRevision === null ) {
return Status::newFatal( 'no-null-revision',
$this->mTitle->getPrefixedText() );
}
@@ -2506,9 +2506,10 @@
* @param array $expiry Per restriction type expiration
* @param int $cascade Set to false if cascading protection isn't
allowed.
* @param string $reason
+ * @param User|null $user
* @return Revision|null Null on error
*/
- public function insertProtectNullRevision( $revCommentMsg, array
$limit, array $expiry, $cascade, $reason ) {
+ public function insertProtectNullRevision( $revCommentMsg, array
$limit, array $expiry, $cascade, $reason, $user = null ) {
global $wgContLang;
$dbw = wfGetDB( DB_MASTER );
@@ -2534,7 +2535,7 @@
)->inContentLanguage()->text();
}
- $nullRev = Revision::newNullRevision( $dbw, $this->getId(),
$editComment, true );
+ $nullRev = Revision::newNullRevision( $dbw, $this->getId(),
$editComment, true, $user );
if ( $nullRev ) {
$nullRev->insertOn( $dbw );
diff --git a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index e3b73e3..5bc7b5e 100644
--- a/includes/filerepo/file/LocalFile.php
+++ b/includes/filerepo/file/LocalFile.php
@@ -1424,7 +1424,8 @@
$dbw,
$descTitle->getArticleID(),
$editSummary,
- false
+ false,
+ $user
);
if ( !is_null( $nullRevision ) ) {
$nullRevision->insertOn( $dbw );
diff --git a/includes/specials/SpecialImport.php
b/includes/specials/SpecialImport.php
index aca8c96..891962b 100644
--- a/includes/specials/SpecialImport.php
+++ b/includes/specials/SpecialImport.php
@@ -492,7 +492,7 @@
$comment = $detail; // quick
$dbw = wfGetDB( DB_MASTER );
$latest = $title->getLatestRevID();
- $nullRevision = Revision::newNullRevision( $dbw,
$title->getArticleID(), $comment, true );
+ $nullRevision = Revision::newNullRevision( $dbw,
$title->getArticleID(), $comment, true, $this->getUser() );
if ( !is_null( $nullRevision ) ) {
$nullRevision->insertOn( $dbw );
$page = WikiPage::factory( $title );
--
To view, visit https://gerrit.wikimedia.org/r/130096
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib67bd706a3c4ef081f475406e9aa1094c42222ef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits