r92277 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92276‎ | r92277 | r92278 >
Date:19:00, 15 July 2011
Author:werdna
Status:deferred (Comments)
Tags:
Comment:
MoodBar: store edit count at time of feedback in the database.
Modified paths:
  • /trunk/extensions/MoodBar/FeedbackItem.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.hooks.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.i18n.php (modified) (history)
  • /trunk/extensions/MoodBar/SpecialMoodBar.php (modified) (history)
  • /trunk/extensions/MoodBar/sql/MoodBar.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/sql/MoodBar.sql
@@ -5,6 +5,7 @@
66 -- User who provided the feedback
77 mbf_user_id int unsigned NOT NULL, -- User ID, or zero
88 mbf_user_ip varchar(255) binary NULL, -- If anonymous, user's IP address
 9+ mbf_user_editcount int unsigned NOT NULL, -- Edit count of the user
910
1011 -- Page where the feedback was received
1112 -- Nullable.
Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -46,6 +46,7 @@
4747 'moodbar-header-locale' => 'Locale',
4848 'moodbar-header-useragent' => 'User-Agent',
4949 'moodbar-header-comment' => 'Comments',
 50+ 'moodbar-header-user-editcount' => 'User edit count',
5051 );
5152
5253 /** Message documentation (Message documentation)
Index: trunk/extensions/MoodBar/FeedbackItem.php
@@ -25,6 +25,7 @@
2626 'locale',
2727 'editmode',
2828 'bucket',
 29+ 'user-editcount',
2930 );
3031
3132 /** Valid values for the 'type' parameter. **/
@@ -100,6 +101,7 @@
101102 'locale' => $row->mbf_locale,
102103 'bucket' => $row->mbf_bucket,
103104 'editmode' => $row->mbf_editing,
 105+ 'user-editcount' => $row->mbf_user_editcount,
104106 );
105107
106108 $properties['page'] = Title::makeTitleSafe( $row->mbf_namespace, $row->mbf_title );
@@ -127,6 +129,14 @@
128130 throw new MWException( "Attempt to set invalid value for $key" );
129131 }
130132
 133+ if ( $key == 'user' ) {
 134+ if ( $user->isAnon() ) {
 135+ $this->setProperty( 'user-editcount', 0 );
 136+ } else {
 137+ $this->setProperty( 'user-editcount', $user->edits() );
 138+ }
 139+ }
 140+
131141 $this->data[$key] = $value;
132142 }
133143 }
@@ -204,6 +214,7 @@
205215 'mbf_locale' => $this->getProperty('locale'),
206216 'mbf_bucket' => $this->getProperty('bucket'),
207217 'mbf_editing' => $this->getProperty('editmode'),
 218+ 'mbf_user_editcount' => $this->getProperty('user-editcount'),
208219 );
209220
210221 $user = $this->getProperty('user');
Index: trunk/extensions/MoodBar/SpecialMoodBar.php
@@ -8,6 +8,7 @@
99 'page',
1010 'usertype',
1111 'user',
 12+ 'user-editcount',
1213 'editmode',
1314 'bucket',
1415 'system',
Index: trunk/extensions/MoodBar/MoodBar.hooks.php
@@ -50,6 +50,10 @@
5151 $updater->addExtensionUpdate( array( 'addTable', 'moodbar_feedback',
5252 dirname(__FILE__).'/sql/MoodBar.sql', true ) );
5353
 54+ $updater->addExtensionUpdate( array( 'addField', 'moodbar_feedback',
 55+ 'mbf_user_editcount', dirname(__FILE__).'/sql/mbf_user_editcount.sql', true )
 56+ );
 57+
5458 return true;
5559 }
5660 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r92509svn add sql/mbf_user_editcount.sqlwerdna23:37, 18 July 2011

Comments

#Comment by Reedy (talk | contribs)   19:58, 15 July 2011

Looks like you didn't svn add sql/mbf_user_editcount.sql

#Comment by Werdna (talk | contribs)   23:38, 18 July 2011

Oops, committed.

#Comment by Werdna (talk | contribs)   23:02, 19 July 2011

It's overwritten in MBFeedbackItem because setProperties() is called by newFromRow

#Comment by Catrope (talk | contribs)   23:18, 19 July 2011

"It" being the user's edit count, which is loaded in two conflicting ways.

#Comment by Werdna (talk | contribs)   23:04, 19 July 2011

(Also, use ! $this->getProperty('id'), instead of a weak comparison with null)

#Comment by Werdna (talk | contribs)   22:10, 20 July 2011

(fixed)

Status & tagging log