Page MenuHomePhabricator

Split up and servicify ChangeTags class
Closed, ResolvedPublic

Description

Pending:

https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/597913/
Move defineTag, undefineTag, deleteTagEverywhere, and purgeTagCacheAll to new ChangeTagStore service

https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/598222/
Move getSoftwareTags, listSoftwareActivatedTags, listDefinedTags, listExplicitlyDefinedTags, and listSoftwareDefinedTags to new ChangeTagLookup service

https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/598226/
Move modifyDisplayQuery and makeTagSummarySubquery to new ChangeTagQueryUtils service

Remaining work to split up the class into narrow services tracked at P11294

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Encapsulating a global state into a class is always a good idea.
At the moment I'm not quite familiar with that area, so can't give you more valuable suggestion.

But I'd appreciate it if you add me as Reviewer.

::tagShortDescriptionMessage, ::tagDescription, ::tagLongDescriptionMessage, ::truncateTagDescription, ::isTagNameValid
should be moved to a ChangeTag (singular) object that represents a specific tag, including providing its description methods

The patch for T27909 does this (sort of).

Change 597913 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add a ChangeTagStore service for defining and undefining tags

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

DannyS712 updated the task description. (Show Details)

Change 597913 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add a ChangeTagStore service for defining and undefining tags

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

Next up: ChangeTagLookup, which replaces:

  • getSoftwareTags
  • listSoftwareActivatedTags
  • listDefinedTags
  • listExplicitlyDefinedTags
  • listSoftwareDefinedTags

Change 598222 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add a ChangeTagLookup store for looking up different lists of tags

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

DannyS712 renamed this task from Factor some static methods out of the ChangeTags class to Split up and servicify ChangeTags class.May 24 2020, 6:29 AM
DannyS712 updated the task description. (Show Details)

Change 598226 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add a new ChangeTagQueryUtils service for adding tag info to queries

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

Notes to help with review:

  • Each patch adds a narrow service for a clear group of methods in ChangeTags that go together, rather than trying to add one service for everything
  • Each patch only adds the new service and updates the ChangesTags method to use it, making no other replacements and making no official deprecations
  • Each patch includes 100% code coverage for the new service with pure unit testing

::tagShortDescriptionMessage, ::tagDescription, ::tagLongDescriptionMessage, ::truncateTagDescription, ::isTagNameValid
should be moved to a ChangeTag (singular) object that represents a specific tag, including providing its description methods

The patch for T27909 does this (sort of).

I have abandoned that patch as the feature was implemented in a different, simpler way. In the meantime, there were some additions and tweaks to the class (P11294 should be updated), so it's better to think again and start from scratch, rather than going through the rebase pain.

Change 916816 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] Introduce ChangeTagsStore service and move some functions of ChangeTags

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

Don't make three different services. One to hold them all is enough. Adding more adds complexity, confusion and harder to onboard people. ChangeTags is a textbook "Table Gateway" pattern and good as is.

Don't break classes that don't need breaking. Interfaces should be narrow but classes can be busy and large ("deep module" from philosophy of software design book)

Change 916816 merged by jenkins-bot:

[mediawiki/core@master] Introduce ChangeTagsStore service and move some functions of ChangeTags

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

Change 922937 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] changetags: Move a bit more from ChangeTags to ChangeTagsStore

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

Change 922937 merged by jenkins-bot:

[mediawiki/core@master] changetags: Move a bit more from ChangeTags to ChangeTagsStore

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

Change 926469 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] changetags: Move more functions from ChangeTags to ChangeTagsStore

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

Change 926469 merged by jenkins-bot:

[mediawiki/core@master] changetags: Move more functions from ChangeTags to ChangeTagsStore

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

Change 928682 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] Start using ChangeTagsStore

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

Change 928842 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] changetags: Move ::modifyDisplayQuery from ChangeTags to ChangeTagsStore

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

Change 928682 merged by jenkins-bot:

[mediawiki/core@master] Start using ChangeTagsStore

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

Change 928842 merged by jenkins-bot:

[mediawiki/core@master] changetags: Move ::modifyDisplayQuery from ChangeTags to ChangeTagsStore

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

Change 930728 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] specials: Migrate some of calls to deprecated method ChangeTags::modifyDisplayQuery

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

Change 597913 abandoned by DannyS712:

[mediawiki/core@master] Add a ChangeTagStore service for defining and undefining tags

Reason:

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

Change 930728 merged by jenkins-bot:

[mediawiki/core@master] specials: Migrate off some calls to method ChangeTags::modifyDisplayQuery

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

Change 598226 abandoned by DannyS712:

[mediawiki/core@master] Add a new ChangeTagQueryUtils service for adding tag info to queries

Reason:

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

Change 598222 abandoned by DannyS712:

[mediawiki/core@master] Add a ChangeTagLookup service for looking up different lists of tags

Reason:

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

Ladsgroup claimed this task.

All of those functions mentioned in the description have been moved to ChangeTagsStore. I did some clean ups of their usages but much more needs to be done and that's out of scope of this ticket.

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

[mediawiki/core@master] TagsDef: inject ChangeTagsStore

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

Change 956053 merged by jenkins-bot:

[mediawiki/core@master] TagsDef: inject ChangeTagsStore

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