r114258 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114257‎ | r114258 | r114259 >
Date:12:12, 20 March 2012
Author:daniel
Status:deferred
Tags:
Comment:
fix JS/CSS view
Modified paths:
  • /branches/Wikidata/phase3/includes/Article.php (modified) (history)
  • /branches/Wikidata/phase3/includes/Content.php (modified) (history)
  • /branches/Wikidata/phase3/includes/EditPage.php (modified) (history)
  • /branches/Wikidata/phase3/includes/WikiPage.php (modified) (history)

Diff [purge]

Index: branches/Wikidata/phase3/includes/Article.php
@@ -620,7 +620,7 @@
621621 # Viewing a redirect page (e.g. with parameter redirect=no)
622622 $wgOut->addHTML( $this->viewRedirect( $rt ) );
623623 # Parse just to get categories, displaytitle, etc.
624 - $this->mParserOutput = $content->getParserOutput( $parserOptions );
 624+ $this->mParserOutput = $content->getParserOutput( $this->getTitle(), $oldid, $parserOptions );
625625 $wgOut->addParserOutputNoText( $this->mParserOutput );
626626 $outputDone = true;
627627 }
@@ -754,7 +754,8 @@
755755
756756 // Give hooks a chance to customise the output
757757 if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
758 - $wgOut->addHTML( $this->mContentObject->getHTML() );
 758+ $po = $this->mContentObject->getParserOutput();
 759+ $wgOut->addHTML( $po->getText() );
759760 }
760761 }
761762
Index: branches/Wikidata/phase3/includes/Content.php
@@ -8,7 +8,7 @@
99 */
1010 abstract class Content {
1111
12 - public function __construct( $modelName = null ) { #FIXME: really need revId? annoying! #FIXME: really $title? or just when parsing, every time?
 12+ public function __construct( $modelName = null ) {
1313 $this->mModelName = $modelName;
1414 }
1515
@@ -100,8 +100,6 @@
101101
102102 # XXX: isCacheable( ) # can/should we do this here?
103103
104 - # TODO: WikiPage::getUndoText( Revision $undo, Revision $undoafter = null )
105 -
106104 # TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText
107105 # TODO: tie into EditPage, make it use Content-objects throughout, make edit form aware of content model and format
108106 # TODO: tie into WikiPage, make it use Content-objects throughout, especially in doEdit(), doDelete(), updateRevisionOn(), etc
@@ -205,10 +203,6 @@
206204 $html = $this->getHtml( $options );
207205 $po = new ParserOutput( $html );
208206
209 - if ( $this->mTitle ) $po->setTitleText( $this->mTitle->getText() );
210 -
211 - #TODO: cache settings, etc?
212 -
213207 return $po;
214208 }
215209
@@ -249,7 +243,7 @@
250244 $options = $this->getDefaultParserOptions();
251245 }
252246
253 - $po = $wgParser->parse( $this->mText, $this->getTitle(), $options, true, true, $this->mRevId );
 247+ $po = $wgParser->parse( $this->mText, $title, $options, true, true, $revId );
254248
255249 return $po;
256250 }
Index: branches/Wikidata/phase3/includes/EditPage.php
@@ -1299,17 +1299,15 @@
13001300
13011301 if ( $this->isConflict ) {
13021302 wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" );
1303 - $cnt = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime );
1304 - $text = ContentHandler::getContentText($cnt); #FIXME: use Content object throughout, make edit form aware of content model and serialization format
 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
13051304 } else {
13061305 wfDebug( __METHOD__ . ": getting section '$this->section'\n" );
1307 - $cnt = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle );
1308 - $text = ContentHandler::getContentText($cnt); #FIXME: use Content object throughout, make edit form aware of content model and serialization format
 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
13091307 }
13101308 if ( is_null( $text ) ) {
13111309 wfDebug( __METHOD__ . ": activating conflict; section replace failed.\n" );
13121310 $this->isConflict = true;
1313 - $text = $this->textbox1; // do not try to merge here!
 1311+ $text = $this->textbox1; // do not try to merge here! #FIXME: unserialize Content
13141312 } elseif ( $this->isConflict ) {
13151313 # Attempt merge
13161314 if ( $this->mergeChangesInto( $text ) ) { #FIXME: passe/receive Content object
@@ -2315,7 +2313,7 @@
23162314
23172315 $oldtext = $this->getOriginalContent();
23182316 $newtext = $this->mArticle->replaceSection(
2319 - $this->section, $this->textbox1, $this->summary, $this->edittime );
 2317+ $this->section, $this->textbox1, $this->summary, $this->edittime ); #FIXME: use Content::replaceSection
23202318
23212319 wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) );
23222320
Index: branches/Wikidata/phase3/includes/WikiPage.php
@@ -303,7 +303,9 @@
304304 if ( $text === false ) $content = $this->getContent();
305305 else $content = ContentHandler::makeContent( $text, $this->mTitle ); # TODO: allow model and format to be provided; or better, expect a Content object
306306
307 - return $content->isRedirect();
 307+
 308+ if ( empty( $content ) ) return false;
 309+ else return $content->isRedirect();
308310 }
309311
310312 /**
@@ -429,7 +431,7 @@
430432 *
431433 * @return Contet|false The text of the current revision
432434 */
433 - protected function getNativeData() {
 435+ protected function getNativeData() { #FIXME: examine all uses carefully! caller must be aware of content model!
434436 $content = $this->getContent( Revision::RAW );
435437 if ( !$content ) return null;
436438
@@ -563,7 +565,7 @@
564566 $content = $this->getContent();
565567 }
566568
567 - if ( $content->isRedirect( ) ) {
 569+ if ( !$content || $content->isRedirect( ) ) {
568570 return false;
569571 }
570572
@@ -1111,7 +1113,11 @@
11121114 $handler = ContentHandler::getForTitle( $this->getTitle() );
11131115 $undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter );
11141116
1115 - return ContentHandler::getContentText( $undone );
 1117+ if ( !$undone ) {
 1118+ return false;
 1119+ } else {
 1120+ return ContentHandler::getContentText( $undone );
 1121+ }
11161122 }
11171123
11181124 return false;
@@ -1123,8 +1129,9 @@
11241130 * @param $sectionTitle String: new section's subject, only if $section is 'new'
11251131 * @param $edittime String: revision timestamp or null to use the current revision
11261132 * @return Content new complete article content, or null if error
 1133+ * @deprecated since 1.20: use Content::replaceSection () instead.
11271134 */
1128 - public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) {
 1135+ public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) { #FIXME: create a Content-based version (take and return Content object)
11291136 wfProfileIn( __METHOD__ );
11301137
11311138 $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); #XXX: could make section title, but that's not required.
@@ -1159,7 +1166,7 @@
11601167 }
11611168
11621169 wfProfileOut( __METHOD__ );
1163 - return $newContent;
 1170+ return ContentHandler::getContentText( $newContent ); #XXX: unclear what will happen for non-wikitext!
11641171 }
11651172
11661173 /**
@@ -2762,7 +2769,7 @@
27632770 }
27642771
27652772 $time = - wfTime();
2766 - $this->parserOutput = $content->getParserOutput( $this->parserOptions );
 2773+ $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
27672774 $time += wfTime();
27682775
27692776 # Timing hack

Status & tagging log