The Revision object needs the Title to determine the default content model.
Providing the Title explicitely wherever possible avoids an extra database
lookup. Most importanlty, this fixes fatal errors that ocurr when the
database lookup fails due to slave lag or transaction state.
Change-Id: I516e82f7a893b274c513b128b8a46db491160b55
if ( $this->getUser()->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
{
$rev = new Revision( array(
if ( $this->getUser()->isAllowed('rollback') && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] )
{
$rev = new Revision( array(
'id' => $rc->mAttribs['rc_this_oldid'],
'user' => $rc->mAttribs['rc_user'],
'user_text' => $rc->mAttribs['rc_user_text'],
'deleted' => $rc->mAttribs['rc_deleted']
) );
'id' => $rc->mAttribs['rc_this_oldid'],
'user' => $rc->mAttribs['rc_user'],
'user_text' => $rc->mAttribs['rc_user_text'],
'deleted' => $rc->mAttribs['rc_deleted']
) );
- $rev->setTitle( $page );
$s .= ' '.Linker::generateRollback( $rev, $this->getContext() );
}
}
$s .= ' '.Linker::generateRollback( $rev, $this->getContext() );
}
}
# @todo FIXME: Use original rev_id optionally (better for backups)
# Insert the row
$revision = new Revision( array(
# @todo FIXME: Use original rev_id optionally (better for backups)
# Insert the row
$revision = new Revision( array(
+ 'title' => $this->title,
'page' => $pageId,
'content_model' => $this->getModel(),
'content_format' => $this->getFormat(),
'page' => $pageId,
'content_model' => $this->getModel(),
'content_format' => $this->getFormat(),
unset( $attribs['content_format'] );
}
unset( $attribs['content_format'] );
}
+ if ( !isset( $attribs['title'] )
+ && isset( $row->ar_namespace )
+ && isset( $row->ar_title ) ) {
+
+ $attribs['title'] = Title::makeTitle( $row->ar_namespace, $row->ar_title );
+ }
+
if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
// Pre-1.5 ar_text row
$attribs['text'] = self::getRevisionText( $row, 'ar_' );
if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
// Pre-1.5 ar_text row
$attribs['text'] = self::getRevisionText( $row, 'ar_' );
$newid = $redirectArticle->insertOn( $dbw );
if ( $newid ) { // sanity
$redirectRevision = new Revision( array(
$newid = $redirectArticle->insertOn( $dbw );
if ( $newid ) { // sanity
$redirectRevision = new Revision( array(
+ 'title' => $this, // for determining the default content model
'page' => $newid,
'comment' => $comment,
'content' => $redirectContent ) );
'page' => $newid,
'comment' => $comment,
'content' => $redirectContent ) );
$dbw = wfGetDB( DB_MASTER );
$revision = new Revision( array(
$dbw = wfGetDB( DB_MASTER );
$revision = new Revision( array(
+ 'title' => $this->getTitle(), // for determining the default content model
'page' => $this->getId(),
'text' => $serialized,
'length' => $content->getSize(),
'page' => $this->getId(),
'text' => $serialized,
'length' => $content->getSize(),
function formatRow( $row ) {
wfProfileIn( __METHOD__ );
function formatRow( $row ) {
wfProfileIn( __METHOD__ );
+ $page = Title::makeTitle( $row->ar_namespace, $row->ar_title );
+
$rev = new Revision( array(
$rev = new Revision( array(
'id' => $row->ar_rev_id,
'comment' => $row->ar_comment,
'user' => $row->ar_user,
'id' => $row->ar_rev_id,
'comment' => $row->ar_comment,
'user' => $row->ar_user,
'deleted' => $row->ar_deleted,
) );
'deleted' => $row->ar_deleted,
) );
- $page = Title::makeTitle( $row->ar_namespace, $row->ar_title );
-
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$logs = SpecialPage::getTitleFor( 'Log' );
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$logs = SpecialPage::getTitleFor( 'Log' );
if ( $redirectContent ) {
$redirectPage = WikiPage::factory( $targetTitle );
$redirectRevision = new Revision( array(
if ( $redirectContent ) {
$redirectPage = WikiPage::factory( $targetTitle );
$redirectRevision = new Revision( array(
+ 'title' => $targetTitle,
'page' => $this->mTargetID,
'comment' => $comment,
'content' => $redirectContent ) );
'page' => $this->mTargetID,
'comment' => $comment,
'content' => $redirectContent ) );
*/
protected function newPage( $title, $model = null ) {
if ( is_string( $title ) ) {
*/
protected function newPage( $title, $model = null ) {
if ( is_string( $title ) ) {
- $title = Title::newFromText( $title );
+ $ns = $this->getDefaultWikitextNS();
+ $title = Title::newFromText( $title, $ns );
}
$p = new WikiPage( $title );
}
$p = new WikiPage( $title );
* @return WikiPage
*/
protected function createPage( $page, $text, $model = null ) {
* @return WikiPage
*/
protected function createPage( $page, $text, $model = null ) {
- if ( is_string( $page ) ) {
- $page = Title::newFromText( $page );
- }
-
- if ( $page instanceof Title ) {
+ if ( is_string( $page ) || $page instanceof Title ) {
$page = $this->newPage( $page, $model );
}
$page = $this->newPage( $page, $model );
}
}
public function testDoEditContent() {
}
public function testDoEditContent() {
- $title = Title::newFromText( "WikiPageTest_testDoEditContent" );
-
- $page = $this->newPage( $title );
+ $page = $this->newPage( "WikiPageTest_testDoEditContent" );
+ $title = $page->getTitle();
$content = ContentHandler::makeContent( "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
. " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
$content = ContentHandler::makeContent( "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
. " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
* @dataProvider provideIsCountable
*/
public function testIsCountable( $title, $model, $text, $mode, $expected ) {
* @dataProvider provideIsCountable
*/
public function testIsCountable( $title, $model, $text, $mode, $expected ) {
- global $wgArticleCountMethod;
+ global $wgContentHandlerUseDB;
- $oldArticleCountMethod = $wgArticleCountMethod;
- $wgArticleCountMethod = $mode;
+ $this->setMwGlobals( 'wgArticleCountMethod', $mode );
+
+ $title = Title::newFromText( $title );
+
+ if ( !$wgContentHandlerUseDB && ContentHandler::getDefaultModelFor( $title ) != $model ) {
+ $this->markTestSkipped( "Can not use non-default content model $model for "
+ . $title->getPrefixedDBkey() . " with \wgArticleCountMethod disabled." );
+ }
$page = $this->createPage( $title, $text, $model );
$hasLinks = wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1,
$page = $this->createPage( $title, $text, $model );
$hasLinks = wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1,
$v = $page->isCountable();
$w = $page->isCountable( $editInfo );
$v = $page->isCountable();
$w = $page->isCountable( $editInfo );
- $wgArticleCountMethod = $oldArticleCountMethod;
-
$this->assertEquals( $expected, $v, "isCountable( null ) returned unexpected value " . var_export( $v, true )
. " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );
$this->assertEquals( $expected, $v, "isCountable( null ) returned unexpected value " . var_export( $v, true )
. " instead of " . var_export( $expected, true ) . " in mode `$mode` for text \"$text\"" );