Index: branches/Wikidata/phase3/includes/diff/DifferenceEngine.php |
— | — | @@ -926,7 +926,7 @@ |
927 | 927 | /** |
928 | 928 | * Use specified text instead of loading from the database |
929 | 929 | */ |
930 | | - function setText( $oldText, $newText ) { |
| 930 | + function setText( $oldText, $newText ) { #FIXME: deprecate, use Content objects instead! |
931 | 931 | $this->mOldtext = $oldText; |
932 | 932 | $this->mNewtext = $newText; |
933 | 933 | $this->mTextLoaded = 2; |
Index: branches/Wikidata/phase3/includes/Content.php |
— | — | @@ -24,10 +24,25 @@ |
25 | 25 | return $this->getContentHandler()->serialize( $this, $format ); |
26 | 26 | } |
27 | 27 | |
| 28 | + /** |
| 29 | + * @return String a string representing the content in a way useful for building a full text search index. |
| 30 | + * If no useful representation exists, this method returns an empty string. |
| 31 | + */ |
28 | 32 | public abstract function getTextForSearchIndex( ); |
29 | 33 | |
30 | | - public abstract function getWikitextForTransclusion( ); |
| 34 | + /** |
| 35 | + * @return String the wikitext to include when another page includes this content, or false if the content is not |
| 36 | + * includable in a wikitext page. |
| 37 | + */ |
| 38 | + #TODO: allow native handling, bypassing wikitext representation, like for includable special pages. |
| 39 | + public abstract function getWikitextForTransclusion( ); #FIXME: use in parser, etc! |
31 | 40 | |
| 41 | + /** |
| 42 | + * Returns a textual representation of the content suitable for use in edit summaries and log messages. |
| 43 | + * |
| 44 | + * @param int $maxlength maximum length of the summary text |
| 45 | + * @return String the summary text |
| 46 | + */ |
32 | 47 | public abstract function getTextForSummary( $maxlength = 250 ); |
33 | 48 | |
34 | 49 | /** |
— | — | @@ -67,16 +82,50 @@ |
68 | 83 | */ |
69 | 84 | public abstract function isCountable( $hasLinks = null ) ; |
70 | 85 | |
| 86 | + /** |
| 87 | + * @param null|Title $title |
| 88 | + * @param null $revId |
| 89 | + * @param null|ParserOptions $options |
| 90 | + * @return ParserOutput |
| 91 | + */ |
71 | 92 | public abstract function getParserOutput( Title $title = null, $revId = null, ParserOptions $options = NULL ); |
72 | 93 | |
73 | | - public function getRedirectChain() { #TODO: document! |
| 94 | + /** |
| 95 | + * Construct the redirect destination from this content and return an |
| 96 | + * array of Titles, or null if this content doesn't represent a redirect. |
| 97 | + * The last element in the array is the final destination after all redirects |
| 98 | + * have been resolved (up to $wgMaxRedirects times). |
| 99 | + * |
| 100 | + * @return Array of Titles, with the destination last |
| 101 | + */ |
| 102 | + public function getRedirectChain() { |
74 | 103 | return null; |
75 | 104 | } |
76 | 105 | |
| 106 | + /** |
| 107 | + * Construct the redirect destination from this content and return an |
| 108 | + * array of Titles, or null if this content doesn't represent a redirect. |
| 109 | + * This will only return the immediate redirect target, useful for |
| 110 | + * the redirect table and other checks that don't need full recursion. |
| 111 | + * |
| 112 | + * @return Title: The corresponding Title |
| 113 | + */ |
77 | 114 | public function getRedirectTarget() { |
78 | 115 | return null; |
79 | 116 | } |
80 | 117 | |
| 118 | + /** |
| 119 | + * Construct the redirect destination from this content and return the |
| 120 | + * Title, or null if this content doesn't represent a redirect. |
| 121 | + * This will recurse down $wgMaxRedirects times or until a non-redirect target is hit |
| 122 | + * in order to provide (hopefully) the Title of the final destination instead of another redirect. |
| 123 | + * |
| 124 | + * @return Title |
| 125 | + */ |
| 126 | + public function getUltimateRedirectTarget() { |
| 127 | + return null; |
| 128 | + } |
| 129 | + |
81 | 130 | public function isRedirect() { |
82 | 131 | return $this->getRedirectTarget() != null; |
83 | 132 | } |
— | — | @@ -117,6 +166,17 @@ |
118 | 167 | return $this; |
119 | 168 | } |
120 | 169 | |
| 170 | + /** |
| 171 | + * Returns a Content object with preload transformations applied (or this object if no transformations apply). |
| 172 | + * |
| 173 | + * @param Title $title |
| 174 | + * @param null|ParserOptions $popts |
| 175 | + * @return Content |
| 176 | + */ |
| 177 | + public function preloadTransform( Title $title, ParserOptions $popts = null ) { |
| 178 | + return $this; |
| 179 | + } |
| 180 | + |
121 | 181 | #TODO: implement specialized ParserOutput for Wikidata model |
122 | 182 | #TODO: provide "combined" ParserOutput for Multipart... somehow. |
123 | 183 | |
— | — | @@ -124,7 +184,6 @@ |
125 | 185 | |
126 | 186 | # TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText |
127 | 187 | # TODO: tie into EditPage, make it use Content-objects throughout, make edit form aware of content model and format |
128 | | - # TODO: tie into WikiPage, make it use Content-objects throughout, especially in doEditUpdates(), doDelete(), updateRevisionOn(), etc |
129 | 188 | # TODO: make model-aware diff view! |
130 | 189 | # TODO: handle ImagePage and CategoryPage |
131 | 190 | |
— | — | @@ -340,12 +399,32 @@ |
341 | 400 | public function preSaveTransform( Title $title, User $user, ParserOptions $popts = null ) { |
342 | 401 | global $wgParser; |
343 | 402 | |
| 403 | + if ( $popts == null ) $popts = $this->getDefaultParserOptions(); |
| 404 | + |
344 | 405 | $text = $this->getNativeData(); |
345 | 406 | $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts ); |
346 | 407 | |
347 | 408 | return new WikitextContent( $pst ); |
348 | 409 | } |
349 | 410 | |
| 411 | + /** |
| 412 | + * Returns a Content object with preload transformations applied (or this object if no transformations apply). |
| 413 | + * |
| 414 | + * @param Title $title |
| 415 | + * @param null|ParserOptions $popts |
| 416 | + * @return Content |
| 417 | + */ |
| 418 | + public function preloadTransform( Title $title, ParserOptions $popts = null ) { |
| 419 | + global $wgParser; |
| 420 | + |
| 421 | + if ( $popts == null ) $popts = $this->getDefaultParserOptions(); |
| 422 | + |
| 423 | + $text = $this->getNativeData(); |
| 424 | + $plt = $wgParser->getPreloadText( $text, $title, $popts ); |
| 425 | + |
| 426 | + return new WikitextContent( $plt ); |
| 427 | + } |
| 428 | + |
350 | 429 | public function getRedirectChain() { |
351 | 430 | $text = $this->getNativeData(); |
352 | 431 | return Title::newFromRedirectArray( $text ); |
— | — | @@ -356,6 +435,11 @@ |
357 | 436 | return Title::newFromRedirect( $text ); |
358 | 437 | } |
359 | 438 | |
| 439 | + public function getUltimateRedirectTarget() { |
| 440 | + $text = $this->getNativeData(); |
| 441 | + return Title::newFromRedirectRecurse( $text ); |
| 442 | + } |
| 443 | + |
360 | 444 | /** |
361 | 445 | * Returns true if this content is not a redirect, and this content's text is countable according to |
362 | 446 | * the criteria defiend by $wgArticleCountMethod. |
— | — | @@ -405,7 +489,7 @@ |
406 | 490 | |
407 | 491 | class MessageContent extends TextContent { |
408 | 492 | public function __construct( $msg_key, $params = null, $options = null ) { |
409 | | - parent::__construct(null, CONTENT_MODEL_WIKITEXT); |
| 493 | + parent::__construct(null, CONTENT_MODEL_WIKITEXT); #XXX: messages may be wikitext, html or plain text! and maybe even something else entirely. |
410 | 494 | |
411 | 495 | $this->mMessageKey = $msg_key; |
412 | 496 | |
Index: branches/Wikidata/phase3/includes/ContentHandler.php |
— | — | @@ -213,7 +213,7 @@ |
214 | 214 | } |
215 | 215 | **/ |
216 | 216 | |
217 | | - public function getDiffEngine( Article $article ) { |
| 217 | + public function getDiffEngine( Article $article ) { #FIXME: change interface of diff engine? or accept content objects here=? |
218 | 218 | $de = new DifferenceEngine( $article->getContext() ); |
219 | 219 | return $de; |
220 | 220 | } |
Index: branches/Wikidata/phase3/includes/EditPage.php |
— | — | @@ -192,6 +192,7 @@ |
193 | 193 | var $textbox1 = '', $textbox2 = '', $summary = '', $nosummary = false; |
194 | 194 | var $edittime = '', $section = '', $sectiontitle = '', $starttime = ''; |
195 | 195 | var $oldid = 0, $editintro = '', $scrolltop = null, $bot = true; |
| 196 | + var $content_model = null, $content_format = null; |
196 | 197 | |
197 | 198 | # Placeholders for text injection by hooks (must be HTML) |
198 | 199 | # extensions should take care to _append_ to the present value |
— | — | @@ -203,7 +204,7 @@ |
204 | 205 | public $editFormTextBottom = ''; |
205 | 206 | public $editFormTextAfterContent = ''; |
206 | 207 | public $previewTextAfterContent = ''; |
207 | | - public $mPreloadText = ''; |
| 208 | + public $mPreloadContent = null; |
208 | 209 | |
209 | 210 | /* $didSave should be set to true whenever an article was succesfully altered. */ |
210 | 211 | public $didSave = false; |
— | — | @@ -217,6 +218,11 @@ |
218 | 219 | public function __construct( Article $article ) { |
219 | 220 | $this->mArticle = $article; |
220 | 221 | $this->mTitle = $article->getTitle(); |
| 222 | + |
| 223 | + $this->content_model = $this->mTitle->getContentModelName(); |
| 224 | + |
| 225 | + $handler = ContentHandler::getForModelName( $this->content_model ); |
| 226 | + $this->content_format = $handler->getDefaultFormat(); #NOTE: should be overridden by format of actual revision |
221 | 227 | } |
222 | 228 | |
223 | 229 | /** |
— | — | @@ -428,10 +434,10 @@ |
429 | 435 | return; |
430 | 436 | } |
431 | 437 | |
432 | | - $content = $this->getContent(); |
| 438 | + $content = $this->getContentObject(); |
433 | 439 | |
434 | 440 | # Use the normal message if there's nothing to display |
435 | | - if ( $this->firsttime && $content === '' ) { |
| 441 | + if ( $this->firsttime && $content->isEmpty() ) { |
436 | 442 | $action = $this->mTitle->exists() ? 'edit' : |
437 | 443 | ( $this->mTitle->isTalkPage() ? 'createtalk' : 'createpage' ); |
438 | 444 | throw new PermissionsError( $action, $permErrors ); |
— | — | @@ -445,13 +451,18 @@ |
446 | 452 | # If the user made changes, preserve them when showing the markup |
447 | 453 | # (This happens when a user is blocked during edit, for instance) |
448 | 454 | if ( !$this->firsttime ) { |
449 | | - $content = $this->textbox1; |
| 455 | + $handler = ContentHandler::getForModelName( $this->content_model ); |
| 456 | + |
| 457 | + if ( empty( $this->textbox1 ) ) $content = $handler->emptyContent(); |
| 458 | + else $content = $handler->unserialize( $this->textbox1 ); |
| 459 | + |
450 | 460 | $wgOut->addWikiMsg( 'viewyourtext' ); |
451 | 461 | } else { |
452 | 462 | $wgOut->addWikiMsg( 'viewsourcetext' ); |
453 | 463 | } |
454 | 464 | |
455 | | - $this->showTextbox( $content, 'wpTextbox1', array( 'readonly' ) ); |
| 465 | + $text = $content->serialize( $this->content_format ); |
| 466 | + $this->showTextbox( $text, 'wpTextbox1', array( 'readonly' ) ); |
456 | 467 | |
457 | 468 | $wgOut->addHTML( Html::rawElement( 'div', array( 'class' => 'templatesUsed' ), |
458 | 469 | Linker::formatTemplates( $this->getTemplates() ) ) ); |
— | — | @@ -563,9 +574,9 @@ |
564 | 575 | // from a conflict page with raw page text, not a custom form |
565 | 576 | // modified by subclasses |
566 | 577 | wfProfileIn( get_class($this)."::importContentFormData" ); |
567 | | - $textbox1 = $this->importContentFormData( $request ); |
| 578 | + $textbox1 = $this->importContentFormData( $request ); #FIXME: what should this return?? |
568 | 579 | if ( isset($textbox1) ) |
569 | | - $this->textbox1 = $textbox1; |
| 580 | + $this->textbox1 = $textbox1; #XXX: unserialize to Content-object... when? |
570 | 581 | wfProfileOut( get_class($this)."::importContentFormData" ); |
571 | 582 | } |
572 | 583 | |
— | — | @@ -657,7 +668,7 @@ |
658 | 669 | } else { |
659 | 670 | # Not a posted form? Start with nothing. |
660 | 671 | wfDebug( __METHOD__ . ": Not a posted form.\n" ); |
661 | | - $this->textbox1 = ''; |
| 672 | + $this->textbox1 = ''; #FIXME: track content object |
662 | 673 | $this->summary = ''; |
663 | 674 | $this->sectiontitle = ''; |
664 | 675 | $this->edittime = ''; |
— | — | @@ -686,10 +697,14 @@ |
687 | 698 | } |
688 | 699 | } |
689 | 700 | |
| 701 | + $this->oldid = $request->getInt( 'oldid' ); |
| 702 | + |
690 | 703 | $this->bot = $request->getBool( 'bot', true ); |
691 | 704 | $this->nosummary = $request->getBool( 'nosummary' ); |
692 | 705 | |
693 | | - $this->oldid = $request->getInt( 'oldid' ); |
| 706 | + $content_handler = ContentHandler::getForTitle( $this->mTitle ); |
| 707 | + $this->content_model = $request->getText( 'model', $content_handler->getModelName() ); #may be overridden by revision |
| 708 | + $this->content_format = $request->getText( 'format', $content_handler->getDefaultFormat() ); #may be overridden by revision |
694 | 709 | |
695 | 710 | $this->live = $request->getCheck( 'live' ); |
696 | 711 | $this->editintro = $request->getText( 'editintro', |
— | — | @@ -722,7 +737,10 @@ |
723 | 738 | function initialiseForm() { |
724 | 739 | global $wgUser; |
725 | 740 | $this->edittime = $this->mArticle->getTimestamp(); |
726 | | - $this->textbox1 = $this->getContent( false ); |
| 741 | + |
| 742 | + $content = $this->getContentObject( false ); #TODO: track content object?! |
| 743 | + $this->textbox1 = $content->serialize( $this->content_format ); |
| 744 | + |
727 | 745 | // activate checkboxes if user wants them to be always active |
728 | 746 | # Sort out the "watch" checkbox |
729 | 747 | if ( $wgUser->getOption( 'watchdefault' ) ) { |
— | — | @@ -751,33 +769,52 @@ |
752 | 770 | * @param $def_text string |
753 | 771 | * @return mixed string on success, $def_text for invalid sections |
754 | 772 | * @private |
| 773 | + * @deprecated since 1.20 |
755 | 774 | */ |
756 | | - function getContent( $def_text = '' ) { |
757 | | - global $wgOut, $wgRequest, $wgParser; |
| 775 | + function getContent( $def_text = false ) { #FIXME: deprecated, replace usage! |
| 776 | + if ( $def_text !== null && $def_text !== false && $def_text !== '' ) { |
| 777 | + $def_content = ContentHandler::makeContent( $def_text, $this->getTitle() ); |
| 778 | + } else { |
| 779 | + $def_content = false; |
| 780 | + } |
758 | 781 | |
| 782 | + $content = $this->getContentObject( $def_content ); |
| 783 | + |
| 784 | + return $content->serialize( $this->content_format ); #XXX: really use serialized form? use ContentHandler::getContentText() instead? |
| 785 | + } |
| 786 | + |
| 787 | + private function getContentObject( $def_content = null ) { #FIXME: use this! |
| 788 | + global $wgOut, $wgRequest; |
| 789 | + |
759 | 790 | wfProfileIn( __METHOD__ ); |
760 | 791 | |
761 | | - $text = false; |
| 792 | + $content = false; |
762 | 793 | |
763 | 794 | // For message page not locally set, use the i18n message. |
764 | 795 | // For other non-existent articles, use preload text if any. |
765 | 796 | if ( !$this->mTitle->exists() || $this->section == 'new' ) { |
766 | 797 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && $this->section != 'new' ) { |
767 | 798 | # If this is a system message, get the default text. |
768 | | - $text = $this->mTitle->getDefaultMessageText(); |
| 799 | + $msg = $this->mTitle->getDefaultMessageText(); |
| 800 | + |
| 801 | + $content = new WikitextContent($msg); //XXX: really hardcode wikitext here? |
769 | 802 | } |
770 | | - if ( $text === false ) { |
| 803 | + if ( $content === false ) { |
771 | 804 | # If requested, preload some text. |
772 | 805 | $preload = $wgRequest->getVal( 'preload', |
773 | 806 | // Custom preload text for new sections |
774 | 807 | $this->section === 'new' ? 'MediaWiki:addsection-preload' : '' ); |
775 | | - $text = $this->getPreloadedText( $preload ); |
| 808 | + |
| 809 | + $content = $this->getPreloadedContent( $preload ); |
776 | 810 | } |
777 | 811 | // For existing pages, get text based on "undo" or section parameters. |
778 | 812 | } else { |
779 | 813 | if ( $this->section != '' ) { |
780 | 814 | // Get section edit text (returns $def_text for invalid sections) |
781 | | - $text = $wgParser->getSection( $this->getOriginalContent(), $this->section, $def_text ); |
| 815 | + $orig = $this->getOriginalContent(); |
| 816 | + $content = $orig ? $orig->getSection( $this->section ) : null; |
| 817 | + |
| 818 | + if ( !$content ) $content = $def_content; |
782 | 819 | } else { |
783 | 820 | $undoafter = $wgRequest->getInt( 'undoafter' ); |
784 | 821 | $undo = $wgRequest->getInt( 'undo' ); |
— | — | @@ -793,15 +830,16 @@ |
794 | 831 | |
795 | 832 | # Sanity check, make sure it's the right page, |
796 | 833 | # the revisions exist and they were not deleted. |
797 | | - # Otherwise, $text will be left as-is. |
| 834 | + # Otherwise, $content will be left as-is. |
798 | 835 | if ( !is_null( $undorev ) && !is_null( $oldrev ) && |
799 | 836 | $undorev->getPage() == $oldrev->getPage() && |
800 | 837 | $undorev->getPage() == $this->mTitle->getArticleId() && |
801 | 838 | !$undorev->isDeleted( Revision::DELETED_TEXT ) && |
802 | 839 | !$oldrev->isDeleted( Revision::DELETED_TEXT ) ) { |
803 | 840 | |
804 | | - $text = $this->mArticle->getUndoText( $undorev, $oldrev ); |
805 | | - if ( $text === false ) { |
| 841 | + $content = $this->mArticle->getUndoContent( $undorev, $oldrev ); |
| 842 | + |
| 843 | + if ( $content === false ) { |
806 | 844 | # Warn the user that something went wrong |
807 | 845 | $undoMsg = 'failure'; |
808 | 846 | } else { |
— | — | @@ -832,14 +870,14 @@ |
833 | 871 | wfMsgNoTrans( 'undo-' . $undoMsg ) . '</div>', true, /* interface */true ); |
834 | 872 | } |
835 | 873 | |
836 | | - if ( $text === false ) { |
837 | | - $text = $this->getOriginalContent(); |
| 874 | + if ( $content === false ) { |
| 875 | + $content = $this->getOriginalContent(); |
838 | 876 | } |
839 | 877 | } |
840 | 878 | } |
841 | 879 | |
842 | 880 | wfProfileOut( __METHOD__ ); |
843 | | - return $text; |
| 881 | + return $content; |
844 | 882 | } |
845 | 883 | |
846 | 884 | /** |
— | — | @@ -856,33 +894,45 @@ |
857 | 895 | * @since 1.19 |
858 | 896 | * @return string |
859 | 897 | */ |
860 | | - private function getOriginalContent() { |
| 898 | + private function getOriginalContent() { #FIXME: use Content! set content_model and content_format! |
861 | 899 | if ( $this->section == 'new' ) { |
862 | | - return $this->getCurrentText(); |
| 900 | + return $this->getCurrentContent(); |
863 | 901 | } |
864 | 902 | $revision = $this->mArticle->getRevisionFetched(); |
865 | 903 | if ( $revision === null ) { |
866 | | - return ''; |
| 904 | + if ( !$this->content_model ) $this->content_model = $this->getTitle()->getContentModelName(); |
| 905 | + $handler = ContentHandler::getForModelName( $this->content_model ); |
| 906 | + |
| 907 | + return $handler->emptyContent(); |
867 | 908 | } |
868 | 909 | |
869 | 910 | $content = $this->mArticle->getContentObject(); |
870 | | - return ContentHandler::getContentText( $content ); # this editor is for editing the raw text. so use the raw text. |
| 911 | + return $content; |
871 | 912 | } |
872 | 913 | |
873 | 914 | /** |
874 | | - * Get the actual text of the page. This is basically similar to |
875 | | - * WikiPage::getRawText() except that when the page doesn't exist an empty |
876 | | - * string is returned instead of false. |
| 915 | + * Get the current content of the page. This is basically similar to |
| 916 | + * WikiPage::getContent( Revision::RAW ) except that when the page doesn't exist an empty |
| 917 | + * content object is returned instead of null. |
877 | 918 | * |
878 | | - * @since 1.19 |
| 919 | + * @since 1.20 |
879 | 920 | * @return string |
880 | 921 | */ |
881 | | - private function getCurrentText() { |
882 | | - $text = $this->mArticle->getRawText(); |
883 | | - if ( $text === false ) { |
884 | | - return ''; |
| 922 | + private function getCurrentContent() { |
| 923 | + $rev = $this->mArticle->getRevision(); |
| 924 | + $content = $rev->getContentObject( Revision::RAW ); |
| 925 | + |
| 926 | + if ( $content === false || $content === null ) { |
| 927 | + if ( !$this->content_model ) $this->content_model = $this->getTitle()->getContentModelName(); |
| 928 | + $handler = ContentHandler::getForModelName( $this->content_model ); |
| 929 | + |
| 930 | + return $handler->emptyContent(); |
885 | 931 | } else { |
886 | | - return $text; |
| 932 | + #FIXME: nasty side-effect! |
| 933 | + $this->content_model = $rev->getContentModelName(); |
| 934 | + $this->content_format = $rev->getContentFormat(); |
| 935 | + |
| 936 | + return $content; |
887 | 937 | } |
888 | 938 | } |
889 | 939 | |
— | — | @@ -890,33 +940,59 @@ |
891 | 941 | * Use this method before edit() to preload some text into the edit box |
892 | 942 | * |
893 | 943 | * @param $text string |
| 944 | + * @deprecated since 1.20 |
894 | 945 | */ |
895 | | - public function setPreloadedText( $text ) { |
896 | | - $this->mPreloadText = $text; |
| 946 | + public function setPreloadedText( $text ) { #FIXME: deprecated, use setPreloadedContent() |
| 947 | + wfDeprecated( __METHOD__, "1.20" ); |
| 948 | + |
| 949 | + $content = ContentHandler::makeContent( $text, $this->getTitle() ); |
| 950 | + |
| 951 | + $this->setPreloadedContent( $content ); |
897 | 952 | } |
898 | 953 | |
| 954 | + /** |
| 955 | + * Use this method before edit() to preload some content into the edit box |
| 956 | + * |
| 957 | + * @param $content Content |
| 958 | + */ |
| 959 | + public function setPreloadedContent( Content $content ) { #FIXME: use this! |
| 960 | + $this->mPreloadedContent = $content; |
| 961 | + } |
| 962 | + |
899 | 963 | /** |
900 | 964 | * Get the contents to be preloaded into the box, either set by |
901 | 965 | * an earlier setPreloadText() or by loading the given page. |
902 | 966 | * |
903 | 967 | * @param $preload String: representing the title to preload from. |
904 | 968 | * @return String |
| 969 | + * @deprecated since 1.20 |
905 | 970 | */ |
906 | | - protected function getPreloadedText( $preload ) { #FIXME: change to getPreloadedContent() |
907 | | - global $wgUser, $wgParser; |
| 971 | + protected function getPreloadedText( $preload ) { #FIXME: B/C only, replace usage! |
| 972 | + wfDeprecated( __METHOD__, "1.20" ); |
908 | 973 | |
909 | | - if ( !empty( $this->mPreloadText ) ) { |
910 | | - return $this->mPreloadText; |
| 974 | + $content = $this->getPreloadedContent( $preload ); |
| 975 | + $text = $content->serialize( $this->content_format ); #XXX: really use serialized form? use ContentHandler::getContentText() instead?! |
| 976 | + |
| 977 | + return $text; |
| 978 | + } |
| 979 | + |
| 980 | + protected function getPreloadedContent( $preload ) { #FIXME: use this! |
| 981 | + global $wgUser; |
| 982 | + |
| 983 | + if ( !empty( $this->mPreloadContent ) ) { |
| 984 | + return $this->mPreloadContent; |
911 | 985 | } |
| 986 | + |
| 987 | + $handler = ContentHandler::getForTitle( $this->getTitle() ); |
912 | 988 | |
913 | 989 | if ( $preload === '' ) { |
914 | | - return ''; |
| 990 | + return $handler->emptyContent(); |
915 | 991 | } |
916 | 992 | |
917 | 993 | $title = Title::newFromText( $preload ); |
918 | 994 | # Check for existence to avoid getting MediaWiki:Noarticletext |
919 | 995 | if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) { |
920 | | - return ''; |
| 996 | + return $handler->emptyContent(); |
921 | 997 | } |
922 | 998 | |
923 | 999 | $page = WikiPage::factory( $title ); |
— | — | @@ -924,13 +1000,15 @@ |
925 | 1001 | $title = $page->getRedirectTarget(); |
926 | 1002 | # Same as before |
927 | 1003 | if ( $title === null || !$title->exists() || !$title->userCan( 'read' ) ) { |
928 | | - return ''; |
| 1004 | + return $handler->emptyContent(); |
929 | 1005 | } |
930 | 1006 | $page = WikiPage::factory( $title ); |
931 | 1007 | } |
932 | 1008 | |
933 | 1009 | $parserOptions = ParserOptions::newFromUser( $wgUser ); |
934 | | - return $wgParser->getPreloadText( $page->getRawText(), $title, $parserOptions ); #FIXME: create Content::getPreloadCopy |
| 1010 | + $content = $page->getContent( Revision::RAW ); |
| 1011 | + |
| 1012 | + return $content->preloadTransform( $title, $parserOptions ); |
935 | 1013 | } |
936 | 1014 | |
937 | 1015 | /** |
— | — | @@ -1227,12 +1305,14 @@ |
1228 | 1306 | } |
1229 | 1307 | } |
1230 | 1308 | |
1231 | | - $text = $this->textbox1; |
| 1309 | + $content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format ); |
| 1310 | + |
1232 | 1311 | $result['sectionanchor'] = ''; |
1233 | 1312 | if ( $this->section == 'new' ) { |
| 1313 | + .........FIXME............... |
1234 | 1314 | if ( $this->sectiontitle !== '' ) { |
1235 | 1315 | // Insert the section title above the content. |
1236 | | - $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->sectiontitle ) . "\n\n" . $text; |
| 1316 | + $T_E_X_T = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->sectiontitle ) . "\n\n" . $T_E_X_T; |
1237 | 1317 | |
1238 | 1318 | // Jump to the new section |
1239 | 1319 | $result['sectionanchor'] = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle ); |
— | — | @@ -1246,7 +1326,7 @@ |
1247 | 1327 | } |
1248 | 1328 | } elseif ( $this->summary !== '' ) { |
1249 | 1329 | // Insert the section title above the content. |
1250 | | - $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $text; |
| 1330 | + $T_E_X_T = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $T_E_X_T; |
1251 | 1331 | |
1252 | 1332 | // Jump to the new section |
1253 | 1333 | $result['sectionanchor'] = $wgParser->guessLegacySectionNameFromWikiText( $this->summary ); |
— | — | @@ -1299,24 +1379,24 @@ |
1300 | 1380 | |
1301 | 1381 | if ( $this->isConflict ) { |
1302 | 1382 | wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" ); |
1303 | | - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
| 1383 | + $T_E_X_T = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
1304 | 1384 | } else { |
1305 | 1385 | wfDebug( __METHOD__ . ": getting section '$this->section'\n" ); |
1306 | | - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
| 1386 | + $T_E_X_T = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle ); #FIXME: use Content object throughout, make edit form aware of content model and serialization format |
1307 | 1387 | } |
1308 | | - if ( is_null( $text ) ) { |
| 1388 | + if ( is_null( $T_E_X_T ) ) { |
1309 | 1389 | wfDebug( __METHOD__ . ": activating conflict; section replace failed.\n" ); |
1310 | 1390 | $this->isConflict = true; |
1311 | | - $text = $this->textbox1; // do not try to merge here! #FIXME: unserialize Content |
| 1391 | + $T_E_X_T = $this->textbox1; // do not try to merge here! #FIXME: unserialize Content |
1312 | 1392 | } elseif ( $this->isConflict ) { |
1313 | 1393 | # Attempt merge |
1314 | | - if ( $this->mergeChangesInto( $text ) ) { #FIXME: passe/receive Content object |
| 1394 | + if ( $this->mergeChangesInto( $T_E_X_T ) ) { #FIXME: passe/receive Content object |
1315 | 1395 | // Successful merge! Maybe we should tell the user the good news? |
1316 | 1396 | $this->isConflict = false; |
1317 | 1397 | wfDebug( __METHOD__ . ": Suppressing edit conflict, successful merge.\n" ); |
1318 | 1398 | } else { |
1319 | 1399 | $this->section = ''; |
1320 | | - $this->textbox1 = $text; |
| 1400 | + $this->textbox1 = $T_E_X_T; |
1321 | 1401 | wfDebug( __METHOD__ . ": Keeping edit conflict, failed merge.\n" ); |
1322 | 1402 | } |
1323 | 1403 | } |
— | — | @@ -1328,7 +1408,7 @@ |
1329 | 1409 | } |
1330 | 1410 | |
1331 | 1411 | // Run post-section-merge edit filter |
1332 | | - if ( !wfRunHooks( 'EditFilterMerged', array( $this, $text, &$this->hookError, $this->summary ) ) ) { |
| 1412 | + if ( !wfRunHooks( 'EditFilterMerged', array( $this, $T_E_X_T, &$this->hookError, $this->summary ) ) ) { |
1333 | 1413 | # Error messages etc. could be handled within the hook... |
1334 | 1414 | $status->fatal( 'hookaborted' ); |
1335 | 1415 | $status->value = self::AS_HOOK_ERROR; |
— | — | @@ -1344,8 +1424,8 @@ |
1345 | 1425 | |
1346 | 1426 | # Handle the user preference to force summaries here, but not for null edits |
1347 | 1427 | if ( $this->section != 'new' && !$this->allowBlankSummary |
1348 | | - && $this->getOriginalContent() != $text |
1349 | | - && !Title::newFromRedirect( $text ) ) # check if it's not a redirect |
| 1428 | + && $this->getOriginalContent()... != $T_E_X_T |
| 1429 | + && !Title::newFromRedirect( $T_E_X_T ) ) # check if it's not a redirect |
1350 | 1430 | { |
1351 | 1431 | if ( md5( $this->summary ) == $this->autoSumm ) { |
1352 | 1432 | $this->missingSummary = true; |
— | — | @@ -1413,14 +1493,14 @@ |
1414 | 1494 | // merged the section into full text. Clear the section field |
1415 | 1495 | // so that later submission of conflict forms won't try to |
1416 | 1496 | // replace that into a duplicated mess. |
1417 | | - $this->textbox1 = $text; |
| 1497 | + $this->textbox1 = $T_E_X_T; |
1418 | 1498 | $this->section = ''; |
1419 | 1499 | |
1420 | 1500 | $status->value = self::AS_SUCCESS_UPDATE; |
1421 | 1501 | } |
1422 | 1502 | |
1423 | 1503 | // Check for length errors again now that the section is merged in |
1424 | | - $this->kblength = (int)( strlen( $text ) / 1024 ); |
| 1504 | + $this->kblength = (int)( strlen( $T_E_X_T ) / 1024 ); |
1425 | 1505 | if ( $this->kblength > $wgMaxArticleSize ) { |
1426 | 1506 | $this->tooBig = true; |
1427 | 1507 | $status->setResult( false, self::AS_MAX_ARTICLE_SIZE_EXCEEDED ); |
— | — | @@ -1433,10 +1513,10 @@ |
1434 | 1514 | ( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) | |
1435 | 1515 | ( $bot ? EDIT_FORCE_BOT : 0 ); |
1436 | 1516 | |
1437 | | - $doEditStatus = $this->mArticle->doEdit( $text, $this->summary, $flags ); # FIXME: use WikiPage::doEditContent() |
| 1517 | + $doEditStatus = $this->mArticle->doEdit( $T_E_X_T, $this->summary, $flags ); # FIXME: use WikiPage::doEditContent() |
1438 | 1518 | |
1439 | 1519 | if ( $doEditStatus->isOK() ) { |
1440 | | - $result['redirect'] = Title::newFromRedirect( $text ) !== null; |
| 1520 | + $result['redirect'] = Title::newFromRedirect( $T_E_X_T ) !== null; |
1441 | 1521 | $this->commitWatch(); |
1442 | 1522 | wfProfileOut( __METHOD__ ); |
1443 | 1523 | return $status; |
— | — | @@ -1524,11 +1604,11 @@ |
1525 | 1605 | $currentContent = $currentRevision->getContent(); |
1526 | 1606 | |
1527 | 1607 | $handler = ContentHandler::getForModelName( $baseContent->getModelName() ); |
1528 | | - $editContent = $handler->unserialize( $editText ); #FIXME: supply serialization fomrat from edit form! |
| 1608 | + $editContent = $handler->unserialize( $editText, $this->content_format ); #FIXME: supply serialization fomrat from edit form! |
1529 | 1609 | |
1530 | 1610 | $result = $handler->merge3( $baseContent, $editContent, $currentContent ); |
1531 | 1611 | if ( $result ) { |
1532 | | - $editText = ContentHandler::getContentText($result); #FIXME: supply serialization fomrat from edit form! |
| 1612 | + $editText = ContentHandler::getContentText($result, $this->content_format ); #FIXME: supply serialization fomrat from edit form! |
1533 | 1613 | wfProfileOut( __METHOD__ ); |
1534 | 1614 | return true; |
1535 | 1615 | } else { |
— | — | @@ -1822,8 +1902,10 @@ |
1823 | 1903 | // resolved between page source edits and custom ui edits using the |
1824 | 1904 | // custom edit ui. |
1825 | 1905 | $this->textbox2 = $this->textbox1; |
1826 | | - $this->textbox1 = $this->getCurrentText(); |
1827 | 1906 | |
| 1907 | + $content = $this->getCurrentContent(); |
| 1908 | + $this->textbox1 = $content->serialize( $this->content_format ); |
| 1909 | + |
1828 | 1910 | $this->showTextbox1(); |
1829 | 1911 | } else { |
1830 | 1912 | $this->showContentForm(); |
— | — | @@ -1857,7 +1939,7 @@ |
1858 | 1940 | |
1859 | 1941 | $wgOut->addHTML( $this->editFormTextBottom . "\n</form>\n" ); |
1860 | 1942 | |
1861 | | - if ( !$wgUser->getOption( 'previewontop' ) ) { |
| 1943 | + if ( !$wgUser->getOption( 'previewontop' ) ) { |
1862 | 1944 | $this->displayPreviewArea( $previewOutput, false ); |
1863 | 1945 | } |
1864 | 1946 | |
— | — | @@ -2230,10 +2312,10 @@ |
2231 | 2313 | $this->showTextbox( $this->textbox2, 'wpTextbox2', array( 'tabindex' => 6, 'readonly' ) ); |
2232 | 2314 | } |
2233 | 2315 | |
2234 | | - protected function showTextbox( $content, $name, $customAttribs = array() ) { |
| 2316 | + protected function showTextbox( $text, $name, $customAttribs = array() ) { |
2235 | 2317 | global $wgOut, $wgUser; |
2236 | 2318 | |
2237 | | - $wikitext = $this->safeUnicodeOutput( $content ); |
| 2319 | + $wikitext = $this->safeUnicodeOutput( $text ); |
2238 | 2320 | if ( strval($wikitext) !== '' ) { |
2239 | 2321 | // Ensure there's a newline at the end, otherwise adding lines |
2240 | 2322 | // is awkward. |
— | — | @@ -2309,23 +2391,38 @@ |
2310 | 2392 | * save and then make a comparison. |
2311 | 2393 | */ |
2312 | 2394 | function showDiff() { |
2313 | | - global $wgUser, $wgContLang, $wgParser, $wgOut; |
| 2395 | + global $wgUser, $wgContLang, $wgOut; |
2314 | 2396 | |
2315 | | - $oldtext = $this->getOriginalContent(); |
2316 | | - $newtext = $this->mArticle->replaceSection( |
2317 | | - $this->section, $this->textbox1, $this->summary, $this->edittime ); #FIXME: use Content::replaceSection |
| 2397 | + $oldContent = $this->getOriginalContent(); |
2318 | 2398 | |
| 2399 | + $textboxContent = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), |
| 2400 | + $this->content_model, $this->content_format ); |
| 2401 | + |
| 2402 | + $newContent = $this->mArticle->replaceSectionContent( |
| 2403 | + $this->section, $textboxContent, |
| 2404 | + $this->summary, $this->edittime ); |
| 2405 | + |
| 2406 | + # hanlde legacy text-based hook |
| 2407 | + $newtext_orig = $newContent->serialize( $this->content_format ); |
| 2408 | + $newtext = $newtext_orig; #clone |
2319 | 2409 | wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) ); |
2320 | 2410 | |
| 2411 | + if ( $newtext != $newtext_orig ) { |
| 2412 | + #if the hook changed the text, create a new Content object accordingly. |
| 2413 | + $newContent = ContentHandler::makeContent( $newtext, $this->getTitle(), $newContent->getModelName() ); |
| 2414 | + } |
| 2415 | + |
| 2416 | + wfRunHooks( 'EditPageGetDiffContent', array( $this, &$newContent ) ); #FIXME: document new hook |
| 2417 | + |
2321 | 2418 | $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); |
2322 | | - $newtext = $wgParser->preSaveTransform( $newtext, $this->mTitle, $wgUser, $popts ); |
| 2419 | + $newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts ); |
2323 | 2420 | |
2324 | | - if ( $oldtext !== false || $newtext != '' ) { |
| 2421 | + if ( ( $oldContent && !$oldContent->isEmpty() ) || ( $newContent && !$newContent->isEmpty() ) ) { |
2325 | 2422 | $oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) ); |
2326 | 2423 | $newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) ); |
2327 | 2424 | |
2328 | 2425 | $de = new DifferenceEngine( $this->mArticle->getContext() ); |
2329 | | - $de->setText( $oldtext, $newtext ); |
| 2426 | + $de->setText( $oldContent, $newContent ); #FIXME: content-based diff! |
2330 | 2427 | $difftext = $de->getDiff( $oldtitle, $newtitle ); |
2331 | 2428 | $de->showDiffStyle(); |
2332 | 2429 | } else { |
— | — | @@ -3043,10 +3140,12 @@ |
3044 | 3141 | $wgOut->addHTML( '</div>' ); |
3045 | 3142 | |
3046 | 3143 | $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourdiff" ); |
3047 | | - $de = new DifferenceEngine( $this->mArticle->getContext() ); |
3048 | | - $de->setText( $this->getCurrentText(), $this->textbox2 ); |
3049 | | - $de->showDiff( wfMsg( "storedversion" ), wfMsgExt( 'yourtext', 'parseinline' ) ); |
| 3144 | + $de = new DifferenceEngine( $this->mArticle->getContext() ); #FIXME: get from content handler! |
3050 | 3145 | |
| 3146 | + $de->setText( $this->getCurrentText(), $this->textbox2 ); #FIXME: make Content based |
| 3147 | + |
| 3148 | + $de->showDiff( wfMsg( "storedversion" ), wfMsgExt( 'yourtext', 'parseinline' ) ); |
| 3149 | + |
3051 | 3150 | $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourtext" ); |
3052 | 3151 | $this->showTextbox2(); |
3053 | 3152 | |
Index: branches/Wikidata/phase3/includes/WikiPage.php |
— | — | @@ -632,7 +632,8 @@ |
633 | 633 | */ |
634 | 634 | public function insertRedirect() { |
635 | 635 | // recurse through to only get the final target |
636 | | - $retval = Title::newFromRedirectRecurse( $this->getRawText() ); #FIXME: move this to Content object |
| 636 | + $content = $this->getContent(); |
| 637 | + $retval = $content ? $content->getUltimateRedirectTarget() : null; |
637 | 638 | if ( !$retval ) { |
638 | 639 | return null; |
639 | 640 | } |
— | — | @@ -983,9 +984,9 @@ |
984 | 985 | public function updateRevisionOn( $dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) { |
985 | 986 | wfProfileIn( __METHOD__ ); |
986 | 987 | |
987 | | - $text = $revision->getText(); |
988 | | - $len = strlen( $text ); |
989 | | - $rt = Title::newFromRedirectRecurse( $text ); |
| 988 | + $content = $revision->getContent(); |
| 989 | + $len = $content->getSize(); |
| 990 | + $rt = $content->getUltimateRedirectTarget(); |
990 | 991 | |
991 | 992 | $conditions = array( 'page_id' => $this->getId() ); |
992 | 993 | |
— | — | @@ -1129,45 +1130,53 @@ |
1130 | 1131 | * @param $sectionTitle String: new section's subject, only if $section is 'new' |
1131 | 1132 | * @param $edittime String: revision timestamp or null to use the current revision |
1132 | 1133 | * @return Content new complete article content, or null if error |
1133 | | - * @deprecated since 1.20: use Content::replaceSection () instead. |
| 1134 | + * @deprected since 1.20, use replaceSectionContent() instead |
1134 | 1135 | */ |
1135 | | - public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { #FIXME: create a Content-based version (take and return Content object) |
1136 | | - wfProfileIn( __METHOD__ ); |
| 1136 | + public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { #FIXME: use replaceSectionContent() instead! |
| 1137 | + wfDeprecated( __METHOD__, '1.20' ); |
1137 | 1138 | |
1138 | 1139 | $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); #XXX: could make section title, but that's not required. |
1139 | 1140 | |
1140 | | - if ( strval( $section ) == '' ) { |
1141 | | - // Whole-page edit; let the whole text through |
| 1141 | + $newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle, $edittime ); |
| 1142 | + |
| 1143 | + return ContentHandler::getContentText( $newContent ); #XXX: unclear what will happen for non-wikitext! |
| 1144 | + } |
| 1145 | + |
| 1146 | + public function replaceSectionContent( $section, $sectionContent, $sectionTitle = '', $edittime = null ) { |
| 1147 | + wfProfileIn( __METHOD__ ); |
| 1148 | + |
| 1149 | + if ( strval( $section ) == '' ) { |
| 1150 | + // Whole-page edit; let the whole text through |
1142 | 1151 | $newContent = $sectionContent; |
1143 | | - } else { |
1144 | | - // Bug 30711: always use current version when adding a new section |
1145 | | - if ( is_null( $edittime ) || $section == 'new' ) { |
1146 | | - $oldContent = $this->getContent(); |
1147 | | - if ( ! $oldContent ) { |
1148 | | - wfDebug( __METHOD__ . ": no page text\n" ); |
1149 | | - wfProfileOut( __METHOD__ ); |
1150 | | - return null; |
1151 | | - } |
1152 | | - } else { |
1153 | | - $dbw = wfGetDB( DB_MASTER ); |
1154 | | - $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime ); |
| 1152 | + } else { |
| 1153 | + // Bug 30711: always use current version when adding a new section |
| 1154 | + if ( is_null( $edittime ) || $section == 'new' ) { |
| 1155 | + $oldContent = $this->getContent(); |
| 1156 | + if ( ! $oldContent ) { |
| 1157 | + wfDebug( __METHOD__ . ": no page text\n" ); |
| 1158 | + wfProfileOut( __METHOD__ ); |
| 1159 | + return null; |
| 1160 | + } |
| 1161 | + } else { |
| 1162 | + $dbw = wfGetDB( DB_MASTER ); |
| 1163 | + $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime ); |
1155 | 1164 | |
1156 | | - if ( !$rev ) { |
1157 | | - wfDebug( "WikiPage::replaceSection asked for bogus section (page: " . |
1158 | | - $this->getId() . "; section: $section; edittime: $edittime)\n" ); |
1159 | | - wfProfileOut( __METHOD__ ); |
1160 | | - return null; |
1161 | | - } |
| 1165 | + if ( !$rev ) { |
| 1166 | + wfDebug( "WikiPage::replaceSection asked for bogus section (page: " . |
| 1167 | + $this->getId() . "; section: $section; edittime: $edittime)\n" ); |
| 1168 | + wfProfileOut( __METHOD__ ); |
| 1169 | + return null; |
| 1170 | + } |
1162 | 1171 | |
1163 | 1172 | $oldContent = $rev->getContent(); |
1164 | | - } |
| 1173 | + } |
1165 | 1174 | |
1166 | 1175 | $newContent = $oldContent->replaceSection( $section, $sectionContent, $sectionTitle ); |
1167 | | - } |
| 1176 | + } |
1168 | 1177 | |
1169 | | - wfProfileOut( __METHOD__ ); |
1170 | | - return ContentHandler::getContentText( $newContent ); #XXX: unclear what will happen for non-wikitext! |
1171 | | - } |
| 1178 | + wfProfileOut( __METHOD__ ); |
| 1179 | + return $newContent; |
| 1180 | + } |
1172 | 1181 | |
1173 | 1182 | /** |
1174 | 1183 | * Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed. |
— | — | @@ -1653,13 +1662,13 @@ |
1654 | 1663 | wfProfileIn( __METHOD__ ); |
1655 | 1664 | |
1656 | 1665 | $options += array( 'changed' => true, 'created' => false, 'oldcountable' => null ); |
1657 | | - $text = $revision->getText(); |
| 1666 | + $content = $revision->getContent(); |
1658 | 1667 | |
1659 | 1668 | # Parse the text |
1660 | 1669 | # Be careful not to double-PST: $text is usually already PST-ed once |
1661 | 1670 | if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { |
1662 | 1671 | wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" ); |
1663 | | - $editInfo = $this->prepareTextForEdit( $text, $revision->getId(), $user ); |
| 1672 | + $editInfo = $this->prepareContentForEdit( $content, $revision->getId(), $user ); |
1664 | 1673 | } else { |
1665 | 1674 | wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" ); |
1666 | 1675 | $editInfo = $this->mPreparedEdit; |
— | — | @@ -1717,7 +1726,7 @@ |
1718 | 1727 | } |
1719 | 1728 | |
1720 | 1729 | DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) ); |
1721 | | - DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $text ) ); |
| 1730 | + DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) ); |
1722 | 1731 | |
1723 | 1732 | # If this is another user's talk page, update newtalk. |
1724 | 1733 | # Don't do this if $options['changed'] = false (null-edits) nor if |
— | — | @@ -1743,7 +1752,10 @@ |
1744 | 1753 | } |
1745 | 1754 | |
1746 | 1755 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
1747 | | - MessageCache::singleton()->replace( $shortTitle, $text ); |
| 1756 | + $msgtext = ContentHandler::getContentText( $content ); #XXX: could skip pseudo-messages like js/css here, based on content model. |
| 1757 | + if ( $msgtext === false || $msgtext === null ) $msgtext = ''; |
| 1758 | + |
| 1759 | + MessageCache::singleton()->replace( $shortTitle, $msgtext ); |
1748 | 1760 | } |
1749 | 1761 | |
1750 | 1762 | if( $options['created'] ) { |
— | — | @@ -2371,7 +2383,7 @@ |
2372 | 2384 | } |
2373 | 2385 | |
2374 | 2386 | # Actually store the edit |
2375 | | - $status = $this->doEdit( $target->getText(), $summary, $flags, $target->getId(), $guser ); |
| 2387 | + $status = $this->doEditContent( $target->getContent(), $summary, $flags, $target->getId(), $guser ); |
2376 | 2388 | if ( !empty( $status->value['revision'] ) ) { |
2377 | 2389 | $revId = $status->value['revision']->getId(); |
2378 | 2390 | } else { |