Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

Re: [MediaWiki-CVS] SVN: trunk/phase3/includes/SiteConfiguration.php

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


vasilvv at gmail

Aug 18, 2008, 11:15 AM

Post #1 of 3 (512 views)
Permalink
Re: [MediaWiki-CVS] SVN: trunk/phase3/includes/SiteConfiguration.php

werdna [at] svn 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

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


andrew at epstone

Aug 18, 2008, 6:12 PM

Post #2 of 3 (474 views)
Permalink
Re: [MediaWiki-CVS] SVN: trunk/phase3/includes/SiteConfiguration.php [In reply to]

On Tue, Aug 19, 2008 at 4:15 AM, Victor Vasiliev <vasilvv [at] gmail> 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 ) );

--
Andrew Garrett

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


vasilvv at gmail

Aug 19, 2008, 6:37 AM

Post #3 of 3 (470 views)
Permalink
Re: [MediaWiki-CVS] SVN: trunk/phase3/includes/SiteConfiguration.php [In reply to]

2008/8/19 Andrew Garrett <andrew [at] epstone>

> On Tue, Aug 19, 2008 at 4:15 AM, Victor Vasiliev <vasilvv [at] gmail>
> 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'
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 mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.