Page MenuHomePhabricator

Introduce common interface for Info classes
Open, Needs TriagePublic1 Estimated Story Points

Description

The IPInfo extension uses InfoRetrievers to collect various data (e.g. GeoIP info) about a principal. These InfoRetrievers each have their own *Info DTOs that currently have no shared base class or interface.

As a result, the DefaultPresenter class, which is responsible for converting the information returned by the different InfoRetrievers, needs to be aware of every concrete *Info class there is and therefore needs to be updated every time a new *Info class or InfoRetriever is added. This is busywork and has caused a regression in T371966.

We should instead introduce a base interface for Info classes in IPInfo, e.g.

<?php
use MediaWiki\Permissions\Authority;

interface InfoInterface() {
    public function toArray( Authority $authority ): array;
}

Doing so would allow decoupling DefaultPresenter from concrete Info classes and allow offloading the relevant conditionals to the corresponding Info class as well.

AC

  • IPInfo Info DTOs share a common interface
  • DefaultPresenter is not aware of concrete Info DTOs

Event Timeline

@mszabo do you intend to work on this task? Might be nice to do, before we finish up this round of IP Info work.

@kostajh I think we could slot this in for next sprint (or even the current one if we find we have headroom). What do you think?

@kostajh I think we could slot this in for next sprint (or even the current one if we find we have headroom). What do you think?

I've added it to the sprint after temp accounts minor pilot wiki deployment.

kostajh set the point value for this task to 1.Sep 27 2024, 11:18 AM
Tchanders subscribed.

I've added this as a point to discuss in future planning meetings, and am removing the sprint tag from it.