Example #1
0
 /**
  * We have our own delete() function, since Article.php's implementation is split in two phases
  *
  * @param Page|WikiPage $page Page or WikiPage object to work on
  * @param User $user User doing the action
  * @param string|null $reason Reason for the deletion. Autogenerated if null
  * @return Status|array
  */
 protected static function delete(Page $page, User $user, &$reason = null)
 {
     $title = $page->getTitle();
     // Auto-generate a summary, if necessary
     if (is_null($reason)) {
         // Need to pass a throwaway variable because generateReason expects
         // a reference
         $hasHistory = false;
         $reason = $page->getAutoDeleteReason($hasHistory);
         if ($reason === false) {
             return array(array('cannotdelete', $title->getPrefixedText()));
         }
     }
     $error = '';
     // Luckily, Article.php provides a reusable delete function that does the hard work for us
     return $page->doDeleteArticleReal($reason, false, 0, true, $error, $user);
 }