Index: branches/Wikidata/phase3/maintenance/populateRevisionLength.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | # Go through and update rev_len from these rows. |
69 | 69 | foreach ( $res as $row ) { |
70 | 70 | $rev = new Revision( $row ); |
71 | | - $text = $rev->getRawText(); |
| 71 | + $text = $rev->getRawText(); #FIXME: go via Content object; #FIXME: get size via Content object |
72 | 72 | if ( !is_string( $text ) ) { |
73 | 73 | # This should not happen, but sometimes does (bug 20757) |
74 | 74 | $this->output( "Text of revision {$row->rev_id} unavailable!\n" ); |
Index: branches/Wikidata/phase3/includes/Article.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | */ |
39 | 39 | public $mParserOptions; |
40 | 40 | |
41 | | - var $mContent; // !< #FIXME: use Content object! |
| 41 | + var $mContent; // !< #BC cruft |
42 | 42 | var $mContentObject; // !< |
43 | 43 | var $mContentLoaded = false; // !< |
44 | 44 | var $mOldId; // !< |
— | — | @@ -192,7 +192,7 @@ |
193 | 193 | * @return Return the text of this revision |
194 | 194 | * @deprecated in 1.20; use getContentObject() instead |
195 | 195 | */ |
196 | | - public function getContent() { #FIXME: deprecated! replace usage! use content object! |
| 196 | + public function getContent() { |
197 | 197 | wfDeprecated( __METHOD__, '1.20' ); |
198 | 198 | $content = $this->getContentObject(); |
199 | 199 | return ContentHandler::getContentText( $content ); |
— | — | @@ -226,7 +226,7 @@ |
227 | 227 | } |
228 | 228 | wfProfileOut( __METHOD__ ); |
229 | 229 | |
230 | | - return new WikitextContent( $text, $this->getTitle() ); |
| 230 | + return ContentHandler::makeContent( $text, $this->getTitle() ); |
231 | 231 | } else { |
232 | 232 | $this->fetchContentObject(); |
233 | 233 | wfProfileOut( __METHOD__ ); |
— | — | @@ -312,7 +312,7 @@ |
313 | 313 | * @return mixed string containing article contents, or false if null |
314 | 314 | * @deprecated in 1.20, use getContentObject() instead |
315 | 315 | */ |
316 | | - function fetchContent() { #BC cruft! #FIXME: deprecated, replace usage |
| 316 | + protected function fetchContent() { #BC cruft! |
317 | 317 | wfDeprecated( __METHOD__, '1.20' ); |
318 | 318 | |
319 | 319 | if ( $this->mContentLoaded && $this->mContent ) { |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | * |
340 | 340 | * @return Content object containing article contents, or null |
341 | 341 | */ |
342 | | - function fetchContentObject() { |
| 342 | + protected function fetchContentObject() { |
343 | 343 | if ( $this->mContentLoaded ) { |
344 | 344 | return $this->mContentObject; |
345 | 345 | } |
— | — | @@ -423,7 +423,7 @@ |
424 | 424 | * @return Revision|null |
425 | 425 | */ |
426 | 426 | public function getRevisionFetched() { |
427 | | - $this->fetchContent(); |
| 427 | + $this->fetchContentObject(); |
428 | 428 | |
429 | 429 | return $this->mRevision; |
430 | 430 | } |
— | — | @@ -582,7 +582,7 @@ |
583 | 583 | break; |
584 | 584 | case 3: |
585 | 585 | # This will set $this->mRevision if needed |
586 | | - $this->fetchContent(); |
| 586 | + $this->fetchContentObject(); |
587 | 587 | |
588 | 588 | # Are we looking at an old revision |
589 | 589 | if ( $oldid && $this->mRevision ) { |
— | — | @@ -603,7 +603,7 @@ |
604 | 604 | |
605 | 605 | # Pages containing custom CSS or JavaScript get special treatment |
606 | 606 | if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) { |
607 | | - #FIXME: use Content object instead! |
| 607 | + #FIXME: use ContentHandler for specialized actions insetad. |
608 | 608 | wfDebug( __METHOD__ . ": showing CSS/JS source\n" ); |
609 | 609 | $this->showCssOrJsPage(); |
610 | 610 | $outputDone = true; |
— | — | @@ -611,14 +611,14 @@ |
612 | 612 | # Allow extensions do their own custom view for certain pages |
613 | 613 | $outputDone = true; |
614 | 614 | } else { |
615 | | - $text = $this->getContent(); |
616 | | - $rt = Title::newFromRedirectArray( $text ); |
| 615 | + $content = $this->getContentObject(); |
| 616 | + $rt = $content->getRedirectChain(); |
617 | 617 | if ( $rt ) { |
618 | 618 | wfDebug( __METHOD__ . ": showing redirect=no page\n" ); |
619 | 619 | # Viewing a redirect page (e.g. with parameter redirect=no) |
620 | 620 | $wgOut->addHTML( $this->viewRedirect( $rt ) ); |
621 | 621 | # Parse just to get categories, displaytitle, etc. |
622 | | - $this->mParserOutput = $wgParser->parse( $text, $this->getTitle(), $parserOptions ); |
| 622 | + $this->mParserOutput = $content->getParserOutput( $parserOptions ); |
623 | 623 | $wgOut->addParserOutputNoText( $this->mParserOutput ); |
624 | 624 | $outputDone = true; |
625 | 625 | } |
— | — | @@ -629,7 +629,7 @@ |
630 | 630 | wfDebug( __METHOD__ . ": doing uncached parse\n" ); |
631 | 631 | |
632 | 632 | $poolArticleView = new PoolWorkArticleView( $this, $parserOptions, |
633 | | - $this->getRevIdFetched(), $useParserCache, $this->getContent() ); |
| 633 | + $this->getRevIdFetched(), $useParserCache, $this->getContentObject() ); |
634 | 634 | |
635 | 635 | if ( !$poolArticleView->execute() ) { |
636 | 636 | $error = $poolArticleView->getError(); |
— | — | @@ -741,24 +741,18 @@ |
742 | 742 | * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these |
743 | 743 | * page views. |
744 | 744 | */ |
745 | | - protected function showCssOrJsPage() { #FIXME: deprecate, keep for BC |
| 745 | + protected function showCssOrJsPage() { #FIXME: move this to handler! |
746 | 746 | global $wgOut; |
747 | 747 | |
748 | 748 | $dir = $this->getContext()->getLanguage()->getDir(); |
749 | 749 | $lang = $this->getContext()->getLanguage()->getCode(); |
750 | 750 | |
751 | 751 | $wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>", |
752 | | - 'clearyourcache' ); #FIXME: get this from handler |
| 752 | + 'clearyourcache' ); #FIXME: do this in handler |
753 | 753 | |
754 | 754 | // Give hooks a chance to customise the output |
755 | 755 | if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) { |
756 | | - #FIXME: use content object instead |
757 | | - // Wrap the whole lot in a <pre> and don't parse |
758 | | - $m = array(); |
759 | | - preg_match( '!\.(css|js)$!u', $this->getTitle()->getText(), $m ); |
760 | | - $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" ); |
761 | | - $wgOut->addHTML( htmlspecialchars( $this->mContent ) ); |
762 | | - $wgOut->addHTML( "\n</pre>\n" ); |
| 756 | + $wgOut->addHTML( $this->mContentObject->getHTML() ); |
763 | 757 | } |
764 | 758 | } |
765 | 759 | |
Index: branches/Wikidata/phase3/includes/Content.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | */ |
8 | 8 | abstract class Content { |
9 | 9 | |
10 | | - public function __construct( Title $title, $revId, $modelName ) { |
| 10 | + public function __construct( Title $title, $revId, $modelName ) { #FIXME: really need revId? annoying! #FIXME: really $title? or just when parsing, every time? |
11 | 11 | $this->mModelName = $modelName; |
12 | 12 | $this->mTitle = $title; |
13 | 13 | $this->mRevId = $revId; |
— | — | @@ -43,6 +43,14 @@ |
44 | 44 | return $update; |
45 | 45 | } |
46 | 46 | |
| 47 | + public function getRedirectChain() { |
| 48 | + return null; |
| 49 | + } |
| 50 | + |
| 51 | + public function getSection( $section ) { #FIXME: should this return text? or a Content object? or what?? |
| 52 | + return null; |
| 53 | + } |
| 54 | + |
47 | 55 | #XXX: is the native model for wikitext a string or the parser output? parse early or parse late? |
48 | 56 | } |
49 | 57 | |
— | — | @@ -90,6 +98,11 @@ |
91 | 99 | return $text; |
92 | 100 | } |
93 | 101 | |
| 102 | + public function getRedirectChain() { |
| 103 | + #XXX: really do this for all text, or just in WikitextContent |
| 104 | + $text = $this->getRawData(); |
| 105 | + return Title::newFromRedirectArray( $text ); |
| 106 | + } |
94 | 107 | } |
95 | 108 | |
96 | 109 | class WikitextContent extends TextContent { |
— | — | @@ -121,11 +134,18 @@ |
122 | 135 | $options = $this->getDefaultParserOptions(); |
123 | 136 | } |
124 | 137 | |
125 | | - $po = $wgParser->parse( $this->mText, $this->getTitle(), $options ); |
| 138 | + $po = $wgParser->parse( $this->mText, $this->getTitle(), $options, true, true, $this->mRevId ); |
126 | 139 | |
127 | 140 | return $po; |
128 | 141 | } |
129 | 142 | |
| 143 | + public function getSection( $section ) { |
| 144 | + global $wgParser; |
| 145 | + |
| 146 | + $text = $this->getRawData(); |
| 147 | + return $wgParser->getSection( $text, $section, false ); |
| 148 | + } |
| 149 | + |
130 | 150 | } |
131 | 151 | |
132 | 152 | class MessageContent extends TextContent { |
Index: branches/Wikidata/phase3/includes/ImagePage.php |
— | — | @@ -245,20 +245,20 @@ |
246 | 246 | return $r; |
247 | 247 | } |
248 | 248 | |
249 | | - /** |
250 | | - * Overloading Article's getContent method. |
251 | | - * |
252 | | - * Omit noarticletext if sharedupload; text will be fetched from the |
253 | | - * shared upload server if possible. |
254 | | - * @return string |
255 | | - */ |
256 | | - public function getContent() { |
257 | | - $this->loadFile(); |
258 | | - if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) { |
259 | | - return ''; |
260 | | - } |
261 | | - return parent::getContent(); |
262 | | - } |
| 249 | + /** |
| 250 | + * Overloading Article's getContentObject method. |
| 251 | + * |
| 252 | + * Omit noarticletext if sharedupload; text will be fetched from the |
| 253 | + * shared upload server if possible. |
| 254 | + * @return string |
| 255 | + */ |
| 256 | + public function getContentObject() { |
| 257 | + $this->loadFile(); |
| 258 | + if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) { |
| 259 | + return null; |
| 260 | + } |
| 261 | + return parent::getContentObject(); |
| 262 | + } |
263 | 263 | |
264 | 264 | protected function openShowImage() { |
265 | 265 | global $wgOut, $wgUser, $wgImageLimits, $wgRequest, |
Index: branches/Wikidata/phase3/includes/ContentHandler.php |
— | — | @@ -25,6 +25,13 @@ |
26 | 26 | return null; |
27 | 27 | } |
28 | 28 | |
| 29 | + public static function makeContent( $text, Title $title, $format = null, $revId = null ) { |
| 30 | + $handler = ContentHandler::getForTitle( $title ); |
| 31 | + |
| 32 | + #FIXME: pass revid? |
| 33 | + return $handler->unserialize( $text, $title, $format ); |
| 34 | + } |
| 35 | + |
29 | 36 | public static function getDefaultModelFor( Title $title ) { |
30 | 37 | global $wgNamespaceContentModels; |
31 | 38 | |
— | — | @@ -130,33 +137,15 @@ |
131 | 138 | return $this->mSupportedFormats[0]; |
132 | 139 | } |
133 | 140 | |
134 | | - public abstract function serialize( $obj, $format = null ); |
| 141 | + public abstract function serialize( $obj, Title $title, $format = null ); |
135 | 142 | # for wikitext, do nothing (in the future: serialise ast/dom) |
136 | 143 | # for wikidata: serialize arrays to json |
137 | 144 | |
138 | | - public abstract function unserialize( $blob, $format = null ); |
| 145 | + public abstract function unserialize( $blob, Title $title, $format = null ); #FIXME: ...and revId? |
139 | 146 | # for wikitext, do nothing (in the future: parse into ast/dom) |
140 | 147 | # for wikidata: serialize arrays to json |
141 | 148 | |
142 | 149 | |
143 | | - public function getSearchText( $obj ) { |
144 | | - # for wikitext, return wikitext |
145 | | - # for wikidata, return pseudo-wikitext composed of property values (or some such) |
146 | | - $text = $this->serialize( $obj ); |
147 | | - return $text; # return the default serialization. |
148 | | - } |
149 | | - |
150 | | - public function getWikitextForTransclusion( $obj ) { |
151 | | - # for wikitext, return text |
152 | | - # for wikidata, return false, or some generated wikitext |
153 | | - $text = $this->serialize( $obj ); |
154 | | - return '<pre>' . $text . '</pre>'; # return a pre-formatted block containing the default serialization. |
155 | | - } |
156 | | - |
157 | | - public abstract function render( $obj, Title $title, ParserOptions $options, $revid = null ); |
158 | | - # returns a ParserOutput instance! |
159 | | - # are parser options, generic?! |
160 | | - |
161 | 150 | public abstract function doPreSaveTransform( $title, $obj ); |
162 | 151 | |
163 | 152 | # TODO: getPreloadText() |
Index: branches/Wikidata/phase3/includes/EditPage.php |
— | — | @@ -864,7 +864,9 @@ |
865 | 865 | if ( $revision === null ) { |
866 | 866 | return ''; |
867 | 867 | } |
868 | | - return $this->mArticle->getContent(); |
| 868 | + |
| 869 | + $content = $this->mArticle->getContentObject(); |
| 870 | + return $content->getRawData(); # this editor is for editing the raw text. so use the raw text. |
869 | 871 | } |
870 | 872 | |
871 | 873 | /** |
— | — | @@ -900,7 +902,7 @@ |
901 | 903 | * @param $preload String: representing the title to preload from. |
902 | 904 | * @return String |
903 | 905 | */ |
904 | | - protected function getPreloadedText( $preload ) { |
| 906 | + protected function getPreloadedText( $preload ) { #FIXME: change to getPreloadedContent() |
905 | 907 | global $wgUser, $wgParser; |
906 | 908 | |
907 | 909 | if ( !empty( $this->mPreloadText ) ) { |
— | — | @@ -928,7 +930,7 @@ |
929 | 931 | } |
930 | 932 | |
931 | 933 | $parserOptions = ParserOptions::newFromUser( $wgUser ); |
932 | | - return $wgParser->getPreloadText( $page->getRawText(), $title, $parserOptions ); |
| 934 | + return $wgParser->getPreloadText( $page->getRawText(), $title, $parserOptions ); #FIXME: create Content::getPreloadCopy |
933 | 935 | } |
934 | 936 | |
935 | 937 | /** |
Index: branches/Wikidata/phase3/includes/api/ApiParse.php |
— | — | @@ -320,7 +320,7 @@ |
321 | 321 | |
322 | 322 | if ( $this->section !== false ) { |
323 | 323 | $this->text = $this->getSectionText( $page->getRawText(), !is_null( $pageId ) |
324 | | - ? 'page id ' . $pageId : $titleObj->getText() ); |
| 324 | + ? 'page id ' . $pageId : $titleObj->getText() ); #FIXME: get section... |
325 | 325 | |
326 | 326 | // Not cached (save or load) |
327 | 327 | return $wgParser->parse( $this->text, $titleObj, $popts ); |
— | — | @@ -329,7 +329,8 @@ |
330 | 330 | // getParserOutput will save to Parser cache if able |
331 | 331 | $pout = $page->getParserOutput( $popts ); |
332 | 332 | if ( $getWikitext ) { |
333 | | - $this->text = $page->getRawText(); |
| 333 | + $this->content = $page->getContent( Revision::RAW ); #FIXME: use $this->content everywhere |
| 334 | + $this->text = $this->content->getRawData(); #FIXME: change $this->text to $this->data?! |
334 | 335 | } |
335 | 336 | return $pout; |
336 | 337 | } |
Index: branches/Wikidata/phase3/includes/api/ApiPurge.php |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | |
92 | 92 | $popts = ParserOptions::newFromContext( $this->getContext() ); |
93 | 93 | $p_result = $wgParser->parse( $page->getRawText(), $title, $popts, |
94 | | - true, true, $page->getLatest() ); |
| 94 | + true, true, $page->getLatest() ); #FIXME: content! |
95 | 95 | |
96 | 96 | # Update the links tables |
97 | 97 | $u = new LinksUpdate( $title, $p_result ); |
Index: branches/Wikidata/phase3/includes/api/ApiEditPage.php |
— | — | @@ -108,21 +108,22 @@ |
109 | 109 | // We do want getContent()'s behavior for non-existent |
110 | 110 | // MediaWiki: pages, though |
111 | 111 | if ( $articleObj->getID() == 0 && $titleObj->getNamespace() != NS_MEDIAWIKI ) { |
112 | | - $content = ''; |
| 112 | + $content = null; |
| 113 | + $text = ''; |
113 | 114 | } else { |
114 | | - $content = $articleObj->getContent(); |
| 115 | + $content = $articleObj->getContentObject(); |
| 116 | + $text = $content->getRawData(); |
115 | 117 | } |
116 | 118 | |
117 | 119 | if ( !is_null( $params['section'] ) ) { |
118 | 120 | // Process the content for section edits |
119 | | - global $wgParser; |
120 | 121 | $section = intval( $params['section'] ); |
121 | | - $content = $wgParser->getSection( $content, $section, false ); |
122 | | - if ( $content === false ) { |
| 122 | + $text = $content->getSection( $section, false ); |
| 123 | + if ( $text === false || $text === null ) { |
123 | 124 | $this->dieUsage( "There is no section {$section}.", 'nosuchsection' ); |
124 | 125 | } |
125 | 126 | } |
126 | | - $params['text'] = $params['prependtext'] . $content . $params['appendtext']; |
| 127 | + $params['text'] = $params['prependtext'] . $text . $params['appendtext']; |
127 | 128 | $toMD5 = $params['prependtext'] . $params['appendtext']; |
128 | 129 | } |
129 | 130 | |
Index: branches/Wikidata/phase3/includes/resourceloader/ResourceLoaderWikiModule.php |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | if ( !$revision ) { |
82 | 82 | return null; |
83 | 83 | } |
84 | | - return $revision->getRawText(); |
| 84 | + return $revision->getRawText(); #FIXME: get raw data from content object after checking the type; |
85 | 85 | } |
86 | 86 | |
87 | 87 | /* Methods */ |
Index: branches/Wikidata/phase3/includes/Revision.php |
— | — | @@ -496,7 +496,7 @@ |
497 | 497 | $this->mCurrent = false; |
498 | 498 | # If we still have no length, see it we have the text to figure it out |
499 | 499 | if ( !$this->mSize ) { |
500 | | - $this->mSize = is_null( $this->mText ) ? null : strlen( $this->mText ); |
| 500 | + $this->mSize = is_null( $this->mText ) ? null : strlen( $this->mText ); #FIXME: do strlen in Content object |
501 | 501 | } |
502 | 502 | # Same for sha1 |
503 | 503 | if ( $this->mSha1 === null ) { |
— | — | @@ -779,7 +779,7 @@ |
780 | 780 | * @return String |
781 | 781 | * @deprectaed in 1.20, use getContent() instead |
782 | 782 | */ |
783 | | - public function getText( $audience = self::FOR_PUBLIC, User $user = null ) { #FIXME: deprecated, replace usage! |
| 783 | + public function getText( $audience = self::FOR_PUBLIC, User $user = null ) { #FIXME: deprecated, replace usage! #FIXME: used a LOT! |
784 | 784 | wfDeprecated( __METHOD__, '1.20' ); |
785 | 785 | |
786 | 786 | $content = $this->getContent(); |
Index: branches/Wikidata/phase3/includes/WikiPage.php |
— | — | @@ -429,6 +429,11 @@ |
430 | 430 | return $this->getText( Revision::RAW ); |
431 | 431 | } |
432 | 432 | |
| 433 | + protected function getRawData() { |
| 434 | + $content = $this->getContent( Revision::RAW ); |
| 435 | + return $content->getRawData(); |
| 436 | + } |
| 437 | + |
433 | 438 | /** |
434 | 439 | * @return string MW timestamp of last article revision |
435 | 440 | */ |
— | — | @@ -542,7 +547,7 @@ |
543 | 548 | * if false, the current database state will be used |
544 | 549 | * @return Boolean |
545 | 550 | */ |
546 | | - public function isCountable( $editInfo = false ) { |
| 551 | + public function isCountable( $editInfo = false ) { #FIXME: move this to Content object |
547 | 552 | global $wgArticleCountMethod; |
548 | 553 | |
549 | 554 | if ( !$this->mTitle->isContentPage() ) { |
— | — | @@ -620,7 +625,7 @@ |
621 | 626 | */ |
622 | 627 | public function insertRedirect() { |
623 | 628 | // recurse through to only get the final target |
624 | | - $retval = Title::newFromRedirectRecurse( $this->getRawText() ); |
| 629 | + $retval = Title::newFromRedirectRecurse( $this->getRawText() ); #FIXME: move this to Content object |
625 | 630 | if ( !$retval ) { |
626 | 631 | return null; |
627 | 632 | } |
— | — | @@ -904,7 +909,7 @@ |
905 | 910 | |
906 | 911 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
907 | 912 | if ( $this->mTitle->exists() ) { |
908 | | - $text = $this->getRawText(); |
| 913 | + $text = $this->getRawData(); |
909 | 914 | } else { |
910 | 915 | $text = false; |
911 | 916 | } |
— | — | @@ -1093,7 +1098,7 @@ |
1094 | 1099 | * @param $undoafter Revision Must be an earlier revision than $undo |
1095 | 1100 | * @return mixed string on success, false on failure |
1096 | 1101 | */ |
1097 | | - public function getUndoText( Revision $undo, Revision $undoafter = null ) { |
| 1102 | + public function getUndoText( Revision $undo, Revision $undoafter = null ) { #FIXME: move undo logic to ContentHandler |
1098 | 1103 | $cur_text = $this->getRawText(); |
1099 | 1104 | if ( $cur_text === false ) { |
1100 | 1105 | return false; // no page |
— | — | @@ -1122,7 +1127,7 @@ |
1123 | 1128 | * @param $edittime String: revision timestamp or null to use the current revision |
1124 | 1129 | * @return string Complete article text, or null if error |
1125 | 1130 | */ |
1126 | | - public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { |
| 1131 | + public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { #FIXME: move to Content object! |
1127 | 1132 | wfProfileIn( __METHOD__ ); |
1128 | 1133 | |
1129 | 1134 | if ( strval( $section ) == '' ) { |
— | — | @@ -1233,7 +1238,7 @@ |
1234 | 1239 | * |
1235 | 1240 | * Compatibility note: this function previously returned a boolean value indicating success/failure |
1236 | 1241 | */ |
1237 | | - public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { |
| 1242 | + public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { #FIXME: change $text to $content |
1238 | 1243 | global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries; |
1239 | 1244 | |
1240 | 1245 | # Low-level sanity check |
— | — | @@ -1268,7 +1273,7 @@ |
1269 | 1274 | $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' ); |
1270 | 1275 | $bot = $flags & EDIT_FORCE_BOT; |
1271 | 1276 | |
1272 | | - $oldtext = $this->getRawText(); // current revision |
| 1277 | + $oldtext = $this->getRawData(); // current revision |
1273 | 1278 | $oldsize = strlen( $oldtext ); |
1274 | 1279 | $oldid = $this->getLatest(); |
1275 | 1280 | $oldIsRedirect = $this->isRedirect(); |
— | — | @@ -1276,7 +1281,7 @@ |
1277 | 1282 | |
1278 | 1283 | # Provide autosummaries if one is not provided and autosummaries are enabled. |
1279 | 1284 | if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) { |
1280 | | - $summary = self::getAutosummary( $oldtext, $text, $flags ); |
| 1285 | + $summary = self::getAutosummary( $oldtext, $text, $flags ); #FIXME: auto-summary from ContentHandler |
1281 | 1286 | } |
1282 | 1287 | |
1283 | 1288 | $editInfo = $this->prepareTextForEdit( $text, null, $user ); |
— | — | @@ -1309,7 +1314,7 @@ |
1310 | 1315 | 'page' => $this->getId(), |
1311 | 1316 | 'comment' => $summary, |
1312 | 1317 | 'minor_edit' => $isminor, |
1313 | | - 'text' => $text, #FIXME: set content instead, leavfe serialization to revision?! |
| 1318 | + 'text' => $text, #FIXME: set content instead, leave serialization to revision?! |
1314 | 1319 | 'parent_id' => $oldid, |
1315 | 1320 | 'user' => $user->getId(), |
1316 | 1321 | 'user_text' => $user->getName(), |
— | — | @@ -1512,7 +1517,7 @@ |
1513 | 1518 | $edit->pst = $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts ); |
1514 | 1519 | $edit->popts = $this->makeParserOptions( 'canonical' ); |
1515 | 1520 | $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid ); |
1516 | | - $edit->oldText = $this->getRawText(); |
| 1521 | + $edit->oldText = $this->getRawText(); #FIXME: $oldcontent instead?! |
1517 | 1522 | |
1518 | 1523 | $this->mPreparedEdit = $edit; |
1519 | 1524 | |
— | — | @@ -2820,14 +2825,18 @@ |
2821 | 2826 | * @param $revid Integer: ID of the revision being parsed |
2822 | 2827 | * @param $useParserCache Boolean: whether to use the parser cache |
2823 | 2828 | * @param $parserOptions parserOptions to use for the parse operation |
2824 | | - * @param $text String: text to parse or null to load it |
| 2829 | + * @param $content Content|String: content to parse or null to load it; may also be given as a wikitext string, for BC |
2825 | 2830 | */ |
2826 | | - function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $text = null ) { |
| 2831 | + function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null ) { |
| 2832 | + if ( is_string($content) ) { #BC: old style call |
| 2833 | + $content = ContentHandler::makeContent( $content, $page->getTitle(), null, $this->revid ); #FIXME: format? from revision? |
| 2834 | + } |
| 2835 | + |
2827 | 2836 | $this->page = $page; |
2828 | 2837 | $this->revid = $revid; |
2829 | 2838 | $this->cacheable = $useParserCache; |
2830 | 2839 | $this->parserOptions = $parserOptions; |
2831 | | - $this->text = $text; |
| 2840 | + $this->content = $content; |
2832 | 2841 | $this->cacheKey = ParserCache::singleton()->getKey( $page, $parserOptions ); |
2833 | 2842 | parent::__construct( 'ArticleView', $this->cacheKey . ':revid:' . $revid ); |
2834 | 2843 | } |
— | — | @@ -2867,21 +2876,20 @@ |
2868 | 2877 | |
2869 | 2878 | $isCurrent = $this->revid === $this->page->getLatest(); |
2870 | 2879 | |
2871 | | - if ( $this->text !== null ) { |
2872 | | - $text = $this->text; |
| 2880 | + if ( $this->content !== null ) { |
| 2881 | + $content = $this->content; |
2873 | 2882 | } elseif ( $isCurrent ) { |
2874 | | - $text = $this->page->getRawText(); |
| 2883 | + $content = $this->page->getContent( Revision::RAW ); #XXX: why use RAW audience here, and PUBLIC (default) below? |
2875 | 2884 | } else { |
2876 | 2885 | $rev = Revision::newFromTitle( $this->page->getTitle(), $this->revid ); |
2877 | 2886 | if ( $rev === null ) { |
2878 | 2887 | return false; |
2879 | 2888 | } |
2880 | | - $text = $rev->getText(); |
| 2889 | + $content = $rev->getContent(); #XXX: why use PUBLIC audience here (default), and RAW above? |
2881 | 2890 | } |
2882 | 2891 | |
2883 | 2892 | $time = - wfTime(); |
2884 | | - $this->parserOutput = $wgParser->parse( $text, $this->page->getTitle(), |
2885 | | - $this->parserOptions, true, true, $this->revid ); |
| 2893 | + $this->parserOutput = $content->getParserOutput( $this->parserOptions ); |
2886 | 2894 | $time += wfTime(); |
2887 | 2895 | |
2888 | 2896 | # Timing hack |