X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiMove.php;h=89ecc43bd9469df85a8fd7fa657b1c5dccba84fe;hp=cc4490e63fdcca319788cf371ee2bac20f7bd7a8;hb=e5ef0fd0c6607dd34f6dee69d716b159662a0a34;hpb=1a3f16f2b5debe6780e23ca25db979f14864e78e diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index cc4490e63f..89ecc43bd9 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -201,22 +201,22 @@ class ApiMove extends ApiBase { public function moveSubpages( $fromTitle, $toTitle, $reason, $noredirect, $changeTags = [] ) { $retval = []; - $success = $fromTitle->moveSubpages( $toTitle, true, $reason, !$noredirect, $changeTags ); - if ( isset( $success[0] ) ) { - $status = $this->errorArrayToStatus( $success ); - return [ 'errors' => $this->getErrorFormatter()->arrayFromStatus( $status ) ]; + $mp = new MovePage( $fromTitle, $toTitle ); + $result = + $mp->moveSubpagesIfAllowed( $this->getUser(), $reason, !$noredirect, $changeTags ); + if ( !$result->isOk() ) { + // This means the whole thing failed + return [ 'errors' => $this->getErrorFormatter()->arrayFromStatus( $result ) ]; } // At least some pages could be moved // Report each of them separately - foreach ( $success as $oldTitle => $newTitle ) { + foreach ( $result->getValue() as $oldTitle => $status ) { $r = [ 'from' => $oldTitle ]; - if ( is_array( $newTitle ) ) { - $status = $this->errorArrayToStatus( $newTitle ); - $r['errors'] = $this->getErrorFormatter()->arrayFromStatus( $status ); + if ( $status->isOK() ) { + $r['to'] = $status->getValue(); } else { - // Success - $r['to'] = $newTitle; + $r['errors'] = $this->getErrorFormatter()->arrayFromStatus( $status ); } $retval[] = $r; }