/** * Hook * * @param Article $article -- instance of Article class * @param User $user -- current user * @param string $reason -- deleting reason * @param integer $id -- article id * * @static * @access public * * @return boolean -- because it's a hook */ public static function articleDeleteComplete(&$article, &$user, $reason, $id) { global $wgOut, $wgRC2UDPEnabled, $wgMaxCommentsToDelete, $wgCityId, $wgUser, $wgEnableMultiDeleteExt; wfProfileIn(__METHOD__); $title = $article->getTitle(); if (!MWNamespace::isTalk($title->getNamespace()) || !ArticleComment::isTitleComment($title)) { if (empty(self::$mArticlesToDelete)) { wfProfileOut(__METHOD__); return true; } } //watch out for recursion if (self::$mDeletionInProgress) { wfProfileOut(__METHOD__); return true; } self::$mDeletionInProgress = true; //redirect to article/blog after deleting a comment (or whole article/blog) $parts = ArticleComment::explode($title->getText()); $parentTitle = Title::newFromText($parts['title'], MWNamespace::getSubject($title->getNamespace())); $wgOut->redirect($parentTitle->getFullUrl()); //do not use $reason as it contains content of parent article/comment - not current ones that we delete in a loop $deleteReason = wfMsgForContent('article-comments-delete-reason'); //we have comment 1st level - checked in articleDelete() (or 2nd - so do nothing) if (is_array(self::$mArticlesToDelete)) { $mDelete = 'live'; if (isset($wgMaxCommentsToDelete) && count(self::$mArticlesToDelete) > $wgMaxCommentsToDelete) { if (!empty($wgEnableMultiDeleteExt)) { $mDelete = 'task'; } } if ($mDelete == 'live') { $irc_backup = $wgRC2UDPEnabled; //backup $wgRC2UDPEnabled = false; //turn off foreach (self::$mArticlesToDelete as $page_id => $oComment) { $oCommentTitle = $oComment->getTitle(); if ($oCommentTitle instanceof Title) { $oComment = new ArticleComment($oCommentTitle); $oComment->doDeleteComment($deleteReason); } } $wgRC2UDPEnabled = $irc_backup; //restore to whatever it was $listing = ArticleCommentList::newFromTitle($parentTitle); $listing->purge(); } else { $taskParams = array('mode' => 'you', 'wikis' => '', 'range' => 'one', 'reason' => 'delete page', 'lang' => '', 'cat' => '', 'selwikia' => $wgCityId, 'edittoken' => $wgUser->getEditToken(), 'user' => $wgUser->getName(), 'admin' => $wgUser->getName()); foreach (self::$mArticlesToDelete as $oComment) { $oCommentTitle = $oComment->getTitle(); if ($oCommentTitle instanceof Title) { /* @var $oCommentTitle Title */ $data = $taskParams; $data['page'] = $oCommentTitle->getFullText(); $thisTask = new MultiDeleteTask($data); $submit_id = $thisTask->submitForm(); Wikia::log(__METHOD__, 'deletecomment', "Added task ({$submit_id}) for {$data['page']} page"); } } } } wfProfileOut(__METHOD__); return true; }