Hi Geeks,
I want to know the best option to store a application wide setting / options in mediawiki for an custom developed extension.
Say for example in my extension I need to create a global variable, if it does not exists and reuse it.
I can't keep this in Localsettings.php file, since I need to generate on the fly (once) and use it throughout the application
Right now it is one option and I may require to create multiple options and use it, please guide me or give some links to go through
thanks, Prince Gerald A
DISCLAIMER: -----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any mail and attachments please check them for viruses and defect.
-----------------------------------------------------------------------------------------------------------------------
2010/4/8 Prince Gerald Albert - ERS, HCL Tech princegeralda@hcl.in:
Hi Geeks,
I want to know the best option to store a application wide setting / options in mediawiki for an custom developed extension.
Say for example in my extension I need to create a global variable, if it does not exists and reuse it.
I can't keep this in Localsettings.php file, since I need to generate on the fly (once) and use it throughout the application
Right now it is one option and I may require to create multiple options and use it, please guide me or give some links to go through
Do you need the variable to be application-wide and persists over multiple requests? In that case, you could store it in the cache; it's not technically guaranteed to last but it'll be pretty solid on most setups.
global $wgMemc; // to set $wgMemc->set( wfMemcKey( 'yourKeyHere', 'maybeWithAParameter', 'orTwo' ), 'value' ); // Optional third param: expiry time in seconds
// to get, returns false if not set $var = $wgMemc->get( wfMemcKey( 'yourKeyHere', 'maybeWithAParameter', 'orTwo' ) );
Roan Kattouw (Catrope)
Or you could create your own database table for your extension.
Depending on how formal you want to be, you can just ask installers to run some SQL before installing, or follow the conventions here:
http://www.mediawiki.org/wiki/Manual:Extensions#Adding_database_tables
What are you really trying to do though? Your question feels a bit off, like what you're doing could be better accomplished another way.
On 04/08/2010 05:40 AM, Roan Kattouw wrote:
2010/4/8 Prince Gerald Albert - ERS, HCL Tech princegeralda@hcl.in:
Hi Geeks,
I want to know the best option to store a application wide setting / options in mediawiki for an custom developed extension.
Say for example in my extension I need to create a global variable, if it does not exists and reuse it.
I can't keep this in Localsettings.php file, since I need to generate on the fly (once) and use it throughout the application
Right now it is one option and I may require to create multiple options and use it, please guide me or give some links to go through
Do you need the variable to be application-wide and persists over multiple requests? In that case, you could store it in the cache; it's not technically guaranteed to last but it'll be pretty solid on most setups.
global $wgMemc; // to set $wgMemc->set( wfMemcKey( 'yourKeyHere', 'maybeWithAParameter', 'orTwo' ), 'value' ); // Optional third param: expiry time in seconds
// to get, returns false if not set $var = $wgMemc->get( wfMemcKey( 'yourKeyHere', 'maybeWithAParameter', 'orTwo' ) );
Roan Kattouw (Catrope)
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org