<?php
/**
- *
- *
- * Created on August 16, 2007
- *
* Copyright © 2007 Iker Labarga "<Firstname><Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
// Now let's check whether we're even allowed to do this
$this->checkTitleUserPermissions(
$titleObj,
- $titleObj->exists() ? 'edit' : [ 'edit', 'create' ]
+ $titleObj->exists() ? 'edit' : [ 'edit', 'create' ],
+ [ 'autoblock' => true ]
);
$toMD5 = $params['text'];
}
try {
- $content = ContentHandler::makeContent( $text, $this->getTitle() );
+ $content = ContentHandler::makeContent( $text, $titleObj );
} catch ( MWContentSerializationException $ex ) {
$this->dieWithException( $ex, [
'wrap' => ApiMessage::create( 'apierror-contentserializationexception', 'parseerror' )
}
// Apply change tags
- if ( count( $params['tags'] ) ) {
+ if ( $params['tags'] ) {
$tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
if ( $tagStatus->isOK() ) {
$requestArray['wpChangeTags'] = implode( ',', $params['tags'] );
return;
}
if ( !$status->getErrors() ) {
- $status->fatal( 'hookaborted' );
+ // This appears to be unreachable right now, because all
+ // code paths will set an error. Could change, though.
+ $status->fatal( 'hookaborted' ); //@codeCoverageIgnore
}
$this->dieStatus( $status );
+ // These two cases will normally have been caught earlier, and will
+ // only occur if something blocks the user between the earlier
+ // check and the check in EditPage (presumably a hook). It's not
+ // obvious that this is even possible.
+ // @codeCoverageIgnoreStart
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
- $this->dieWithError(
- 'apierror-blocked',
- 'blocked',
- [ 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) ]
- );
+ $this->dieBlocked( $user->getBlock() );
case EditPage::AS_READ_ONLY_PAGE:
$this->dieReadOnly();
+ // @codeCoverageIgnoreEnd
case EditPage::AS_SUCCESS_NEW_ARTICLE:
$r['new'] = true;
case EditPage::AS_SUCCESS_UPDATE:
$r['result'] = 'Success';
- $r['pageid'] = intval( $titleObj->getArticleID() );
+ $r['pageid'] = (int)$titleObj->getArticleID();
$r['title'] = $titleObj->getPrefixedText();
$r['contentmodel'] = $articleObject->getContentModel();
$newRevId = $articleObject->getLatest();
if ( $newRevId == $oldRevId ) {
$r['nochange'] = true;
} else {
- $r['oldrevid'] = intval( $oldRevId );
- $r['newrevid'] = intval( $newRevId );
+ $r['oldrevid'] = (int)$oldRevId;
+ $r['newrevid'] = (int)$newRevId;
$r['newtimestamp'] = wfTimestamp( TS_ISO_8601,
$pageObj->getTimestamp() );
}
$status->fatal( 'apierror-noimageredirect-anon' );
break;
case EditPage::AS_IMAGE_REDIRECT_LOGGED:
- $status->fatal( 'apierror-noimageredirect-logged' );
+ $status->fatal( 'apierror-noimageredirect' );
break;
case EditPage::AS_CONTENT_TOO_BIG:
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
// Currently shouldn't be needed, but here in case
// hooks use them without setting appropriate
// errors on the status.
+ // @codeCoverageIgnoreStart
case EditPage::AS_SPAM_ERROR:
$status->fatal( 'apierror-spamdetected', $result['spam'] );
break;
wfWarn( __METHOD__ . ": Unknown EditPage code {$status->value} with no message" );
$status->fatal( 'apierror-unknownerror-editpage', $status->value );
break;
+ // @codeCoverageIgnoreEnd
}
}
$this->dieStatus( $status );
- break;
}
$apiResult->addValue( null, $this->getModuleName(), $r );
}
ApiBase::PARAM_TYPE => 'text',
],
'undo' => [
- ApiBase::PARAM_TYPE => 'integer'
+ ApiBase::PARAM_TYPE => 'integer',
+ ApiBase::PARAM_MIN => 0,
+ ApiBase::PARAM_RANGE_ENFORCE => true,
],
'undoafter' => [
- ApiBase::PARAM_TYPE => 'integer'
+ ApiBase::PARAM_TYPE => 'integer',
+ ApiBase::PARAM_MIN => 0,
+ ApiBase::PARAM_RANGE_ENFORCE => true,
],
'redirect' => [
ApiBase::PARAM_TYPE => 'boolean',