Page MenuHomePhabricator

Introduce a DatabaseBlock factory service
Closed, ResolvedPublic

Description

The DatabaseBlock class has lots of static methods that perform factory functions, which should be moved to a new DatabaseBlockFactory service.

This includes the public methods:

  • DatabaseBlock::newfromID
  • DatabaseBlock::newfromRow
  • DatabaseBlock::newfromTarget
  • DatabaseBlock::newfromListFromTarget

...and their associated private/protected methods.

This and the new block store service (T221075) should make it easier to write unit tests for classes that use blocking.

Event Timeline

Change 605614 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[mediawiki/core@master] WIP Introduce DatabaseBlockFactory for getting blocks

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

@Tchanders is the intent for this to be before DatabaseBlockStore or afterwards?

@DannyS712 I don't think it matters too much, but the store can go first.

@DannyS712 I don't think it matters too much, but the store can go first.

In that case, other than removing the $this->expects() calls (which I'm doing now) is there anything blocking that from merging?

Thanks - I've added some comments to the patch, so let's discuss there. In general I think it's good to time merging patches like this so that we have a good opportunity to test before it hits production.

Change 709200 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/core@master] Add a DatabaseBlockFactory service

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

I forgot about this task when I created a patch to do this, thanks @matej_suchanek for pointing this out. Presenting as an alternative to the other patch

Ugg, sorry, apparently I can't read, not a duplicate

@Tchanders: Removing task assignee as this open task has been assigned for more than two years - See the email sent to task assignee on Feburary 22nd, 2023.
Please assign this task to yourself again if you still realistically [plan to] work on this task - it would be welcome! :)
If this task has been resolved in the meantime, or should not be worked on by anybody ("declined"), please update its task status via "Add Action… 🡒 Change Status".
Also see https://www.mediawiki.org/wiki/Bug_management/Assignee_cleanup for tips how to best manage your individual work in Phabricator. Thanks!

Per my comments on the Gerrit change, we are moving those methods to DatabaseBlockStore instead.

Change 970015 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] Move DatabaseBlock read query methods to DatabaseBlockStore

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

Change 970475 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/core@master] Migrate callers of DatabaseBlock methods moved to DatabaseBlockStore

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

Change 970015 merged by jenkins-bot:

[mediawiki/core@master] Move DatabaseBlock read query methods to DatabaseBlockStore

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

Change 970475 merged by jenkins-bot:

[mediawiki/core@master] Migrate callers of DatabaseBlock methods moved to DatabaseBlockStore

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

Change 709200 abandoned by Tim Starling:

[mediawiki/core@master] Add a DatabaseBlockFactory service

Reason:

superseded

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