->getRedirectChain();
// array_shift( $titles );
- $redirValues = array();
+ $redirValues = [];
/** @var $newTitle Title */
foreach ( $titles as $id => $newTitle ) {
$titles[$id - 1] = $oldTitle;
}
- $redirValues[] = array(
+ $redirValues[] = [
'from' => $titles[$id - 1]->getPrefixedText(),
'to' => $newTitle->getPrefixedText()
- );
+ ];
$titleObj = $newTitle;
}
'You have been blocked from editing',
'blocked',
0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) )
+ [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
);
break;
case 'autoblockedtext':
'Your IP address has been blocked automatically, because it was used by a blocked user',
'autoblocked',
0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) )
+ [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
);
break;
default:
if ( $params['undoafter'] > 0 ) {
if ( $params['undo'] < $params['undoafter'] ) {
list( $params['undo'], $params['undoafter'] ) =
- array( $params['undoafter'], $params['undo'] );
+ [ $params['undoafter'], $params['undo'] ];
}
$undoafterRev = Revision::newFromId( $params['undoafter'] );
}
$undoRev = Revision::newFromId( $params['undo'] );
if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) {
- $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) );
+ $this->dieUsageMsg( [ 'nosuchrevid', $params['undo'] ] );
}
if ( $params['undoafter'] == 0 ) {
$undoafterRev = $undoRev->getPrevious();
}
if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) {
- $this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) );
+ $this->dieUsageMsg( [ 'nosuchrevid', $params['undoafter'] ] );
}
if ( $undoRev->getPage() != $pageObj->getId() ) {
- $this->dieUsageMsg( array( 'revwrongpage', $undoRev->getId(),
- $titleObj->getPrefixedText() ) );
+ $this->dieUsageMsg( [ 'revwrongpage', $undoRev->getId(),
+ $titleObj->getPrefixedText() ] );
}
if ( $undoafterRev->getPage() != $pageObj->getId() ) {
- $this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getId(),
- $titleObj->getPrefixedText() ) );
+ $this->dieUsageMsg( [ 'revwrongpage', $undoafterRev->getId(),
+ $titleObj->getPrefixedText() ] );
}
$newContent = $contentHandler->getUndoContent(
// EditPage wants to parse its stuff from a WebRequest
// That interface kind of sucks, but it's workable
- $requestArray = array(
+ $requestArray = [
'wpTextbox1' => $params['text'],
'format' => $contentFormat,
'model' => $contentHandler->getModelID(),
'wpIgnoreBlankArticle' => true,
'wpIgnoreSelfRedirect' => true,
'bot' => $params['bot'],
- );
+ ];
if ( !is_null( $params['summary'] ) ) {
$requestArray['wpSummary'] = $params['summary'];
$section = $params['section'];
if ( !preg_match( '/^((T-)?\d+|new)$/', $section ) ) {
$this->dieUsage( "The section parameter must be a valid section id or 'new'",
- "invalidsection" );
+ 'invalidsection' );
}
$content = $pageObj->getContent();
if ( $section !== '0' && $section != 'new'
// Apply change tags
if ( count( $params['tags'] ) ) {
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
- if ( $tagStatus->isOk() ) {
+ if ( $tagStatus->isOK() ) {
$requestArray['wpChangeTags'] = implode( ',', $params['tags'] );
} else {
$this->dieStatus( $tagStatus );
$ep->importFormData( $req );
$content = $ep->textbox1;
- // The following is needed to give the hook the full content of the
- // new revision rather than just the current section. (Bug 52077)
- if ( !is_null( $params['section'] ) &&
- $contentHandler->supportsSections() && $titleObj->exists()
- ) {
- // If sectiontitle is set, use it, otherwise use the summary as the section title (for
- // backwards compatibility with old forms/bots).
- if ( $ep->sectiontitle !== '' ) {
- $sectionTitle = $ep->sectiontitle;
- } else {
- $sectionTitle = $ep->summary;
- }
-
- $contentObj = $contentHandler->unserializeContent( $content, $contentFormat );
-
- $fullContentObj = $articleObject->replaceSectionContent(
- $params['section'],
- $contentObj,
- $sectionTitle
- );
- if ( $fullContentObj ) {
- $content = $fullContentObj->serialize( $contentFormat );
- } else {
- // This most likely means we have an edit conflict which means that the edit
- // wont succeed anyway.
- $this->dieUsageMsg( 'editconflict' );
- }
- }
-
// Run hooks
// Handle APIEditBeforeSave parameters
- $r = array();
- if ( !Hooks::run( 'APIEditBeforeSave', array( $ep, $content, &$r ) ) ) {
+ $r = [];
+ // Deprecated in favour of EditFilterMergedContent
+ if ( !Hooks::run( 'APIEditBeforeSave', [ $ep, $content, &$r ], '1.28' ) ) {
if ( count( $r ) ) {
$r['result'] = 'Failure';
$apiResult->addValue( null, $this->getModuleName(), $r );
$this->dieUsageMsg( 'noimageredirect-logged' );
case EditPage::AS_SPAM_ERROR:
- $this->dieUsageMsg( array( 'spamdetected', $result['spam'] ) );
+ $this->dieUsageMsg( [ 'spamdetected', $result['spam'] ] );
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
$this->dieUsage(
'You have been blocked from editing',
'blocked',
0,
- array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) )
+ [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
);
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case EditPage::AS_CONTENT_TOO_BIG:
- $this->dieUsageMsg( array( 'contenttoobig', $this->getConfig()->get( 'MaxArticleSize' ) ) );
+ $this->dieUsageMsg( [ 'contenttoobig', $this->getConfig()->get( 'MaxArticleSize' ) ] );
case EditPage::AS_READ_ONLY_PAGE_ANON:
$this->dieUsageMsg( 'noedit-anon' );
}
public function getAllowedParams() {
- return array(
- 'title' => array(
+ return [
+ 'title' => [
ApiBase::PARAM_TYPE => 'string',
- ),
- 'pageid' => array(
+ ],
+ 'pageid' => [
ApiBase::PARAM_TYPE => 'integer',
- ),
+ ],
'section' => null,
- 'sectiontitle' => array(
+ 'sectiontitle' => [
ApiBase::PARAM_TYPE => 'string',
- ),
- 'text' => array(
+ ],
+ 'text' => [
ApiBase::PARAM_TYPE => 'text',
- ),
+ ],
'summary' => null,
- 'tags' => array(
+ 'tags' => [
ApiBase::PARAM_TYPE => 'tags',
ApiBase::PARAM_ISMULTI => true,
- ),
+ ],
'minor' => false,
'notminor' => false,
'bot' => false,
- 'basetimestamp' => array(
+ 'basetimestamp' => [
ApiBase::PARAM_TYPE => 'timestamp',
- ),
- 'starttimestamp' => array(
+ ],
+ 'starttimestamp' => [
ApiBase::PARAM_TYPE => 'timestamp',
- ),
+ ],
'recreate' => false,
'createonly' => false,
'nocreate' => false,
- 'watch' => array(
+ 'watch' => [
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_DEPRECATED => true,
- ),
- 'unwatch' => array(
+ ],
+ 'unwatch' => [
ApiBase::PARAM_DFLT => false,
ApiBase::PARAM_DEPRECATED => true,
- ),
- 'watchlist' => array(
+ ],
+ 'watchlist' => [
ApiBase::PARAM_DFLT => 'preferences',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'watch',
'unwatch',
'preferences',
'nochange'
- ),
- ),
+ ],
+ ],
'md5' => null,
- 'prependtext' => array(
+ 'prependtext' => [
ApiBase::PARAM_TYPE => 'text',
- ),
- 'appendtext' => array(
+ ],
+ 'appendtext' => [
ApiBase::PARAM_TYPE => 'text',
- ),
- 'undo' => array(
+ ],
+ 'undo' => [
ApiBase::PARAM_TYPE => 'integer'
- ),
- 'undoafter' => array(
+ ],
+ 'undoafter' => [
ApiBase::PARAM_TYPE => 'integer'
- ),
- 'redirect' => array(
+ ],
+ 'redirect' => [
ApiBase::PARAM_TYPE => 'boolean',
ApiBase::PARAM_DFLT => false,
- ),
- 'contentformat' => array(
+ ],
+ 'contentformat' => [
ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
- ),
- 'contentmodel' => array(
+ ],
+ 'contentmodel' => [
ApiBase::PARAM_TYPE => ContentHandler::getContentModels(),
- ),
- 'token' => array(
+ ],
+ 'token' => [
// Standard definition automatically inserted
- ApiBase::PARAM_HELP_MSG_APPEND => array( 'apihelp-edit-param-token' ),
- ),
- );
+ ApiBase::PARAM_HELP_MSG_APPEND => [ 'apihelp-edit-param-token' ],
+ ],
+ ];
}
public function needsToken() {
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=edit&title=Test&summary=test%20summary&' .
'text=article%20content&basetimestamp=2007-08-24T12:34:54Z&token=123ABC'
=> 'apihelp-edit-example-edit',
'action=edit&title=Test&undo=13585&undoafter=13579&' .
'basetimestamp=2007-08-24T12:34:54Z&token=123ABC'
=> 'apihelp-edit-example-undo',
- );
+ ];
}
public function getHelpUrls() {