ParamValidator: Flag as unstable for 1.34
[lhc/web/wiklou.git] / includes / api / ApiDelete.php
index ec857b7..ad171c6 100644 (file)
@@ -42,6 +42,7 @@ class ApiDelete extends ApiBase {
                $pageObj = $this->getTitleOrPageId( $params, 'fromdbmaster' );
                $titleObj = $pageObj->getTitle();
                if ( !$pageObj->exists() &&
+                       // @phan-suppress-next-line PhanUndeclaredMethod
                        !( $titleObj->getNamespace() == NS_FILE && self::canDeleteFile( $pageObj->getFile() ) )
                ) {
                        $this->dieWithError( 'apierror-missingtitle' );
@@ -75,9 +76,10 @@ class ApiDelete extends ApiBase {
                        $status = self::delete( $pageObj, $user, $reason, $params['tags'] );
                }
 
-               if ( !$status->isGood() ) {
+               if ( !$status->isOK() ) {
                        $this->dieStatus( $status );
                }
+               $this->addMessagesFromStatus( $status, [ 'warning' ], [ 'delete-scheduled' ] );
 
                // Deprecated parameters
                if ( $params['watch'] ) {
@@ -92,8 +94,14 @@ class ApiDelete extends ApiBase {
                $r = [
                        'title' => $titleObj->getPrefixedText(),
                        'reason' => $reason,
-                       'logid' => $status->value
                ];
+               if ( $status->hasMessage( 'delete-scheduled' ) ) {
+                       $r['scheduled'] = true;
+               }
+               if ( $status->value !== null ) {
+                       // Scheduled deletions don't currently have a log entry available at this point
+                       $r['logid'] = $status->value;
+               }
                $this->getResult()->addValue( null, $this->getModuleName(), $r );
        }
 
@@ -149,6 +157,7 @@ class ApiDelete extends ApiBase {
        ) {
                $title = $page->getTitle();
 
+               // @phan-suppress-next-line PhanUndeclaredMethod There's no right typehint for it
                $file = $page->getFile();
                if ( !self::canDeleteFile( $file ) ) {
                        return self::delete( $page, $user, $reason, $tags );