https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112603

Revision: 112603
Author:   emsmith
Date:     2012-02-28 15:21:45 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
bug 34090 - Add the logging of automated hide/show errors by the "Article 
Feedback V5" fake user

Modified Paths:
--------------
    trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
    trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php

Modified: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php        
2012-02-28 15:13:50 UTC (rev 112602)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php        
2012-02-28 15:21:45 UTC (rev 112603)
@@ -207,8 +207,9 @@
         * @param $pageId    int    the id of the page so we can look it up
         * @param $itemId    int    the id of the feedback item, used to build 
permalinks
         * @param $notes     string any notes that were stored with the activity
+        * @param $auto      boolean true if this was an "automatic" action, if 
so the log doer is changed
         */
-       public static function logActivity( $type, $pageId, $itemId, $notes) {
+       public static function logActivity( $type, $pageId, $itemId, $notes, 
$auto = false) {
 
                // These are our valid activity log actions
                $valid = array( 'oversight', 'unoversight', 'hidden', 
'unhidden',
@@ -237,9 +238,20 @@
                global $wgArticleFeedbackv5MaxActivityNoteLength;
                $notes = substr($notes, 0, 
$wgArticleFeedbackv5MaxActivityNoteLength);
 
+               // if this is an automatic action, we create our special 
extension doer and send
+               if ($auto) {
+                       $doer = User::newFromName( 'Article Feedback V5' );
+                       // I cannot see how this could fail, but if it does do 
not log
+                       if (!$doer) {
+                               return;
+                       }
+               } else {
+                       $doer = null;
+               }
+
                $log = new LogPage( 'articlefeedbackv5' );
                // comments become the notes section from the feedback
-               $log->addEntry( $type, $title, $notes );
+               $log->addEntry( $type, $permalink, $notes, array(), $doer);
 
                // update our log count by 1
                $dbw = wfGetDB( DB_MASTER );

Modified: 
trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php 
2012-02-28 15:13:50 UTC (rev 112602)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php 
2012-02-28 15:21:45 UTC (rev 112603)
@@ -328,7 +328,15 @@
                                ApiArticleFeedbackv5Utils::logActivity( 
$activity , $pageId, $feedbackId, $notes );
                        }
 
-                       // TODO: handle implicit hide/show logging
+                       // handle implicit hide/show logging
+                       if ( isset( $implicit_hide ) || isset ( 
$implicit_unhide )) {
+                               if ( $implicit_hide ) {
+                                       $activity = 'hidden';
+                               } else {
+                                       $activity = 'show';
+                               }
+                               ApiArticleFeedbackv5Utils::logActivity( 
$activity , $pageId, $feedbackId, '', true);
+                       }
 
                        // Update helpful/unhelpful display count after 
submission.
                        if ( $flag == 'helpful' || $flag == 'unhelpful' ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to