API:Watchlist does not provide text and comment of log entries
Open, Needs TriagePublic

Description

I can't find a way to get the text and comment of log entries through API:Watchlist.
There are fields 'logtype', 'logaction' and 'logparams' but how can I make human friendly text message using them?

Would be great to have also fields 'logtext' and 'logcomment' in response. (it looks like 'logcomment' can be different of 'comment', but I'm not sure)

It seems this is easily done by adding a few lines of code, as:

$vals['logtext'] = LogFormatter::newFromRow( $row )->getActionText();
$vals['logcomment'] = LogFormatter::newFromRow( $row )->getComment();

after line 409

Pastakhov created this task.Mar 9 2016, 1:44 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 9 2016, 1:44 PM
Anomie closed this task as Declined.Mar 9 2016, 2:57 PM
Anomie added a subscriber: Anomie.

There are no fields corresponding to "logtext" or "logcomment" in the recentchanges table. Joining against the logging table as you suggest would likely be prohibitively expensive in what is already a rather expensive query.

I'm not sure about logcomment, maybe it's generally the same as 'comment', actually it is not so important.

But for making 'logtext' is used a Message that uses only already loaded 'logparams'.
the Message-id stored in variable $wgLogActions and maybe others, such as $wgLogNames, $wgLogHeaders... it is not important here, because there is already created LogFormatter that has cheap method getActionText().

I'm sure it isn't expensive and there is no other easy way to make this text of log entry.

Anomie reopened this task as Open.Mar 9 2016, 4:28 PM

I was confused about how exactly DatabaseLogEntry works.

I note that LogFormatter::getComment() is just going to return nearly the same thing as the existing parsedcomment property, just wrapped in a span or two and parentheses.

As for "logtext", chances are we'd want to make a new prop of some sort to all other clients don't have to get the probably-useless-to-them HTML blob. What exactly is your use case for this HTML blob that LogFormatter::getActionText() is going to return to you?

I note that LogFormatter::getComment() is just going to return nearly the same thing as the existing parsedcomment property, just wrapped in a span or two and parentheses.

Very well

What exactly is your use case for this HTML blob that LogFormatter::getActionText() is going to return to you?

For example now I have log entry with data:

{
  logtype: 'approval',
  logaction: 'approve',
  logparams '<a href="http://localhost/~pastakhov/index.php?title=Template:ServiceGroup&amp;oldid=1082">1082</a>'
}

And I'd like to get text:

'set <a href="http://localhost/~pastakhov/index.php?title=Template:Test&amp;oldid=1082">1082</a> as the approved revision for "<a href="/~pastakhov/index.php?title=Template:Test" title="Template:Test">Template:Test</a>"   '

And the same for other log entry types...

It looks like there will be HTML anyway. :-(

For Approve Revs extension there is variable

$wgLogActions['approval/approve'] = 'approvedrevs-approveaction';

and Message:

"approvedrevs-approveaction": "set $2 as the approved revision for \"[[$1]]\"",

For me the probably-useless-to-them HTML is not a problem, I just want to make watchlist by JS...