User "Happy-melon" posted a comment on MediaWiki.r103893. Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/103893#c26338 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: There are loads of ways to avoid breaking stuff: # Convert the <tt>NS_</tt> constants to objects and thereby convert to doing object comparisons 'under the hood'. # Allow an implicit cast from a Namespace object to an int; would be nicer, but I don't think PHP allows it. # Redefine the <tt>NS_</tt> constants as strings, and define the <tt>__toString()</tt> magic method on the Namespace class to return the namespace number as a string. # Add a $returnObj parameter to getNamespace() and gradually migrate calls to use it. Or add a separate getNamespaceObj() method to Title, and migrate similarly. # Just migrate stuff (this can be done in conjunction with one of the above). You've basically already said that all <tt>getNamespace() == NS_FOO</tt> calls will need to be replaced at some point anyway to accommodate new features; it's only slightly more disruptive to do it all in the space of a single release. _______________________________________________ MediaWiki-CodeReview mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview
