User "Happy-melon" posted a comment on MediaWiki.r103893. Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/103893#c26336 Commit summary:
Implement a number of namespace related equals functions: * MWNamespace::equals to test equivalence of two namespaces (forward compatible with any changes we may make like introducing namespace keys like 'USER') * MWNamespace::subjectEquals to test equivalence of the subject of two namespaces e.g.: MWNamespace::subjectEquals( NS_USER, $ns ); instead of testing for equivalence to both NS_USER and NS_USER_TALK * Title::inNamespace to use instead of $title->getNamespace() == NS_??? * Title::inNamespaces for use like $title->inNamespaces( NS_USER, NS_PROJECT ) when you only care if it's in one of a number of namespaces (also accepts an array) * Title::hasSubjectNamespace for use instead of testing for equivalence to both the subject and talk such as NS_USER and NS_USER_TALK. Include phpunit tests for all this new code, and also add some tests for some existing code. Comment: I see the benefit to abstracting away these comparisons (I finished your first section of your wikitech-l post thinking "whytf", but it actually makes some sense to create more flexibility in these comparisons), but this is not a very object-oriented or modular way of going about it. Surely the more elegant way of doing this is to rework the MWNamespace class into an actual lightweight object that can be instantiated, and return it from $title->getNamespace(). "is this namespace one of these namespaces" is logic that has nothing to do with Title objects, so it does not really belong in Title.php; we're trying to break up those huge ancient classes, not expand them. $title->getNamespace()->isOneOf( NS_FOO, NS_BAR ) is no harder to code, but rather cleaner, especially when we want to start expanding those comparison methods beyond stubs. _______________________________________________ MediaWiki-CodeReview mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview
