Hi folks,
I've been looking at the namespace manager in wikidata, as well as looking at how things are in the trunk. I'm eager to have improved namespace facilities, since it makes my life easier in creating extensions. It may be easier to discuss these ideas face-to-face later this week, but I figured it'd be better to compose my thoughts as a starting point.
Suggestions: * Change $wgNamespace to a static variable, accessed by new global function: wfGetNamespace($nsnumber). This makes it much easier to enforce the edict "Do NOT alter the $wgNamespaces object" (especially if you threaten to return a clone from wfGetNamespace in future versions, performance be damned) * Create mNamespace member variable for the Title and Article objects which is merely a reference to the corresponding namespace object (viva PHP5). * Add utility function for getting the default name given a constant. Change this: global $wgNamespace; $wgNamespaces[NS_TALK]->getDefaultName() ...to one of the following, as appropriate: wfGetDefaultNSName(NS_TALK) ...or (preferable when applicable): $this->mNamespace->getDefaultName() * (down the road) Create new objects which extend the Article object, and remove some/all of the namespace conditionals from the Article object altogether (e.g. UserTalkPage object for User_talk:, SpecialPage for "Special:", and SystemPage or MediaWikiPage for "MediaWiki:") * Consolidate "new Article" instantiation in a class factory. It may be easiest to make this a method of the Title object, so that rather than creating an article like this: $article = new Article($title) ...you create it using: $article = $title->newArticle(); (actually, this doesn't need to wait for a new namespace manager...I may just submit a patch for this)
Those are some thoughts for now. Looking forward to seeing everyone at Wikimania.
Rob
On 7/31/06, Rob Lanphier robla@robla.net wrote:
Suggestions:
- Change $wgNamespace to a static variable, accessed by new global
function: wfGetNamespace($nsnumber). This makes it much easier to enforce the edict "Do NOT alter the $wgNamespaces object" (especially if you threaten to return a clone from wfGetNamespace in future versions, performance be damned)
- Create mNamespace member variable for the Title and Article objects
which is merely a reference to the corresponding namespace object (viva PHP5).
- Add utility function for getting the default name given a constant.
Change this: global $wgNamespace; $wgNamespaces[NS_TALK]->getDefaultName() ...to one of the following, as appropriate: wfGetDefaultNSName(NS_TALK) ...or (preferable when applicable): $this->mNamespace->getDefaultName()
All this seems sensible and in line with the existing effort to reduce reliance on globals. There's at least one other dev who is interested in helping us with the final stretch in integrating the namespace changes, so we should probably coordinate this by e-mail between the three of us + Brion.
- (down the road) Create new objects which extend the Article object,
and remove some/all of the namespace conditionals from the Article object altogether (e.g. UserTalkPage object for User_talk:, SpecialPage for "Special:", and SystemPage or MediaWikiPage for "MediaWiki:")
Or something like that. I think it definitely makes sense to completely eliminate any hardcoded "magic" functionality of namespaces. Indeed, it might even be nice for functionality like image handling to be so compartmentalized that it can easily be ripped out altogether.
Those are some thoughts for now. Looking forward to seeing everyone at Wikimania.
Likewise - I'm a few e-mails away from the airport. ;-)
Erik
mediawiki-l@lists.wikimedia.org