User "Brion VIBBER" posted a comment on MediaWiki.r103893. Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/103893#c26381 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: Constants must be scalar values: http://us2.php.net/define And of course, the database can't store namespace objects into integer fields. Ultimately the DB schema comes down to an integer ID number, and that's what's stored in the various _namespace fields. :) You could play with magic toString methods to have them return the number, which might work, but ick! It feels like it would be very fragile. I would love some nice lightweight namespace objects in a next-gen interface, but probably distinct to avoid conflicts and confusion -- eg, don't override existing getNamespace() methods but have a new method with a different name that returns an object; have things that take namespaces change to take either. _______________________________________________ MediaWiki-CodeReview mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview
