* Fix caching
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sun, 28 Sep 2008 19:34:14 +0000 (19:34 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Sun, 28 Sep 2008 19:34:14 +0000 (19:34 +0000)
* Fix messages

includes/User.php
includes/specials/SpecialRemoveRestrictions.php
includes/specials/SpecialRestrictUser.php

index 2efe9f1..c1ce092 100644 (file)
@@ -14,7 +14,7 @@ define( 'USER_TOKEN_LENGTH', 32 );
  * \type{\int} Serialized record version.
  * @ingroup Constants
  */
-define( 'MW_USER_VERSION', 6 );
+define( 'MW_USER_VERSION', 7 );
 
 /**
  * \type{\string} Some punctuation to prevent editing from broken text-mangling proxies.
@@ -3245,7 +3245,7 @@ class User {
        // Restrictions-related block
 
        public function loadRestrictions() {
-               if( !$this->mRestrictions )
+               if( is_null( $this->mRestrictions ) )
                        $this->mRestrictions = UserRestriction::fetchForUser( $this->isLoggedIn() ? 
                                intval( $this->getId() ) : $this->getName()  );
        }
index ded6cbe..5ad21dd 100644 (file)
@@ -56,5 +56,7 @@ function wfSpecialRemoveRestrictionsProcess( $r ) {
        if( $r->isNamespace() )
                $params[] = $r->getNamespace();
        $log->addEntry( 'remove', Title::makeTitle( NS_USER, $r->getSubjectText() ), $reason, $params );
+       $userObj = User::newFromName( $r->getSubjectText(), false );
+       $userObj->invalidateCache();
        return $result;
 }
index 86de2d1..edf5f22 100644 (file)
@@ -106,7 +106,7 @@ class RestrictUserForm {
                if ( $error )
                        $wgOut->wrapWikiMsg( '<strong class="error">$1</strong>', $error );
                if ( $success )
-                       $wgOut->wrapWikiMsg( '<strong class="success">$1/strong>', $success );
+                       $wgOut->wrapWikiMsg( '<strong class="success">$1</strong>', $success );
        }
 
        public static function doPageRestriction( $uid, $user ) {
@@ -126,6 +126,7 @@ class RestrictUserForm {
                $l = new LogPage( 'restrict' );
                $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), $r->getReason(),
                        array( $r->getType(), $r->getPage()->getFullText(), $logExpiry) );
+               self::invalidateCache( $user );
        }
 
        public static function namespaceRestrictionForm( $uid, $user, $oldRestrictions ) {
@@ -136,13 +137,13 @@ class RestrictUserForm {
                        $wgUser->matchEditToken( $wgRequest->getVal( 'edittoken' ) ) ) {
                                $ns = $wgRequest->getVal( 'namespace' );
                                if( $wgContLang->getNsText( $ns ) === false )
-                                       $error = wfMsgExt( 'restrictuser-badnamespace', 'parseinline' );
+                                       $error = array( 'restrictuser-badnamespace' );
                                elseif( UserRestriction::convertExpiry( $wgRequest->getVal( 'expiry' ) ) === false )
-                                       $error = wfMsgExt( 'restrictuser-badexpiry', 'parseinline', $wgRequest->getVal( 'expiry' ) );
+                                       $error = array( 'restrictuser-badexpiry', $wgRequest->getVal( 'expiry' ) );
                                else 
                                        foreach( $oldRestrictions as $r )
                                                if( $r->isNamespace() && $r->getNamespace() == $ns )
-                                                       $error = wfMsgExt( 'restrictuser-dupnamespace', 'parse' );
+                                                       $error = array( 'restrictuser-dupnamespace' );
                                if( !$error ) {
                                        self::doNamespaceRestriction( $uid, $user );
                                        $success = array('restrictuser-success', $user);
@@ -185,5 +186,11 @@ class RestrictUserForm {
                $l = new LogPage( 'restrict' );
                $l->addEntry( 'restrict', Title::makeTitle( NS_USER, $user ), $r->getReason(),
                        array( $r->getType(), $r->getNamespace(), $logExpiry ) );
+               self::invalidateCache( $user );
+       }
+
+       private static function invalidateCache( $user ) {
+               $userObj = User::newFromName( $user, false );
+               $userObj->invalidateCache();
        }
 }