$ns = 0;
}
- $conds = array(
+ $conds = [
'ar_namespace' => $ns,
'ar_title' . $dbr->buildLike( $prefix, $dbr->anyString() ),
- );
+ ];
return self::listPages( $dbr, $conds );
}
*/
protected static function listPages( $dbr, $condition ) {
return $dbr->select(
- array( 'archive' ),
- array(
+ [ 'archive' ],
+ [
'ar_namespace',
'ar_title',
'count' => 'COUNT(*)'
- ),
+ ],
$condition,
__METHOD__,
- array(
- 'GROUP BY' => array( 'ar_namespace', 'ar_title' ),
- 'ORDER BY' => array( 'ar_namespace', 'ar_title' ),
+ [
+ 'GROUP BY' => [ 'ar_namespace', 'ar_title' ],
+ 'ORDER BY' => [ 'ar_namespace', 'ar_title' ],
'LIMIT' => 100,
- )
+ ]
);
}
function listRevisions() {
$dbr = wfGetDB( DB_SLAVE );
- $tables = array( 'archive' );
+ $tables = [ 'archive' ];
- $fields = array(
+ $fields = [
'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text',
'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1',
- );
+ ];
if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
}
- $conds = array( 'ar_namespace' => $this->title->getNamespace(),
- 'ar_title' => $this->title->getDBkey() );
+ $conds = [ 'ar_namespace' => $this->title->getNamespace(),
+ 'ar_title' => $this->title->getDBkey() ];
- $options = array( 'ORDER BY' => 'ar_timestamp DESC' );
+ $options = [ 'ORDER BY' => 'ar_timestamp DESC' ];
- $join_conds = array();
+ $join_conds = [];
ChangeTags::modifyDisplayQuery(
$tables,
return $dbr->select(
'filearchive',
ArchivedFile::selectFields(),
- array( 'fa_name' => $this->title->getDBkey() ),
+ [ 'fa_name' => $this->title->getDBkey() ],
__METHOD__,
- array( 'ORDER BY' => 'fa_timestamp DESC' )
+ [ 'ORDER BY' => 'fa_timestamp DESC' ]
);
}
function getRevision( $timestamp ) {
$dbr = wfGetDB( DB_SLAVE );
- $fields = array(
+ $fields = [
'ar_rev_id',
'ar_text',
'ar_comment',
'ar_deleted',
'ar_len',
'ar_sha1',
- );
+ ];
if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$row = $dbr->selectRow( 'archive',
$fields,
- array( 'ar_namespace' => $this->title->getNamespace(),
+ [ 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDBkey(),
- 'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
+ 'ar_timestamp' => $dbr->timestamp( $timestamp ) ],
__METHOD__ );
if ( $row ) {
- return Revision::newFromArchiveRow( $row, array( 'title' => $this->title ) );
+ return Revision::newFromArchiveRow( $row, [ 'title' => $this->title ] );
}
return null;
// Check the previous deleted revision...
$row = $dbr->selectRow( 'archive',
'ar_timestamp',
- array( 'ar_namespace' => $this->title->getNamespace(),
+ [ 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDBkey(),
'ar_timestamp < ' .
- $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
+ $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ],
__METHOD__,
- array(
+ [
'ORDER BY' => 'ar_timestamp DESC',
- 'LIMIT' => 1 ) );
+ 'LIMIT' => 1 ] );
$prevDeleted = $row ? wfTimestamp( TS_MW, $row->ar_timestamp ) : false;
- $row = $dbr->selectRow( array( 'page', 'revision' ),
- array( 'rev_id', 'rev_timestamp' ),
- array(
+ $row = $dbr->selectRow( [ 'page', 'revision' ],
+ [ 'rev_id', 'rev_timestamp' ],
+ [
'page_namespace' => $this->title->getNamespace(),
'page_title' => $this->title->getDBkey(),
'page_id = rev_page',
'rev_timestamp < ' .
- $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
+ $dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ],
__METHOD__,
- array(
+ [
'ORDER BY' => 'rev_timestamp DESC',
- 'LIMIT' => 1 ) );
+ 'LIMIT' => 1 ] );
$prevLive = $row ? wfTimestamp( TS_MW, $row->rev_timestamp ) : false;
$prevLiveId = $row ? intval( $row->rev_id ) : null;
// New-style: keyed to the text storage backend.
$dbr = wfGetDB( DB_SLAVE );
$text = $dbr->selectRow( 'text',
- array( 'old_text', 'old_flags' ),
- array( 'old_id' => $row->ar_text_id ),
+ [ 'old_text', 'old_flags' ],
+ [ 'old_id' => $row->ar_text_id ],
__METHOD__ );
return Revision::getRevisionText( $text );
function getLastRevisionText() {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'archive',
- array( 'ar_text', 'ar_flags', 'ar_text_id' ),
- array( 'ar_namespace' => $this->title->getNamespace(),
- 'ar_title' => $this->title->getDBkey() ),
+ [ 'ar_text', 'ar_flags', 'ar_text_id' ],
+ [ 'ar_namespace' => $this->title->getNamespace(),
+ 'ar_title' => $this->title->getDBkey() ],
__METHOD__,
- array( 'ORDER BY' => 'ar_timestamp DESC' ) );
+ [ 'ORDER BY' => 'ar_timestamp DESC' ] );
if ( $row ) {
return $this->getTextFromRow( $row );
function isDeleted() {
$dbr = wfGetDB( DB_SLAVE );
$n = $dbr->selectField( 'archive', 'COUNT(ar_title)',
- array( 'ar_namespace' => $this->title->getNamespace(),
- 'ar_title' => $this->title->getDBkey() ),
+ [ 'ar_namespace' => $this->title->getNamespace(),
+ 'ar_title' => $this->title->getDBkey() ],
__METHOD__
);
* @param array $fileVersions
* @param bool $unsuppress
* @param User $user User performing the action, or null to use $wgUser
+ * @param string|string[] $tags Change tags to add to log entry
+ * ($user should be able to add the specified tags before this is called)
* @return array(number of file revisions restored, number of image revisions
* restored, log message) on success, false on failure.
*/
- function undelete( $timestamps, $comment = '', $fileVersions = array(),
- $unsuppress = false, User $user = null
+ function undelete( $timestamps, $comment = '', $fileVersions = [],
+ $unsuppress = false, User $user = null, $tags = null
) {
// If both the set of text revisions and file revisions are empty,
// restore everything. Otherwise, just restore the requested items.
$logEntry->setPerformer( $user );
$logEntry->setTarget( $this->title );
$logEntry->setComment( $reason );
+ $logEntry->setTags( $tags );
- Hooks::run( 'ArticleUndeleteLogEntry', array( $this, &$logEntry, $user ) );
+ Hooks::run( 'ArticleUndeleteLogEntry', [ $this, &$logEntry, $user ] );
$logid = $logEntry->insert();
$logEntry->publish( $logid );
- return array( $textRestored, $filesRestored, $reason );
+ return [ $textRestored, $filesRestored, $reason ];
}
/**
$oldcountable = $article->isCountable();
$page = $dbw->selectRow( 'page',
- array( 'page_id', 'page_latest' ),
- array( 'page_namespace' => $this->title->getNamespace(),
- 'page_title' => $this->title->getDBkey() ),
+ [ 'page_id', 'page_latest' ],
+ [ 'page_namespace' => $this->title->getNamespace(),
+ 'page_title' => $this->title->getDBkey() ],
__METHOD__,
- array( 'FOR UPDATE' ) // lock page
+ [ 'FOR UPDATE' ] // lock page
);
if ( $page ) {
# Get the time span of this page
$previousTimestamp = $dbw->selectField( 'revision', 'rev_timestamp',
- array( 'rev_id' => $previousRevId ),
+ [ 'rev_id' => $previousRevId ],
__METHOD__ );
if ( $previousTimestamp === false ) {
$previousTimestamp = 0;
}
- $oldWhere = array(
+ $oldWhere = [
'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDBkey(),
- );
+ ];
if ( !$restoreAll ) {
- $oldWhere['ar_timestamp'] = array_map( array( &$dbw, 'timestamp' ), $timestamps );
+ $oldWhere['ar_timestamp'] = array_map( [ &$dbw, 'timestamp' ], $timestamps );
}
- $fields = array(
+ $fields = [
'ar_rev_id',
'ar_text',
'ar_comment',
'ar_page_id',
'ar_len',
'ar_sha1'
- );
+ ];
if ( $this->config->get( 'ContentHandlerUseDB' ) ) {
$fields[] = 'ar_content_format';
$fields,
$oldWhere,
__METHOD__,
- /* options */ array( 'ORDER BY' => 'ar_timestamp' )
+ /* options */ [ 'ORDER BY' => 'ar_timestamp' ]
);
$rev_count = $result->numRows();
// grab the content to check consistency with global state before restoring the page.
$revision = Revision::newFromArchiveRow( $row,
- array(
+ [
'title' => $article->getTitle(), // used to derive default content model
- )
+ ]
);
$user = User::newFromName( $revision->getUserText( Revision::RAW ), false );
$content = $revision->getContent( Revision::RAW );
// Check for key dupes due to needed archive integrity.
if ( $row->ar_rev_id ) {
$exists = $dbw->selectField( 'revision', '1',
- array( 'rev_id' => $row->ar_rev_id ), __METHOD__ );
+ [ 'rev_id' => $row->ar_rev_id ], __METHOD__ );
if ( $exists ) {
continue; // don't throw DB errors
}
// Insert one revision at a time...maintaining deletion status
// unless we are specifically removing all restrictions...
$revision = Revision::newFromArchiveRow( $row,
- array(
+ [
'page' => $pageId,
'title' => $this->title,
'deleted' => $unsuppress ? 0 : $row->ar_deleted
- ) );
+ ] );
$revision->insertOn( $dbw );
$restored++;
- Hooks::run( 'ArticleRevisionUndeleted', array( &$this->title, $revision, $row->ar_page_id ) );
+ Hooks::run( 'ArticleRevisionUndeleted', [ &$this->title, $revision, $row->ar_page_id ] );
}
# Now that it's safely stored, take it out of the archive
$dbw->delete( 'archive',
$article->doEditUpdates(
$revision,
User::newFromName( $revision->getUserText( Revision::RAW ), false ),
- array(
+ [
'created' => $created,
'oldcountable' => $oldcountable,
'restored' => true
- )
+ ]
);
}
- Hooks::run( 'ArticleUndelete', array( &$this->title, $created, $comment, $oldPageId ) );
+ Hooks::run( 'ArticleUndelete', [ &$this->title, $created, $comment, $oldPageId ] );
if ( $this->title->getNamespace() == NS_FILE ) {
DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->title, 'imagelinks' ) );
}
if ( $this->mRestore || $this->mInvert ) {
- $timestamps = array();
- $this->mFileVersions = array();
+ $timestamps = [];
+ $this->mFileVersions = [];
foreach ( $request->getValues() as $key => $val ) {
- $matches = array();
+ $matches = [];
if ( preg_match( '/^ts(\d{14})$/', $key, $matches ) ) {
array_push( $timestamps, $matches[1] );
}
private function redirectToRevDel() {
$archive = new PageArchive( $this->mTargetObj );
- $revisions = array();
+ $revisions = [];
foreach ( $this->getRequest()->getValues() as $key => $val ) {
- $matches = array();
+ $matches = [];
if ( preg_match( "/^ts(\d{14})$/", $key, $matches ) ) {
$revisions[ $archive->getRevision( $matches[1] )->getId() ] = 1;
}
}
- $query = array(
+ $query = [
"type" => "revision",
"ids" => $revisions,
- "target" => wfUrlencode( $this->mTargetObj->getPrefixedText() )
- );
+ "target" => $this->mTargetObj->getPrefixedText()
+ ];
$url = SpecialPage::getTitleFor( "RevisionDelete" )->getFullURL( $query );
$this->getOutput()->redirect( $url );
}
$out = $this->getOutput();
$out->setPageTitle( $this->msg( 'undelete-search-title' ) );
$out->addHTML(
- Xml::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) ) .
+ Xml::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] ) .
Xml::fieldset( $this->msg( 'undelete-search-box' )->text() ) .
Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ) .
Html::rawElement(
'label',
- array( 'for' => 'prefix' ),
+ [ 'for' => 'prefix' ],
$this->msg( 'undelete-search-prefix' )->parse()
) .
Xml::input(
'prefix',
20,
$this->mSearchPrefix,
- array( 'id' => 'prefix', 'autofocus' => '' )
+ [ 'id' => 'prefix', 'autofocus' => '' ]
) . ' ' .
Xml::submitButton( $this->msg( 'undelete-search-submit' )->text() ) .
Xml::closeElement( 'fieldset' ) .
$item = Linker::linkKnown(
$undelete,
htmlspecialchars( $title->getPrefixedText() ),
- array(),
- array( 'target' => $title->getPrefixedText() )
+ [],
+ [ 'target' => $title->getPrefixedText() ]
);
} else {
// The title is no longer valid, show as text
$item = Html::element(
'span',
- array( 'class' => 'mw-invalidtitle' ),
+ [ 'class' => 'mw-invalidtitle' ],
Linker::getInvalidTitleDescription(
$this->getContext(),
$row->ar_namespace,
}
$archive = new PageArchive( $this->mTargetObj, $this->getConfig() );
- if ( !Hooks::run( 'UndeleteForm::showRevision', array( &$archive, $this->mTargetObj ) ) ) {
+ if ( !Hooks::run( 'UndeleteForm::showRevision', [ &$archive, $this->mTargetObj ] ) ) {
return;
}
$rev = $archive->getRevision( $timestamp );
$out->addHTML( $this->msg( 'undelete-revision' )->rawParams( $link )->params(
$time )->rawParams( $userLink )->params( $d, $t )->parse() . '</div>' );
- if ( !Hooks::run( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) ) ) {
+ if ( !Hooks::run( 'UndeleteShowRevision', [ $this->mTargetObj, $rev ] ) ) {
return;
}
// source view for textual content
$sourceView = Xml::element(
'textarea',
- array(
+ [
'readonly' => 'readonly',
'cols' => $user->getIntOption( 'cols' ),
'rows' => $user->getIntOption( 'rows' )
- ),
+ ],
$content->getNativeData() . "\n"
);
- $previewButton = Xml::element( 'input', array(
+ $previewButton = Xml::element( 'input', [
'type' => 'submit',
'name' => 'preview',
'value' => $this->msg( 'showpreview' )->text()
- ) );
+ ] );
} else {
$sourceView = '';
$previewButton = '';
}
- $diffButton = Xml::element( 'input', array(
+ $diffButton = Xml::element( 'input', [
'name' => 'diff',
'type' => 'submit',
- 'value' => $this->msg( 'showdiff' )->text() ) );
+ 'value' => $this->msg( 'showdiff' )->text() ] );
$out->addHTML(
$sourceView .
- Xml::openElement( 'div', array(
- 'style' => 'clear: both' ) ) .
- Xml::openElement( 'form', array(
+ Xml::openElement( 'div', [
+ 'style' => 'clear: both' ] ) .
+ Xml::openElement( 'form', [
'method' => 'post',
- 'action' => $this->getPageTitle()->getLocalURL( array( 'action' => 'submit' ) ) ) ) .
- Xml::element( 'input', array(
+ 'action' => $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] ) ] ) .
+ Xml::element( 'input', [
'type' => 'hidden',
'name' => 'target',
- 'value' => $this->mTargetObj->getPrefixedDBkey() ) ) .
- Xml::element( 'input', array(
+ 'value' => $this->mTargetObj->getPrefixedDBkey() ] ) .
+ Xml::element( 'input', [
'type' => 'hidden',
'name' => 'timestamp',
- 'value' => $timestamp ) ) .
- Xml::element( 'input', array(
+ 'value' => $timestamp ] ) .
+ Xml::element( 'input', [
'type' => 'hidden',
'name' => 'wpEditToken',
- 'value' => $user->getEditToken() ) ) .
+ 'value' => $user->getEditToken() ] ) .
$previewButton .
$diffButton .
Xml::closeElement( 'form' ) .
if ( $isDeleted ) {
/// @todo FIXME: $rev->getTitle() is null for deleted revs...?
$targetPage = $this->getPageTitle();
- $targetQuery = array(
+ $targetQuery = [
'target' => $this->mTargetObj->getPrefixedText(),
'timestamp' => wfTimestamp( TS_MW, $rev->getTimestamp() )
- );
+ ];
} else {
/// @todo FIXME: getId() may return non-zero for deleted revs...
$targetPage = $rev->getTitle();
- $targetQuery = array( 'oldid' => $rev->getId() );
+ $targetQuery = [ 'oldid' => $rev->getId() ];
}
// Add show/hide deletion links if available
$tags = wfGetDB( DB_SLAVE )->selectField(
'tag_summary',
'ts_tags',
- array( 'ts_rev_id' => $rev->getId() ),
+ [ 'ts_rev_id' => $rev->getId() ],
__METHOD__
);
$tagSummary = ChangeTags::formatSummaryRow( $tags, 'deleteddiff', $this->getContext() );
$lang->userDate( $rev->getTimestamp(), $user ),
$lang->userTime( $rev->getTimestamp(), $user )
)->escaped(),
- array(),
+ [],
$targetQuery
) .
'</strong></div>' .
$lang->userDate( $file->getTimestamp(), $user ),
$lang->userTime( $file->getTimestamp(), $user ) );
$out->addHTML(
- Xml::openElement( 'form', array(
+ Xml::openElement( 'form', [
'method' => 'POST',
- 'action' => $this->getPageTitle()->getLocalURL( array(
+ 'action' => $this->getPageTitle()->getLocalURL( [
'target' => $this->mTarget,
'file' => $key,
'token' => $user->getEditToken( $key ),
- ) ),
- )
+ ] ),
+ ]
) .
Xml::submitButton( $this->msg( 'undelete-show-file-submit' )->text() ) .
'</form>'
}
$out->wrapWikiMsg(
"<div class='mw-undelete-pagetitle'>\n$1\n</div>\n",
- array( 'undeletepagetitle', wfEscapeWikiText( $this->mTargetObj->getPrefixedText() ) )
+ [ 'undeletepagetitle', wfEscapeWikiText( $this->mTargetObj->getPrefixedText() ) ]
);
$archive = new PageArchive( $this->mTargetObj, $this->getConfig() );
- Hooks::run( 'UndeleteForm::showHistory', array( &$archive, $this->mTargetObj ) );
+ Hooks::run( 'UndeleteForm::showHistory', [ &$archive, $this->mTargetObj ] );
/*
$text = $archive->getLastRevisionText();
if( is_null( $text ) ) {
}
if ( $this->mAllowed ) {
- $action = $this->getPageTitle()->getLocalURL( array( 'action' => 'submit' ) );
+ $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
# Start the form here
$top = Xml::openElement(
'form',
- array( 'method' => 'post', 'action' => $action, 'id' => 'undelete' )
+ [ 'method' => 'post', 'action' => $action, 'id' => 'undelete' ]
);
$out->addHTML( $top );
}
}
$table = Xml::fieldset( $this->msg( 'undelete-fieldset-title' )->text() ) .
- Xml::openElement( 'table', array( 'id' => 'mw-undelete-table' ) ) .
+ Xml::openElement( 'table', [ 'id' => 'mw-undelete-table' ] ) .
"<tr>
<td colspan='2' class='mw-undelete-extrahelp'>" .
$this->msg( 'undeleteextrahelp' )->parseAsBlock() .
'wpComment',
50,
$this->mComment,
- array( 'id' => 'wpComment', 'autofocus' => '' )
+ [ 'id' => 'wpComment', 'autofocus' => '' ]
) .
"</td>
</tr>
<td class='mw-submit'>" .
Xml::submitButton(
$this->msg( 'undeletebtn' )->text(),
- array( 'name' => 'restore', 'id' => 'mw-undelete-submit' )
+ [ 'name' => 'restore', 'id' => 'mw-undelete-submit' ]
) . ' ' .
Xml::submitButton(
$this->msg( 'undeleteinvert' )->text(),
- array( 'name' => 'invert', 'id' => 'mw-undelete-invert' )
+ [ 'name' => 'invert', 'id' => 'mw-undelete-invert' ]
) .
"</td>
</tr>" .
if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
$out->addHTML( Html::element(
'button',
- array(
+ [
'name' => 'revdel',
'type' => 'submit',
'class' => 'deleterevision-log-submit mw-log-deleterevision-button'
- ),
+ ],
$this->msg( 'showhideselectedversions' )->text()
) . "\n" );
}
protected function formatRevisionRow( $row, $earliestLiveTime, $remaining ) {
$rev = Revision::newFromArchiveRow( $row,
- array(
+ [
'title' => $this->mTargetObj
- ) );
+ ] );
$revTextSize = '';
$ts = wfTimestamp( TS_MW, $row->ar_timestamp );
$last = Linker::linkKnown(
$titleObj,
$this->msg( 'diff' )->escaped(),
- array(),
- array(
+ [],
+ [
'target' => $this->mTargetObj->getPrefixedText(),
'timestamp' => $ts,
'diff' => 'prev'
- )
+ ]
);
} else {
$pageLink = $this->getPageLink( $rev, $titleObj, $ts );
$comment = Linker::revComment( $rev );
// Tags
- $attribs = array();
+ $attribs = [];
list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
$row->ts_tags,
'deletedhistory',
// Revision was hidden from sysops
$revdlink = Linker::revDeleteLinkDisabled( $canHide );
} else {
- $query = array(
+ $query = [
'type' => 'filearchive',
'target' => $this->mTargetObj->getPrefixedDBkey(),
'ids' => $row->fa_id
- );
+ ];
$revdlink = Linker::revDeleteLink( $query,
$file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
}
$link = Linker::linkKnown(
$titleObj,
htmlspecialchars( $time ),
- array(),
- array(
+ [],
+ [
'target' => $this->mTargetObj->getPrefixedText(),
'timestamp' => $ts
- )
+ ]
);
if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
$link = Linker::linkKnown(
$titleObj,
htmlspecialchars( $time ),
- array(),
- array(
+ [],
+ [
'target' => $this->mTargetObj->getPrefixedText(),
'file' => $key,
'token' => $user->getEditToken( $key )
- )
+ ]
);
if ( $file->isDeleted( File::DELETED_FILE ) ) {
$out = $this->getOutput();
$archive = new PageArchive( $this->mTargetObj, $this->getConfig() );
- Hooks::run( 'UndeleteForm::undelete', array( &$archive, $this->mTargetObj ) );
+ Hooks::run( 'UndeleteForm::undelete', [ &$archive, $this->mTargetObj ] );
$ok = $archive->undelete(
$this->mTargetTimestamp,
$this->mComment,
if ( is_array( $ok ) ) {
if ( $ok[1] ) { // Undeleted file count
- Hooks::run( 'FileUndeleteComplete', array(
+ Hooks::run( 'FileUndeleteComplete', [
$this->mTargetObj, $this->mFileVersions,
- $this->getUser(), $this->mComment ) );
+ $this->getUser(), $this->mComment ] );
}
$link = Linker::linkKnown( $this->mTargetObj );