r81995 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81994‎ | r81995 | r81996 >
Date:21:08, 11 February 2011
Author:ialex
Status:ok
Tags:
Comment:
Pass the EditPage object to the assert functions
Modified paths:
  • /trunk/extensions/AssertEdit/AssertEdit.php (modified) (history)
  • /trunk/extensions/AssertEdit/AssertEdit_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AssertEdit/AssertEdit_body.php
@@ -7,17 +7,16 @@
88 /**
99 * methods for core assertions
1010 */
11 - static function assert_user() {
 11+ static function assert_user( $editPage ) {
1212 global $wgUser;
1313 return $wgUser->isLoggedIn();
1414 }
15 - static function assert_bot() {
 15+ static function assert_bot( $editPage ) {
1616 global $wgUser;
1717 return $wgUser->isAllowed( 'bot' );
1818 }
19 - static function assert_exists() {
20 - global $wgTitle;
21 - return ( $wgTitle->getArticleID() != 0 );
 19+ static function assert_exists( $editPage ) {
 20+ return $editPage->mTitle->exists();
2221 }
2322
2423 /*
@@ -56,12 +55,12 @@
5756 }
5857
5958 // call the specified assertion
60 - static function callAssert( $assertName, $negate ) {
 59+ static function callAssert( $editPage, $assertName, $negate ) {
6160 if ( isset( self::$msAssert[$assertName] ) ) {
6261 if ( is_bool( self::$msAssert[$assertName] ) ) {
6362 $pass = self::$msAssert[$assertName];
6463 } elseif ( is_callable( self::$msAssert[$assertName] ) ) {
65 - $pass = call_user_func( self::$msAssert[$assertName] );
 64+ $pass = call_user_func( self::$msAssert[$assertName], $editPage );
6665 }
6766
6867 if ( $negate && isset( $pass ) ) {
Index: trunk/extensions/AssertEdit/AssertEdit.php
@@ -37,14 +37,14 @@
3838 $pass = true;
3939
4040 if ( $assertName != '' ) {
41 - $pass = AssertEdit::callAssert( $assertName, false );
 41+ $pass = AssertEdit::callAssert( $editpage, $assertName, false );
4242 }
4343
4444 // check for negative assert
4545 if ( $pass ) {
4646 $assertName = $wgRequest->getVal( 'nassert' );
4747 if ( $assertName != '' ) {
48 - $pass = AssertEdit::callAssert( $assertName, true );
 48+ $pass = AssertEdit::callAssert( $editpage, $assertName, true );
4949 }
5050 }
5151
@@ -74,7 +74,7 @@
7575 $pass = true;
7676
7777 if ( $assertName != '' ) {
78 - $pass = AssertEdit::callAssert( $assertName, false );
 78+ $pass = AssertEdit::callAssert( $editPage, $assertName, false );
7979 if ( !$pass ) {
8080 $result['assert'] = $assertName;
8181 }
@@ -84,7 +84,7 @@
8585 if ( $pass ) {
8686 $assertName = $wgRequest->getVal( 'nassert' );
8787 if ( $assertName != '' ) {
88 - $pass = AssertEdit::callAssert( $assertName, true );
 88+ $pass = AssertEdit::callAssert( $editPage, $assertName, true );
8989 }
9090 if ( !$pass ) {
9191 $result['nassert'] = $assertName;

Status & tagging log