Index: branches/Wikidata/phase3/includes/Article.php |
— | — | @@ -38,6 +38,7 @@ |
39 | 39 | public $mParserOptions; |
40 | 40 | |
41 | 41 | var $mContent; // !< #FIXME: use Content object! |
| 42 | + var $mContentObject; // !< |
42 | 43 | var $mContentLoaded = false; // !< |
43 | 44 | var $mOldId; // !< |
44 | 45 | |
— | — | @@ -189,8 +190,25 @@ |
190 | 191 | * only want the real revision text if any. |
191 | 192 | * |
192 | 193 | * @return Return the text of this revision |
| 194 | + * @deprecated in 1.20; use getContentObject() instead |
193 | 195 | */ |
194 | | - public function getContent() { |
| 196 | + public function getContent() { #FIXME: deprecated! replace usage! use content object! |
| 197 | + wfDeprecated( __METHOD__, '1.20' ); |
| 198 | + $content = $this->getContentObject(); |
| 199 | + return ContentHandler::getContentText( $content ); |
| 200 | + } |
| 201 | + |
| 202 | + /** |
| 203 | + * Note that getContent/loadContent do not follow redirects anymore. |
| 204 | + * If you need to fetch redirectable content easily, try |
| 205 | + * the shortcut in WikiPage::getRedirectTarget() |
| 206 | + * |
| 207 | + * This function has side effects! Do not use this function if you |
| 208 | + * only want the real revision text if any. |
| 209 | + * |
| 210 | + * @return Return the content of this revision |
| 211 | + */ |
| 212 | + public function getContentObject() { |
195 | 213 | global $wgUser; |
196 | 214 | |
197 | 215 | wfProfileIn( __METHOD__ ); |
— | — | @@ -208,12 +226,12 @@ |
209 | 227 | } |
210 | 228 | wfProfileOut( __METHOD__ ); |
211 | 229 | |
212 | | - return $text; |
| 230 | + return new WikitextContent( $text, $this->getTitle() ); |
213 | 231 | } else { |
214 | | - $this->fetchContent(); |
| 232 | + $this->fetchContentObject(); |
215 | 233 | wfProfileOut( __METHOD__ ); |
216 | 234 | |
217 | | - return $this->mContent; |
| 235 | + return $this->mContentObject; |
218 | 236 | } |
219 | 237 | } |
220 | 238 | |
— | — | @@ -292,61 +310,89 @@ |
293 | 311 | * Does *NOT* follow redirects. |
294 | 312 | * |
295 | 313 | * @return mixed string containing article contents, or false if null |
| 314 | + * @deprecated in 1.20, use getContentObject() instead |
296 | 315 | */ |
297 | | - function fetchContent() { |
298 | | - if ( $this->mContentLoaded ) { |
| 316 | + function fetchContent() { #BC cruft! #FIXME: deprecated, replace usage |
| 317 | + wfDeprecated( __METHOD__, '1.20' ); |
| 318 | + |
| 319 | + if ( $this->mContentLoaded && $this->mContent ) { |
299 | 320 | return $this->mContent; |
300 | 321 | } |
301 | 322 | |
302 | 323 | wfProfileIn( __METHOD__ ); |
303 | 324 | |
304 | | - $this->mContentLoaded = true; |
| 325 | + $content = $this->fetchContentObject(); |
305 | 326 | |
306 | | - $oldid = $this->getOldID(); |
| 327 | + $this->mContent = ContentHandler::getContentText( $content ); |
| 328 | + wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) ); #BC cruft! |
307 | 329 | |
308 | | - # Pre-fill content with error message so that if something |
309 | | - # fails we'll have something telling us what we intended. |
310 | | - $t = $this->getTitle()->getPrefixedText(); |
311 | | - $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : ''; |
312 | | - $this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ; |
| 330 | + wfProfileOut( __METHOD__ ); |
313 | 331 | |
314 | | - if ( $oldid ) { |
315 | | - # $this->mRevision might already be fetched by getOldIDFromRequest() |
316 | | - if ( !$this->mRevision ) { |
317 | | - $this->mRevision = Revision::newFromId( $oldid ); |
318 | | - if ( !$this->mRevision ) { |
319 | | - wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" ); |
320 | | - wfProfileOut( __METHOD__ ); |
321 | | - return false; |
322 | | - } |
323 | | - } |
324 | | - } else { |
325 | | - if ( !$this->mPage->getLatest() ) { |
326 | | - wfDebug( __METHOD__ . " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n" ); |
327 | | - wfProfileOut( __METHOD__ ); |
328 | | - return false; |
329 | | - } |
| 332 | + return $this->mContent; |
| 333 | + } |
330 | 334 | |
331 | | - $this->mRevision = $this->mPage->getRevision(); |
332 | | - if ( !$this->mRevision ) { |
333 | | - wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n" ); |
334 | | - wfProfileOut( __METHOD__ ); |
335 | | - return false; |
336 | | - } |
337 | | - } |
338 | 335 | |
339 | | - // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks. |
340 | | - // We should instead work with the Revision object when we need it... |
341 | | - $this->mContent = $this->mRevision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed |
342 | | - $this->mRevIdFetched = $this->mRevision->getId(); |
| 336 | + /** |
| 337 | + * Get text content object |
| 338 | + * Does *NOT* follow redirects. |
| 339 | + * |
| 340 | + * @return Content object containing article contents, or null |
| 341 | + */ |
| 342 | + function fetchContentObject() { |
| 343 | + if ( $this->mContentLoaded ) { |
| 344 | + return $this->mContentObject; |
| 345 | + } |
343 | 346 | |
344 | | - wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) ); |
| 347 | + wfProfileIn( __METHOD__ ); |
345 | 348 | |
346 | | - wfProfileOut( __METHOD__ ); |
| 349 | + $this->mContentLoaded = true; |
| 350 | + $this->mContent = null; |
347 | 351 | |
348 | | - return $this->mContent; |
349 | | - } |
| 352 | + $oldid = $this->getOldID(); |
350 | 353 | |
| 354 | + # Pre-fill content with error message so that if something |
| 355 | + # fails we'll have something telling us what we intended. |
| 356 | + $t = $this->getTitle()->getPrefixedText(); |
| 357 | + $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : ''; |
| 358 | + $this->mContentObject = new MessageContent( 'missing-article', array($t, $d), array() ) ; |
| 359 | + |
| 360 | + if ( $oldid ) { |
| 361 | + # $this->mRevision might already be fetched by getOldIDFromRequest() |
| 362 | + if ( !$this->mRevision ) { |
| 363 | + $this->mRevision = Revision::newFromId( $oldid ); |
| 364 | + if ( !$this->mRevision ) { |
| 365 | + wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" ); |
| 366 | + wfProfileOut( __METHOD__ ); |
| 367 | + return false; |
| 368 | + } |
| 369 | + } |
| 370 | + } else { |
| 371 | + if ( !$this->mPage->getLatest() ) { |
| 372 | + wfDebug( __METHOD__ . " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n" ); |
| 373 | + wfProfileOut( __METHOD__ ); |
| 374 | + return false; |
| 375 | + } |
| 376 | + |
| 377 | + $this->mRevision = $this->mPage->getRevision(); |
| 378 | + if ( !$this->mRevision ) { |
| 379 | + wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n" ); |
| 380 | + wfProfileOut( __METHOD__ ); |
| 381 | + return false; |
| 382 | + } |
| 383 | + } |
| 384 | + |
| 385 | + // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks. |
| 386 | + // We should instead work with the Revision object when we need it... |
| 387 | + $this->mContentObject = $this->mRevision->getContent( Revision::FOR_THIS_USER ); // Loads if user is allowed |
| 388 | + $this->mRevIdFetched = $this->mRevision->getId(); |
| 389 | + |
| 390 | + wfRunHooks( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) ); #FIXME: register new hook |
| 391 | + |
| 392 | + wfProfileOut( __METHOD__ ); |
| 393 | + |
| 394 | + return $this->mContentObject; |
| 395 | + } |
| 396 | + |
351 | 397 | /** |
352 | 398 | * No-op |
353 | 399 | * @deprecated since 1.18 |
Index: branches/Wikidata/phase3/includes/Content.php |
— | — | @@ -68,6 +68,8 @@ |
69 | 69 | $html = $this->getHtml( $options ); |
70 | 70 | $po = new ParserOutput( $html ); |
71 | 71 | |
| 72 | + if ( $this->mTitle ) $po->setTitleText( $this->mTitle->getText() ); |
| 73 | + |
72 | 74 | #TODO: cache settings, etc? |
73 | 75 | |
74 | 76 | return $po; |
— | — | @@ -84,8 +86,6 @@ |
85 | 87 | |
86 | 88 | |
87 | 89 | public function getRawData( ) { |
88 | | - global $wgParser, $wgUser; |
89 | | - |
90 | 90 | $text = $this->mText; |
91 | 91 | return $text; |
92 | 92 | } |
— | — | @@ -128,7 +128,36 @@ |
129 | 129 | |
130 | 130 | } |
131 | 131 | |
| 132 | +class MessageContent extends TextContent { |
| 133 | + public function __construct( $msg_key, $params = null, $options = null ) { |
| 134 | + parent::__construct(null, null, null, CONTENT_MODEL_WIKITEXT); |
132 | 135 | |
| 136 | + $this->mMessageKey = $msg_key; |
| 137 | + |
| 138 | + $this->mParameters = $params; |
| 139 | + |
| 140 | + if ( !$options ) $options = array(); |
| 141 | + $this->mOptions = $options; |
| 142 | + |
| 143 | + $this->mHtmlOptions = null; |
| 144 | + } |
| 145 | + |
| 146 | + |
| 147 | + public function getHtml( ParserOptions $options ) { |
| 148 | + $opt = array_merge( $this->mOptions, array('parse') ); |
| 149 | + return wfMsgExt( $this->mMessageKey, $this->mParameters, $opt ); |
| 150 | + } |
| 151 | + |
| 152 | + |
| 153 | + public function getRawData( ) { |
| 154 | + $opt = array_diff( $this->mOptions, array('parse', 'parseinline') ); |
| 155 | + |
| 156 | + return wfMsgExt( $this->mMessageKey, $this->mParameters, $opt ); |
| 157 | + } |
| 158 | + |
| 159 | +} |
| 160 | + |
| 161 | + |
133 | 162 | class JavaScriptContent extends TextContent { |
134 | 163 | public function __construct( $text, Title $title, $revId = null ) { |
135 | 164 | parent::__construct($text, $title, $revId, CONTENT_MODEL_JAVASCRIPT); |
— | — | @@ -160,6 +189,9 @@ |
161 | 190 | } |
162 | 191 | } |
163 | 192 | |
| 193 | +#FIXME: special type for redirects?! |
| 194 | +#FIXME: special type for message-based pseudo-content? with raw html? |
| 195 | + |
164 | 196 | #TODO: MultipartMultipart < WikipageContent (Main + Links + X) |
165 | 197 | #TODO: LinksContent < LanguageLinksContent, CategoriesContent |
166 | 198 | #EXAMPLE: CoordinatesContent |
Index: branches/Wikidata/phase3/includes/ContentHandler.php |
— | — | @@ -13,6 +13,18 @@ |
14 | 14 | */ |
15 | 15 | abstract class ContentHandler { |
16 | 16 | |
| 17 | + public static function getContentText( Content $content ) { |
| 18 | + if ( !$content ) return ''; |
| 19 | + |
| 20 | + if ( $content instanceof TextContent ) { |
| 21 | + #XXX: or check by model name? |
| 22 | + #XXX: or define $content->allowRawData()? |
| 23 | + return $content->getRawData(); |
| 24 | + } |
| 25 | + |
| 26 | + return null; |
| 27 | + } |
| 28 | + |
17 | 29 | public static function getDefaultModelFor( Title $title ) { |
18 | 30 | global $wgNamespaceContentModels; |
19 | 31 | |
Index: branches/Wikidata/phase3/includes/Revision.php |
— | — | @@ -21,7 +21,9 @@ |
22 | 22 | protected $mTitle; |
23 | 23 | protected $mCurrent; |
24 | 24 | protected $mContentModelName; |
25 | | - protected $mContentType; |
| 25 | + protected $mContentFormat; |
| 26 | + protected $mContent; |
| 27 | + protected $mContentHandler; |
26 | 28 | |
27 | 29 | const DELETED_TEXT = 1; |
28 | 30 | const DELETED_COMMENT = 2; |
— | — | @@ -128,7 +130,7 @@ |
129 | 131 | 'len' => $row->ar_len, |
130 | 132 | 'sha1' => isset( $row->ar_sha1 ) ? $row->ar_sha1 : null, |
131 | 133 | 'content_model' => isset( $row->ar_content_model ) ? $row->ar_content_model : null, |
132 | | - 'content_type' => isset( $row->ar_content_type ) ? $row->ar_content_type : null, |
| 134 | + 'content_format' => isset( $row->ar_content_format ) ? $row->ar_content_format : null, |
133 | 135 | ); |
134 | 136 | if ( isset( $row->ar_text ) && !$row->ar_text_id ) { |
135 | 137 | // Pre-1.5 ar_text row |
— | — | @@ -339,7 +341,9 @@ |
340 | 342 | 'rev_deleted', |
341 | 343 | 'rev_len', |
342 | 344 | 'rev_parent_id', |
343 | | - 'rev_sha1' |
| 345 | + 'rev_sha1', |
| 346 | + 'rev_content_format', |
| 347 | + 'rev_content_model' |
344 | 348 | ); |
345 | 349 | } |
346 | 350 | |
— | — | @@ -422,10 +426,10 @@ |
423 | 427 | $this->mContentModelName = strval( $row->rev_content_model ); |
424 | 428 | } |
425 | 429 | |
426 | | - if( !isset( $row->rev_content_type ) || is_null( $row->rev_content_type ) ) { |
427 | | - $this->mContentType = null; # determine on demand if needed |
| 430 | + if( !isset( $row->rev_content_format ) || is_null( $row->rev_content_format ) ) { |
| 431 | + $this->mContentFormat = null; # determine on demand if needed |
428 | 432 | } else { |
429 | | - $this->mContentType = strval( $row->rev_content_type ); |
| 433 | + $this->mContentFormat = strval( $row->rev_content_format ); |
430 | 434 | } |
431 | 435 | |
432 | 436 | // Lazy extraction... |
— | — | @@ -449,6 +453,19 @@ |
450 | 454 | // Build a new revision to be saved... |
451 | 455 | global $wgUser; // ugh |
452 | 456 | |
| 457 | + |
| 458 | + # if we have a content object, use it to set the model and type |
| 459 | + if ( !empty( $row['content'] ) ) { |
| 460 | + if ( !empty( $row['text_id'] ) ) { #FIXME: when is that set? test with external store setup! check out insertOn() |
| 461 | + throw new MWException( "Text already stored in external store (id {$row['text_id']}), can't serialize content object" ); |
| 462 | + } |
| 463 | + |
| 464 | + $row['content_model'] = $row['content']->getModelName(); |
| 465 | + # note: mContentFormat is initializes later accordingly |
| 466 | + # note: content is serialized later in this method! |
| 467 | + # also set text to null? |
| 468 | + } |
| 469 | + |
453 | 470 | $this->mId = isset( $row['id'] ) ? intval( $row['id'] ) : null; |
454 | 471 | $this->mPage = isset( $row['page'] ) ? intval( $row['page'] ) : null; |
455 | 472 | $this->mTextId = isset( $row['text_id'] ) ? intval( $row['text_id'] ) : null; |
— | — | @@ -462,12 +479,12 @@ |
463 | 480 | $this->mSha1 = isset( $row['sha1'] ) ? strval( $row['sha1'] ) : null; |
464 | 481 | |
465 | 482 | $this->mContentModelName = isset( $row['content_model'] ) ? strval( $row['content_model'] ) : null; |
466 | | - $this->mContentType = isset( $row['content_type'] ) ? strval( $row['content_type'] ) : null; |
| 483 | + $this->mContentFormat = isset( $row['content_format'] ) ? strval( $row['content_format'] ) : null; |
467 | 484 | |
468 | | - if( !isset( $row->rev_content_type ) || is_null( $row->rev_content_type ) ) { |
469 | | - $this->mContentType = null; # determine on demand if needed |
| 485 | + if( !isset( $row->rev_content_format ) || is_null( $row->rev_content_format ) ) { |
| 486 | + $this->mContentFormat = null; # determine on demand if needed |
470 | 487 | } else { |
471 | | - $this->mContentType = $row->rev_content_type; |
| 488 | + $this->mContentFormat = $row->rev_content_format; |
472 | 489 | } |
473 | 490 | |
474 | 491 | // Enforce spacing trimming on supplied text |
— | — | @@ -487,11 +504,20 @@ |
488 | 505 | } |
489 | 506 | |
490 | 507 | $this->getContentModelName(); # force lazy init |
491 | | - $this->getContentType(); # force lazy init |
| 508 | + $this->getContentFormat(); # force lazy init |
| 509 | + |
| 510 | + # if we have a content object, serialize it, overriding mText |
| 511 | + if ( !empty( $row['content'] ) ) { |
| 512 | + $handler = $this->getContentHandler(); |
| 513 | + $this->mText = $handler->serialize( $row['content'], $this->getContentFormat() ); |
| 514 | + } |
492 | 515 | } else { |
493 | 516 | throw new MWException( 'Revision constructor passed invalid row format.' ); |
494 | 517 | } |
495 | 518 | $this->mUnpatrolled = null; |
| 519 | + |
| 520 | + #FIXME: add patch for ar_content_format, ar_content_model, rev_content_format, rev_content_model to installer |
| 521 | + #FIXME: add support for ar_content_format, ar_content_model, rev_content_format, rev_content_model to API |
496 | 522 | } |
497 | 523 | |
498 | 524 | /** |
— | — | @@ -755,19 +781,9 @@ |
756 | 782 | */ |
757 | 783 | public function getText( $audience = self::FOR_PUBLIC, User $user = null ) { #FIXME: deprecated, replace usage! |
758 | 784 | wfDeprecated( __METHOD__, '1.20' ); |
| 785 | + |
759 | 786 | $content = $this->getContent(); |
760 | | - |
761 | | - if ( $content == null ) { |
762 | | - return ""; # not allowed |
763 | | - } |
764 | | - |
765 | | - if ( $content instanceof TextContent ) { |
766 | | - #FIXME: or check by model name? or define $content->allowRawData()? |
767 | | - return $content->getRawData(); |
768 | | - } |
769 | | - |
770 | | - #TODO: log this failure! |
771 | | - return null; |
| 787 | + return ContentHandler::getContentText( $content ); # returns the raw content text, if applicable |
772 | 788 | } |
773 | 789 | |
774 | 790 | /** |
— | — | @@ -818,14 +834,14 @@ |
819 | 835 | // Revision is immutable. Load on demand: |
820 | 836 | |
821 | 837 | $handler = $this->getContentHandler(); |
822 | | - $type = $this->getContentType(); |
| 838 | + $format = $this->getContentFormat(); |
823 | 839 | |
824 | 840 | if( is_null( $this->mText ) ) { |
825 | 841 | // Load text on demand: |
826 | 842 | $this->mText = $this->loadText(); |
827 | 843 | } |
828 | 844 | |
829 | | - $this->mContent = $handler->unserialize( $this->mText, $type ); |
| 845 | + $this->mContent = $handler->unserialize( $this->mText, $format ); |
830 | 846 | } |
831 | 847 | |
832 | 848 | return $this->mContent; |
— | — | @@ -840,19 +856,22 @@ |
841 | 857 | return $this->mContentModelName; |
842 | 858 | } |
843 | 859 | |
844 | | - public function getContentType() { |
845 | | - if ( !$this->mContentType ) { |
| 860 | + public function getContentFormat() { |
| 861 | + if ( !$this->mContentFormat ) { |
846 | 862 | $handler = $this->getContentHandler(); |
847 | | - $this->mContentType = $handler->getDefaultFormat(); |
| 863 | + $this->mContentFormat = $handler->getDefaultFormat(); |
848 | 864 | } |
849 | 865 | |
850 | | - return $this->mContentType; |
| 866 | + return $this->mContentFormat; |
851 | 867 | } |
852 | 868 | |
853 | 869 | public function getContentHandler() { |
854 | 870 | if ( !$this->mContentHandler ) { |
855 | 871 | $m = $this->getModelName(); |
856 | 872 | $this->mContentHandler = ContentHandler::getForModelName( $m ); |
| 873 | + |
| 874 | + #XXX: do we need to verify that mContentHandler supports mContentFormat? |
| 875 | + # otherwise, a fixed content format may cause problems on insert. |
857 | 876 | } |
858 | 877 | |
859 | 878 | return $this->mContentHandler; |
— | — | @@ -1098,7 +1117,7 @@ |
1099 | 1118 | ? Revision::base36Sha1( $this->mText ) |
1100 | 1119 | : $this->mSha1, |
1101 | 1120 | 'rev_content_model' => $this->getContentModelName(), |
1102 | | - 'rev_content_type' => $this->getContentType(), |
| 1121 | + 'rev_content_format' => $this->getContentFormat(), |
1103 | 1122 | ), __METHOD__ |
1104 | 1123 | ); |
1105 | 1124 | |
— | — | @@ -1199,7 +1218,7 @@ |
1200 | 1219 | $current = $dbw->selectRow( |
1201 | 1220 | array( 'page', 'revision' ), |
1202 | 1221 | array( 'page_latest', 'rev_text_id', 'rev_len', 'rev_sha1', |
1203 | | - 'rev_content_model', 'rev_content_type' ), |
| 1222 | + 'rev_content_model', 'rev_content_format' ), |
1204 | 1223 | array( |
1205 | 1224 | 'page_id' => $pageId, |
1206 | 1225 | 'page_latest=rev_id', |
— | — | @@ -1216,7 +1235,7 @@ |
1217 | 1236 | 'len' => $current->rev_len, |
1218 | 1237 | 'sha1' => $current->rev_sha1, |
1219 | 1238 | 'content_model' => $current->rev_content_model, |
1220 | | - 'content_type' => $current->rev_content_type |
| 1239 | + 'content_format' => $current->rev_content_format |
1221 | 1240 | ) ); |
1222 | 1241 | } else { |
1223 | 1242 | $revision = null; |
Index: branches/Wikidata/phase3/includes/WikiPage.php |
— | — | @@ -161,6 +161,7 @@ |
162 | 162 | 'page_touched', |
163 | 163 | 'page_latest', |
164 | 164 | 'page_len', |
| 165 | + 'page_content_model', |
165 | 166 | ); |
166 | 167 | } |
167 | 168 | |
— | — | @@ -383,6 +384,23 @@ |
384 | 385 | return null; |
385 | 386 | } |
386 | 387 | |
| 388 | + /** |
| 389 | + * Get the content of the current revision. No side-effects... |
| 390 | + * |
| 391 | + * @param $audience Integer: one of: |
| 392 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 393 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 394 | + * Revision::RAW get the text regardless of permissions |
| 395 | + * @return String|null The content of the current revision |
| 396 | + */ |
| 397 | + public function getContent( $audience = Revision::FOR_PUBLIC ) { |
| 398 | + $this->loadLastEdit(); |
| 399 | + if ( $this->mLastRevision ) { |
| 400 | + return $this->mLastRevision->getContent( $audience ); |
| 401 | + } |
| 402 | + return false; |
| 403 | + } |
| 404 | + |
387 | 405 | /** |
388 | 406 | * Get the text of the current revision. No side-effects... |
389 | 407 | * |
— | — | @@ -391,8 +409,10 @@ |
392 | 410 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
393 | 411 | * Revision::RAW get the text regardless of permissions |
394 | 412 | * @return String|false The text of the current revision |
| 413 | + * @deprecated as of 1.20, getContent() should be used instead. |
395 | 414 | */ |
396 | | - public function getText( $audience = Revision::FOR_PUBLIC ) { |
| 415 | + public function getText( $audience = Revision::FOR_PUBLIC ) { #FIXME: deprecated, replace usage! |
| 416 | + wfDeprecated( __METHOD__, '1.20' ); |
397 | 417 | $this->loadLastEdit(); |
398 | 418 | if ( $this->mLastRevision ) { |
399 | 419 | return $this->mLastRevision->getText( $audience ); |
— | — | @@ -405,12 +425,8 @@ |
406 | 426 | * |
407 | 427 | * @return String|false The text of the current revision |
408 | 428 | */ |
409 | | - public function getRawText() { |
410 | | - $this->loadLastEdit(); |
411 | | - if ( $this->mLastRevision ) { |
412 | | - return $this->mLastRevision->getRawText(); |
413 | | - } |
414 | | - return false; |
| 429 | + public function getRawText() { #FIXME: deprecated, replace usage! |
| 430 | + return $this->getText( Revision::RAW ); |
415 | 431 | } |
416 | 432 | |
417 | 433 | /** |
— | — | @@ -1293,7 +1309,7 @@ |
1294 | 1310 | 'page' => $this->getId(), |
1295 | 1311 | 'comment' => $summary, |
1296 | 1312 | 'minor_edit' => $isminor, |
1297 | | - 'text' => $text, |
| 1313 | + 'text' => $text, #FIXME: set content instead, leavfe serialization to revision?! |
1298 | 1314 | 'parent_id' => $oldid, |
1299 | 1315 | 'user' => $user->getId(), |
1300 | 1316 | 'user_text' => $user->getName(), |
— | — | @@ -1963,7 +1979,9 @@ |
1964 | 1980 | 'ar_len' => 'rev_len', |
1965 | 1981 | 'ar_page_id' => 'page_id', |
1966 | 1982 | 'ar_deleted' => $bitfield, |
1967 | | - 'ar_sha1' => 'rev_sha1' |
| 1983 | + 'ar_sha1' => 'rev_content_model', |
| 1984 | + 'ar_content_format' => 'rev_content_format', |
| 1985 | + 'ar_content_format' => 'rev_sha1' |
1968 | 1986 | ), array( |
1969 | 1987 | 'page_id' => $id, |
1970 | 1988 | 'page_id = rev_page' |
Index: branches/Wikidata/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -116,7 +116,8 @@ |
117 | 117 | $res = $dbr->select( 'archive', |
118 | 118 | array( |
119 | 119 | 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', |
120 | | - 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1' |
| 120 | + 'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1', |
| 121 | + 'ar_content_format', 'ar_content_model' |
121 | 122 | ), |
122 | 123 | array( 'ar_namespace' => $this->title->getNamespace(), |
123 | 124 | 'ar_title' => $this->title->getDBkey() ), |
— | — | @@ -189,6 +190,8 @@ |
190 | 191 | 'ar_deleted', |
191 | 192 | 'ar_len', |
192 | 193 | 'ar_sha1', |
| 194 | + 'ar_content_format', |
| 195 | + 'ar_content_model', |
193 | 196 | ), |
194 | 197 | array( 'ar_namespace' => $this->title->getNamespace(), |
195 | 198 | 'ar_title' => $this->title->getDBkey(), |
— | — | @@ -463,7 +466,9 @@ |
464 | 467 | 'ar_deleted', |
465 | 468 | 'ar_page_id', |
466 | 469 | 'ar_len', |
467 | | - 'ar_sha1' ), |
| 470 | + 'ar_sha1', |
| 471 | + 'ar_content_format', |
| 472 | + 'ar_content_model' ), |
468 | 473 | /* WHERE */ array( |
469 | 474 | 'ar_namespace' => $this->title->getNamespace(), |
470 | 475 | 'ar_title' => $this->title->getDBkey(), |