* (bug 12574) Allow bots to specify whether an edit should be marked as a bot
authorDaniel Cannon <amidaniel@users.mediawiki.org>
Thu, 10 Jan 2008 09:54:35 +0000 (09:54 +0000)
committerDaniel Cannon <amidaniel@users.mediawiki.org>
Thu, 10 Jan 2008 09:54:35 +0000 (09:54 +0000)
  edit, via the parameter 'bot'. (Default: '1')

Patch by Cobi <Winbots at gmail dot com>.

RELEASE-NOTES
includes/Article.php
includes/RecentChange.php

index fa39373..69b8fe3 100644 (file)
@@ -122,6 +122,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * When submitting changes on Special:Userrights, show the full form again, not
   just the search box.
 * Added exception hooks
+* (bug 12574) Allow bots to specify whether an edit should be marked as a bot
+  edit, via the parameter 'bot'. (Default: '1')
 
 
 === Bug fixes in 1.12 ===
index 473e01d..bca4461 100644 (file)
@@ -1298,7 +1298,7 @@ class Article {
         * @return bool success
         */
        function doEdit( $text, $summary, $flags = 0 ) {
-               global $wgUser, $wgDBtransactions;
+               global $wgUser, $wgDBtransactions, $wgRequest;
 
                wfProfileIn( __METHOD__ );
                $good = true;
@@ -1323,7 +1323,7 @@ class Article {
 
                # Silently ignore EDIT_MINOR if not allowed
                $isminor = ( $flags & EDIT_MINOR ) && $wgUser->isAllowed('minoredit');
-               $bot = $wgUser->isAllowed( 'bot' ) || ( $flags & EDIT_FORCE_BOT );
+               $bot = ( $wgUser->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0 ) || ( $flags & EDIT_FORCE_BOT );
 
                $oldtext = $this->getContent();
                $oldsize = strlen( $oldtext );
@@ -2280,7 +2280,7 @@ class Article {
         * @return self::SUCCESS on succes, self::* on failure
         */
        public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails ) {
-               global $wgUser, $wgUseRCPatrol;
+               global $wgUser, $wgUseRCPatrol, $wgRequest;
                $resultDetails = null;
 
                # Just in case it's being called from elsewhere         
@@ -2368,7 +2368,7 @@ class Article {
                if ($wgUser->isAllowed('minoredit'))
                        $flags |= EDIT_MINOR;
 
-               if( $bot )
+               if( $bot && $wgRequest->getBool( 'bot' , true ) )
                        $flags |= EDIT_FORCE_BOT;
                $this->doEdit( $target->getText(), $summary, $flags );
 
index 41af45a..2db82ca 100644 (file)
@@ -262,8 +262,13 @@ class RecentChange
                $newId = 0)
        {
 
+               global $wgRequest;
+
                if ( $bot === 'default' ) {
                        $bot = $user->isAllowed( 'bot' );
+                       if ( $bot ) {
+                               $bot = $wgRequest->getBool( 'bot' , true );
+                       }
                }
 
                if ( !$ip ) {
@@ -315,6 +320,8 @@ class RecentChange
        public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = 'default',
          $ip='', $size = 0, $newId = 0 )
        {
+               global $wgRequest;
+
                if ( !$ip ) {
                        $ip = wfGetIP();
                        if ( !$ip ) {
@@ -323,6 +330,9 @@ class RecentChange
                }
                if ( $bot === 'default' ) {
                        $bot = $user->isAllowed( 'bot' );
+                       if ( $bot ) {
+                               $bot = $wgRequest->getBool( 'bot' , true );
+                       }
                }
 
                $rc = new RecentChange;
@@ -362,6 +372,8 @@ class RecentChange
        # Makes an entry in the database corresponding to a rename
        public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
        {
+               global $wgRequest;
+
                if ( !$ip ) {
                        $ip = wfGetIP();
                        if ( !$ip ) {
@@ -383,7 +395,7 @@ class RecentChange
                        'rc_comment'    => $comment,
                        'rc_this_oldid' => 0,
                        'rc_last_oldid' => 0,
-                       'rc_bot'        => $user->isAllowed( 'bot' ) ? 1 : 0,
+                       'rc_bot'        => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
                        'rc_moved_to_ns'        => $newTitle->getNamespace(),
                        'rc_moved_to_title'     => $newTitle->getDBkey(),
                        'rc_ip'         => $ip,
@@ -414,6 +426,8 @@ class RecentChange
        public static function notifyLog( $timestamp, &$title, &$user, $comment, $ip='',
           $type, $action, $target, $logComment, $params )
        {
+               global $wgRequest;
+
                if ( !$ip ) {
                        $ip = wfGetIP();
                        if ( !$ip ) {
@@ -435,7 +449,7 @@ class RecentChange
                        'rc_comment'    => $comment,
                        'rc_this_oldid' => 0,
                        'rc_last_oldid' => 0,
-                       'rc_bot'        => $user->isAllowed( 'bot' ) ? 1 : 0,
+                       'rc_bot'        => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot' , true ) : 0,
                        'rc_moved_to_ns'        => 0,
                        'rc_moved_to_title'     => '',
                        'rc_ip' => $ip,