fixing long lines

Change-Id: Iebcd40a1a37a3a93cc571fa2c2b0a87f53dc97a4
This commit is contained in:
daniel 2012-08-20 21:33:07 +02:00
parent b642ae2b87
commit 0139923580
21 changed files with 181 additions and 91 deletions

View file

@ -424,7 +424,8 @@ class Article extends Page {
# Pre-fill content with error message so that if something
# fails we'll have something telling us what we intended.
$this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ), array() ) ; // @todo: this isn't page content but a UI message. horrible.
// @todo: this isn't page content but a UI message. horrible.
$this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ), array() ) ;
if ( $oldid ) {
# $this->mRevision might already be fetched by getOldIDFromRequest()
@ -1720,7 +1721,8 @@ class Article extends Page {
throw new MWException( "can't change parser options after they have already been set" );
}
$this->mParserOptions = clone $options; // clone, so if $options is modified later, it doesn't confuse the parser cache.
// clone, so if $options is modified later, it doesn't confuse the parser cache.
$this->mParserOptions = clone $options;
}
/**

View file

@ -297,7 +297,7 @@ define( 'CONTENT_FORMAT_JAVASCRIPT', 'text/javascript' ); // for js pages
define( 'CONTENT_FORMAT_CSS', 'text/css' ); // for css pages
define( 'CONTENT_FORMAT_TEXT', 'text/plain' ); // for future use, e.g. with some plain-html messages.
define( 'CONTENT_FORMAT_HTML', 'text/html' ); // for future use, e.g. with some plain-html messages.
define( 'CONTENT_FORMAT_SERIALIZED', 'application/vnd.php.serialized' ); // for future use with the api, and for use by extensions
define( 'CONTENT_FORMAT_SERIALIZED', 'application/vnd.php.serialized' ); // for future use with the api and for extensions
define( 'CONTENT_FORMAT_JSON', 'application/json' ); // for future use with the api, and for use by extensions
define( 'CONTENT_FORMAT_XML', 'application/xml' ); // for future use with the api, and for use by extensions
/**@}*/

View file

