Index: trunk/phase3/includes/Article.php |
— | — | @@ -150,6 +150,7 @@ |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Get the title object of the article |
| 154 | + * |
154 | 155 | * @return Title object of this page |
155 | 156 | */ |
156 | 157 | public function getTitle() { |
— | — | @@ -157,6 +158,16 @@ |
158 | 159 | } |
159 | 160 | |
160 | 161 | /** |
| 162 | + * Get the WikiPage object of this instance |
| 163 | + * |
| 164 | + * @since 1.19 |
| 165 | + * @return WikiPage |
| 166 | + */ |
| 167 | + public function getPage() { |
| 168 | + return $this->mPage; |
| 169 | + } |
| 170 | + |
| 171 | + /** |
161 | 172 | * Clear the object |
162 | 173 | */ |
163 | 174 | public function clear() { |
Index: trunk/phase3/includes/context/RequestContext.php |
— | — | @@ -40,6 +40,11 @@ |
41 | 41 | private $title; |
42 | 42 | |
43 | 43 | /** |
| 44 | + * @var WikiPage |
| 45 | + */ |
| 46 | + private $wikipage; |
| 47 | + |
| 48 | + /** |
44 | 49 | * @var OutputPage |
45 | 50 | */ |
46 | 51 | private $output; |
— | — | @@ -104,6 +109,33 @@ |
105 | 110 | } |
106 | 111 | |
107 | 112 | /** |
| 113 | + * Set the WikiPage object |
| 114 | + * |
| 115 | + * @since 1.19 |
| 116 | + * @param $p WikiPage object |
| 117 | + */ |
| 118 | + public function setWikiPage( WikiPage $p ) { |
| 119 | + $this->wikipage = $p; |
| 120 | + } |
| 121 | + |
| 122 | + /** |
| 123 | + * Get the WikiPage object |
| 124 | + * |
| 125 | + * @since 1.19 |
| 126 | + * @return WikiPage |
| 127 | + */ |
| 128 | + public function getWikiPage() { |
| 129 | + if ( $this->wikipage === null ) { |
| 130 | + $title = $this->getTitle(); |
| 131 | + if ( $title === null ) { |
| 132 | + throw new MWException( __METHOD__ . ' called without Title object set' ); |
| 133 | + } |
| 134 | + $this->wikipage = WikiPage::factory( $title ); |
| 135 | + } |
| 136 | + return $this->wikipage; |
| 137 | + } |
| 138 | + |
| 139 | + /** |
108 | 140 | * @param $o OutputPage |
109 | 141 | */ |
110 | 142 | public function setOutput( OutputPage $o ) { |
Index: trunk/phase3/includes/context/IContextSource.php |
— | — | @@ -43,6 +43,14 @@ |
44 | 44 | public function getTitle(); |
45 | 45 | |
46 | 46 | /** |
| 47 | + * Get the WikiPage object |
| 48 | + * |
| 49 | + * @since 1.19 |
| 50 | + * @return WikiPage |
| 51 | + */ |
| 52 | + public function getWikiPage(); |
| 53 | + |
| 54 | + /** |
47 | 55 | * Get the OutputPage object |
48 | 56 | * |
49 | 57 | * @return OutputPage object |
Index: trunk/phase3/includes/context/ContextSource.php |
— | — | @@ -79,6 +79,16 @@ |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
| 83 | + * Get the WikiPage object |
| 84 | + * |
| 85 | + * @since 1.19 |
| 86 | + * @return WikiPage |
| 87 | + */ |
| 88 | + public function getWikiPage() { |
| 89 | + return $this->getContext()->getWikiPage(); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
83 | 93 | * Get the OutputPage object |
84 | 94 | * |
85 | 95 | * @since 1.18 |
Index: trunk/phase3/includes/context/DerivativeContext.php |
— | — | @@ -42,6 +42,11 @@ |
43 | 43 | private $title; |
44 | 44 | |
45 | 45 | /** |
| 46 | + * @var WikiPage |
| 47 | + */ |
| 48 | + private $wikipage; |
| 49 | + |
| 50 | + /** |
46 | 51 | * @var OutputPage |
47 | 52 | */ |
48 | 53 | private $output; |
— | — | @@ -114,6 +119,32 @@ |
115 | 120 | } |
116 | 121 | |
117 | 122 | /** |
| 123 | + * Set the WikiPage object |
| 124 | + * |
| 125 | + * @since 1.19 |
| 126 | + * @param $p WikiPage object |
| 127 | + */ |
| 128 | + public function setWikiPage( WikiPage $p ) { |
| 129 | + $this->wikipage = $p; |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * Get the WikiPage object |
| 134 | + * |
| 135 | + * @since 1.19 |
| 136 | + * @return WikiPage |
| 137 | + */ |
| 138 | + public function getWikiPage() { |
| 139 | + if ( !is_null( $this->wikipage ) ) { |
| 140 | + return $this->wikipage; |
| 141 | + } else { |
| 142 | + return $this->getContext()->getWikiPage(); |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Set the OutputPage object |
| 148 | + * |
118 | 149 | * @param $o OutputPage |
119 | 150 | */ |
120 | 151 | public function setOutput( OutputPage $o ) { |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -337,19 +337,21 @@ |
338 | 338 | |
339 | 339 | wfProfileIn( __METHOD__ ); |
340 | 340 | |
341 | | - $request = $this->context->getRequest(); |
342 | 341 | $title = $this->context->getTitle(); |
343 | | - |
344 | | - $action = $request->getVal( 'action', 'view' ); |
345 | 342 | $article = Article::newFromTitle( $title, $this->context ); |
| 343 | + $this->context->setWikiPage( $article->getPage() ); |
346 | 344 | // NS_MEDIAWIKI has no redirects. |
347 | 345 | // It is also used for CSS/JS, so performance matters here... |
348 | 346 | if ( $title->getNamespace() == NS_MEDIAWIKI ) { |
349 | 347 | wfProfileOut( __METHOD__ ); |
350 | 348 | return $article; |
351 | 349 | } |
| 350 | + |
| 351 | + $request = $this->context->getRequest(); |
| 352 | + |
352 | 353 | // Namespace might change when using redirects |
353 | 354 | // Check for redirects ... |
| 355 | + $action = $request->getVal( 'action', 'view' ); |
354 | 356 | $file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null; |
355 | 357 | if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content |
356 | 358 | && !$request->getVal( 'oldid' ) && // ... and are not old revisions |
— | — | @@ -384,10 +386,12 @@ |
385 | 387 | $rarticle->setRedirectedFrom( $title ); |
386 | 388 | $article = $rarticle; |
387 | 389 | $this->context->setTitle( $target ); |
| 390 | + $this->context->setWikiPage( $article->getPage() ); |
388 | 391 | } |
389 | 392 | } |
390 | 393 | } else { |
391 | 394 | $this->context->setTitle( $article->getTitle() ); |
| 395 | + $this->context->setWikiPage( $article->getPage() ); |
392 | 396 | } |
393 | 397 | } |
394 | 398 | |
— | — | @@ -604,8 +608,7 @@ |
605 | 609 | $cache->loadFromFileCache( $this->context ); |
606 | 610 | } |
607 | 611 | # Do any stats increment/watchlist stuff |
608 | | - $page = WikiPage::factory( $this->getTitle() ); |
609 | | - $page->doViewUpdates( $this->context->getUser() ); |
| 612 | + $this->context->getWikiPage()->doViewUpdates( $this->context->getUser() ); |
610 | 613 | # Tell OutputPage that output is taken care of |
611 | 614 | $this->context->getOutput()->disable(); |
612 | 615 | wfProfileOut( 'main-try-filecache' ); |