* $wgRequest shouldn't be used in functions like Article::doEdit() that are also called by API modules
* Moving code that decides whether the edit is bot out of DB logic and into UI logic: API and UI each decide indepentently from one another
* Removing $bot==='default' behavior from RecentChange::notifyEdit() and notifyNew(): nobody uses it, and it shouldn't be used anyway; whether the edit is bot should've been decided long ago
/**
* @deprecated use Article::doEdit()
*/
- function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false ) {
+ function insertNewArticle( $text, $summary, $isminor, $watchthis, $suppressRC=false, $comment=false, $bot=false ) {
$flags = EDIT_NEW | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
( $isminor ? EDIT_MINOR : 0 ) |
( $suppressRC ? EDIT_SUPPRESS_RC : 0 );
* @return bool success
*/
function doEdit( $text, $summary, $flags = 0 ) {
- global $wgUser, $wgDBtransactions, $wgRequest;
+ global $wgUser, $wgDBtransactions;
wfProfileIn( __METHOD__ );
$good = true;
# Silently ignore EDIT_MINOR if not allowed
$isminor = ( $flags & EDIT_MINOR ) && $wgUser->isAllowed('minoredit');
- $bot = ( $wgUser->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0 ) || ( $flags & EDIT_FORCE_BOT );
+ $bot = $flags & EDIT_FORCE_BOT;
$oldtext = $this->getContent();
$oldsize = strlen( $oldtext );
* @return self::SUCCESS on succes, self::* on failure
*/
public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails ) {
- global $wgUser, $wgUseRCPatrol, $wgRequest;
+ global $wgUser, $wgUseRCPatrol;
$resultDetails = null;
# Just in case it's being called from elsewhere
if ($wgUser->isAllowed('minoredit'))
$flags |= EDIT_MINOR;
- if( $bot && $wgRequest->getBool( 'bot' , true ) )
+ if( $bot )
$flags |= EDIT_FORCE_BOT;
$this->doEdit( $target->getText(), $summary, $flags );
* Attempt submission (no UI)
* @return one of the constants describing the result
*/
- function internalAttemptSave( &$result ) {
+ function internalAttemptSave( &$result, $bot = false ) {
global $wgSpamRegex, $wgFilterCallback, $wgUser, $wgOut, $wgParser;
global $wgMaxArticleSize, $wgTitle;
$isComment = ( $this->section == 'new' );
$this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
- $this->minoredit, $this->watchthis, false, $isComment);
+ $this->minoredit, $this->watchthis, false, $isComment, $bot);
wfProfileOut( $fname );
return self::AS_SUCCESS_NEW_ARTICLE;
# update the article here
if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
- $this->watchthis, '', $sectionanchor ) ) {
+ $this->watchthis, $bot, $sectionanchor ) ) {
wfProfileOut( $fname );
return self::AS_SUCCESS_UPDATE;
} else {
* @return bool false if output is done, true if the rest of the form should be displayed
*/
function attemptSave() {
- global $wgUser, $wgOut, $wgTitle;
+ global $wgUser, $wgOut, $wgTitle, $wgRequest;
$resultDetails = false;
- $value = $this->internalAttemptSave( $resultDetails );
+ $value = $this->internalAttemptSave( $resultDetails, $wgUser->isAllowed('bot') && $wgRequest->getBool('bot', true) );
if( $value == self::AS_SUCCESS_UPDATE || $value == self::AS_SUCCESS_NEW_ARTICLE ) {
$this->didSave = true;
# Makes an entry in the database corresponding to an edit
public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
- $oldId, $lastTimestamp, $bot = "default", $ip = '', $oldSize = 0, $newSize = 0,
+ $oldId, $lastTimestamp, $bot, $ip = '', $oldSize = 0, $newSize = 0,
$newId = 0)
{
global $wgRequest;
- if ( $bot === 'default' ) {
- $bot = $user->isAllowed( 'bot' );
- if ( $bot ) {
- $bot = $wgRequest->getBool( 'bot' , true );
- }
- }
-
if ( !$ip ) {
$ip = wfGetIP();
if ( !$ip ) {
* Note: the title object must be loaded with the new id using resetArticleID()
* @todo Document parameters and return
*/
- public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = 'default',
+ public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot,
$ip='', $size = 0, $newId = 0 )
{
- global $wgRequest;
-
if ( !$ip ) {
$ip = wfGetIP();
if ( !$ip ) {
$ip = '';
}
}
- if ( $bot === 'default' ) {
- $bot = $user->isAllowed( 'bot' );
- if ( $bot ) {
- $bot = $wgRequest->getBool( 'bot' , true );
- }
- }
$rc = new RecentChange;
$rc->mAttribs = array(