werdna@svn.wikimedia.org wrote:
function extractGlobal( $setting, $wiki, $suffix, $params, $wikiTags = array() ) { $value = $this->get( $setting, $wiki, $suffix, $params, $wikiTags ); if ( !is_null( $value ) ) {
$GLOBALS[$setting] = $value;
if (substr($setting,0,1) == '+'&& is_array($value)) {
$setting = substr($setting,1);
if ( is_array($GLOBALS[$setting]) ) {
$GLOBALS[$setting] = array_merge( $GLOBALS[$setting], $value );
} else {
$GLOBALS[$setting] = $value;
}
} else {
$GLOBALS[$setting] = $value;
} }}
* Note that extractGlobal() is not used on Wikimedia. * extractGlobal() supposes that configuration variable has a "+" prefix, while get() supposes that target wiki should have it. * Mergability should be property of a configuration variable (so we use "+wgGroupPermissions" instead of "wgGroupPermissions" => array( "+enwiki" => ... ). * It doesn't seem to merge arrays recursively. That means that in "wgGroupPermissions" => array( 'default' => array( 'user' => array( 'something' => true ) ), 'enwiki' => array( 'user' => array( 'somthingelse' => true ) ), ) enwiki settings will override defaults, therefore you should use array_merge_recursive(). * If we want it to be usable for other parts of the code which are ran when $wgConf is already extracted, we need to know default settings. To determine default settings it's possible to include DefaultSettings.php in the local scope and get a value of the configuration variable, but it does not work with group permissions since they are modified by extensions + CommonSettings.php also modifies them. --vvv
On Tue, Aug 19, 2008 at 4:15 AM, Victor Vasiliev vasilvv@gmail.com wrote:
- Note that extractGlobal() is not used on Wikimedia.
I'll move that code into get over the next few days.
- extractGlobal() supposes that configuration variable has a "+" prefix,
while get() supposes that target wiki should have it.
They're *different* ideas. One is for settings for different tags to be cumulative, i.e. the setting for enwiki will add to, not override the setting for default. The other is for settings in $wgConf to be cumulative with settings set outright, i.e. the settings in wgConf will add to, not override the original global.
- Mergability should be property of a configuration variable (so we use
"+wgGroupPermissions" instead of "wgGroupPermissions" => array( "+enwiki" => ... ).
See above. They're *different* ideas.
- It doesn't seem to merge arrays recursively. That means that in "wgGroupPermissions" => array( 'default' => array( 'user' => array( 'something' => true ) ), 'enwiki' => array( 'user' => array( 'somthingelse' => true ) ), ) enwiki settings will override defaults, therefore you should use
array_merge_recursive().
Good point, fixed in r39623.
- If we want it to be usable for other parts of the code which are ran
when $wgConf is already extracted, we need to know default settings. To determine default settings it's possible to include DefaultSettings.php in the local scope and get a value of the configuration variable, but it does not work with group permissions since they are modified by extensions + CommonSettings.php also modifies them.
DefaultSettings.php is already included by the time we extract wgConf. Extensions tend to arrays in-place, instead of replacing it by something new, i.e. $wgGroupPermissions['sysop']['move'] = true, rather than $wgGroupPermissions = array( 'sysop' => array( 'move' => true ) );
2008/8/19 Andrew Garrett andrew@epstone.net
On Tue, Aug 19, 2008 at 4:15 AM, Victor Vasiliev vasilvv@gmail.com wrote:
- It doesn't seem to merge arrays recursively. That means that in "wgGroupPermissions" => array( 'default' => array( 'user' => array( 'something' => true ) ), 'enwiki' => array( 'user' => array( 'somthingelse' => true ) ), ) enwiki settings will override defaults, therefore you should use
array_merge_recursive().
Good point, fixed in r39623.
He-he. I checked, it still works incorrectly: when array_merge_recursive() merges 'sysop' => array( 'importupload' =>true ) in DefaultSettings with 'sysop' => array( 'importupload' => false ) in InitialiseSettings as 'sysop' => array( 'importupload' => array( true, false ) ) (which works of course incorrect).
- If we want it to be usable for other parts of the code which are ran
when $wgConf is already extracted, we need to know default settings. To determine default settings it's possible to include DefaultSettings.php in the local scope and get a value of the configuration variable, but it does not work with group permissions since they are modified by extensions + CommonSettings.php also modifies them.
DefaultSettings.php is already included by the time we extract wgConf. Extensions tend to arrays in-place, instead of replacing it by something new, i.e. $wgGroupPermissions['sysop']['move'] = true, rather than $wgGroupPermissions = array( 'sysop' => array( 'move' => true ) ); https://lists.wikimedia.org/mailman/listinfo/wikitech-l
I know. Look: in Special:Userrights we have to determine $wgGroupPermissions of some other wiki. To use it, we have to get wiki-specific $wgGroupPermissions and merge them with default group permissions. Default group permissions are specified in extensions, DefaultSettings, etc. so it is nearly-impossible to get them all.
Another points: * If code invokes $wgConf->get( 'wgGroupPermissions' ), get() function should check for presence of settings with "+" in its name, and if it's present, merge returned value with default settings. * Some SpecialUserrights bugs: ** $wgConf->get( 'wgGroupPermissions', ... ) return null, since it is present in $wgConf as '+wgGroupPermissions' (see the point above) ** It does not exclude implicit groups
wikitech-l@lists.wikimedia.org