From 0139923580d49247e1f92ac0346522c3ef16806b Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 20 Aug 2012 21:33:07 +0200 Subject: [PATCH] fixing long lines Change-Id: Iebcd40a1a37a3a93cc571fa2c2b0a87f53dc97a4 --- includes/Article.php | 6 ++- includes/Defines.php | 2 +- includes/EditPage.php | 49 +++++++++++++------ includes/Revision.php | 18 ++++--- includes/Title.php | 15 +++--- includes/WikiPage.php | 25 +++++++--- includes/api/ApiEditPage.php | 15 ++++-- includes/api/ApiParse.php | 3 +- includes/api/ApiQueryRevisions.php | 20 +++++--- includes/api/ApiSetNotificationTimestamp.php | 9 ++-- includes/cache/MessageCache.php | 7 ++- includes/diff/DifferenceEngine.php | 9 ++-- includes/parser/ParserOutput.php | 5 +- includes/search/SearchEngine.php | 7 ++- includes/specials/SpecialBooksources.php | 3 +- includes/specials/SpecialNewpages.php | 3 +- includes/specials/SpecialUndelete.php | 4 +- tests/phpunit/includes/ContentHandlerTest.php | 6 ++- .../includes/JavascriptContentTest.php | 3 +- .../phpunit/includes/RevisionStorageTest.php | 25 +++++++--- tests/phpunit/includes/WikiPageTest.php | 38 +++++++++----- 21 files changed, 181 insertions(+), 91 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 2e34950a2e..dc6294f2b7 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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; } /** diff --git a/includes/Defines.php b/includes/Defines.php index 71dd956ad9..1a04e5a6be 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -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 /**@}*/ diff --git a/includes/EditPage.php b/includes/EditPage.php index b61f08d28d..3e38fb8ca9 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 = ''; } diff --git a/includes/Revision.php b/includes/Revision.php index 97ae8e849f..30ffbea35a 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -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" ); } } diff --git a/includes/Title.php b/includes/Title.php index 08b8f0ae51..594ade5a42 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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( diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 91fd9e0fc6..a4afda7ef4 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -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 ); diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 5c4e7995e4..7574e6ce81 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -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' ), ) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index c964a81f20..3500795232 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -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(); diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 2c0bf1f0bf..5e4b8f6e57 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -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' ), ) ); } diff --git a/includes/api/ApiSetNotificationTimestamp.php b/includes/api/ApiSetNotificationTimestamp.php index 098b1a6601..177087c6ec 100644 --- a/includes/api/ApiSetNotificationTimestamp.php +++ b/includes/api/ApiSetNotificationTimestamp.php @@ -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×tamp=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×tamp=2012-01-01T00:00:00Z&token=ABC123' + => 'Set the notification timestamp for "Main page" so all edits since 1 January 2012 are unviewed', ); } diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index 70b53f9b47..d8acc4f450 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -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; diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index e1db2c7ac3..f76d9f0cab 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -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 diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 8538b5bb31..cf8b4a97df 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -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="(.*?)"(?:/>|>(.*?)())#'; @@ -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 diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 77c7c9214c..59dd7ab9ca 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -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 diff --git a/includes/specials/SpecialBooksources.php b/includes/specials/SpecialBooksources.php index efa28889b5..d271a620d0 100644 --- a/includes/specials/SpecialBooksources.php +++ b/includes/specials/SpecialBooksources.php @@ -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; } diff --git a/includes/specials/SpecialNewpages.php b/includes/specials/SpecialNewpages.php index d8ceb1fd89..ef293d1f74 100644 --- a/includes/specials/SpecialNewpages.php +++ b/includes/specials/SpecialNewpages.php @@ -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 '

' . htmlspecialchars( $revision->getUserText() ) . $this->msg( 'colon-separator' )->inContentLanguage()->escaped() . htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) . "

\n
\n
" . - nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . "
"; //TODO: include content model/type in feed item? + nl2br( htmlspecialchars( $revision->getContent()->serialize() ) ) . ""; } return ''; } diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 1fcba12e7b..b51879ce65 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -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', diff --git a/tests/phpunit/includes/ContentHandlerTest.php b/tests/phpunit/includes/ContentHandlerTest.php index 1ef4ef9a17..afeddf88df 100644 --- a/tests/phpunit/includes/ContentHandlerTest.php +++ b/tests/phpunit/includes/ContentHandlerTest.php @@ -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." ); } } diff --git a/tests/phpunit/includes/JavascriptContentTest.php b/tests/phpunit/includes/JavascriptContentTest.php index f8fb75ae63..cb40e764d9 100644 --- a/tests/phpunit/includes/JavascriptContentTest.php +++ b/tests/phpunit/includes/JavascriptContentTest.php @@ -12,7 +12,8 @@ class JavascriptContentTest extends WikitextContentTest { public function dataGetParserOutput() { return array( - array("MediaWiki:Test.js", "hello \n", "
\nhello <world>\n\n
\n"), + array("MediaWiki:Test.js", "hello \n", + "
\nhello <world>\n\n
\n"), // @todo: more...? ); } diff --git a/tests/phpunit/includes/RevisionStorageTest.php b/tests/phpunit/includes/RevisionStorageTest.php index 15cf9eceae..a98b20032a 100644 --- a/tests/phpunit/includes/RevisionStorageTest.php +++ b/tests/phpunit/includes/RevisionStorageTest.php @@ -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() ); } } diff --git a/tests/phpunit/includes/WikiPageTest.php b/tests/phpunit/includes/WikiPageTest.php index 98406495e8..02c06772dc 100644 --- a/tests/phpunit/includes/WikiPageTest.php +++ b/tests/phpunit/includes/WikiPageTest.php @@ -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" ); } -- 2.20.1