Talk:Requests for comment/Configuration database

From MediaWiki.org
Jump to: navigation, search
Start a new discussion

Contents

Thread titleRepliesLast modified
Singletons511:10, 16 July 2011
Wikia code017:05, 5 July 2011
(no subject)017:05, 5 July 2011

Singletons

Singletons are really just globals in disguise. I don't really like them, but they are probably unavoidable without significantly rewriting MediaWiki. -- Bryan 145.94.184.252 13:43, 5 July 2011 (UTC)

Bryan 145.94.184.25217:06, 5 July 2011

Singletons do provide a few significant advantages over a set of globals ($wgFoo, $wgBar) or a global array ($wg['Foo'], $wg['Bar']). Mainly:

  • Related functions can be stored and referenced together by being in the same class (rather than being put in random utility classes or global functions)
  • Input/Output Read/Write is controlled rather than on the loose. A get/set function (either one-for-all or more specifically) can limit/verify/validate the input (ie. throw exception or correct value when it doesn't validate, instead of having to sanity check every time we access the configuration variable since it could be set to anything...)
    • likewise the read function is able to limit reading values based on the context or moment in execution time (ie. before hook X is fired, or if variable Y is set to Z)
  • They are one step closer to an even better system.


I agree though that Singletons, when used as such, are much like globals. A better way would perhaps be a static cache of instances, ie. like Conf::newFromId('enwiki') instead of Conf::singleton() which would either load it or get it from static cache, where Conf::get('foo') would be like Conf::newFromId(Conf::defaultId)->reallyGet using Conf::defaultId which would be set during initialization of the wiki/run.

Krinkle17:15, 5 July 2011
 

Yes they're globals in disguise, but for something like this you only need a single instance of the config object. Unless you think it's a good idea to have people construct config objects all over the place ;-)

Actually: expanding on the idea of "Contexts" a bit more...we could possibly move in the direction we did with RequestContext. Something like a WikiContext could be easily passed/made available as a member and has access to the configuration.

^demon17:30, 5 July 2011

I was indeed thinking more along the way of a WikiContext, which should contain the configuration object, among other things like a RequestContext, getDatabase() function, getRepoGroup() function and things like that.

-- Bryan (talk|commons)12:44, 13 July 2011
 

Well a WikiContext wouldn't necessarily have a RequestContext, but a RequestContext should always have a WikiContext. But otherwise I completely agree.

^demon18:10, 13 July 2011
 

Yeah, maintenance script for instance.

Krinkle11:10, 16 July 2011
 
 

Wikia code

You may want to check out our code that does a similar thing: https://svn.wikia-code.com/wikia/trunk/extensions/wikia/WikiFactory/

--Emil Wikia 16:48, 26 August 2009 (UTC)

Emil Wikia17:05, 5 July 2011

(no subject)

Some things out of from my head:

  • How to structure configuration options? Relations between them? Related options displayed together?
  • Some configuration options have equivalent user preference.

Nikerabbit 15:35, 25 August 2009 (UTC)

Nikerabbit17:05, 5 July 2011
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox