User "Happy-melon" posted a comment on MediaWiki.r90901. Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90901#c18837 Commit summary:
Follow-up r89408, r86872: restore IContextSource and ContextSource, to be more carefully reimplemented. Comment: See r86872, which should eventually be reimplented. Over the past few months we've built into numerous classes the ability to store a RequestContext and access its properties via <tt>$this->context->getSomething()</tt>; then we realised that it would be better to include direct getter methods so we could just call <tt>$this->getSomething()</tt>. We now have a lot of duplication of this code, some of which is complete, some of which is not. Sooner or later we'll get something calling $something->getLang() where no one's actually implemented getLang() in the Something class, and pain will result. For these simple cases, it makes eminent sense to abstract all of those accessors into a base class, then you can turn something into a context source simply by extending from the base class. That's simply a piece of code engineering; on a more theoretical level we realise that the fact that this stuff is being implemented so widely is indicative of the fact that we have a widespread need for being able to make (or mark) classes as "places I can get context objects from". The interface is the more abstract representation of that statement, it's what would be used for, say, Article, where there are a lot of complexities about particularly the Title object that make the simple store-a-RequestContext-and-pass-through-accesses-to-it model overly simplistic. Remembering that no one really cares about the RequestContext itself, it's just a box to keep the OutputPage/WebRequest/User/Title/Language objects, RequestContext is ''itself'' a place we can get context objects from (or at least RequestContext::getMain() is). _______________________________________________ MediaWiki-CodeReview mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview
