From 8aafaaedb678246471123850a933a3b9744b30e3 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Mon, 19 Mar 2012 20:34:30 +0000 Subject: [PATCH] avoid getNativeData() --- includes/EditPage.php | 2 +- includes/WikiPage.php | 4 ++-- includes/api/ApiEditPage.php | 5 +++-- includes/api/ApiParse.php | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 84cca5eb76..cd7a8ac8d0 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -866,7 +866,7 @@ class EditPage { } $content = $this->mArticle->getContentObject(); - return $content->getNativeData(); # this editor is for editing the raw text. so use the raw text. + return ContentHandler::getContentText( $content ); # this editor is for editing the raw text. so use the raw text. } /** diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 4f7ba15281..df81657edb 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -911,7 +911,7 @@ class WikiPage extends Page { if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { if ( $this->mTitle->exists() ) { - $text = $this->getNativeData(); + $text = $this->getNativeData(); #FIXME: may not be a string. check Content model! } else { $text = false; } @@ -1265,7 +1265,7 @@ class WikiPage extends Page { $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' ); $bot = $flags & EDIT_FORCE_BOT; - $oldtext = $this->getNativeData(); // current revision + $oldtext = $this->getNativeData(); // current revision #FIXME: may not be a string. check Content model! $oldsize = strlen( $oldtext ); $oldid = $this->getLatest(); $oldIsRedirect = $this->isRedirect(); diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index e3cc80e232..e93b1a2293 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -112,13 +112,14 @@ class ApiEditPage extends ApiBase { $text = ''; } else { $content = $articleObj->getContentObject(); - $text = $content->getNativeData(); + $text = ContentHandler::getContentText( $content ); #FIXME: serialize?! get format from params?... } if ( !is_null( $params['section'] ) ) { // Process the content for section edits $section = intval( $params['section'] ); - $text = $content->getSection( $section, false ); + $sectionContent = $content->getSection( $section ); + $text = ContentHandler::getContentText( $sectionContent ); #FIXME: serialize?! get format from params?... if ( $text === false || $text === null ) { $this->dieUsage( "There is no section {$section}.", 'nosuchsection' ); } diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 070a43d217..10f17a27c2 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -318,7 +318,7 @@ class ApiParse extends ApiBase { $page = WikiPage::factory( $titleObj ); - if ( $this->section !== false ) { + if ( $this->section !== false ) { #FIXME: get section Content, get parser output, ... $this->text = $this->getSectionText( $page->getRawText(), !is_null( $pageId ) ? 'page id ' . $pageId : $titleObj->getText() ); #FIXME: get section... @@ -330,13 +330,13 @@ class ApiParse extends ApiBase { $pout = $page->getParserOutput( $popts ); if ( $getWikitext ) { $this->content = $page->getContent( Revision::RAW ); #FIXME: use $this->content everywhere - $this->text = $this->content->getNativeData(); #FIXME: change $this->text to $this->data?! + $this->text = ContentHandler::getContentText( $this->content ); #FIXME: serialize, get format from params; or use object structure in result? } return $pout; } } - private function getSectionText( $text, $what ) { + private function getSectionText( $text, $what ) { #FIXME: replace with Content::getSection global $wgParser; // Not cached (save or load) $text = $wgParser->getSection( $text, $this->section, false ); -- 2.20.1