@ -1007,7 +1007,8 @@ class EditPage {
wfDeprecated( __METHOD__, "1.WD" );
$content = $this->getPreloadedContent( $preload );
$text = $content->serialize( $this->content_format ); #XXX: really use serialized form? use ContentHandler::getContentText() instead?!
$text = $content->serialize( $this->content_format );
#XXX: really use serialized form? use ContentHandler::getContentText() instead?!
return $text;
}
@ -1344,7 +1345,8 @@ class EditPage {
return $status;
}
$content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
$content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
$this->content_model, $this->content_format );
$result['sectionanchor'] = '';
if ( $this->section == 'new' ) {
@ -1415,14 +1417,18 @@ class EditPage {
$sectionTitle = $this->summary;
}
$textbox_content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
$textbox_content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
$this->content_model, $this->content_format );
$content = null;
if ( $this->isConflict ) {
wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" );
$content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle, $this->edittime );
wfDebug( __METHOD__ . ": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
. " (article time '{$timestamp}')\n" );
$content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content,
$sectionTitle, $this->edittime );
} else {
wfDebug( __METHOD__ . ": getting section '$this->section'\n" );
wfDebug( __METHOD__ . ": getting section '{$this->section}'\n" );
$content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle );
}
@ -1466,7 +1472,8 @@ class EditPage {
return $status;
}
$content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
$content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
$this->content_model, $this->content_format );
# Handle the user preference to force summaries here, but not for null edits
if ( $this->section != 'new' && !$this->allowBlankSummary
@ -1559,7 +1566,8 @@ class EditPage {
( ( $this->minoredit && !$this->isNew ) ? EDIT_MINOR : 0 ) |
( $bot ? EDIT_FORCE_BOT : 0 );
$doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags, false, null, $this->content_format );
$doEditStatus = $this->mArticle->doEditContent( $content, $this->summary, $flags,
false, null, $this->content_format );
if ( $doEditStatus->isOK() ) {
$result['redirect'] = $content->isRedirect();
@ -1647,7 +1655,8 @@ class EditPage {
function mergeChangesInto( &$editText ){
wfDebug( __METHOD__, "1.WD" );
$editContent = ContentHandler::makeContent( $editText, $this->getTitle(), $this->content_model, $this->content_format );
$editContent = ContentHandler::makeContent( $editText, $this->getTitle(),
$this->content_model, $this->content_format );
$ok = $this->mergeChangesIntoContent( $editContent );
@ -2530,8 +2539,9 @@ HTML
$oldContent = $this->getOriginalContent();
}
#XXX: handle parse errors ?
$textboxContent = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
$this->content_model, $this->content_format ); #XXX: handle parse errors ?
$this->content_model, $this->content_format );
$newContent = $this->mArticle->replaceSectionContent(
$this->section, $textboxContent,
@ -2544,7 +2554,9 @@ HTML
if ( $newtext != $newtext_orig ) {
#if the hook changed the text, create a new Content object accordingly.
$newContent = ContentHandler::makeContent( $newtext, $this->getTitle(), $newContent->getModel() ); #XXX: handle parse errors ?
#XXX: handle parse errors ?
$newContent = ContentHandler::makeContent( $newtext, $this->getTitle(),
$newContent->getModel() );
}
wfRunHooks( 'EditPageGetDiffContent', array( $this, &$newContent ) );
@ -2786,7 +2798,8 @@ HTML
$note = '';
try {
$content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(), $this->content_model, $this->content_format );
$content = ContentHandler::makeContent( $this->textbox1, $this->getTitle(),
$this->content_model, $this->content_format );
if ( $this->mTriedSave && !$this->mTokenOk ) {
if ( $this->mTokenOkExceptSuffix ) {
@ -2798,7 +2811,8 @@ HTML
$note = wfMessage( 'edit_form_incomplete' )->text() ;
} else {
$note = wfMessage( 'previewnote' )->text() .
' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage( 'continue-editing' )->text() . ']]';
' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' '
. wfMessage( 'continue-editing' )->text() . ']]';
}
$parserOptions = ParserOptions::newFromUser( $wgUser );
@ -2854,14 +2868,16 @@ HTML
if ( $toparse !== $toparse_orig ) {
#hook changed the text, create new Content object
$content = ContentHandler::makeContent( $toparse, $this->getTitle(), $this->content_model, $this->content_format );
$content = ContentHandler::makeContent( $toparse, $this->getTitle(),
$this->content_model, $this->content_format );
}
wfRunHooks( 'EditPageGetPreviewContent', array( $this, &$content ) );
$parserOptions->enableLimitReport();
#XXX: For CSS/JS pages, we should have called the ShowRawCssJs hook here. But it's now deprecated, so never mind
#XXX: For CSS/JS pages, we should have called the ShowRawCssJs hook here.
# But it's now deprecated, so never mind
$content = $content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
// TODO: might be a saner way to get a meaningfull context here?
@ -2876,7 +2892,8 @@ HTML
}
}
} catch (MWContentSerializationException $ex) {
$note .= "\n\n" . wfMessage('content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() )->parse();
$m = wfMessage('content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() );
$note .= "\n\n" . $m->parse();
$previewHTML = '';
}

View file

@ -534,8 +534,10 @@ class Revision implements IDBAccessObject {
# if we have a content object, use it to set the model and type
if ( !empty( $row['content'] ) ) {
if ( !empty( $row['text_id'] ) ) { //@todo: when is that set? test with external store setup! check out insertOn() [dk]
throw new MWException( "Text already stored in external store (id {$row['text_id']}), can't serialize content object" );
//@todo: when is that set? test with external store setup! check out insertOn() [dk]
if ( !empty( $row['text_id'] ) ) {
throw new MWException( "Text already stored in external store (id {$row['text_id']}), "
. "can't serialize content object" );
}
$row['content_model'] = $row['content']->getModel();
@ -588,7 +590,8 @@ class Revision implements IDBAccessObject {
$this->mTitle = null; // Load on demand if needed
}
$this->mCurrent = false; // @todo: XXX: really? we are about to create a revision. it will usually then be the current one.
// @todo: XXX: really? we are about to create a revision. it will usually then be the current one.
$this->mCurrent = false;
// If we still have no length, see it we have the text to figure it out
if ( !$this->mSize ) {
@ -931,7 +934,8 @@ class Revision implements IDBAccessObject {
*
* @return String
*
* @deprecated since 1.WD. Instead, use Revision::getContent( Revision::RAW ) or Revision::getSerializedData() as appropriate.
* @deprecated since 1.WD. Instead, use Revision::getContent( Revision::RAW )
* or Revision::getSerializedData() as appropriate.
*/
public function getRawText() {
wfDeprecated( __METHOD__, "1.WD" );
@ -1319,13 +1323,15 @@ class Revision implements IDBAccessObject {
if ( $this->getContentModel() != $defaultModel ) {
$t = $title->getPrefixedDBkey();
throw new MWException( "Can't save non-default content model with \$wgContentHandlerUseDB disabled: model is $model , default for $t is $defaultModel" );
throw new MWException( "Can't save non-default content model with \$wgContentHandlerUseDB disabled: "
. "model is $model , default for $t is $defaultModel" );
}
if ( $this->getContentFormat() != $defaultFormat ) {
$t = $title->getPrefixedDBkey();
throw new MWException( "Can't use non-default content format with \$wgContentHandlerUseDB disabled: format is $format, default for $t is $defaultFormat" );
throw new MWException( "Can't use non-default content format with \$wgContentHandlerUseDB disabled: "
. "format is $format, default for $t is $defaultFormat" );
}
}

View file

@ -3884,7 +3884,8 @@ class Title {
}
} else {
# Fail safe (not a redirect after all. strange.)
wfDebug( __METHOD__ . ": failsafe: database sais " . $nt->getPrefixedDBkey() . " is a redirect, but it doesn't contain a valid redirect.\n" );
wfDebug( __METHOD__ . ": failsafe: database sais " . $nt->getPrefixedDBkey() .
" is a redirect, but it doesn't contain a valid redirect.\n" );
return false;
}
}
@ -4158,11 +4159,11 @@ class Title {
if ( in_array( 'include_old', $options ) ) {
$old_cmp = '>=';
}
if ( in_array( 'include_new', $options ) ) {
$new_cmp = '<=';
}
if ( in_array( 'include_both', $options ) ) {
$old_cmp = '>=';
if ( in_array( 'include_new', $options ) ) {
$new_cmp = '<=';
}
if ( in_array( 'include_both', $options ) ) {
$old_cmp = '>=';
$new_cmp = '<=';
}
// No DB query needed if $old and $new are the same or successive revisions:
@ -4173,7 +4174,7 @@ class Title {
return ( $old_cmp === '>' && $new_cmp === '<' ) ? 0 : 1;
}
return ( $old->getRawUserText() === $new->getRawUserText() ) ? 1 : 2;
}
}
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'revision', 'DISTINCT rev_user_text',
array(

View file

@ -1259,7 +1259,8 @@ class WikiPage extends Page implements IDBAccessObject {
$this->mLatest = $revision->getId();
$this->mIsRedirect = (bool)$rt;
# Update the LinkCache.
LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect, $this->mLatest, $revision->getContentModel() );
LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect,
$this->mLatest, $revision->getContentModel() );
}
wfProfileOut( __METHOD__ );
@ -1410,7 +1411,8 @@ class WikiPage extends Page implements IDBAccessObject {
throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() );
}
$sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); # could even make section title, but that's not required.
# could even make section title, but that's not required.
$sectionContent = ContentHandler::makeContent( $text, $this->getTitle() );
$newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle, $edittime );
@ -1543,8 +1545,9 @@ class WikiPage extends Page implements IDBAccessObject {
* Compatibility note: this function previously returned a boolean value indicating success/failure
*
* @deprecated since 1.WD: use doEditContent() instead.
* @todo: use doEditContent() instead everywhere
*/
public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { #@todo: use doEditContent() instead
public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) {
wfDeprecated( __METHOD__, '1.WD' );
$content = ContentHandler::makeContent( $text, $this->getTitle() );
@ -2064,7 +2067,8 @@ class WikiPage extends Page implements IDBAccessObject {
}
DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) ); #TODO: let the search engine decide what to do with the content object
DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) );
#@TODO: let the search engine decide what to do with the content object
# If this is another user's talk page, update newtalk.
# Don't do this if $options['changed'] = false (null-edits) nor if
@ -2090,7 +2094,8 @@ class WikiPage extends Page implements IDBAccessObject {
}
if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
$msgtext = $content->getWikitextForTransclusion(); #XXX: could skip pseudo-messages like js/css here, based on content model.
#XXX: could skip pseudo-messages like js/css here, based on content model.
$msgtext = $content->getWikitextForTransclusion();
if ( $msgtext === false || $msgtext === null ) $msgtext = '';
MessageCache::singleton()->replace( $shortTitle, $msgtext );
@ -3281,20 +3286,24 @@ class PoolWorkArticleView extends PoolCounterWork {
function doWork() {
global $wgUseFileCache;
// @todo: several of the methods called on $this->page are not declared in Page, but present in WikiPage and delegated by Article.
// @todo: several of the methods called on $this->page are not declared in Page, but present
// in WikiPage and delegated by Article.
$isCurrent = $this->revid === $this->page->getLatest();
if ( $this->content !== null ) {
$content = $this->content;
} elseif ( $isCurrent ) {
$content = $this->page->getContent( Revision::RAW ); #XXX: why use RAW audience here, and PUBLIC (default) below?
#XXX: why use RAW audience here, and PUBLIC (default) below?
$content = $this->page->getContent( Revision::RAW );
} else {
$rev = Revision::newFromTitle( $this->page->getTitle(), $this->revid );
if ( $rev === null ) {
return false;
}
$content = $rev->getContent(); #XXX: why use PUBLIC audience here (default), and RAW above?
#XXX: why use PUBLIC audience here (default), and RAW above?
$content = $rev->getContent();
}
$time = - microtime( true );

View file

@ -68,7 +68,8 @@ class ApiEditPage extends ApiBase {
$name = $titleObj->getPrefixedDBkey();
$model = $contentHandler->getModelID();
$this->dieUsage( "The requested format $contentFormat is not supported for content model $model used by $name", 'badformat' );
$this->dieUsage( "The requested format $contentFormat is not supported for content model ".
" $model used by $name", 'badformat' );
}
$apiResult = $this->getResult();
@ -123,7 +124,8 @@ class ApiEditPage extends ApiBase {
if ( !( $content instanceof TextContent ) ) {
// @todo: ContentHandler should have an isFlat() method or some such
// @todo: XXX: or perhaps there should be Content::append(), Content::prepend() and Content::supportsConcatenation()
// @todo: XXX: or perhaps there should be Content::append(), Content::prepend()
// @todo: ...and Content::supportsConcatenation()
$mode = $contentHandler->getModelID();
$this->dieUsage( "Can't append to pages using content model $mode", 'appendnotsupported' );
}
@ -441,9 +443,12 @@ class ApiEditPage extends ApiBase {
array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ),
array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ),
array( 'code' => 'sectionsnotsupported', 'info' => 'Sections are not supported for this type of page.' ),
array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using the text based edit API.' ),
array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending or prepending text.' ),
array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to the page\'s content model' ),
array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using '
. 'the text based edit API.' ),
array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending '
. 'or prepending text.' ),
array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to '
. 'the page\'s content model' ),
array( 'customcssprotected' ),
array( 'customjsprotected' ),
)

View file

@ -189,7 +189,8 @@ class ApiParse extends ApiBase {
return;
}
// Not cached (save or load)
$p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts ); #FIXME: use Content object¡
#FIXME: use Content object!
$p_result = $wgParser->parse( $params['pst'] ? $this->pstText : $this->text, $titleObj, $popts );
}
$result_array = array();

View file

@ -550,7 +550,8 @@ class ApiQueryRevisions extends ApiQueryBase {
$model = $content->getModel();
$name = $title->getPrefixedDBkey();
$this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
$this->dieUsage( "The requested format {$this->contentFormat} is not supported ".
"for content model $model used by $name", 'badformat' );
}
$text = $content->serialize( $format );
@ -576,10 +577,13 @@ class ApiQueryRevisions extends ApiQueryBase {
if ( !is_null( $this->difftotext ) ) {
$model = $title->getContentModel();
if ( $this->contentFormat && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
if ( $this->contentFormat
&& !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
$name = $title->getPrefixedDBkey();
$this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
$this->dieUsage( "The requested format {$this->contentFormat} is not supported for ".
"content model $model used by $name", 'badformat' );
}
$difftocontent = ContentHandler::makeContent( $this->difftotext, $title, $model, $this->contentFormat );
@ -799,14 +803,18 @@ class ApiQueryRevisions extends ApiQueryBase {
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'nosuchrevid', 'diffto' ),
array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).' ),
array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.' ),
array( 'code' => 'revids', 'info' => 'The revids= parameter may not be used with the list options '
. '(limit, startid, endid, dirNewer, start, end).' ),
array( 'code' => 'multpages', 'info' => 'titles, pageids or a generator was used to supply multiple pages, '
. ' but the limit, startid, endid, dirNewer, user, excludeuser, '
. 'start and end parameters may only be used on a single page.' ),
array( 'code' => 'diffto', 'info' => 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"' ),
array( 'code' => 'badparams', 'info' => 'start and startid cannot be used together' ),
array( 'code' => 'badparams', 'info' => 'end and endid cannot be used together' ),
array( 'code' => 'badparams', 'info' => 'user and excludeuser cannot be used together' ),
array( 'code' => 'nosuchsection', 'info' => 'There is no section section in rID' ),
array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to the page\'s content model' ),
array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied '
. ' to the page\'s content model' ),
) );
}

