r90933 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90932‎ | r90933 | r90934 >
Date:03:51, 28 June 2011
Author:aaron
Status:ok
Tags:
Comment:
Follow-up r85226: use getContext()->getUser() instead of $wgOut->getUser()
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -98,24 +98,22 @@
9999 $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
100100 }
101101
102 - $article = null;
103 - wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) );
104 - if ( $article ) {
105 - $article->setContext( $context );
106 - return $article;
 102+ $page = null;
 103+ wfRunHooks( 'ArticleFromTitle', array( &$title, &$page ) );
 104+ if ( !$page ) {
 105+ switch( $title->getNamespace() ) {
 106+ case NS_FILE:
 107+ $page = new ImagePage( $title );
 108+ break;
 109+ case NS_CATEGORY:
 110+ $page = new CategoryPage( $title );
 111+ break;
 112+ default:
 113+ $page = new Article( $title );
 114+ }
107115 }
108 -
109 - switch( $title->getNamespace() ) {
110 - case NS_FILE:
111 - $page = new ImagePage( $title );
112 - break;
113 - case NS_CATEGORY:
114 - $page = new CategoryPage( $title );
115 - break;
116 - default:
117 - $page = new Article( $title );
118 - }
119116 $page->setContext( $context );
 117+
120118 return $page;
121119 }
122120
@@ -1685,9 +1683,9 @@
16861684 foreach ( $tbs as $o ) {
16871685 $rmvtxt = "";
16881686
1689 - if ( $wgOut->getUser()->isAllowed( 'trackback' ) ) {
 1687+ if ( $this->getContext()->getUser()->isAllowed( 'trackback' ) ) {
16901688 $delurl = $this->mTitle->getFullURL( "action=deletetrackback&tbid=" .
1691 - $o->tb_id . "&token=" . urlencode( $wgOut->getUser()->editToken() ) );
 1689+ $o->tb_id . "&token=" . urlencode( $this->getContext()->getUser()->editToken() ) );
16921690 $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) );
16931691 }
16941692
@@ -2688,7 +2686,7 @@
26892687 global $wgOut, $wgRequest;
26902688
26912689 $confirm = $wgRequest->wasPosted() &&
2692 - $wgOut->getUser()->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
 2690+ $this->getContext()->getUser()->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
26932691
26942692 $this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
26952693 $this->DeleteReason = $wgRequest->getText( 'wpReason' );
@@ -2703,7 +2701,7 @@
27042702 }
27052703
27062704 # Flag to hide all contents of the archived revisions
2707 - $suppress = $wgRequest->getVal( 'wpSuppress' ) && $wgOut->getUser()->isAllowed( 'suppressrevision' );
 2705+ $suppress = $wgRequest->getVal( 'wpSuppress' ) && $this->getContext()->getUser()->isAllowed( 'suppressrevision' );
27082706
27092707 # This code desperately needs to be totally rewritten
27102708
@@ -2715,7 +2713,7 @@
27162714 }
27172715
27182716 # Check permissions
2719 - $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $wgOut->getUser() );
 2717+ $permission_errors = $this->mTitle->getUserPermissionsErrors( 'delete', $this->getContext()->getUser() );
27202718
27212719 if ( count( $permission_errors ) > 0 ) {
27222720 $wgOut->showPermissionsErrorPage( $permission_errors );
@@ -2762,7 +2760,7 @@
27632761 if ( $confirm ) {
27642762 $this->doDelete( $reason, $suppress );
27652763
2766 - if ( $wgRequest->getCheck( 'wpWatch' ) && $wgOut->getUser()->isLoggedIn() ) {
 2764+ if ( $wgRequest->getCheck( 'wpWatch' ) && $this->getContext()->getUser()->isLoggedIn() ) {
27672765 $this->doWatch();
27682766 } elseif ( $this->mTitle->userIsWatching() ) {
27692767 $this->doUnwatch();
@@ -2899,7 +2897,7 @@
29002898
29012899 wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
29022900
2903 - if ( $wgOut->getUser()->isAllowed( 'suppressrevision' ) ) {
 2901+ if ( $this->getContext()->getUser()->isAllowed( 'suppressrevision' ) ) {
29042902 $suppress = "<tr id=\"wpDeleteSuppressRow\">
29052903 <td></td>
29062904 <td class='mw-input'><strong>" .
@@ -2910,7 +2908,7 @@
29112909 } else {
29122910 $suppress = '';
29132911 }
2914 - $checkWatch = $wgOut->getUser()->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching();
 2912+ $checkWatch = $this->getContext()->getUser()->getBoolOption( 'watchdeletion' ) || $this->mTitle->userIsWatching();
29152913
29162914 $form = Xml::openElement( 'form', array( 'method' => 'post',
29172915 'action' => $this->mTitle->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
@@ -2943,7 +2941,7 @@
29442942 </tr>";
29452943
29462944 # Disallow watching if user is not logged in
2947 - if ( $wgOut->getUser()->isLoggedIn() ) {
 2945+ if ( $this->getContext()->getUser()->isLoggedIn() ) {
29482946 $form .= "
29492947 <tr>
29502948 <td></td>
@@ -2965,10 +2963,10 @@
29662964 </tr>" .
29672965 Xml::closeElement( 'table' ) .
29682966 Xml::closeElement( 'fieldset' ) .
2969 - Html::hidden( 'wpEditToken', $wgOut->getUser()->editToken() ) .
 2967+ Html::hidden( 'wpEditToken', $this->getContext()->getUser()->editToken() ) .
29702968 Xml::closeElement( 'form' );
29712969
2972 - if ( $wgOut->getUser()->isAllowed( 'editinterface' ) ) {
 2970+ if ( $this->getContext()->getUser()->isAllowed( 'editinterface' ) ) {
29732971 $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
29742972 $link = Linker::link(
29752973 $title,

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85226Start better utalizing OutputPage as the focal point for things related to th...dantman03:59, 3 April 2011

Status & tagging log