r111211 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111210‎ | r111211 | r111212 >
Date:22:53, 10 February 2012
Author:emsmith
Status:resolved (Comments)
Tags:i18nreview 
Comment:
bug 34090 - Added a log namespace and log types for the Article Feedback v5 extension to create a log of all activity that takes place to feedback including abuse flagging, hiding and unhiding, and other actions. This is not entirely finished, there are two known cases (decline oversight and auto-hide) that are not yet being logged properly and because the extension doesn't have notes/reasons for activity in place yet there is placeholder text instead. For now activity can be viewed on the special:logs page. The api hooks are not yet complete for the feedback page.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -263,6 +263,19 @@
264264 'right-aftv5-see-deleted-feedback' => 'View deleted feedback',
265265 'right-aftv5-see-hidden-feedback' => 'View hidden feedback',
266266
 267+ // Log types
 268+ 'articlefeedbackv5-log-name' => 'Article Feedback Activity Log',
 269+ 'articlefeedbackv5-log-header' => 'This is the log of activity taken on feedback items collected for articles using Article Feedback.',
 270+ 'articlefeedbackv5-log-oversight' => 'changed the feedback [[$1]] status to oversight',
 271+ 'articlefeedbackv5-log-unoversight' => 'removed the oversight [[$1]] status from feedback',
 272+ 'articlefeedbackv5-log-hidden' => 'hid the feedback [[$1]]',
 273+ 'articlefeedbackv5-log-unhidden' => 'unhid the feedback [[$1]]',
 274+ 'articlefeedbackv5-log-decline' => 'declined oversight request from the feedback [[$1]]',
 275+ 'articlefeedbackv5-log-request' => 'requested oversight on the feedback [[$1]]',
 276+ 'articlefeedbackv5-log-unrequest' => 'removed the requested oversight on the feedback [[$1]]',
 277+ 'articlefeedbackv5-log-flag' => 'flagged the feedback [[$1]] as abuse',
 278+ 'articlefeedbackv5-log-unflag' => 'unflagged the feedback [[$1]] as abuse',
 279+
267280 /* EmailCapture */
268281 'articlefeedbackv5-emailcapture-response-body' => 'Hello!
269282
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php
@@ -287,3 +287,17 @@
288288 $wgAvailableRights[] = 'aftv5-delete-feedback';
289289 $wgAvailableRights[] = 'aftv5-see-deleted-feedback';
290290 $wgAvailableRights[] = 'aftv5-see-hidden-feedback';
 291+
 292+// Logging
 293+$wgLogTypes[] = 'articlefeedbackv5';
 294+$wgLogNames['articlefeedbackv5'] = 'articlefeedbackv5-log-name';
 295+$wgLogHeaders['articlefeedbackv5'] = 'articlefeedbackv5-log-header';
 296+$wgLogActions['articlefeedbackv5/oversight'] = 'articlefeedbackv5-log-oversight';
 297+$wgLogActions['articlefeedbackv5/unoversight'] = 'articlefeedbackv5-log-unoversight';
 298+$wgLogActions['articlefeedbackv5/hidden'] = 'articlefeedbackv5-log-hidden';
 299+$wgLogActions['articlefeedbackv5/unhidden'] = 'articlefeedbackv5-log-unhidden';
 300+$wgLogActions['articlefeedbackv5/decline'] = 'articlefeedbackv5-log-decline';
 301+$wgLogActions['articlefeedbackv5/request'] = 'articlefeedbackv5-log-request';
 302+$wgLogActions['articlefeedbackv5/unrequest'] = 'articlefeedbackv5-log-unrequest';
 303+$wgLogActions['articlefeedbackv5/flag'] = 'articlefeedbackv5-log-flag';
 304+$wgLogActions['articlefeedbackv5/unflag'] = 'articlefeedbackv5-log-unflag';
