Index: trunk/phase3/includes/RequestContext.php |
— | — | @@ -1,19 +1,19 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * Group all the pieces relevant to the context of a request into one instance |
5 | | - * |
| 5 | + * |
6 | 6 | * @author IAlex |
7 | 7 | * @author Daniel Friesen |
8 | 8 | * @file |
9 | 9 | */ |
10 | 10 | |
11 | 11 | class RequestContext { |
12 | | - private $request; /// WebRequest object |
13 | | - private $title; /// Title object |
14 | | - private $output; /// OutputPage object |
15 | | - private $user; /// User object |
16 | | - private $lang; /// Language object |
17 | | - private $skin; /// Skin object |
| 12 | + private $mRequest; // / WebRequest object |
| 13 | + private $mTitle; // / Title object |
| 14 | + private $mOutput; // / OutputPage object |
| 15 | + private $mUser; // / User object |
| 16 | + private $mLang; // / Language object |
| 17 | + private $mSkin; // / Skin object |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Set the WebRequest object |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | * @param $r WebRequest object |
23 | 23 | */ |
24 | 24 | public function setRequest( WebRequest $r ) { |
25 | | - $this->request = $r; |
| 25 | + $this->mRequest = $r; |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
— | — | @@ -30,11 +30,11 @@ |
31 | 31 | * @return WebRequest |
32 | 32 | */ |
33 | 33 | public function getRequest() { |
34 | | - if ( !isset($this->request) ) { |
| 34 | + if ( !isset( $this->mRequest ) ) { |
35 | 35 | global $wgRequest; # fallback to $wg till we can improve this |
36 | | - $this->request = $wgRequest; |
| 36 | + $this->mRequest = $wgRequest; |
37 | 37 | } |
38 | | - return $this->request; |
| 38 | + return $this->mRequest; |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | * @param $t Title object |
45 | 45 | */ |
46 | 46 | public function setTitle( Title $t ) { |
47 | | - $this->title = $t; |
| 47 | + $this->mTitle = $t; |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
— | — | @@ -52,11 +52,11 @@ |
53 | 53 | * @return Title |
54 | 54 | */ |
55 | 55 | public function getTitle() { |
56 | | - if ( !isset($this->title) ) { |
| 56 | + if ( !isset( $this->mTitle ) ) { |
57 | 57 | global $wgTitle; # fallback to $wg till we can improve this |
58 | | - $this->title = $wgTitle; |
| 58 | + $this->mTitle = $wgTitle; |
59 | 59 | } |
60 | | - return $this->title; |
| 60 | + return $this->mTitle; |
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
— | — | @@ -64,8 +64,8 @@ |
65 | 65 | * |
66 | 66 | * @param $u OutputPage |
67 | 67 | */ |
68 | | - public function setOutput( OutputPage $u ) { |
69 | | - $this->output = $u; |
| 68 | + public function setOutput( OutputPage $o ) { |
| 69 | + $this->mOutput = $o; |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
— | — | @@ -74,11 +74,11 @@ |
75 | 75 | * @return OutputPage object |
76 | 76 | */ |
77 | 77 | public function getOutput() { |
78 | | - if ( !isset($this->output) ) { |
79 | | - $this->output = new OutputPage; |
80 | | - $this->output->setContext( $this ); |
| 78 | + if ( !isset( $this->mOutput ) ) { |
| 79 | + $this->mOutput = new OutputPage; |
| 80 | + $this->mOutput->setContext( $this ); |
81 | 81 | } |
82 | | - return $this->output; |
| 82 | + return $this->mOutput; |
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | * @param $u User |
89 | 89 | */ |
90 | 90 | public function setUser( User $u ) { |
91 | | - $this->user = $u; |
| 91 | + $this->mUser = $u; |
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
— | — | @@ -96,11 +96,13 @@ |
97 | 97 | * @return User |
98 | 98 | */ |
99 | 99 | public function getUser() { |
100 | | - if ( !isset($this->user) ) { |
| 100 | + if ( !isset( $this->mUser ) ) { |
101 | 101 | global $wgCommandLineMode; |
102 | | - $this->user = $wgCommandLineMode ? new User : User::newFromSession( $this->getRequest() ); |
| 102 | + $this->mUser = $wgCommandLineMode |
| 103 | + ? new User |
| 104 | + : User::newFromSession( $this->getRequest() ); |
103 | 105 | } |
104 | | - return $this->user; |
| 106 | + return $this->mUser; |
105 | 107 | } |
106 | 108 | |
107 | 109 | /** |
— | — | @@ -109,28 +111,31 @@ |
110 | 112 | * @return Language |
111 | 113 | */ |
112 | 114 | public function getLang() { |
113 | | - if ( !isset($this->lang) ) { |
| 115 | + if ( !isset( $this->mLang ) ) { |
114 | 116 | global $wgLanguageCode, $wgContLang; |
115 | | - $code = $this->getRequest()->getVal( 'uselang', $this->getUser()->getOption( 'language' ) ); |
| 117 | + $code = $this->getRequest()->getVal( |
| 118 | + 'uselang', |
| 119 | + $this->getUser()->getOption( 'language' ) |
| 120 | + ); |
116 | 121 | // BCP 47 - letter case MUST NOT carry meaning |
117 | 122 | $code = strtolower( $code ); |
118 | 123 | |
119 | 124 | # Validate $code |
120 | | - if( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) { |
| 125 | + if ( empty( $code ) || !Language::isValidCode( $code ) || ( $code === 'qqq' ) ) { |
121 | 126 | wfDebug( "Invalid user language code\n" ); |
122 | 127 | $code = $wgLanguageCode; |
123 | 128 | } |
124 | 129 | |
125 | 130 | wfRunHooks( 'UserGetLanguageObject', array( $this->getUser(), &$code ) ); |
126 | 131 | |
127 | | - if( $code === $wgLanguageCode ) { |
128 | | - $this->lang = $wgContLang; |
| 132 | + if ( $code === $wgLanguageCode ) { |
| 133 | + $this->mLang = $wgContLang; |
129 | 134 | } else { |
130 | 135 | $obj = Language::factory( $code ); |
131 | | - $this->lang = $obj; |
| 136 | + $this->mLang = $obj; |
132 | 137 | } |
133 | 138 | } |
134 | | - return $this->lang; |
| 139 | + return $this->mLang; |
135 | 140 | } |
136 | 141 | |
137 | 142 | /** |
— | — | @@ -139,11 +144,11 @@ |
140 | 145 | * @return Skin |
141 | 146 | */ |
142 | 147 | public function getSkin() { |
143 | | - if ( !isset($this->skin) ) { |
| 148 | + if ( !isset( $this->mSkin ) ) { |
144 | 149 | wfProfileIn( __METHOD__ . '-createskin' ); |
145 | | - |
| 150 | + |
146 | 151 | global $wgHiddenPrefs; |
147 | | - if( !in_array( 'skin', $wgHiddenPrefs ) ) { |
| 152 | + if ( !in_array( 'skin', $wgHiddenPrefs ) ) { |
148 | 153 | # get the user skin |
149 | 154 | $userSkin = $this->getUser()->getOption( 'skin' ); |
150 | 155 | $userSkin = $this->getRequest()->getVal( 'useskin', $userSkin ); |
— | — | @@ -153,11 +158,11 @@ |
154 | 159 | $userSkin = $wgDefaultSkin; |
155 | 160 | } |
156 | 161 | |
157 | | - $this->skin = Skin::newFromKey( $userSkin ); |
158 | | - $this->skin->setContext( $this ); |
| 162 | + $this->mSkin = Skin::newFromKey( $userSkin ); |
| 163 | + $this->mSkin->setContext( $this ); |
159 | 164 | wfProfileOut( __METHOD__ . '-createskin' ); |
160 | 165 | } |
161 | | - return $this->skin; |
| 166 | + return $this->mSkin; |
162 | 167 | } |
163 | 168 | |
164 | 169 | /** Helpful methods **/ |
— | — | @@ -182,10 +187,31 @@ |
183 | 188 | */ |
184 | 189 | public static function getMain() { |
185 | 190 | static $instance = null; |
186 | | - if ( !isset($instance) ) { |
| 191 | + if ( !isset( $instance ) ) { |
187 | 192 | $instance = new self; |
188 | 193 | } |
189 | 194 | return $instance; |
190 | 195 | } |
| 196 | + |
| 197 | + /** |
| 198 | + * Make these C#-style accessors, so you can do $context->user->getName() which is |
| 199 | + * internally mapped to $context->__get('user')->getName() which is mapped to |
| 200 | + * $context->getUser()->getName() |
| 201 | + */ |
| 202 | + public function __get( $name ) { |
| 203 | + if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) { |
| 204 | + $fname = 'get' . ucfirst( $name ); |
| 205 | + return $this->$fname(); |
| 206 | + } |
| 207 | + trigger_error( "Undefined property {$name}", E_NOTICE ); |
| 208 | + } |
| 209 | + |
| 210 | + public function __set( $name, $value ) { |
| 211 | + if ( in_array( $name, array( 'request', 'title', 'output', 'user', 'lang', 'skin' ) ) ) { |
| 212 | + $fname = 'set' . ucfirst( $name ); |
| 213 | + return $this->$fname( $value ); |
| 214 | + } |
| 215 | + trigger_error( "Undefined property {$name}", E_NOTICE ); |
| 216 | + } |
191 | 217 | } |
192 | 218 | |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -15,26 +15,6 @@ |
16 | 16 | private $params = array(); |
17 | 17 | |
18 | 18 | /** |
19 | | - * The request object |
20 | | - * @var WebRequest |
21 | | - */ |
22 | | - private $request; |
23 | | - |
24 | | - /** |
25 | | - * Output to deliver content to |
26 | | - * FIXME: most stuff in the codebase doesn't actually write to this, it'll write to |
27 | | - * $wgOut instead. So in practice this has to be $wgOut; |
28 | | - * @var OutputPage |
29 | | - */ |
30 | | - private $output; |
31 | | - |
32 | | - /** |
33 | | - * The Title we'll be working on |
34 | | - * @var Title |
35 | | - */ |
36 | | - private $title; |
37 | | - |
38 | | - /** |
39 | 19 | * TODO: fold $output, etc, into this |
40 | 20 | * @var RequestContext |
41 | 21 | */ |
— | — | @@ -69,22 +49,18 @@ |
70 | 50 | } |
71 | 51 | |
72 | 52 | public function request( WebRequest &$x = null ){ |
73 | | - return wfSetVar( $this->request, $x ); |
| 53 | + return wfSetVar( $this->context->request, $x ); |
74 | 54 | } |
75 | 55 | |
76 | 56 | public function output( OutputPage &$x = null ){ |
77 | | - return wfSetVar( $this->output, $x ); |
| 57 | + return wfSetVar( $this->context->output, $x ); |
78 | 58 | } |
79 | 59 | |
80 | 60 | public function __construct( WebRequest &$request, /*OutputPage*/ &$output ){ |
81 | | - $this->request =& $request; |
82 | | - $this->output =& $output; |
83 | | - $this->title = $this->parseTitle(); |
84 | | - |
85 | 61 | $this->context = new RequestContext(); |
86 | | - $this->context->setRequest( $this->request ); |
87 | | - $this->context->setOutput( $this->output ); |
88 | | - $this->context->setTitle( $this->title ); |
| 62 | + $this->context->setRequest( $request ); |
| 63 | + $this->context->setOutput( $output ); |
| 64 | + $this->context->setTitle( $this->parseTitle() ); |
89 | 65 | } |
90 | 66 | |
91 | 67 | /** |
— | — | @@ -97,27 +73,27 @@ |
98 | 74 | public function performRequestForTitle( &$article, &$user ) { |
99 | 75 | wfProfileIn( __METHOD__ ); |
100 | 76 | |
101 | | - $this->output->setTitle( $this->title ); |
102 | | - if ( $this->request->getVal( 'printable' ) === 'yes' ) { |
103 | | - $this->output->setPrintable(); |
| 77 | + $this->context->output->setTitle( $this->context->title ); |
| 78 | + if ( $this->context->request->getVal( 'printable' ) === 'yes' ) { |
| 79 | + $this->context->output->setPrintable(); |
104 | 80 | } |
105 | 81 | |
106 | 82 | wfRunHooks( 'BeforeInitialize', array( |
107 | | - &$this->title, |
| 83 | + &$this->context->title, |
108 | 84 | &$article, |
109 | | - &$this->output, |
| 85 | + &$this->context->output, |
110 | 86 | &$user, |
111 | | - $this->request, |
| 87 | + $this->context->request, |
112 | 88 | $this |
113 | 89 | ) ); |
114 | 90 | |
115 | 91 | // If the user is not logged in, the Namespace:title of the article must be in |
116 | 92 | // the Read array in order for the user to see it. (We have to check here to |
117 | 93 | // catch special pages etc. We check again in Article::view()) |
118 | | - if ( !is_null( $this->title ) && !$this->title->userCanRead() ) { |
119 | | - $this->output->loginToUse(); |
| 94 | + if ( !is_null( $this->context->title ) && !$this->context->title->userCanRead() ) { |
| 95 | + $this->context->output->loginToUse(); |
120 | 96 | $this->finalCleanup(); |
121 | | - $this->output->disable(); |
| 97 | + $this->context->output->disable(); |
122 | 98 | wfProfileOut( __METHOD__ ); |
123 | 99 | return false; |
124 | 100 | } |
— | — | @@ -131,7 +107,7 @@ |
132 | 108 | $article = $new_article; |
133 | 109 | $this->performAction( $article, $user ); |
134 | 110 | } elseif ( is_string( $new_article ) ) { |
135 | | - $this->output->redirect( $new_article ); |
| 111 | + $this->context->output->redirect( $new_article ); |
136 | 112 | } else { |
137 | 113 | wfProfileOut( __METHOD__ ); |
138 | 114 | throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" ); |
— | — | @@ -148,10 +124,10 @@ |
149 | 125 | private function parseTitle() { |
150 | 126 | global $wgContLang; |
151 | 127 | |
152 | | - $curid = $this->request->getInt( 'curid' ); |
153 | | - $title = $this->request->getVal( 'title' ); |
| 128 | + $curid = $this->context->request->getInt( 'curid' ); |
| 129 | + $title = $this->context->request->getVal( 'title' ); |
154 | 130 | |
155 | | - if ( $this->request->getCheck( 'search' ) ) { |
| 131 | + if ( $this->context->request->getCheck( 'search' ) ) { |
156 | 132 | // Compatibility with old search URLs which didn't use Special:Search |
157 | 133 | // Just check for presence here, so blank requests still |
158 | 134 | // show the search page when using ugly URLs (bug 8054). |
— | — | @@ -171,8 +147,8 @@ |
172 | 148 | // For non-special titles, check for implicit titles |
173 | 149 | if ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) { |
174 | 150 | // We can have urls with just ?diff=,?oldid= or even just ?diff= |
175 | | - $oldid = $this->request->getInt( 'oldid' ); |
176 | | - $oldid = $oldid ? $oldid : $this->request->getInt( 'diff' ); |
| 151 | + $oldid = $this->context->request->getInt( 'oldid' ); |
| 152 | + $oldid = $oldid ? $oldid : $this->context->request->getInt( 'diff' ); |
177 | 153 | // Allow oldid to override a changed or missing title |
178 | 154 | if ( $oldid ) { |
179 | 155 | $rev = Revision::newFromId( $oldid ); |
— | — | @@ -187,10 +163,10 @@ |
188 | 164 | * @return Title |
189 | 165 | */ |
190 | 166 | public function getTitle(){ |
191 | | - if( $this->title === null ){ |
192 | | - $this->title = $this->parseTitle(); |
| 167 | + if( $this->context->title === null ){ |
| 168 | + $this->context->title = $this->parseTitle(); |
193 | 169 | } |
194 | | - return $this->title; |
| 170 | + return $this->context->title; |
195 | 171 | } |
196 | 172 | |
197 | 173 | /** |
— | — | @@ -206,46 +182,46 @@ |
207 | 183 | wfProfileIn( __METHOD__ ); |
208 | 184 | |
209 | 185 | // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. |
210 | | - if ( is_null( $this->title ) || ( ( $this->title->getDBkey() == '' ) && ( $this->title->getInterwiki() == '' ) ) ) { |
211 | | - $this->title = SpecialPage::getTitleFor( 'Badtitle' ); |
212 | | - $this->output->setTitle( $this->title ); // bug 21456 |
| 186 | + if ( is_null( $this->context->title ) || ( ( $this->context->title->getDBkey() == '' ) && ( $this->context->title->getInterwiki() == '' ) ) ) { |
| 187 | + $this->context->title = SpecialPage::getTitleFor( 'Badtitle' ); |
| 188 | + $this->context->output->setTitle( $this->context->title ); // bug 21456 |
213 | 189 | // Die now before we mess up $wgArticle and the skin stops working |
214 | 190 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
215 | 191 | |
216 | 192 | // Interwiki redirects |
217 | | - } else if ( $this->title->getInterwiki() != '' ) { |
218 | | - $rdfrom = $this->request->getVal( 'rdfrom' ); |
| 193 | + } else if ( $this->context->title->getInterwiki() != '' ) { |
| 194 | + $rdfrom = $this->context->request->getVal( 'rdfrom' ); |
219 | 195 | if ( $rdfrom ) { |
220 | | - $url = $this->title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) ); |
| 196 | + $url = $this->context->title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) ); |
221 | 197 | } else { |
222 | | - $query = $this->request->getValues(); |
| 198 | + $query = $this->context->request->getValues(); |
223 | 199 | unset( $query['title'] ); |
224 | | - $url = $this->title->getFullURL( $query ); |
| 200 | + $url = $this->context->title->getFullURL( $query ); |
225 | 201 | } |
226 | 202 | /* Check for a redirect loop */ |
227 | | - if ( !preg_match( '/^' . preg_quote( $this->getVal( 'Server' ), '/' ) . '/', $url ) && $this->title->isLocal() ) { |
| 203 | + if ( !preg_match( '/^' . preg_quote( $this->getVal( 'Server' ), '/' ) . '/', $url ) && $this->context->title->isLocal() ) { |
228 | 204 | // 301 so google et al report the target as the actual url. |
229 | | - $this->output->redirect( $url, 301 ); |
| 205 | + $this->context->output->redirect( $url, 301 ); |
230 | 206 | } else { |
231 | | - $this->title = SpecialPage::getTitleFor( 'Badtitle' ); |
232 | | - $this->output->setTitle( $this->title ); // bug 21456 |
| 207 | + $this->context->title = SpecialPage::getTitleFor( 'Badtitle' ); |
| 208 | + $this->context->output->setTitle( $this->context->title ); // bug 21456 |
233 | 209 | wfProfileOut( __METHOD__ ); |
234 | 210 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
235 | 211 | } |
236 | 212 | // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant |
237 | | - } else if ( $this->request->getVal( 'action', 'view' ) == 'view' && !$this->request->wasPosted() |
238 | | - && ( $this->request->getVal( 'title' ) === null || $this->title->getPrefixedDBKey() != $this->request->getVal( 'title' ) ) |
239 | | - && !count( array_diff( array_keys( $this->request->getValues() ), array( 'action', 'title' ) ) ) ) |
| 213 | + } else if ( $this->context->request->getVal( 'action', 'view' ) == 'view' && !$this->context->request->wasPosted() |
| 214 | + && ( $this->context->request->getVal( 'title' ) === null || $this->context->title->getPrefixedDBKey() != $this->context->request->getVal( 'title' ) ) |
| 215 | + && !count( array_diff( array_keys( $this->context->request->getValues() ), array( 'action', 'title' ) ) ) ) |
240 | 216 | { |
241 | | - if ( $this->title->getNamespace() == NS_SPECIAL ) { |
242 | | - list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $this->title->getDBkey() ); |
| 217 | + if ( $this->context->title->getNamespace() == NS_SPECIAL ) { |
| 218 | + list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $this->context->title->getDBkey() ); |
243 | 219 | if ( $name ) { |
244 | | - $this->title = SpecialPage::getTitleFor( $name, $subpage ); |
| 220 | + $this->context->title = SpecialPage::getTitleFor( $name, $subpage ); |
245 | 221 | } |
246 | 222 | } |
247 | | - $targetUrl = $this->title->getFullURL(); |
| 223 | + $targetUrl = $this->context->title->getFullURL(); |
248 | 224 | // Redirect to canonical url, make it a 301 to allow caching |
249 | | - if ( $targetUrl == $this->request->getFullRequestURL() ) { |
| 225 | + if ( $targetUrl == $this->context->request->getFullRequestURL() ) { |
250 | 226 | $message = "Redirect loop detected!\n\n" . |
251 | 227 | "This means the wiki got confused about what page was " . |
252 | 228 | "requested; this sometimes happens when moving a wiki " . |
— | — | @@ -269,13 +245,13 @@ |
270 | 246 | wfProfileOut( __METHOD__ ); |
271 | 247 | return false; |
272 | 248 | } else { |
273 | | - $this->output->setSquidMaxage( 1200 ); |
274 | | - $this->output->redirect( $targetUrl, '301' ); |
| 249 | + $this->context->output->setSquidMaxage( 1200 ); |
| 250 | + $this->context->output->redirect( $targetUrl, '301' ); |
275 | 251 | } |
276 | 252 | // Special pages |
277 | | - } else if ( NS_SPECIAL == $this->title->getNamespace() ) { |
| 253 | + } else if ( NS_SPECIAL == $this->context->title->getNamespace() ) { |
278 | 254 | /* actions that need to be made when we have a special pages */ |
279 | | - SpecialPage::executePath( $this->title, $this->context ); |
| 255 | + SpecialPage::executePath( $this->context->title, $this->context ); |
280 | 256 | } else { |
281 | 257 | /* No match to special cases */ |
282 | 258 | wfProfileOut( __METHOD__ ); |
— | — | @@ -324,7 +300,7 @@ |
325 | 301 | public function getAction() { |
326 | 302 | global $wgDisabledActions; |
327 | 303 | |
328 | | - $action = $this->request->getVal( 'action', 'view' ); |
| 304 | + $action = $this->context->request->getVal( 'action', 'view' ); |
329 | 305 | |
330 | 306 | // Check for disabled actions |
331 | 307 | if ( in_array( $action, $wgDisabledActions ) ) { |
— | — | @@ -334,9 +310,9 @@ |
335 | 311 | // Workaround for bug #20966: inability of IE to provide an action dependent |
336 | 312 | // on which submit button is clicked. |
337 | 313 | if ( $action === 'historysubmit' ) { |
338 | | - if ( $this->request->getBool( 'revisiondelete' ) ) { |
| 314 | + if ( $this->context->request->getBool( 'revisiondelete' ) ) { |
339 | 315 | return 'revisiondelete'; |
340 | | - } elseif ( $this->request->getBool( 'revisionmove' ) ) { |
| 316 | + } elseif ( $this->context->request->getBool( 'revisionmove' ) ) { |
341 | 317 | return 'revisionmove'; |
342 | 318 | } else { |
343 | 319 | return 'view'; |
— | — | @@ -357,21 +333,21 @@ |
358 | 334 | private function initializeArticle() { |
359 | 335 | wfProfileIn( __METHOD__ ); |
360 | 336 | |
361 | | - $action = $this->request->getVal( 'action', 'view' ); |
362 | | - $article = self::articleFromTitle( $this->title ); |
| 337 | + $action = $this->context->request->getVal( 'action', 'view' ); |
| 338 | + $article = self::articleFromTitle( $this->context->title ); |
363 | 339 | // NS_MEDIAWIKI has no redirects. |
364 | 340 | // It is also used for CSS/JS, so performance matters here... |
365 | | - if ( $this->title->getNamespace() == NS_MEDIAWIKI ) { |
| 341 | + if ( $this->context->title->getNamespace() == NS_MEDIAWIKI ) { |
366 | 342 | wfProfileOut( __METHOD__ ); |
367 | 343 | return $article; |
368 | 344 | } |
369 | 345 | // Namespace might change when using redirects |
370 | 346 | // Check for redirects ... |
371 | | - $file = ( $this->title->getNamespace() == NS_FILE ) ? $article->getFile() : null; |
| 347 | + $file = ( $this->context->title->getNamespace() == NS_FILE ) ? $article->getFile() : null; |
372 | 348 | if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content |
373 | | - && !$this->request->getVal( 'oldid' ) && // ... and are not old revisions |
374 | | - !$this->request->getVal( 'diff' ) && // ... and not when showing diff |
375 | | - $this->request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to |
| 349 | + && !$this->context->request->getVal( 'oldid' ) && // ... and are not old revisions |
| 350 | + !$this->context->request->getVal( 'diff' ) && // ... and not when showing diff |
| 351 | + $this->context->request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to |
376 | 352 | // ... and the article is not a non-redirect image page with associated file |
377 | 353 | !( is_object( $file ) && $file->exists() && !$file->getRedirected() ) ) |
378 | 354 | { |
— | — | @@ -379,7 +355,7 @@ |
380 | 356 | $ignoreRedirect = $target = false; |
381 | 357 | |
382 | 358 | wfRunHooks( 'InitializeArticleMaybeRedirect', |
383 | | - array( &$this->title, &$this->request, &$ignoreRedirect, &$target, &$article ) ); |
| 359 | + array( &$this->context->title, &$this->context->request, &$ignoreRedirect, &$target, &$article ) ); |
384 | 360 | |
385 | 361 | // Follow redirects only for... redirects. |
386 | 362 | // If $target is set, then a hook wanted to redirect. |
— | — | @@ -398,14 +374,14 @@ |
399 | 375 | $rarticle = self::articleFromTitle( $target ); |
400 | 376 | $rarticle->loadPageData(); |
401 | 377 | if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) { |
402 | | - $rarticle->setRedirectedFrom( $this->title ); |
| 378 | + $rarticle->setRedirectedFrom( $this->context->title ); |
403 | 379 | $article = $rarticle; |
404 | | - $this->title = $target; |
405 | | - $this->output->setTitle( $this->title ); |
| 380 | + $this->context->title = $target; |
| 381 | + $this->context->output->setTitle( $this->context->title ); |
406 | 382 | } |
407 | 383 | } |
408 | 384 | } else { |
409 | | - $this->title = $article->getTitle(); |
| 385 | + $this->context->title = $article->getTitle(); |
410 | 386 | } |
411 | 387 | } |
412 | 388 | wfProfileOut( __METHOD__ ); |
— | — | @@ -422,7 +398,7 @@ |
423 | 399 | $factory = wfGetLBFactory(); |
424 | 400 | $factory->commitMasterChanges(); |
425 | 401 | // Output everything! |
426 | | - $this->output->output(); |
| 402 | + $this->context->output->output(); |
427 | 403 | // Do any deferred jobs |
428 | 404 | wfDoUpdates( 'commit' ); |
429 | 405 | // Close the session so that jobs don't access the current session |
— | — | @@ -488,8 +464,8 @@ |
489 | 465 | wfProfileIn( __METHOD__ ); |
490 | 466 | |
491 | 467 | if ( !wfRunHooks( 'MediaWikiPerformAction', array( |
492 | | - $this->output, $article, $this->title, |
493 | | - $user, $this->request, $this ) ) ) |
| 468 | + $this->context->output, $article, $this->context->title, |
| 469 | + $user, $this->context->request, $this ) ) ) |
494 | 470 | { |
495 | 471 | wfProfileOut( __METHOD__ ); |
496 | 472 | return; |
— | — | @@ -499,7 +475,7 @@ |
500 | 476 | |
501 | 477 | switch( $action ) { |
502 | 478 | case 'view': |
503 | | - $this->output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
| 479 | + $this->context->output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
504 | 480 | $article->view(); |
505 | 481 | break; |
506 | 482 | case 'raw': // includes JS/CSS |
— | — | @@ -552,24 +528,24 @@ |
553 | 529 | /* Continue... */ |
554 | 530 | case 'edit': |
555 | 531 | if ( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { |
556 | | - $internal = $this->request->getVal( 'internaledit' ); |
557 | | - $external = $this->request->getVal( 'externaledit' ); |
558 | | - $section = $this->request->getVal( 'section' ); |
559 | | - $oldid = $this->request->getVal( 'oldid' ); |
| 532 | + $internal = $this->context->request->getVal( 'internaledit' ); |
| 533 | + $external = $this->context->request->getVal( 'externaledit' ); |
| 534 | + $section = $this->context->request->getVal( 'section' ); |
| 535 | + $oldid = $this->context->request->getVal( 'oldid' ); |
560 | 536 | if ( !$this->getVal( 'UseExternalEditor' ) || $action == 'submit' || $internal || |
561 | 537 | $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { |
562 | 538 | $editor = new EditPage( $article ); |
563 | 539 | $editor->submit(); |
564 | 540 | } elseif ( $this->getVal( 'UseExternalEditor' ) && ( $external || $user->getOption( 'externaleditor' ) ) ) { |
565 | | - $mode = $this->request->getVal( 'mode' ); |
| 541 | + $mode = $this->context->request->getVal( 'mode' ); |
566 | 542 | $extedit = new ExternalEdit( $article, $mode ); |
567 | 543 | $extedit->edit(); |
568 | 544 | } |
569 | 545 | } |
570 | 546 | break; |
571 | 547 | case 'history': |
572 | | - if ( $this->request->getFullRequestURL() == $this->title->getInternalURL( 'action=history' ) ) { |
573 | | - $this->output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
| 548 | + if ( $this->context->request->getFullRequestURL() == $this->context->title->getInternalURL( 'action=history' ) ) { |
| 549 | + $this->context->output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
574 | 550 | } |
575 | 551 | $history = new HistoryPage( $article ); |
576 | 552 | $history->history(); |
— | — | @@ -586,7 +562,7 @@ |
587 | 563 | break; |
588 | 564 | default: |
589 | 565 | if ( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) { |
590 | | - $this->output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
| 566 | + $this->context->output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
591 | 567 | } |
592 | 568 | } |
593 | 569 | wfProfileOut( __METHOD__ ); |