Page MenuHomePhabricator

Decoupling: Create Article factory
Open, LowPublic

Description

Decoupling: Create Article factory

Risks:

  • step1: low
  • step2: low+
  • step3: medium. Reason: too much code needs to be changed

Step1:

  • Create ArticleFactory class
  • deprecate static factory methods: Article::newFrom*
  • cover by tests
  • mark old factories as soft-deprecated
  • register them to MediaWiki ServiceContainer

Step2:

  • switch all calling from an old factory to a new factory
  • use Page instead title where Page is part of the scope or IContext

Step3:

  • Change all direct construction from "new Article()" to ArticleFactory

https://codesearch.wmflabs.org/deployed/?q=new%20Article%5C(&i=nope&files=%5C.php%24&repos=

Event Timeline

Art-Baltai updated the task description. (Show Details)
Art-Baltai added a subscriber: Pchelolo.

use Page instead title where Page is part of the scope or IContext

I don't understand this part. Weren't we going to remove the Page interface? If not, what methods does it have? Or are we talking about a PageRecord as per T195069: Factor PageStore and PageRecord out of WikiPage?

IContext should generally be avoided. At least, service objects should not know or use it.

I mean use

Article::newFromWikiPage($wikiPage)

instead

Article::newFromTitle($wikiPage->getTitle())

I mean use

Article::newFromWikiPage($wikiPage)

instead

Article::newFromTitle($wikiPage->getTitle())

It seems to me that the caller should not know or care if the implementation of Article needs a WikiPage internally. Can you tell my the advantage?

Can you tell my the advantage?

Is Similar logic for same cases

We can guarantee of same Wiki Page in scope and Article

WikiPages can has different:

  • classes(new WIkiPage($title) != WikiPage::factory($title))
  • custom filled properties (public/protected )

WikiPage creation is take a time to calls of each related hooks of extensions

Peter.ovchyn updated the task description. (Show Details)