if ( !$titleObj ) {
$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
}
+ $pageObj = WikiPage::factory( $titleObj );
+ $pageObj->loadPageData( 'fromdbmaster' );
+ if ( !$pageObj->exists() ) {
+ $this->dieUsageMsg( 'notanarticle' );
+ }
} elseif ( isset( $params['pageid'] ) ) {
- $titleObj = Title::newFromID( $params['pageid'] );
- if ( !$titleObj ) {
+ $pageObj = WikiPage::newFromID( $params['pageid'] );
+ if ( !$pageObj ) {
$this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) );
}
- }
- if ( !$titleObj->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 ) ) {
* @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 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"',
);
}