Page MenuHomePhabricator

Create framework for fetching on-wiki information [L]
Closed, ResolvedPublic

Description

Context: T268657: Epic: IP Info popup

This piece is needed for fetching Block and Contribs information to display in the IP Info popup.

  • Decouple where the assumption of GeoIP is harcoded
  • Add another source of truth - Wikipedia

Event Timeline

ARamirez_WMF renamed this task from Create framework for fetching on-wiki information to Create framework for fetching on-wiki information [L].Jul 14 2021, 4:23 PM

AFAICT this is mostly done. The extension can use multiple strategies to fetch information about an IP address from anywhere we choose. However, as modelled, the extension expects each of those strategies to return the same information but this can be fixed with a very small change to the codebase.


Decouple where the assumption of GeoIP is harcoded

Because the extension can use multiple strategies to fetch information about an IP address, it's conceivable that we could have one strategy that makes that assumption (that the GeoIP database is available on the local filesystem) and another strategy that doesn't.

Change 708556 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/IPInfo@master] Relax return type of InfoRetriever::retrieveFromIP

https://gerrit.wikimedia.org/r/708556

AFAICT this is mostly done. The extension can use multiple strategies to fetch information about an IP address from anywhere we choose. However, as modelled, the extension expects each of those strategies to return the same information but this can be fixed with a very small change to the codebase.

Working on T270318: Block info in the popup [M] a little highlighted an issue with the current design that I hadn't considered yesterday: The domain objects know how to serialise themselves to JSON (and only JSON). Up until now, this was acceptable because no additional context was required during serialisation. However, what happens when you want to display a message as is the case when displaying a block's comment and/or duration. As well as relaxing the return type of MediaWiki\IPInfo\InfoRetriever::retrieveFromIP, I plan to remove these limitations by doing the following:

  • Rename the MediaWiki\IPInfo\RestHandler namespace to MediaWiki\IPInfo\Rest\Handler namespace
  • Create the MediaWiki\IPInfo\Rest\DefaultPresenter class to marshall instances of MediaWiki\IPInfo\Info\Info to Plain Ol' PHP arrays to be passed to MediaWiki's REST framework
  • Update MediaWiki\IPInfo\Info\Info to not implement JsonSerializable

and for T270318: Block info in the popup [M]:

  • Update MediaWiki\IPInfo\Rest\DefaultPresenter to accept the desired output language and use that to parse messages and/or format durations

Change 709687 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/IPInfo@master] rest: MediaWiki\\IPInfo\\RestHandler -> ..\\Rest\\Handler

https://gerrit.wikimedia.org/r/709687

Change 709688 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/IPInfo@master] rest: Add presenter

https://gerrit.wikimedia.org/r/709688

Change 708556 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] retriever: Several closely related changes

https://gerrit.wikimedia.org/r/708556

Change 709687 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] rest: MediaWiki\\IPInfo\\RestHandler -> ..\\Rest\\Handler

https://gerrit.wikimedia.org/r/709687

Change 709688 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] rest: Add DefaultPresenter

https://gerrit.wikimedia.org/r/709688

The patches for this task should be NOPs from the point of view of the UI. Testing that the infobox/popup UXs are still working should suffice.

Change 713828 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/IPInfo@master] Update mw.IpInfo.IpInfoWidget for new API response

https://gerrit.wikimedia.org/r/713828

Change 713828 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Update mw.IpInfo.IpInfoWidget for new API response

https://gerrit.wikimedia.org/r/713828

Change 731097 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/IPInfo@master] widget: Several display fixes

https://gerrit.wikimedia.org/r/731097

Moving this back to Done: Q2 2021-22 as code review and QA of the above will be done as part of T286662: Display block and contribs info in popup and infobox [S].

phuedx subscribed.
Niharika claimed this task.

Change 731097 abandoned by Phuedx:

[mediawiki/extensions/IPInfo@master] widget: Several display fixes

Reason:

Merged into wikitrents patch elsewhere.

https://gerrit.wikimedia.org/r/731097