View file

@ -269,9 +269,12 @@ class ApiSetNotificationTimestamp extends ApiBase {
public function getExamples() {
return array(
'api.php?action=setnotificationtimestamp&entirewatchlist=&token=ABC123' => 'Reset the notification status for the entire watchlist',
'api.php?action=setnotificationtimestamp&titles=Main_page&token=ABC123' => 'Reset the notification status for "Main page"',
'api.php?action=setnotificationtimestamp&titles=Main_page&timestamp=2012-01-01T00:00:00Z&token=ABC123' => 'Set the notification timestamp for "Main page" so all edits since 1 January 2012 are unviewed',
'api.php?action=setnotificationtimestamp&entirewatchlist=&token=ABC123'
=> 'Reset the notification status for the entire watchlist',
'api.php?action=setnotificationtimestamp&titles=Main_page&token=ABC123'
=> 'Reset the notification status for "Main page"',
'api.php?action=setnotificationtimestamp&titles=Main_page&timestamp=2012-01-01T00:00:00Z&token=ABC123'
=> 'Set the notification timestamp for "Main page" so all edits since 1 January 2012 are unviewed',
);
}

View file

@ -774,10 +774,13 @@ class MessageCache {
wfDebugLog( 'MessageCache', __METHOD__ . ": failed to load message page text for {$title} ($code)" );
$message = null; // no negative caching
} else {
$message = $content->getWikitextForTransclusion(); #XXX: is this the reight way to turn a Content object into a mesage?
#XXX: is this the reight way to turn a Content object into a mesage?
$message = $content->getWikitextForTransclusion();
if ( $message === false || $message === null ) {
wfDebugLog( 'MessageCache', __METHOD__ . ": message content doesn't provide wikitext (content model: #" . $content->getContentHandler() . ")" );
wfDebugLog( 'MessageCache', __METHOD__ . ": message content doesn't provide wikitext "
. "(content model: #" . $content->getContentHandler() . ")" );
$message = false; // negative caching
} else {
$this->mCache[$code][$title] = ' ' . $message;

View file

@ -510,12 +510,14 @@ class DifferenceEngine extends ContextSource {
$out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
$out->setArticleFlag( true );
if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) { #NOTE: only needed for B/C: custom rendering of JS/CSS via hook
#NOTE: only needed for B/C: custom rendering of JS/CSS via hook
if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
// Stolen from Article::view --AG 2007-10-11
// Give hooks a chance to customise the output
// @TODO: standardize this crap into one function
if ( !Hook::isRegistered( 'ShowRawCssJs' )
|| wfRunHooks( 'ShowRawCssJs', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) { #NOTE: deperecated hook, B/C only
|| wfRunHooks( 'ShowRawCssJs', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) {
// NOTE: deprecated hook, B/C only
// use the content object's own rendering
$po = $this->mContentObject->getParserOutput();
$out->addHTML( $po->getText() );
@ -523,7 +525,8 @@ class DifferenceEngine extends ContextSource {
} elseif( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
// Handled by extension
} elseif( Hooks::isRegistered( 'ArticleViewCustom' )
&& !wfRunHooks( 'ArticleViewCustom', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) { #NOTE: deperecated hook, B/C only
&& !wfRunHooks( 'ArticleViewCustom', array( ContentHandler::getContentText( $this->mNewContent ), $this->mNewPage, $out ) ) ) {
// NOTE: deprecated hook, B/C only
// Handled by extension
} else {
// Normal page

View file

@ -50,7 +50,7 @@ class ParserOutput extends CacheTime {
$mTimestamp; # Timestamp of the revision
private $mIndexPolicy = ''; # 'index' or 'noindex'? Any other value will result in no change.
private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
private $mSecondaryDataUpdates = array(); # List of instances of DataUpdate, used to cause some information extracted from the page in a custom place.
private $mSecondaryDataUpdates = array(); # List of DataUpdate, used to save info from the page somewhere else.
const EDITSECTION_REGEX = '#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
@ -380,7 +380,8 @@ class ParserOutput extends CacheTime {
*
* @since 1.20
*
* @param $title Title of the page we're updating. If not given, a title object will be created based on $this->getTitleText()
* @param $title Title The title of the page we're updating. If not given, a title object will be created
* based on $this->getTitleText()
* @param $recursive Boolean: queue jobs for recursive updates?
*
* @return Array. An array of instances of DataUpdate

View file

@ -803,8 +803,9 @@ class SearchResult {
protected function initText() {
if ( !isset( $this->mText ) ) {
if ( $this->mRevision != null ) {
//TODO: don't use the text, but the content object!
$content = $this->mRevision->getContent();
$this->mText = $content->getTextForSearchIndex(); //XXX: maybe we don't even need the text, but the content object?
$this->mText = $content->getTextForSearchIndex();
} else { // TODO: can we fetch raw wikitext for commons images?
$this->mText = '';
}
@ -818,8 +819,10 @@ class SearchResult {
function getTextSnippet( $terms ) {
global $wgUser, $wgAdvancedSearchHighlighting;
$this->initText();
// TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter.
list( $contextlines, $contextchars ) = SearchEngine::userHighlightPrefs( $wgUser );
$h = new SearchHighlighter(); // TODO: make highliter take a content object. Make ContentHandler a factory for SearchHighliter.
$h = new SearchHighlighter();
if ( $wgAdvancedSearchHighlighting )
return $h->highlightText( $this->mText, $terms, $contextlines, $contextchars );
else

View file

@ -144,7 +144,8 @@ class SpecialBookSources extends SpecialPage {
$title = Title::makeTitleSafe( NS_PROJECT, $page ); # Show list in content language
if( is_object( $title ) && $title->exists() ) {
$rev = Revision::newFromTitle( $title, false, Revision::READ_NORMAL );
$this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) ); #FIXME: need a way to do this via ContentHandler (or enforce flat text-based content)
#FIXME: need a way to do this via ContentHandler (or enforce flat text-based content)
$this->getOutput()->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) );
return true;
}

View file

@ -459,11 +459,12 @@ class SpecialNewpages extends IncludableSpecialPage {
protected function feedItemDesc( $row ) {
$revision = Revision::newFromId( $row->rev_id );
if( $revision ) {
//XXX: include content model/type in feed item?
return '<p>' . htmlspecialchars( $revision->getUserText() ) .
$this->msg( 'colon-separator' )->inContentLanguage()->escaped() .
htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
"</p>\n<hr />\n<div>" .
nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>"; //TODO: include content model/type in feed item?
nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "</div>";
}
return '';
}

View file

@ -889,12 +889,14 @@ class SpecialUndelete extends SpecialPage {
$out->addWikiTextTitleTidy( $rev->getText( Revision::FOR_THIS_USER, $user ), $this->mTargetObj, true );
}
//FIXME: ContentHandler will have to provide some specialized magic for reviewing content before undeletion
$out->addHTML(
Xml::element( 'textarea', array(
'readonly' => 'readonly',
'cols' => intval( $user->getOption( 'cols' ) ),
'rows' => intval( $user->getOption( 'rows' ) ) ),
$rev->getText( Revision::FOR_THIS_USER, $user ) . "\n" ) . //FIXME: ContentHandler will have to provide some specialized magic to do this
$rev->getText( Revision::FOR_THIS_USER, $user ) . "\n" ) .
Xml::openElement( 'div' ) .
Xml::openElement( 'form', array(
'method' => 'post',

View file

@ -89,9 +89,11 @@ class ContentHandlerTest extends MediaWikiTestCase {
if ( $expected ) {
$this->assertNotNull( $name, "no name found for content model $id" );
$this->assertTrue( preg_match( $expected, $name ) > 0 , "content model name for #$id did not match pattern $expected" );
$this->assertTrue( preg_match( $expected, $name ) > 0 ,
"content model name for #$id did not match pattern $expected" );
} else {
$this->assertEquals( $id, $name, "localization of unknown model $id should have fallen back to use the model id directly." );
$this->assertEquals( $id, $name, "localization of unknown model $id should have "
. "fallen back to use the model id directly." );
}
}

View file

@ -12,7 +12,8 @@ class JavascriptContentTest extends WikitextContentTest {
public function dataGetParserOutput() {
return array(
array("MediaWiki:Test.js", "hello <world>\n", "<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello &lt;world&gt;\n\n</pre>\n"),
array("MediaWiki:Test.js", "hello <world>\n",
"<pre class=\"mw-code mw-js\" dir=\"ltr\">\nhello &lt;world&gt;\n\n</pre>\n"),
// @todo: more...?
);
}

View file

@ -217,8 +217,10 @@ class RevisionStorageTest extends MediaWikiTestCase {
$this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields');
if ( $wgContentHandlerUseDB ) {
$this->assertTrue( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields');
$this->assertTrue( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields');
$this->assertTrue( in_array( 'rev_content_model', $fields ),
'missing rev_content_model in list of fields');
$this->assertTrue( in_array( 'rev_content_format', $fields ),
'missing rev_content_format in list of fields');
} else {
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
@ -292,7 +294,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
$orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
$orig = $this->makeRevision( array( 'text' => 'hello hello.',
'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
$rev = Revision::newFromId( $orig->getId() );
$this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );
@ -309,7 +312,9 @@ class RevisionStorageTest extends MediaWikiTestCase {
$this->markTestSkipped( '$wgContentHandlerUseDB is disabled' );
}
$orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT, 'content_format' => CONTENT_FORMAT_JAVASCRIPT ) );
$orig = $this->makeRevision( array( 'text' => 'hello hello.',
'content_model' => CONTENT_MODEL_JAVASCRIPT,
'content_format' => CONTENT_FORMAT_JAVASCRIPT ) );
$rev = Revision::newFromId( $orig->getId() );
$this->assertEquals( CONTENT_FORMAT_JAVASCRIPT, $rev->getContentFormat() );
@ -352,7 +357,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
$this->assertNull( $rev1->getPrevious() );
$page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ), 'second rev testGetPrevious' );
$page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ),
'second rev testGetPrevious' );
$rev2 = $page->getRevision();
$this->assertNotNull( $rev2->getPrevious() );
@ -369,7 +375,8 @@ class RevisionStorageTest extends MediaWikiTestCase {
$this->assertNull( $rev1->getNext() );
$page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ), 'second rev testGetNext' );
$page->doEditContent( ContentHandler::makeContent( 'Bla bla', $page->getTitle() ),
'second rev testGetNext' );
$rev2 = $page->getRevision();
$this->assertNotNull( $rev1->getNext() );
@ -387,8 +394,10 @@ class RevisionStorageTest extends MediaWikiTestCase {
$dbw = wfGetDB( DB_MASTER );
$rev = Revision::newNullRevision( $dbw, $page->getId(), 'a null revision', false );
$this->assertNotEquals( $orig->getId(), $rev->getId(), 'new null revision shold have a different id from the original revision' );
$this->assertEquals( $orig->getTextId(), $rev->getTextId(), 'new null revision shold have the same text id as the original revision' );
$this->assertNotEquals( $orig->getId(), $rev->getId(),
'new null revision shold have a different id from the original revision' );
$this->assertEquals( $orig->getTextId(), $rev->getTextId(),
'new null revision shold have the same text id as the original revision' );
$this->assertEquals( 'some testing text', $rev->getContent()->getNativeData() );
}
}

View file

@ -96,8 +96,8 @@ class WikiPageTest extends MediaWikiLangTestCase {
$page = $this->newPage( $title );
$content = ContentHandler::makeContent( "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
. " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
$title );
. " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
$title );
$page->doEditContent( $content, "[[testing]] 1" );
@ -596,7 +596,9 @@ more stuff
"2",
"== TEST ==\nmore fun",
null,
trim( preg_replace( '/^== test ==.*== foo ==/sm', "== TEST ==\nmore fun\n\n== foo ==", WikiPageTest::$sections ) )
trim( preg_replace( '/^== test ==.*== foo ==/sm',
"== TEST ==\nmore fun\n\n== foo ==",
WikiPageTest::$sections ) )
),
array( 'WikiPageTest_testReplaceSection',
WikiPageTest::$sections,
@ -698,19 +700,22 @@ more stuff
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "section one", EDIT_NEW, false, $admin );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
"section one", EDIT_NEW, false, $admin );
$user1 = new User();
$user1->setName( "127.0.1.11" );
$text .= "\n\ntwo";
$page = new WikiPage( $page->getTitle() );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section two", 0, false, $user1 );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
"adding section two", 0, false, $user1 );
$user2 = new User();
$user2->setName( "127.0.2.13" );
$text .= "\n\nthree";
$page = new WikiPage( $page->getTitle() );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section three", 0, false, $user2 );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
"adding section three", 0, false, $user2 );
# we are having issues with doRollback spuriously failing. apparently the last revision somehow goes missing
# or not committed under some circumstances. so, make sure the last revision has the right user name.
@ -737,7 +742,8 @@ more stuff
}
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( $rev2->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision" );
$this->assertEquals( $rev2->getSha1(), $page->getRevision()->getSha1(),
"rollback did not revert to the correct revision" );
$this->assertEquals( "one\n\ntwo", $page->getContent()->getNativeData() );
}
@ -750,14 +756,16 @@ more stuff
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "section one", EDIT_NEW, false, $admin );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
"section one", EDIT_NEW, false, $admin );
$rev1 = $page->getRevision();
$user1 = new User();
$user1->setName( "127.0.1.11" );
$text .= "\n\ntwo";
$page = new WikiPage( $page->getTitle() );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ), "adding section two", 0, false, $user1 );
$page->doEditContent( ContentHandler::makeContent( $text, $page->getTitle() ),
"adding section two", 0, false, $user1 );
# now, try the rollback
$admin->addGroup( "sysop" ); #XXX: make the test user a sysop...
@ -769,7 +777,8 @@ more stuff
}
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( $rev1->getSha1(), $page->getRevision()->getSha1(), "rollback did not revert to the correct revision" );
$this->assertEquals( $rev1->getSha1(), $page->getRevision()->getSha1(),
"rollback did not revert to the correct revision" );
$this->assertEquals( "one", $page->getContent()->getNativeData() );
}
@ -822,7 +831,8 @@ more stuff
$summary = $page->getAutosummary( $old, $new, $flags );
$this->assertTrue( (bool)preg_match( $expected, $summary ), "Autosummary didn't match expected pattern $expected: $summary" );
$this->assertTrue( (bool)preg_match( $expected, $summary ),
"Autosummary didn't match expected pattern $expected: $summary" );
}
public function dataGetAutoDeleteReason( ) {
@ -909,9 +919,11 @@ more stuff
$reason = $page->getAutoDeleteReason( $hasHistory );
if ( is_bool( $expectedResult ) || is_null( $expectedResult ) ) $this->assertEquals( $expectedResult, $reason );
else $this->assertTrue( (bool)preg_match( $expectedResult, $reason ), "Autosummary didn't match expected pattern $expectedResult: $reason" );
else $this->assertTrue( (bool)preg_match( $expectedResult, $reason ),
"Autosummary didn't match expected pattern $expectedResult: $reason" );
$this->assertEquals( $expectedHistory, $hasHistory, "expected \$hasHistory to be " . var_export( $expectedHistory, true ) );
$this->assertEquals( $expectedHistory, $hasHistory,
"expected \$hasHistory to be " . var_export( $expectedHistory, true ) );
$page->doDeleteArticle( "done" );
}