jenkins-bot has submitted this change and it was merged.
Change subject: Edit via the API instead of WikiPage::doEditContent.
......................................................................
Edit via the API instead of WikiPage::doEditContent.
The API will automatically check permissions and other sanity checks that we
would have bypassed.
We are forced to override the global $wgUser since EditPage uses it when
figuring out who is editing.
Any errors raised by the API will be logged to Special:Log.
Change-Id: Ib51f2f4a65a45d70e278c13c198733fd47bc3229
---
M MassMessageJob.php
1 file changed, 30 insertions(+), 10 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MassMessageJob.php b/MassMessageJob.php
index 79be647..0fccd76 100644
--- a/MassMessageJob.php
+++ b/MassMessageJob.php
@@ -93,17 +93,37 @@
return true;
}
- // Mark the edit as bot
- $flags = $flags | EDIT_FORCE_BOT;
+ $this->editPage();
- $status = $talkPage->doEditContent(
- ContentHandler::makeContent( $text, $this->title ),
- $this->params['subject'],
- $flags,
- false,
- $user
+ return true;
+ }
+
+ function editPage() {
+ global $wgUser, $wgRequest;
+ $user = MassMessage::getMessengerUser();
+ $wgUser = $user; // Is this safe? We need to do this for
EditPage.php
+ $api = new ApiMain(
+ new DerivativeRequest(
+ $wgRequest,
+ array(
+ 'action' => 'edit',
+ 'title' =>
$this->title->getPrefixedText(),
+ 'section' => 'new',
+ 'summary' => $this->params['subject'],
+ 'text' => $this->params['message'],
+ 'notminor' => true,
+ 'bot' => true,
+ 'token' => $user->getEditToken()
+ ),
+ true // was posted?
+ ),
+ true // enable write?
);
-
- return $status->isGood();
+ $api->getContext()->setUser( $user );
+ try {
+ $api->execute();
+ } catch ( UsageException $e ) {
+ $this->logLocalFailure( $this->title,
$this->params['subject'], $e->getCodeString() );
+ }
}
}
--
To view, visit https://gerrit.wikimedia.org/r/75299
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib51f2f4a65a45d70e278c13c198733fd47bc3229
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits