r111605 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111604‎ | r111605 | r111606 >
Date:00:54, 16 February 2012
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Fix user related direct member variable access
Modified paths:
  • /trunk/phase3/includes/Action.php (modified) (history)
  • /trunk/phase3/includes/AjaxResponse.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/Export.php (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserrights.php (modified) (history)
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/Maintenance.php
@@ -297,6 +297,9 @@
298298 return rtrim( $input );
299299 }
300300
 301+ /**
 302+ * @return bool
 303+ */
301304 public function isQuiet() {
302305 return $this->mQuiet;
303306 }
Index: trunk/phase3/includes/Export.php
@@ -486,13 +486,13 @@
487487 $out .= ' ' . Xml::element( 'redirect', array( 'title' => self::canonicalTitle( $redirect ) ) ) . "\n";
488488 }
489489 }
490 -
 490+
491491 if ( $row->rev_sha1 ) {
492 - $out .= " " . Xml::element('sha1', null, strval($row->rev_sha1) ) . "\n";
 492+ $out .= " " . Xml::element('sha1', null, strval( $row->rev_sha1 ) ) . "\n";
493493 } else {
494494 $out .= " <sha1/>\n";
495495 }
496 -
 496+
497497 if ( $row->page_restrictions != '' ) {
498498 $out .= ' ' . Xml::element( 'restrictions', array(),
499499 strval( $row->page_restrictions ) ) . "\n";
Index: trunk/phase3/includes/EditPage.php
@@ -1019,7 +1019,7 @@
10201020 return false;
10211021
10221022 case self::AS_BLOCKED_PAGE_FOR_USER:
1023 - throw new UserBlockedError( $wgUser->mBlock );
 1023+ throw new UserBlockedError( $wgUser->getBlock() );
10241024
10251025 case self::AS_IMAGE_REDIRECT_ANON:
10261026 case self::AS_IMAGE_REDIRECT_LOGGED:
@@ -2959,7 +2959,7 @@
29602960 wfDeprecated( __METHOD__, '1.19' );
29612961 global $wgUser;
29622962
2963 - throw new UserBlockedError( $wgUser->mBlock );
 2963+ throw new UserBlockedError( $wgUser->getBlock() );
29642964 }
29652965
29662966 /**
Index: trunk/phase3/includes/Title.php
@@ -1927,7 +1927,7 @@
19281928 // Don't block the user from editing their own talk page unless they've been
19291929 // explicitly blocked from that too.
19301930 } elseif( $user->isBlocked() && $user->mBlock->prevents( $action ) !== false ) {
1931 - $block = $user->mBlock;
 1931+ $block = $user->getBlock();
19321932
19331933 // This is from OutputPage::blockedPage
19341934 // Copied at r23888 by werdna
@@ -1947,15 +1947,15 @@
19481948
19491949 $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
19501950 $blockid = $block->getId();
1951 - $blockExpiry = $user->mBlock->mExpiry;
1952 - $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
 1951+ $blockExpiry = $block->getExpiry();
 1952+ $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $block->mTimestamp ), true );
19531953 if ( $blockExpiry == 'infinity' ) {
19541954 $blockExpiry = wfMessage( 'infiniteblock' )->text();
19551955 } else {
19561956 $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
19571957 }
19581958
1959 - $intended = strval( $user->mBlock->getTarget() );
 1959+ $intended = strval( $block->getTarget() );
19601960
19611961 $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
19621962 $blockid, $blockExpiry, $intended, $blockTimestamp );
Index: trunk/phase3/includes/specials/SpecialUserrights.php
@@ -72,7 +72,7 @@
7373 * allow them to use Special:UserRights.
7474 */
7575 if( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
76 - throw new UserBlockedError( $user->mBlock );
 76+ throw new UserBlockedError( $user->getBlock() );
7777 }
7878
7979 $request = $this->getRequest();
Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -157,7 +157,7 @@
158158
159159 # Check blocks
160160 if( $user->isBlocked() ) {
161 - throw new UserBlockedError( $user->mBlock );
 161+ throw new UserBlockedError( $user->getBlock() );
162162 }
163163
164164 # Check whether we actually want to allow changing stuff
Index: trunk/phase3/includes/Preferences.php
@@ -84,9 +84,9 @@
8585 // Already set, no problem
8686 continue;
8787 } elseif ( !is_null( $prefFromUser ) && // Make sure we're not just pulling nothing
88 - $field->validate( $prefFromUser, $user->mOptions ) === true ) {
 88+ $field->validate( $prefFromUser, $user->getOptions() ) === true ) {
8989 $info['default'] = $prefFromUser;
90 - } elseif ( $field->validate( $globalDefault, $user->mOptions ) === true ) {
 90+ } elseif ( $field->validate( $globalDefault, $user->getOptions() ) === true ) {
9191 $info['default'] = $globalDefault;
9292 } else {
9393 throw new MWException( "Global default '$globalDefault' is invalid for field $name" );
Index: trunk/phase3/includes/SpecialPage.php
@@ -891,7 +891,7 @@
892892 $this->checkPermissions();
893893
894894 if ( $this->requiresUnblock() && $user->isBlocked() ) {
895 - $block = $user->mBlock;
 895+ $block = $user->getBlock();
896896 throw new UserBlockedError( $block );
897897 }
898898
Index: trunk/phase3/includes/Action.php
@@ -277,7 +277,7 @@
278278 }
279279
280280 if ( $this->requiresUnblock() && $user->isBlocked() ) {
281 - $block = $user->mBlock;
 281+ $block = $user->getBlock();
282282 throw new UserBlockedError( $block );
283283 }
284284
Index: trunk/phase3/includes/AjaxResponse.php
@@ -163,7 +163,7 @@
164164 }
165165
166166 $timestamp = wfTimestamp( TS_MW, $timestamp );
167 - $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched, $wgCacheEpoch ) );
 167+ $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->getTouched(), $wgCacheEpoch ) );
168168
169169 if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
170170 # IE sends sizes after the date like this:
@@ -181,11 +181,11 @@
182182 $this->disable();
183183 $this->mLastModified = $lastmod;
184184
185 - wfDebug( "$fname: CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
 185+ wfDebug( "$fname: CACHED client: $ismodsince ; user: $wgUser->getTouched() ; page: $timestamp ; site $wgCacheEpoch\n", false );
186186
187187 return true;
188188 } else {
189 - wfDebug( "$fname: READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
 189+ wfDebug( "$fname: READY client: $ismodsince ; user: $wgUser->getTouched() ; page: $timestamp ; site $wgCacheEpoch\n", false );
190190 $this->mLastModified = $lastmod;
191191 }
192192 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r112855Add some {}...reedy00:15, 2 March 2012

Comments

#Comment by Krinkle (talk | contribs)   23:49, 1 March 2012
Notice: Undefined property: User::$getTouched in /Users/krinkle/Sites/mw/trunk/phase3/includes/AjaxResponse.php on line 188

Is showing up in the html response of CategoryTree to index.php?action=ajax&... on my local wiki, (http://i.imgur.com/Lg3ou.png)

#Comment by Reedy (talk | contribs)   00:13, 2 March 2012

> echo "user: {$wgUser->getTouched()}\n";
user: 0

> echo "user: $wgUser->getTouched()\n";
PHP Notice:  Undefined property: User::$getTouched in /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php(72) : eval()'d code on line 1
PHP Stack trace:
PHP   1. {main}() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:0
PHP   2. eval() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:72

Notice: Undefined property: User::$getTouched in /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php(72) : eval()'d code on line 1

Call Stack:
    0.0358     649440   1. {main}() /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:0
   30.2723   18701576   2. eval(''echo "user: $wgUser->getTouched()\\n";;'') /home/reedy/mediawiki/trunk/phase3/maintenance/eval.php:72

user: ()

Status & tagging log