public function execute() {
$params = $this->extractRequestParams();
- $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
-
- if ( isset( $params['title'] ) ) {
- $titleObj = Title::newFromText( $params['title'] );
- if ( !$titleObj ) {
- $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
- }
- } elseif ( isset( $params['pageid'] ) ) {
- $titleObj = Title::newFromID( $params['pageid'] );
- if ( !$titleObj ) {
- $this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) );
- }
- }
- if ( !$titleObj->exists() ) {
+ $pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
+ if ( !$pageObj->exists() ) {
$this->dieUsageMsg( 'notanarticle' );
}
+ $titleObj = $pageObj->getTitle();
$reason = ( isset( $params['reason'] ) ? $params['reason'] : null );
- $pageObj = WikiPage::factory( $titleObj );
$user = $this->getUser();
if ( $titleObj->getNamespace() == NS_FILE ) {
* @return Title::getUserPermissionsErrors()-like array
*/
public static function delete( Page $page, User $user, $token, &$reason = null ) {
- if ( $page->isBigDeletion() && !$user->isAllowed( 'bigdelete' ) ) {
- global $wgDeleteRevisionsLimit;
- return array( array( 'delete-toobig', $wgDeleteRevisionsLimit ) );
- }
-
$title = $page->getTitle();
$errors = self::getPermissionsError( $title, $user, $token );
if ( count( $errors ) ) {
// Need to pass a throwaway variable because generateReason expects
// a reference
$hasHistory = false;
- $reason = $page->getAutoDeleteReason( $hasHistory );
+ $reason = $page->getAutoDeleteReason( $hasHistory ); #FIXME: use ContentHandler::getAutoDeleteReason()
if ( $reason === false ) {
return array( array( 'cannotdelete', $title->getPrefixedText() ) );
}
* @param $oldimage
* @param $reason
* @param $suppress bool
- * @return \type|array|Title
+ * @return array|Title
*/
public static function deleteFile( Page $page, User $user, $token, $oldimage, &$reason = null, $suppress = false ) {
$title = $page->getTitle();
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(),
- $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ),
+ $this->getTitleOrPageIdErrorMessage(),
array(
- array( 'invalidtitle', 'title' ),
- array( 'nosuchpageid', 'pageid' ),
array( 'notanarticle' ),
array( 'hookaborted', 'error' ),
array( 'delete-toobig', 'limit' ),
public function getExamples() {
return array(
- 'api.php?action=delete&title=Main%20Page&token=123ABC',
- 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move'
+ 'api.php?action=delete&title=Main%20Page&token=123ABC' => 'Delete the Main Page',
+ 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move' => 'Delete the Main Page with the reason "Preparing for move"',
);
}
public function getHelpUrls() {
- return 'http://www.mediawiki.org/wiki/API:Delete';
+ return 'https://www.mediawiki.org/wiki/API:Delete';
}
public function getVersion() {