Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -26,57 +26,6 @@ |
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | | - * Initialization of ... everything |
31 | | - * Performs the request too |
32 | | - * |
33 | | - * @param $article Article |
34 | | - */ |
35 | | - public function performRequestForTitle( &$article ) { |
36 | | - wfProfileIn( __METHOD__ ); |
37 | | - |
38 | | - if ( $this->context->request->getVal( 'printable' ) === 'yes' ) { |
39 | | - $this->context->output->setPrintable(); |
40 | | - } |
41 | | - |
42 | | - wfRunHooks( 'BeforeInitialize', array( |
43 | | - &$this->context->title, |
44 | | - &$article, |
45 | | - &$this->context->output, |
46 | | - &$this->context->user, |
47 | | - $this->context->request, |
48 | | - $this |
49 | | - ) ); |
50 | | - |
51 | | - // If the user is not logged in, the Namespace:title of the article must be in |
52 | | - // the Read array in order for the user to see it. (We have to check here to |
53 | | - // catch special pages etc. We check again in Article::view()) |
54 | | - if ( !is_null( $this->context->title ) && !$this->context->title->userCanRead() ) { |
55 | | - $this->context->output->loginToUse(); |
56 | | - $this->finalCleanup(); |
57 | | - $this->context->output->disable(); |
58 | | - wfProfileOut( __METHOD__ ); |
59 | | - return false; |
60 | | - } |
61 | | - |
62 | | - // Call handleSpecialCases() to deal with all special requests... |
63 | | - if ( !$this->handleSpecialCases() ) { |
64 | | - // ...otherwise treat it as an article view. The article |
65 | | - // may be a redirect to another article or URL. |
66 | | - $new_article = $this->initializeArticle(); |
67 | | - if ( is_object( $new_article ) ) { |
68 | | - $article = $new_article; |
69 | | - $this->performAction( $article ); |
70 | | - } elseif ( is_string( $new_article ) ) { |
71 | | - $this->context->output->redirect( $new_article ); |
72 | | - } else { |
73 | | - wfProfileOut( __METHOD__ ); |
74 | | - throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" ); |
75 | | - } |
76 | | - } |
77 | | - wfProfileOut( __METHOD__ ); |
78 | | - } |
79 | | - |
80 | | - /** |
81 | 30 | * Parse $request to get the Title object |
82 | 31 | * |
83 | 32 | * @return Title object to be $wgTitle |
— | — | @@ -135,23 +84,42 @@ |
136 | 85 | } |
137 | 86 | |
138 | 87 | /** |
139 | | - * Initialize some special cases: |
| 88 | + * Performs the request. |
140 | 89 | * - bad titles |
| 90 | + * - read restriction |
141 | 91 | * - local interwiki redirects |
142 | 92 | * - redirect loop |
143 | 93 | * - special pages |
| 94 | + * - normal pages |
144 | 95 | * |
145 | | - * @return bool true if the request is already executed |
| 96 | + * @return Article object |
146 | 97 | */ |
147 | | - private function handleSpecialCases() { |
| 98 | + public function performRequest() { |
148 | 99 | global $wgServer, $wgUsePathInfo; |
149 | 100 | |
150 | 101 | wfProfileIn( __METHOD__ ); |
151 | 102 | |
| 103 | + if ( $this->context->request->getVal( 'printable' ) === 'yes' ) { |
| 104 | + $this->context->output->setPrintable(); |
| 105 | + } |
| 106 | + |
| 107 | + wfRunHooks( 'BeforeInitialize', array( |
| 108 | + &$this->context->title, |
| 109 | + null, |
| 110 | + &$this->context->output, |
| 111 | + &$this->context->user, |
| 112 | + $this->context->request, |
| 113 | + $this |
| 114 | + ) ); |
| 115 | + |
152 | 116 | // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. |
153 | 117 | if ( $this->context->title instanceof BadTitle ) { |
154 | 118 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
155 | | - |
| 119 | + // If the user is not logged in, the Namespace:title of the article must be in |
| 120 | + // the Read array in order for the user to see it. (We have to check here to |
| 121 | + // catch special pages etc. We check again in Article::view()) |
| 122 | + } else if ( !$this->context->title->userCanRead() ) { |
| 123 | + $this->context->output->loginToUse(); |
156 | 124 | // Interwiki redirects |
157 | 125 | } else if ( $this->context->title->getInterwiki() != '' ) { |
158 | 126 | $rdfrom = $this->context->request->getVal( 'rdfrom' ); |
— | — | @@ -205,8 +173,6 @@ |
206 | 174 | "to true."; |
207 | 175 | } |
208 | 176 | wfHttpError( 500, "Internal error", $message ); |
209 | | - wfProfileOut( __METHOD__ ); |
210 | | - return false; |
211 | 177 | } else { |
212 | 178 | $this->context->output->setSquidMaxage( 1200 ); |
213 | 179 | $this->context->output->redirect( $targetUrl, '301' ); |
— | — | @@ -216,13 +182,21 @@ |
217 | 183 | // actions that need to be made when we have a special pages |
218 | 184 | SpecialPageFactory::executePath( $this->context->title, $this->context ); |
219 | 185 | } else { |
220 | | - // No match to special cases |
221 | | - wfProfileOut( __METHOD__ ); |
222 | | - return false; |
| 186 | + // ...otherwise treat it as an article view. The article |
| 187 | + // may be a redirect to another article or URL. |
| 188 | + $article = $this->initializeArticle(); |
| 189 | + if ( is_object( $article ) ) { |
| 190 | + $this->performAction( $article ); |
| 191 | + wfProfileOut( __METHOD__ ); |
| 192 | + return $article; |
| 193 | + } elseif ( is_string( $new_article ) ) { |
| 194 | + $this->context->output->redirect( $new_article ); |
| 195 | + } else { |
| 196 | + wfProfileOut( __METHOD__ ); |
| 197 | + throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" ); |
| 198 | + } |
223 | 199 | } |
224 | | - // Did match a special case |
225 | 200 | wfProfileOut( __METHOD__ ); |
226 | | - return true; |
227 | 201 | } |
228 | 202 | |
229 | 203 | /** |
Index: trunk/phase3/index.php |
— | — | @@ -138,16 +138,15 @@ |
139 | 139 | wfProfileOut( 'index.php-filecache' ); |
140 | 140 | } |
141 | 141 | |
142 | | - $mediaWiki->performRequestForTitle( $article ); |
143 | | - |
144 | 142 | /** |
145 | 143 | * $wgArticle is deprecated, do not use it. This will possibly be removed |
146 | 144 | * entirely in 1.20 or 1.21 |
147 | 145 | * @deprecated since 1.19 |
148 | 146 | */ |
149 | 147 | global $wgArticle; |
150 | | - $wgArticle = $article; |
151 | 148 | |
| 149 | + $wgArticle = $mediaWiki->performRequest(); |
| 150 | + |
152 | 151 | $mediaWiki->finalCleanup(); |
153 | 152 | |
154 | 153 | wfProfileOut( 'index.php' ); |