Last modified: 2014-11-17 15:15:40 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 T75411, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 73411 - The API list=recentchanges and prop=revisions should return the rev_sha1 field in the internal base-36 format rather than base-16
The API list=recentchanges and prop=revisions should return the rev_sha1 fiel...
Status: NEW
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.25-git
All All
: Low enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-11-14 04:46 UTC by Nathan Larson
Modified: 2014-11-17 15:15 UTC (History)
5 users (show)

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


Attachments

Description Nathan Larson 2014-11-14 04:46:14 UTC
It's unclear why the API in general converts from the internally-stored base-36 representation to base-16, except maybe because people usually use base-16 for hashes so it's less likely to be surprising. The first addition of a "sha1" parameter in the API appears to be Gerrit change #25456.
Comment 1 Nathan Larson 2014-11-14 04:46:31 UTC
h/t Brad Jorsch
Comment 2 Brad Jorsch 2014-11-14 15:14:09 UTC
The title, as stated, makes this a WORKSFORME because it already returns the field.

Comment 0 makes it clear that it's just not encoded in the specific way you'd like. Why should we either break existing clients expecting the base-16 representation or bloat the API with an ability to select between base-16 and base-36?
Comment 3 Umherirrender 2014-11-14 17:30:24 UTC
the file sha1 (in imageinfo or allimages) is also converted before outputting, when than should all modules with hash processing should have prop=sha1base36 along with prop=sha1 to allow this. (For input in allimages there are two params).
Comment 4 Nathan Larson 2014-11-15 18:19:23 UTC
I don't really mind bloating the API, but maybe better documentation would suffice to avoid confusion.

It sounds like there's a two-step process going on to arrive at the final sha1:

wfBaseConvert( sha1( $text ), 16, 36, 31 );
wfBaseConvert( $revision->getSha1(), 36, 16, 40 );

What would be the parameters to wfBaseConvert if one wanted to do this in one step? Thanks.
Comment 5 Brad Jorsch 2014-11-17 15:15:40 UTC
(In reply to Nathan Larson from comment #4)
> I don't really mind bloating the API

I do. Without a good reason, there's little point in returning data in two different formats when it can easily be converted client-side.

> It sounds like there's a two-step process going on to arrive at the final
> sha1:
> 
> wfBaseConvert( sha1( $text ), 16, 36, 31 );
> wfBaseConvert( $revision->getSha1(), 36, 16, 40 );
> 
> What would be the parameters to wfBaseConvert if one wanted to do this in
> one step? Thanks.

I note that $revision->getSha1() is returning the value returned by the first line, so the above is more correctly stated as:

 $stored = wfBaseConvert( sha1( $text ), 16, 36, 31 );
 $output = wfBaseConvert( $stored, 36, 16, 40 );

The two wfBaseConvert calls are undoing each other. The one-step process would be:

 $output = sha1( $text );

Or if you really want to use wfBaseConvert for some reason,

 $output = wfBaseConvert( sha1( $text ), 16, 16, 40 );

(it turns out that both wfBaseConvert() and sha1() output lowercase hexits, so we don't need to worry about even that potential difference).

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


Navigation
Links