Boris Steipe | 8 May 00:20

Re: Is there a way to control edit rights for talk pages differently from content pages?

Guys,
while this looks elegant on the surface, this is almost a textbook  
example of inadvertent obfuscation. No-one who does not remember the  
connection between talk namespaces and their ID will be able to  
figure out _why_ this loop is being run. Moreover, the code will  
break in case this connection is at some point lost.

If this were in my lab, I would require the permissions to be  
explicitly set. This will go a long way to make the code  
maintainable. Even if the only maintainer is you, yourself, half a  
year from now. Sure, you type more; but code is very much more often  
read than written. And making implicit knowledge explicit, that's  
what software engineering is all about.

$0.02

Boris
(At the very least add a comment and explanation!)

On 7-May-08, at 6:08 PM, Thomas Dalton wrote:
> On 07/05/2008, Daniel Barrett <danb@...> wrote:
>> Something like this loop should work, if you haven't defined any  
>> custom namespaces in your wiki:
>>
>>  global $wgCanonicalNamespaceNames;
>>  foreach ($wgCanonicalNamespaceNames as $ns => $name) {
>>   // If namespace ID is non-negative and even, protect it.
>>   if ($ns >= 0 && $ns % 2 == 0) {
>>     $wgNamespaceProtection[$ns] = array( 'sysop' );
>>   }
>>  }
>
> Don't you need namespace ids, rather than namespace names? I may just
> be mis-remembering what the various arrays are called...
>
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l@...
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Gmane