Last modified: 2013-07-25 07:03:28 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T46917, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 44917 - Merging users fails to merge edit counts.
Merging users fails to merge edit counts.
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
UserMerge (Other open bugs)
master
All All
: Normal normal with 1 vote (vote)
: ---
Assigned To: T. Gries
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-12 20:55 UTC by Technical 13
Modified: 2013-07-25 07:03 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Git Diff of my updates. (1.28 KB, patch)
2013-05-30 03:51 UTC, iboyinc
Details

Description Technical 13 2013-02-12 20:55:55 UTC
When merging two users with https://www.mediawiki.org/wiki/Extension:User_Merge_and_Delete the edits are merged, but the edit count is not updated as a total of all merged edits.

As you can see on http://ddowiki.com/page/Special:Contributions/ShoeMaker where I merged an account that had 12 edits with an account that had only 1 edit, in the top left corner of the page it is still reporting that "This user has made one edit." then goes on to list all 13.
Comment 1 Technical 13 2013-03-08 19:34:30 UTC
Forgot to note that we are using User Merge and Delete (Version 1.6.31) 	(r115688) on my wiki and I'm not sure if this may have been fixed in 1.7.  If so, please comment as such and close it as resolved.
Comment 2 T. Gries 2013-03-08 19:57:46 UTC
Let's keep it open. I will check the issue wit the edit counts later.
Comment 3 iboyinc 2013-05-21 01:40:34 UTC
G'day all,

Which version I have, no idea.  But I've downed the Git Snapshot from http://www.mediawiki.org/wiki/Extension:User_Merge_and_Delete so I only assume I have 1.7.

I got the <insert vulgarity> with it and found the prob.  selectField returns (in this case) an int and not an array of ints.  Below is a patch.  I also updated the "print" statement to output the counts rather than the user ids.

        /**
         * Function to add edit count
         *
         * Adds edit count of both users
         *
         * @param $newuserID int ID of user to merge references TO
         * @param $olduserID int ID of user to remove references FROM
         *
         * @return bool Always returns true - throws exceptions on failure.
         *
         * @author Matthew April <Matthew.April@tbs-sct.gc.ca>
         */
        private function mergeEditcount( $newuserID, $olduserID ) {
                $dbw = wfGetDB( DB_MASTER );

                # old user edit count
                $oldEdits = $dbw->selectField( 'user',
                                'user_editcount',
                                array( 'user_id' => $olduserID ),
                                __METHOD__
                          );

                # new user edit count
                $newEdits = $dbw->selectField( 'user',
                                'user_editcount',
                                array( 'user_id' => $newuserID ),
                                __METHOD__
                          );

                # add edits
                $totalEdits = $oldEdits + $newEdits;

                # don't run querys if neither user has any edits
                if ( $totalEdits > 0 ) {
                        # update new user with total edits
                        $dbw->update( 'user',
                                array( 'user_editcount' => $totalEdits ),
                                array( 'user_id' => $newuserID ),
                                __METHOD__
                        );

                        # clear old users edits
                        $dbw->update( 'user',
                                array( 'user_editcount' => 0 ),
                                array( 'user_id' => $olduserID ),
                                __METHOD__
                        );
                }

                $this->getOutput()->addHTML( $this->msg( 'usermerge-editcount-success', $oldEdits, $newEdits )->escaped() . "<br />\n" );

                return true;
        }

Cheers,
Idiot Boy Incorporated
Comment 4 Alex Monk 2013-05-21 18:34:09 UTC
Hi iboyinc. Can you put a patch in Gerrit (our Git code review system) please?
Comment 5 iboyinc 2013-05-30 03:51:50 UTC
Created attachment 12424 [details]
Git Diff of my updates.

Had a surrenderable amount of troubles git-ting behind the corp proxy and so have attached a file containing output of git diff of the changes I made.  I hope this helps any and all.
Comment 6 T. Gries 2013-05-30 05:49:16 UTC
(In reply to comment #1)
> Forgot to note that we are using User Merge and Delete (Version 1.6.31)    
> (r115688) on my wiki and I'm not sure if this may have been fixed in 1.7.  If
> so, please comment as such and close it as resolved.

I looked to extension's version 1.7 in git https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/UserMerge.git;a=blob;f=UserMerge_body.php;h=10a0167c2967557a4aca483de1eb43876fe26ed8;hb=b14eba4f2709cdb18ccbfefec8be462ed37360a3 , and this seems pretty much the same code, i.e. I close this bug here, because it is solved. Please update your mediawiki extensions (always) to the latest versions.

Your database select statements ( $oldedits = selectFields ) are however more elegant than the present version in git, and perhaps I upgrade them using your syntax (later).

For the time being: please can you confirm here, that the code in git is working ?
Comment 7 T. Gries 2013-05-30 06:18:03 UTC
I close the bug now, because the problem is - according to me - solved the git version of the extension.

If you think, that this is not the case, please feel free to reopen the bug.
Comment 8 iboyinc 2013-05-30 11:34:22 UTC
The difference was that in the current Git version, [old,new]Edit was equated to the first item in the array result.  This is a bug as SelectField returns a value, not an array.

I confirm that the changes I made, as detailed in the 4th comment and in the attached git diff, work.

Cheers,
Idiot Boy Supremo
Comment 9 iboyinc 2013-05-30 11:41:37 UTC
The other solution to get the current HEAD to work is to change SelectField to SelectFields.
Comment 10 Gerrit Notification Bot 2013-05-30 18:42:06 UTC
Related URL: https://gerrit.wikimedia.org/r/66139 (Gerrit Change Ic837e2f84ad793d6f48b508d16919332812be6ac)
Comment 11 T. Gries 2013-05-30 19:14:53 UTC
fixed in https://bugzilla.wikimedia.org/44917
Comment 12 T. Gries 2013-05-30 19:24:23 UTC
(In reply to comment #11)
> fixed in https://bugzilla.wikimedia.org/44917

fixed in https://gerrit.wikimedia.org/r/#/c/66139/

;-)
Comment 13 Andre Klapper 2013-05-31 11:07:16 UTC
T. Gries: If you move the bug number from the first line to the last line, there will be automatic notifications by Gerrit into the corresponding bug report. See http://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines
Comment 14 T. Gries 2013-05-31 21:18:31 UTC
(In reply to comment #13)
> If you move the bug number from the first line to the last line,
> there will be automatic notifications by Gerrit into the corresponding bug
> report. See http://www.mediawiki.org/wiki/Gerrit/Commit_message_guidelines

okay, thanks for letting me know. I will use this concept for future commits.
Comment 15 T. Gries 2013-06-11 08:44:25 UTC
closing the bug. it is solved by https://gerrit.wikimedia.org/r/#/c/66139/ .

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links