\ No newline at end of file
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -24,6 +24,7 @@
2525 public function execute() {
2626 $params = $this->extractRequestParams();
2727 $pageId = $params['pageid'];
 28+ $feedbackId = $params['feedbackid'];
2829 $flag = $params['flagtype'];
2930 $direction = isset( $params['direction'] ) ? $params['direction'] : 'increase';
3031 $counts = array( 'increment' => array(), 'decrement' => array() );
@@ -32,15 +33,16 @@
3334 $results = array();
3435 $helpful = null;
3536 $error = null;
36 - $where = array( 'af_id' => $params['feedbackid'] );
 37+ $where = array( 'af_id' => $feedbackId );
3738
3839 # load feedback record, bail if we don't have one
39 - $record = $this->fetchRecord( $params['feedbackid'] );
 40+ $record = $this->fetchRecord( $feedbackId );
4041
4142 if ( $record === false || !$record->af_id ) {
4243 // no-op, because this is already broken
4344 $error = 'articlefeedbackv5-invalid-feedback-id';
4445 } elseif ( in_array( $flag, $flags ) ) {
 46+
4547 $count = null;
4648 switch( $flag ) {
4749 case 'hide':
@@ -159,6 +161,13 @@
160162
161163 // If the query worked...
162164 if( $success ) {
 165+
 166+ // Log the feedback activity entry via the utils method
 167+ $activity = $this->getActivity( $flag, $direction );
 168+
 169+ // TODO: when activities have notes attached, they need to be fed as the last parameter
 170+ ApiArticleFeedbackv5Utils::logActivity( $activity , $pageId, $feedbackId, 'placeholder activity notes' );
 171+
163172 // Update the filter count rollups.
164173 ApiArticleFeedbackv5Utils::incrementFilterCounts( $pageId, $counts['increment'] );
165174 ApiArticleFeedbackv5Utils::decrementFilterCounts( $pageId, $counts['decrement'] );
@@ -193,6 +202,7 @@
194203 __METHOD__
195204 );
196205 }
 206+
197207 }
198208
199209 // Conditional formatting for abuse flag
@@ -336,6 +346,47 @@
337347 }
338348
339349 /**
 350+ * Figures out which activity happened so it can be logged correctly
 351+ *
 352+ * @param $flag string type of flag sent to the form
 353+ * @param $direction string type of direction sent to the form
 354+ * @return string name of activity to log
 355+ */
 356+ protected function getActivity($flag, $direction) {
 357+
 358+ // handle flag as abuse / remove abuse flag
 359+ if ( 'abuse' == $flag && 'increase' == $direction) {
 360+ return 'flag';
 361+ } elseif ( 'abuse' == $flag && 'decrease' == $direction) {
 362+ return 'unflag';
 363+ }
 364+
 365+ // handle hide as hidden, unhidden
 366+ if ( 'hide' == $flag && 'increase' == $direction) {
 367+ return 'hidden';
 368+ } elseif ( 'hide' == $flag && 'decrease' == $direction) {
 369+ return 'unhidden';
 370+ }
 371+
 372+ // handle delete as oversight, unoversight
 373+ if ( 'delete' == $flag && 'increase' == $direction) {
 374+ return 'oversight';
 375+ } elseif ( 'delete' == $flag && 'decrease' == $direction) {
 376+ return 'unoversight';
 377+ }
 378+
 379+ // handle oversight as request and unrequest oversighting
 380+ if ( 'oversight' == $flag && 'increase' == $direction) {
 381+ return 'request';
 382+ } elseif ( 'oversight' == $flag && 'decrease' == $direction) {
 383+ return 'unrequest';
 384+ }
 385+
 386+ // TODO: how is "decline oversight" handled?
 387+ // how should fall out the bottom here be handled? a simple "feedback altered"?
 388+ }
 389+
 390+ /**
340391 * Gets the version info
341392 *
342393 * @return string the SVN version info
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
@@ -215,4 +215,36 @@
216216
217217 $dbw->commit();
218218 }
 219+
 220+ /**
 221+ * Adds an activity item to the global log under the articlefeedbackv5
 222+ *
 223+ * @param $type string the type of activity we'll be logging
 224+ * @param $pageId int the id of the page so we can look it up
 225+ * @param $itemId int the id of the feedback item, used to build permalinks
 226+ * @param $notes string any notes that were stored with the activity
 227+ */
 228+ public static function logActivity( $type, $pageId, $itemId, $notes) {
 229+
 230+ // These are our valid activity log actions
 231+ $valid = array( 'oversight', 'unoversight', 'hidden', 'unhidden',
 232+ 'decline', 'request', 'unrequest','flag','unflag' );
 233+
 234+ // if we do not have a valid action, return immediately
 235+ if ( !in_array( $type, $valid )) {
 236+ return;
 237+ }
 238+
 239+ // create a title for the page
 240+ $page = Title::newFromID( $pageId );
 241+ $title = $page->getPartialURL();
 242+
 243+ // to build our permalink, use the feedback entry key
 244+ $title = SpecialPage::getTitleFor( 'ArticleFeedbackv5', "$title/$itemId" );
 245+
 246+ $log = new LogPage( 'articlefeedbackv5' );
 247+ // comments become the notes section from the feedback
 248+ $log->addEntry( $type, $title, $notes );
 249+ }
