// Convert into a Status object
if ( $errors ) {
foreach ( $errors as $error ) {
- call_user_func_array( array( $status, 'fatal' ), $error );
+ call_user_func_array( [ $status, 'fatal' ], $error );
}
}
}
Hooks::run( 'MovePageCheckPermissions',
- array( $this->oldTitle, $this->newTitle, $user, $reason, $status )
+ [ $this->oldTitle, $this->newTitle, $user, $reason, $status ]
);
return $status;
}
// Hook for extensions to say a title can't be moved for technical reasons
- Hooks::run( 'MovePageIsValidMove', array( $this->oldTitle, $this->newTitle, $status ) );
+ Hooks::run( 'MovePageIsValidMove', [ $this->oldTitle, $this->newTitle, $status ] );
return $status;
}
public function move( User $user, $reason, $createRedirect ) {
global $wgCategoryCollation;
- Hooks::run( 'TitleMove', array( $this->oldTitle, $this->newTitle, $user ) );
+ Hooks::run( 'TitleMove', [ $this->oldTitle, $this->newTitle, $user ] );
// If it is a file, move it first.
// It is done before all other moving stuff is done because it's hard to revert.
$file->load( File::READ_LATEST );
if ( $file->exists() ) {
$status = $file->move( $this->newTitle );
- if ( !$status->isOk() ) {
+ if ( !$status->isOK() ) {
return $status;
}
}
}
$dbw->startAtomic( __METHOD__ );
+
+ Hooks::run( 'TitleMoveStarting', [ $this->oldTitle, $this->newTitle, $user ] );
+
$pageid = $this->oldTitle->getArticleID( Title::GAID_FOR_UPDATE );
$protected = $this->oldTitle->isProtected();
// from LinksUpdate::getCategoryInsertions() and friends.
$prefixes = $dbw->select(
'categorylinks',
- array( 'cl_sortkey_prefix', 'cl_to' ),
- array( 'cl_from' => $pageid ),
+ [ 'cl_sortkey_prefix', 'cl_to' ],
+ [ 'cl_from' => $pageid ],
__METHOD__
);
if ( $this->newTitle->getNamespace() == NS_CATEGORY ) {
$prefix = $prefixRow->cl_sortkey_prefix;
$catTo = $prefixRow->cl_to;
$dbw->update( 'categorylinks',
- array(
+ [
'cl_sortkey' => Collation::singleton()->getSortKey(
$this->newTitle->getCategorySortkey( $prefix ) ),
'cl_collation' => $wgCategoryCollation,
'cl_type' => $type,
- 'cl_timestamp=cl_timestamp' ),
- array(
+ 'cl_timestamp=cl_timestamp' ],
+ [
'cl_from' => $pageid,
- 'cl_to' => $catTo ),
+ 'cl_to' => $catTo ],
__METHOD__
);
}
if ( $protected ) {
# Protect the redirect title as the title used to be...
$dbw->insertSelect( 'page_restrictions', 'page_restrictions',
- array(
+ [
'pr_page' => $redirid,
'pr_type' => 'pr_type',
'pr_level' => 'pr_level',
'pr_cascade' => 'pr_cascade',
'pr_user' => 'pr_user',
'pr_expiry' => 'pr_expiry'
- ),
- array( 'pr_page' => $pageid ),
+ ],
+ [ 'pr_page' => $pageid ],
__METHOD__,
- array( 'IGNORE' )
+ [ 'IGNORE' ]
);
// Build comment for log
$insertedPrIds = $dbw->select(
'page_restrictions',
'pr_id',
- array( 'pr_page' => $redirid ),
+ [ 'pr_page' => $redirid ],
__METHOD__
);
- $logRelationsValues = array();
+ $logRelationsValues = [];
foreach ( $insertedPrIds as $prid ) {
$logRelationsValues[] = $prid->pr_id;
}
$logEntry->setTarget( $this->newTitle );
$logEntry->setComment( $comment );
$logEntry->setPerformer( $user );
- $logEntry->setParameters( array(
+ $logEntry->setParameters( [
'4::oldtitle' => $this->oldTitle->getPrefixedText(),
- ) );
- $logEntry->setRelations( array( 'pr_id' => $logRelationsValues ) );
+ ] );
+ $logEntry->setRelations( [ 'pr_id' => $logRelationsValues ] );
$logId = $logEntry->insert();
$logEntry->publish( $logId );
}
// Update *_from_namespace fields as needed
if ( $this->oldTitle->getNamespace() != $this->newTitle->getNamespace() ) {
$dbw->update( 'pagelinks',
- array( 'pl_from_namespace' => $this->newTitle->getNamespace() ),
- array( 'pl_from' => $pageid ),
+ [ 'pl_from_namespace' => $this->newTitle->getNamespace() ],
+ [ 'pl_from' => $pageid ],
__METHOD__
);
$dbw->update( 'templatelinks',
- array( 'tl_from_namespace' => $this->newTitle->getNamespace() ),
- array( 'tl_from' => $pageid ),
+ [ 'tl_from_namespace' => $this->newTitle->getNamespace() ],
+ [ 'tl_from' => $pageid ],
__METHOD__
);
$dbw->update( 'imagelinks',
- array( 'il_from_namespace' => $this->newTitle->getNamespace() ),
- array( 'il_from' => $pageid ),
+ [ 'il_from_namespace' => $this->newTitle->getNamespace() ],
+ [ 'il_from' => $pageid ],
__METHOD__
);
}
$oldsnamespace = MWNamespace::getSubject( $this->oldTitle->getNamespace() );
$newsnamespace = MWNamespace::getSubject( $this->newTitle->getNamespace() );
if ( $oldsnamespace != $newsnamespace || $oldtitle != $newtitle ) {
- WatchedItem::duplicateEntries( $this->oldTitle, $this->newTitle );
+ $store = WatchedItemStore::getDefaultInstance();
+ $store->duplicateAllAssociatedEntries( $this->oldTitle, $this->newTitle );
}
Hooks::run(
'TitleMoveCompleting',
- array( $this->oldTitle, $this->newTitle,
- $user, $pageid, $redirid, $reason, $nullRevision )
+ [ $this->oldTitle, $this->newTitle,
+ $user, $pageid, $redirid, $reason, $nullRevision ]
);
$dbw->endAtomic( __METHOD__ );
- $params = array(
+ $params = [
&$this->oldTitle,
&$this->newTitle,
&$user,
$redirid,
$reason,
$nullRevision
- );
+ ];
$dbw->onTransactionIdle( function () use ( $params, $dbw ) {
// Keep each single hook handler atomic
$dbw->setFlag( DBO_TRX ); // flag is automatically reset by DB layer
$logEntry->setPerformer( $user );
$logEntry->setTarget( $logTitle );
$logEntry->setComment( $reason );
- $logEntry->setParameters( array(
+ $logEntry->setParameters( [
'4::target' => $nt->getPrefixedText(),
'5::noredir' => $redirectContent ? '0': '1',
- ) );
+ ] );
$formatter = LogFormatter::newFromEntry( $logEntry );
$formatter->setContext( RequestContext::newExtraneousContext( $this->oldTitle ) );
# by definition if we've got here it's rather uninteresting.
# We have to remove it so that the next step doesn't trigger
# a conflict on the unique namespace+title index...
- $dbw->delete( 'page', array( 'page_id' => $newid ), __METHOD__ );
+ $dbw->delete( 'page', [ 'page_id' => $newid ], __METHOD__ );
$newpage->doDeleteUpdates( $newid, $newcontent );
}
# Change the name of the target page:
$dbw->update( 'page',
- /* SET */ array(
+ /* SET */ [
'page_namespace' => $nt->getNamespace(),
'page_title' => $nt->getDBkey(),
- ),
- /* WHERE */ array( 'page_id' => $oldid ),
+ ],
+ /* WHERE */ [ 'page_id' => $oldid ],
__METHOD__
);
$newpage->updateRevisionOn( $dbw, $nullRevision );
Hooks::run( 'NewRevisionFromEditComplete',
- array( $newpage, $nullRevision, $nullRevision->getParentId(), $user ) );
+ [ $newpage, $nullRevision, $nullRevision->getParentId(), $user ] );
$newpage->doEditUpdates( $nullRevision, $user,
- array( 'changed' => false, 'moved' => true, 'oldcountable' => $oldcountable ) );
+ [ 'changed' => false, 'moved' => true, 'oldcountable' => $oldcountable ] );
// If the default content model changes, we need to populate rev_content_model
if ( $defaultContentModelChanging ) {
$dbw->update(
'revision',
- array( 'rev_content_model' => $contentModel ),
- array( 'rev_page' => $nt->getArticleID(), 'rev_content_model IS NULL' ),
+ [ 'rev_content_model' => $contentModel ],
+ [ 'rev_page' => $nt->getArticleID(), 'rev_content_model IS NULL' ],
__METHOD__
);
}
$newid = $redirectArticle->insertOn( $dbw );
if ( $newid ) { // sanity
$this->oldTitle->resetArticleID( $newid );
- $redirectRevision = new Revision( array(
+ $redirectRevision = new Revision( [
'title' => $this->oldTitle, // for determining the default content model
'page' => $newid,
'user_text' => $user->getName(),
'user' => $user->getId(),
'comment' => $comment,
- 'content' => $redirectContent ) );
+ 'content' => $redirectContent ] );
$redirectRevision->insertOn( $dbw );
$redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
Hooks::run( 'NewRevisionFromEditComplete',
- array( $redirectArticle, $redirectRevision, false, $user ) );
+ [ $redirectArticle, $redirectRevision, false, $user ] );
- $redirectArticle->doEditUpdates( $redirectRevision, $user, array( 'created' => true ) );
+ $redirectArticle->doEditUpdates( $redirectRevision, $user, [ 'created' => true ] );
}
}