From: [email protected]
what changes did you make in these files? I'm still looking for a way to show the real names in my PDFs.

Hi Stefan,

I am replying to the group in case others find this useful or wish to comment to make it better.

In ApiQueryRevisions.php, I modified the list of tables to look like this:
$this->addTables('revision');
$this->addFields(Revision::selectFields());
$this->addTables('user');
$this->addWhere('rev_user = user_id');
$this->addFields('user_real_name');
$this->addTables('page');
$this->addWhere('page_id = rev_page');

This causes the user table to be joined such that user_real_name is available later.

Then, I add to vals when user is specified as one of the fields:

if ($this->fld_user) {
   if ($revision->isDeleted(Revision::DELETED_USER)) {
       $vals['userhidden'] = '';
   } else {
       $vals['user'] = $revision->getUserText();
       $vals['user_real_name'] = $row->user_real_name;
       if (!$revision->getUser())
           $vals['anon'] = '';
   }

I found some of this code to be different for different versions of MediaWiki so it is likely that you will have to think about it and understand the change instead of just copy/paste.

The result of this is that when “user” is specified in query revisions, a property for “user_real_name” will also be included. Example template:
http://<url>/api.php?action=query&prop=revisions&rvlimit=500&rvprop=ids|timestamp|flags|comment|user|size&titles=<title>

Finally, in authors.py, I modified scan_edits to look like:
def scan_edits(self, revs):
   authors = self.authors

   for r in revs:
       user = r.get('user', u'')
       user_real_name = r.get('user_real_name', u'')
       if not user_real_name:
           user_real_name = user
       if 'anon' in r and (not user or self.ip_rex.match(user)):  # anon
           self.num_anon += 1
       elif not user:
           continue
elif self.bot_rex.search(user) or self.bot_rex.search(r.get('comment', '')):
           continue  # filter bots
       else:
           authors.add(user_real_name)

I am not certain as to all of the side effects of this change; but, it accomplishes exactly what I wanted for my purposes.

Hope this helps,
William



--
You received this message because you are subscribed to the Google Groups 
"mwlib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to