Thread:Project:Support desk/Set extention config variable before or after call require once/reply (6)

The following conventions:


 * Extensions must not change behaviour from the global scope, instead they should use hooks and callbacks.
 * Extensions should provide the default values for their configurations from the global scope in the main php file.

Are there for good reasons.
 * The placement of configuration variables is in fact quite important, because if they are set before, it is likely the values will be overridden by the defaults.
 * Extensions should use hoooks because that ensures all configurations have applied first: DefaultSettings, the remainder of LocalSettings and Setup.php. Especially Setup is important for some variables are dynamically constructed. This also ensures they don't make wrong assumptions about the configuration. For example, a variable might change before the setup has completed, the extension would be acting on the wrong value.
 * This also ensures extensions follow the proper procedure and not invent custom mechanisms (since pretty much all supported ways of providing functionality from an extension use a hook or callback that does not run in the global scope during setup).

The only way for LocalSettings to set a variable is after the extension file is loaded (otherwise they'd be reverted immediately by the extension file).

Though some extensions have done it otherwise in the past, to my knowledge this has never lead to anything good nor did it improve anything. I'd highly recommend any developer to follow this convention. If you believe there is a very good reason not to, I'd recommend you ask a fellow MediaWiki developer for confirmation that this indeed a necessity for your extension.