219250 }
 251+

Follow-up revisions

RevisionCommit summaryAuthorDate
r111474bug 34090 - remove a todo - take the note from the flag submission and save i...emsmith19:57, 14 February 2012
r111552bug 34090 - split activity notes into their own config for maximum length (th...emsmith16:07, 15 February 2012
r111557bug 34090 - changed structure of the link classes and ids per the following f...emsmith16:47, 15 February 2012
r111570bug 34090 - request oversight is now a counter - so you can request/unrequest...emsmith19:53, 15 February 2012
r111573bug 34090 - removed the "header" portion of the html generation from the acti...emsmith20:18, 15 February 2012
r111645bug 34090 - updated the filter count update script to get requested oversight...emsmith15:45, 16 February 2012
r112038bug 34090 - added additional counts for filters including unhidden, undeleted...emsmith20:28, 21 February 2012
r112039bug 34090 - fixed issue noted : if $feedback is false return nothing - not th...emsmith20:50, 21 February 2012
r112041bug 34090 - kill the -1 issue by never letting it get below 0emsmith21:08, 21 February 2012
r112115bug 34090 - no code changes, just fixing/adding keyword svn propertiesemsmith16:31, 22 February 2012
r112119bug 34090 - cast the naughty column so it can be signed, the greatest still k...emsmith16:57, 22 February 2012
r112142bug 34090 - toggle for atomic un/helpful changing (and elimination of an extr...emsmith20:37, 22 February 2012
r112147bug 34090 - note to self, watch the copy and paste errors...emsmith21:01, 22 February 2012
r112149bug 34090 - no upper limit, only lower limit - we can't get any worse then 0emsmith21:21, 22 February 2012
r112154bug 34090 - quick and dirty helper script to get missing documentation keysemsmith21:57, 22 February 2012
r112156bug 34090 - only send the activity header if continue < 1, make the more div ...emsmith22:14, 22 February 2012
r112161bug 34090 - fix limit and use old continue to determine if we do the headeremsmith23:15, 22 February 2012
r112218bug 34090 - make sure the name are right for hidden/unhidden logging (argh)emsmith16:44, 23 February 2012
r112225bug 34090 - unhidden and unoversight logic adjustmentsemsmith18:06, 23 February 2012
r112228bug 34090 - fix filter - needsoversight are always autohiddenemsmith19:16, 23 February 2012
r112230bug 34090 - let's try this again - needsoversight and declined will have hidd...emsmith19:38, 23 February 2012
r112232bug 34090 - hide and show shouldn't fiddle with oversight counts or declined ...emsmith19:48, 23 February 2012
r112599bug 34090 - follow up to r111211 - rename things to make them "less confusin...emsmith14:43, 28 February 2012
r112603bug 34090 - Add the logging of automated hide/show errors by the "Article Fee...emsmith15:21, 28 February 2012
r112604bug 34090 - can't believe there were no permissions checks in this - only del...emsmith15:38, 28 February 2012
r112610bug 34090 - change all sql updates to use escaping except for explicitly comm...emsmith16:22, 28 February 2012
r112611bug 34090 - take out implicit show and add returning user that hid/oversighte...emsmith17:02, 28 February 2012
r112627bug 34090 - follow up to r112599 - change to use getText since it's going int...emsmith18:53, 28 February 2012
r112825bug 34090 - insert custom attributes (sigh) for the user and formatted timest...emsmith18:14, 1 March 2012
r112830bug 34090 - follow up to r111474 - use truncate for choppingemsmith19:42, 1 March 2012
r113052bug 34090 - remaining backend feature in requirements, oversight email genera...emsmith18:04, 5 March 2012
r113062bug 34090 - follow up to r110520 1. change index 2. default of null for conti...emsmith18:54, 5 March 2012
r113073bug 34090 - follow up to r111472 part 1 - change to use getDbKey, check for b...emsmith19:48, 5 March 2012
r113082bug 34090 - follow up to r111471 - changed to use text()emsmith20:42, 5 March 2012
r113083bug 34090 - follow up to rr111472 part 2 - only use log_id for orderingemsmith20:48, 5 March 2012
r113104bug 34090 - follow up to rr111472 part 3 - totally redo the continue function...emsmith23:10, 5 March 2012
r113159bug 34090 - follow up to rr111472 part 4 and follow up to r111596 (same issue...emsmith17:37, 6 March 2012
r113160bug 34090 - follow up to rr111472 part 5 plural and number format action countemsmith17:48, 6 March 2012
r113161bug 34090 - follow up to rr111472 part 6 last of lego messagesemsmith17:53, 6 March 2012
r113163bug 34090 - two additional configuration settings (help url and admin user ur...emsmith18:02, 6 March 2012
r113193bug 34090 - followup to r113104 - only sort by timestamp (sorting by log id w...emsmith22:56, 6 March 2012
r113228bug 34090 - followup to r113160emsmith14:05, 7 March 2012
r113247bug 34090 - db issue, remove one of the sorts from the query, use the ids arr...emsmith16:52, 7 March 2012
r113269bug 34090 - followup to r113247emsmith19:01, 7 March 2012
r113273bug 34090 - add javascript level hiding on request oversight IF autohidden is...emsmith19:22, 7 March 2012
r113287bug 34090 - usernames and formatted timestamps into red lines for hidden/over...emsmith20:22, 7 March 2012
r113311bug 34090 - fixing the username bugs - apparently using the data- stuff with ...emsmith22:34, 7 March 2012
r113317bug 34090 - js and css voodoo to make the element with the red lines appear a...emsmith23:01, 7 March 2012
r113370bug 34090 - make different titles for masking appear if it's been hidden or o...emsmith16:43, 8 March 2012
r113371bug 34090 - fixes for oversighter view for hide/oversight panelsemsmith17:51, 8 March 2012
r113383bug 34090 - not entirely necessary, but keeps $2 from showing up in hiders pa...emsmith19:25, 8 March 2012
r113384bug 34090 - fix for double red line issues when hiding an oversighted post ha...emsmith19:28, 8 March 2012
r113390bug 34090 - adding translation for "automatic hider" useremsmith19:44, 8 March 2012
r113392bug 34090 - followup to r113287 - adjusted localization documentationemsmith20:03, 8 March 2012
r113393bug 34090 - followup to r113370 - adjusted localization documentationemsmith20:05, 8 March 2012

Comments

#Comment by Catrope (talk | contribs)   02:17, 28 February 2012
+ $page = Title::newFromID( $pageId );
+ $title = $page->getPartialURL();

You're using $page for the Title object, and then $title for something that is not a Title object, and then $title for something that is a Title object? That's a bit confusing. Also, unless the page ID has been validated before this point, Title::newFromID() might return null if fed a nonexistent page ID, which would cause the line below to explode with a fatal error.

Marking fixme for the fatal error issue.

#Comment by Elizabeth M Smith (talk | contribs)   14:49, 28 February 2012

What I need to do is rather confusing - the permalink structure of all feedback is $string_title_of_page/$feedbackId - I only have the pageId - which means some running around looking stuff up to get the title of the page to build the permalink to stick it in the log

Tried to comment/rename to make that clearer

If this was sent a bogus page id, bail and skip the logging

fixed in r112599

Status & tagging log