r103637 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103636‎ | r103637 | r103638 >
Date:04:17, 19 November 2011
Author:robin
Status:resolved (Comments)
Tags:
Comment:
Apparently behaviour changed in trunk, so blacklisting actions instead of whitelisting
Modified paths:
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -309,9 +309,7 @@
310310 * @return Boolean
311311 */
312312 static function onGetUserPermissionsErrors( $title, $user, $action, &$result ) {
313 - if ( $action == 'read' ) {
314 - return true;
315 - }
 313+ $notAllowedActions = in_array( array( 'edit', 'createpage' ) );
316314
317315 $titletext = $title->getText();
318316 $prefixdata = self::analyzePrefix( $titletext );
@@ -329,7 +327,7 @@
330328 # faking external link to support prot-rel URLs
331329 $link = "[$link ". self::makeExternalLinkText( $link ) . "]";
332330 $result[] = array( 'wminc-error-wiki-exists', $link );
333 - return $action == 'delete' ? true : false;
 331+ return $notAllowedActions ? false : true;
334332 }
335333
336334 if( !self::shouldWeShowUnprefixedError( $title ) || $action != 'create' ) {
@@ -348,7 +346,7 @@
349347 $error = 'wminc-error-unprefixed';
350348 }
351349 $result = $error;
352 - return false;
 350+ return $notAllowedActions ? false : true;
353351 }
354352
355353 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r103649Fix r103637robin08:38, 19 November 2011
r103822simplify code, 'createpage' requires 'edit' right anywayrobin16:54, 21 November 2011
r105776MFT for WikimediaIncubator: r95582, r96122, r96138, r96141, r97175, r98670, r...siebrand00:32, 11 December 2011

Comments

#Comment by Siebrand (talk | contribs)   08:16, 7 December 2011

Hmm. Blacklisting instead of whitelisting is inherently unsafe. Do you know where this was changed, as we may want to point that out there...

#Comment by SPQRobin (talk | contribs)   21:38, 11 December 2011

I think it is r102187. It changed behaviour in Translate for a similar reason.

#Comment by Nikerabbit (talk | contribs)   12:03, 7 December 2011

in_array() already returns boolean. X ? true : false; is redundant then.

#Comment by Nikerabbit (talk | contribs)   09:30, 8 December 2011

This has been superseded by r103822

Status & tagging log