From: Alexandre Emsenhuber Date: Tue, 15 Nov 2011 21:46:05 +0000 (+0000) Subject: Deprecated WikiPage::preSaveTransform() in favour of Parser::preSaveTransform() and... X-Git-Tag: 1.31.0-rc.0~26482 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=018d885f6416c5e672992319abd48afd5b25803d;p=lhc%2Fweb%2Fwiklou.git Deprecated WikiPage::preSaveTransform() in favour of Parser::preSaveTransform() and updated callers; added wfDeprecated() call since there are no callers in extensions --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 8bcb2a3258..780cb531c7 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2091,13 +2091,16 @@ HTML * save and then make a comparison. */ function showDiff() { + global $wgUser, $wgContLang, $wgParser; + $oldtext = $this->mArticle->fetchContent(); $newtext = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime ); wfRunHooks( 'EditPageGetDiffText', array( $this, &$newtext ) ); - $newtext = $this->mArticle->preSaveTransform( $newtext ); + $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang ); + $newtext = $wgParser->preSaveTransform( $newtext, $this->mTitle, $wgUser, $popts ); $oldtitle = wfMsgExt( 'currentrev', array( 'parseinline' ) ); $newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) ); if ( $oldtext !== false || $newtext != '' ) { @@ -2296,10 +2299,25 @@ HTML * @return string */ function getPreviewText() { - global $wgOut, $wgUser, $wgParser; + global $wgOut, $wgUser, $wgParser, $wgRawHtml; wfProfileIn( __METHOD__ ); + if ( $wgRawHtml && !$this->mTokenOk ) { + // Could be an offsite preview attempt. This is very unsafe if + // HTML is enabled, as it could be an attack. + $parsedNote = ''; + if ( $this->textbox1 !== '' ) { + // Do not put big scary notice, if previewing the empty + // string, which happens when you initially edit + // a category page, due to automatic preview-on-open. + $parsedNote = $wgOut->parse( "
" . + wfMsg( 'session_fail_preview_html' ) . "
", true, /* interface */true ); + } + wfProfileOut( __METHOD__ ); + return $parsedNote; + } + if ( $this->mTriedSave && !$this->mTokenOk ) { if ( $this->mTokenOkExceptSuffix ) { $note = wfMsg( 'token_suffix_mismatch' ); @@ -2314,25 +2332,10 @@ HTML $parserOptions = ParserOptions::newFromUser( $wgUser ); $parserOptions->setEditSection( false ); + $parserOptions->setTidy( true ); $parserOptions->setIsPreview( true ); $parserOptions->setIsSectionPreview( !is_null($this->section) && $this->section !== '' ); - global $wgRawHtml; - if ( $wgRawHtml && !$this->mTokenOk ) { - // Could be an offsite preview attempt. This is very unsafe if - // HTML is enabled, as it could be an attack. - $parsedNote = ''; - if ( $this->textbox1 !== '' ) { - // Do not put big scary notice, if previewing the empty - // string, which happens when you initially edit - // a category page, due to automatic preview-on-open. - $parsedNote = $wgOut->parse( "
" . - wfMsg( 'session_fail_preview_html' ) . "
", true, /* interface */true ); - } - wfProfileOut( __METHOD__ ); - return $parsedNote; - } - # don't parse non-wikitext pages, show message about preview # XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago? @@ -2359,7 +2362,6 @@ HTML } } - $parserOptions->setTidy( true ); $parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions ); $previewHTML = $parserOutput->mText; $previewHTML .= "
\n" . htmlspecialchars( $this->textbox1 ) . "\n
\n"; @@ -2378,10 +2380,10 @@ HTML wfRunHooks( 'EditPageGetPreviewText', array( $this, &$toparse ) ); - $parserOptions->setTidy( true ); $parserOptions->enableLimitReport(); - $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $toparse ), - $this->mTitle, $parserOptions ); + + $toparse = $wgParser->preSaveTransform( $toparse, $this->mTitle, $wgUser, $parserOptions ); + $parserOutput = $wgParser->parse( $toparse, $this->mTitle, $parserOptions ); $previewHTML = $parserOutput->getText(); $this->mParserOutput = $parserOutput; diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 9b7a02cad2..fe85e8be47 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1977,7 +1977,7 @@ class WikiPage extends Page { $edit = (object)array(); $edit->revid = $revid; $edit->newText = $text; - $edit->pst = $this->preSaveTransform( $text, $user, $popts ); + $edit->pst = $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts ); $edit->popts = $this->makeParserOptions( 'canonical' ); $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid ); $edit->oldText = $this->getRawText(); @@ -2131,6 +2131,7 @@ class WikiPage extends Page { * This function is called right before saving the wikitext, * so we can do things like signatures and links-in-context. * + * @deprecated in 1.19; use Parser::preSaveTransform() instead * @param $text String article contents * @param $user User object: user doing the edit * @param $popts ParserOptions object: parser options, default options for @@ -2140,6 +2141,9 @@ class WikiPage extends Page { */ public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) { global $wgParser, $wgUser; + + wfDeprecated( __METHOD__ ); + $user = is_null( $user ) ? $wgUser : $user; if ( $popts === null ) {