/**
  * After a page is saved, add or remove it from the blank_page table if
  * it has been blanked or unblanked, respectively; if blanked, redirect
  * the user to the "Action complete" page
  */
 public static function PureWikiDeletionSaveCompleteHook(&$article, &$user, $text, $summary, $minoredit, &$watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId, &$redirect)
 {
     global $wgOut, $wgInterWikiIntegrationInEffect;
     if (!isset($revision)) {
         return true;
     }
     $mTitle = $article->getTitle();
     if ($mTitle->getNamespace() == NS_FILE) {
         return true;
     }
     $blankRevId = $revision->getId();
     if ($text == "") {
         if ($summary == wfMsgForContent('autosumm-blank')) {
             $hasHistory = false;
             $summary = $article->generateReason($hasHistory);
         }
         $dbw = wfGetDB(DB_MASTER);
         $blank_row = array('blank_page_id' => $article->getID(), 'blank_user_id' => $user->getId(), 'blank_user_name' => $user->getName(), 'blank_timestamp' => $revision->getTimeStamp(), 'blank_summary' => $summary, 'blank_parent_id' => $revision->getParentId());
         $dbw->insert('blanked_page', $blank_row);
         $log = new LogPage('blank');
         $log->addEntry('blank', $mTitle, $summary, array(), $user);
         $dbw->commit();
         $dbw->delete('recentchanges', array('rc_this_oldid' => $blankRevId));
         Article::onArticleDelete($mTitle);
         $mTitle->resetArticleID(0);
         if ($user->getOption('watchblank')) {
             $watchthis = true;
         }
         wfRunHooks('PureWikiDeletionArticleBlankComplete', array($mTitle));
         $redirect = false;
         $wgOut->setPagetitle(wfMsg('actioncomplete'));
         $wgOut->setRobotPolicy('noindex,nofollow');
         $loglink = wfMsg('blank-log-link');
         $wgOut->addWikiMsg('purewikideletion-blankedtext', $mTitle->getPrefixedText(), $loglink);
         $wgOut->returnToMain(false);
     } else {
         $dbr = wfGetDB(DB_SLAVE);
         $blank_page_id = $article->getID();
         $result = $dbr->selectRow('blanked_page', 'blank_page_id', array("blank_page_id" => $blank_page_id));
         if (!$result) {
             return true;
         } else {
             if ($summary == '') {
                 $summary = $article->getAutosummary('', $text, EDIT_NEW);
             }
             $dbw = wfGetDB(DB_MASTER);
             $blank_page_id = $article->getID();
             $dbw->delete('blanked_page', array("blank_page_id" => $blank_page_id));
             $log = new LogPage('blank');
             $log->addEntry('unblank', $mTitle, $summary, array(), $user);
             $dbw->commit();
             $dbw->delete('recentchanges', array('rc_this_oldid' => $blankRevId));
             $mTitle->touchLinks();
             $mTitle->invalidateCache();
             $mTitle->purgeSquid();
             wfRunHooks('PureWikiDeletionArticleUnblankComplete', array($mTitle));
         }
     }
     return true;
 }
Example #2
0
 /**
  * Back-end article deletion
  * Deletes the article with database consistency, writes logs, purges caches
  *
  * @param $reason string delete reason for deletion log
  * @param suppress bitfield
  * 	Revision::DELETED_TEXT
  * 	Revision::DELETED_COMMENT
  * 	Revision::DELETED_USER
  * 	Revision::DELETED_RESTRICTED
  * @param $id int article ID
  * @param $commit boolean defaults to true, triggers transaction end
  * @return boolean true if successful
  */
 public function doDeleteArticle($reason, $suppress = false, $id = 0, $commit = true)
 {
     global $wgDeferredUpdateList, $wgUseTrackbacks;
     wfDebug(__METHOD__ . "\n");
     $dbw = wfGetDB(DB_MASTER);
     $t = $this->mTitle->getDBkey();
     $id = $id ? $id : $this->mTitle->getArticleID(Title::GAID_FOR_UPDATE);
     if ($t === '' || $id == 0) {
         return false;
     }
     $u = new SiteStatsUpdate(0, 1, -(int) $this->isCountable($this->getRawText()), -1);
     array_push($wgDeferredUpdateList, $u);
     // Bitfields to further suppress the content
     if ($suppress) {
         $bitfield = 0;
         // This should be 15...
         $bitfield |= Revision::DELETED_TEXT;
         $bitfield |= Revision::DELETED_COMMENT;
         $bitfield |= Revision::DELETED_USER;
         $bitfield |= Revision::DELETED_RESTRICTED;
     } else {
         $bitfield = 'rev_deleted';
     }
     $dbw->begin();
     // For now, shunt the revision data into the archive table.
     // Text is *not* removed from the text table; bulk storage
     // is left intact to avoid breaking block-compression or
     // immutable storage schemes.
     //
     // For backwards compatibility, note that some older archive
     // table entries will have ar_text and ar_flags fields still.
     //
     // In the future, we may keep revisions and mark them with
     // the rev_deleted field, which is reserved for this purpose.
     $dbw->insertSelect('archive', array('page', 'revision'), array('ar_namespace' => 'page_namespace', 'ar_title' => 'page_title', 'ar_comment' => 'rev_comment', 'ar_user' => 'rev_user', 'ar_user_text' => 'rev_user_text', 'ar_timestamp' => 'rev_timestamp', 'ar_minor_edit' => 'rev_minor_edit', 'ar_rev_id' => 'rev_id', 'ar_text_id' => 'rev_text_id', 'ar_text' => '\'\'', 'ar_flags' => '\'\'', 'ar_len' => 'rev_len', 'ar_page_id' => 'page_id', 'ar_deleted' => $bitfield), array('page_id' => $id, 'page_id = rev_page'), __METHOD__);
     # Delete restrictions for it
     $dbw->delete('page_restrictions', array('pr_page' => $id), __METHOD__);
     # Now that it's safely backed up, delete it
     $dbw->delete('page', array('page_id' => $id), __METHOD__);
     $ok = $dbw->affectedRows() > 0;
     // getArticleId() uses slave, could be laggy
     if (!$ok) {
         $dbw->rollback();
         return false;
     }
     # Fix category table counts
     $cats = array();
     $res = $dbw->select('categorylinks', 'cl_to', array('cl_from' => $id), __METHOD__);
     foreach ($res as $row) {
         $cats[] = $row->cl_to;
     }
     $this->updateCategoryCounts(array(), $cats);
     # If using cascading deletes, we can skip some explicit deletes
     if (!$dbw->cascadingDeletes()) {
         $dbw->delete('revision', array('rev_page' => $id), __METHOD__);
         if ($wgUseTrackbacks) {
             $dbw->delete('trackbacks', array('tb_page' => $id), __METHOD__);
         }
         # Delete outgoing links
         $dbw->delete('pagelinks', array('pl_from' => $id));
         $dbw->delete('imagelinks', array('il_from' => $id));
         $dbw->delete('categorylinks', array('cl_from' => $id));
         $dbw->delete('templatelinks', array('tl_from' => $id));
         $dbw->delete('externallinks', array('el_from' => $id));
         $dbw->delete('langlinks', array('ll_from' => $id));
         $dbw->delete('iwlinks', array('iwl_from' => $id));
         $dbw->delete('redirect', array('rd_from' => $id));
     }
     # If using cleanup triggers, we can skip some manual deletes
     if (!$dbw->cleanupTriggers()) {
         # Clean up recentchanges entries...
         $dbw->delete('recentchanges', array('rc_type != ' . RC_LOG, 'rc_namespace' => $this->mTitle->getNamespace(), 'rc_title' => $this->mTitle->getDBkey()), __METHOD__);
         $dbw->delete('recentchanges', array('rc_type != ' . RC_LOG, 'rc_cur_id' => $id), __METHOD__);
     }
     # Clear caches
     Article::onArticleDelete($this->mTitle);
     # Clear the cached article id so the interface doesn't act like we exist
     $this->mTitle->resetArticleID(0);
     # Log the deletion, if the page was suppressed, log it at Oversight instead
     $logtype = $suppress ? 'suppress' : 'delete';
     $log = new LogPage($logtype);
     # Make sure logging got through
     $log->addEntry('delete', $this->mTitle, $reason, array());
     if ($commit) {
         $dbw->commit();
     }
     return true;
 }
Example #3
0
 /**
  * Back-end article deletion
  * Deletes the article with database consistency, writes logs, purges caches
  * Returns success
  */
 function doDeleteArticle($reason)
 {
     global $wgUseSquid, $wgDeferredUpdateList;
     global $wgUseTrackbacks;
     wfDebug(__METHOD__ . "\n");
     $dbw =& wfGetDB(DB_MASTER);
     $ns = $this->mTitle->getNamespace();
     $t = $this->mTitle->getDBkey();
     $id = $this->mTitle->getArticleID();
     if ($t == '' || $id == 0) {
         return false;
     }
     $u = new SiteStatsUpdate(0, 1, -(int) $this->isCountable($this->getContent()), -1);
     array_push($wgDeferredUpdateList, $u);
     // For now, shunt the revision data into the archive table.
     // Text is *not* removed from the text table; bulk storage
     // is left intact to avoid breaking block-compression or
     // immutable storage schemes.
     //
     // For backwards compatibility, note that some older archive
     // table entries will have ar_text and ar_flags fields still.
     //
     // In the future, we may keep revisions and mark them with
     // the rev_deleted field, which is reserved for this purpose.
     $dbw->insertSelect('archive', array('page', 'revision'), array('ar_namespace' => 'page_namespace', 'ar_title' => 'page_title', 'ar_comment' => 'rev_comment', 'ar_user' => 'rev_user', 'ar_user_text' => 'rev_user_text', 'ar_timestamp' => 'rev_timestamp', 'ar_minor_edit' => 'rev_minor_edit', 'ar_rev_id' => 'rev_id', 'ar_text_id' => 'rev_text_id', 'ar_text' => '\'\'', 'ar_flags' => '\'\''), array('page_id' => $id, 'page_id = rev_page'), __METHOD__);
     # Now that it's safely backed up, delete it
     $dbw->delete('page', array('page_id' => $id), __METHOD__);
     # If using cascading deletes, we can skip some explicit deletes
     if (!$dbw->cascadingDeletes()) {
         $dbw->delete('revision', array('rev_page' => $id), __METHOD__);
         if ($wgUseTrackbacks) {
             $dbw->delete('trackbacks', array('tb_page' => $id), __METHOD__);
         }
         # Delete outgoing links
         $dbw->delete('pagelinks', array('pl_from' => $id));
         $dbw->delete('imagelinks', array('il_from' => $id));
         $dbw->delete('categorylinks', array('cl_from' => $id));
         $dbw->delete('templatelinks', array('tl_from' => $id));
         $dbw->delete('externallinks', array('el_from' => $id));
         $dbw->delete('langlinks', array('ll_from' => $id));
         $dbw->delete('redirect', array('rd_from' => $id));
     }
     # If using cleanup triggers, we can skip some manual deletes
     if (!$dbw->cleanupTriggers()) {
         # Clean up recentchanges entries...
         $dbw->delete('recentchanges', array('rc_namespace' => $ns, 'rc_title' => $t), __METHOD__);
     }
     # Clear caches
     Article::onArticleDelete($this->mTitle);
     # Log the deletion
     $log = new LogPage('delete');
     $log->addEntry('delete', $this->mTitle, $reason);
     # Clear the cached article id so the interface doesn't act like we exist
     $this->mTitle->resetArticleID(0);
     $this->mTitle->mArticleID = 0;
     return true;
 }
Example #4
0
 /**
  * Back-end article deletion
  * Deletes the article with database consistency, writes logs, purges caches
  * Returns success
  */
 function doDeleteArticle($reason, $rc = true)
 {
     global $wgUseSquid, $wgDeferredUpdateList;
     global $wgPostCommitUpdateList, $wgUseTrackbacks;
     wfDebug(__METHOD__ . "\n");
     $dbw =& wfGetDB(DB_MASTER);
     $ns = $this->mTitle->getNamespace();
     $t = $this->mTitle->getDBkey();
     $id = $this->mTitle->getArticleID();
     if ($t == '' || $id == 0) {
         return false;
     }
     $u = new SiteStatsUpdate(0, 1, -(int) $this->isCountable($this->getContent()), -1);
     array_push($wgDeferredUpdateList, $u);
     // For now, shunt the revision data into the archive table.
     // Text is *not* removed from the text table; bulk storage
     // is left intact to avoid breaking block-compression or
     // immutable storage schemes.
     //
     // For backwards compatibility, note that some older archive
     // table entries will have ar_text and ar_flags fields still.
     //
     // In the future, we may keep revisions and mark them with
     // the rev_deleted field, which is reserved for this purpose.
     $dbw->insertSelect('archive', array('page', 'revision'), array('ar_namespace' => 'page_namespace', 'ar_title' => 'page_title', 'ar_comment' => 'rev_comment', 'ar_user' => 'rev_user', 'ar_user_text' => 'rev_user_text', 'ar_timestamp' => 'rev_timestamp', 'ar_minor_edit' => 'rev_minor_edit', 'ar_rev_id' => 'rev_id', 'ar_text_id' => 'rev_text_id'), array('page_id' => $id, 'page_id = rev_page'), __METHOD__);
     # Now that it's safely backed up, delete it
     $dbw->delete('revision', array('rev_page' => $id), __METHOD__);
     $dbw->delete('page', array('page_id' => $id), __METHOD__);
     if ($wgUseTrackbacks) {
         $dbw->delete('trackbacks', array('tb_page' => $id), __METHOD__);
     }
     # Clean up recentchanges entries...
     $dbw->delete('recentchanges', array('rc_namespace' => $ns, 'rc_title' => $t), __METHOD__);
     // WERELATE: remove from watchlists on delete
     if (Namespac::isMain($ns)) {
         $rows = $dbw->select(array('watchlist', 'user'), array('user_name'), array('wl_user=user_id', 'wl_namespace' => $ns, 'wl_title' => $t));
         while ($row = $dbw->fetchObject($rows)) {
             $user = User::newFromName($row->user_name, false);
             $wl = WatchedItem::fromUserTitle($user, $this->mTitle);
             $wl->removeWatch();
         }
         $dbw->freeResult($rows);
     }
     # Finally, clean up the link tables
     $t = $this->mTitle->getPrefixedDBkey();
     # Clear caches
     Article::onArticleDelete($this->mTitle);
     # Delete outgoing links
     $dbw->delete('pagelinks', array('pl_from' => $id));
     $dbw->delete('imagelinks', array('il_from' => $id));
     $dbw->delete('categorylinks', array('cl_from' => $id));
     $dbw->delete('templatelinks', array('tl_from' => $id));
     $dbw->delete('externallinks', array('el_from' => $id));
     $dbw->delete('langlinks', array('ll_from' => $id));
     # Log the deletion
     $log = new LogPage('delete', $rc);
     // WERELATE - add id as a log param
     $log->addEntry('delete', $this->mTitle, $reason, array($id));
     # Clear the cached article id so the interface doesn't act like we exist
     $this->mTitle->resetArticleID(0);
     $this->mTitle->mArticleID = 0;
     return true;
 }
Example #5
0
 /**
  * Back-end article deletion
  * Deletes the article with database consistency, writes logs, purges caches
  * Returns success
  */
 function doDeleteArticle($reason)
 {
     global $wgUser;
     global $wgUseSquid, $wgDeferredUpdateList, $wgInternalServer, $wgPostCommitUpdateList;
     global $wgUseTrackbacks;
     $fname = 'Article::doDeleteArticle';
     wfDebug($fname . "\n");
     $dbw =& wfGetDB(DB_MASTER);
     $ns = $this->mTitle->getNamespace();
     $t = $this->mTitle->getDBkey();
     $id = $this->mTitle->getArticleID();
     if ($t == '' || $id == 0) {
         return false;
     }
     $u = new SiteStatsUpdate(0, 1, -$this->isCountable($this->getContent(true)), -1);
     array_push($wgDeferredUpdateList, $u);
     $linksTo = $this->mTitle->getLinksTo();
     # Squid purging
     if ($wgUseSquid) {
         $urls = array($this->mTitle->getInternalURL(), $this->mTitle->getInternalURL('history'));
         $u = SquidUpdate::newFromTitles($linksTo, $urls);
         array_push($wgPostCommitUpdateList, $u);
     }
     # Client and file cache invalidation
     Title::touchArray($linksTo);
     // For now, shunt the revision data into the archive table.
     // Text is *not* removed from the text table; bulk storage
     // is left intact to avoid breaking block-compression or
     // immutable storage schemes.
     //
     // For backwards compatibility, note that some older archive
     // table entries will have ar_text and ar_flags fields still.
     //
     // In the future, we may keep revisions and mark them with
     // the rev_deleted field, which is reserved for this purpose.
     $dbw->insertSelect('archive', array('page', 'revision'), array('ar_namespace' => 'page_namespace', 'ar_title' => 'page_title', 'ar_comment' => 'rev_comment', 'ar_user' => 'rev_user', 'ar_user_text' => 'rev_user_text', 'ar_timestamp' => 'rev_timestamp', 'ar_minor_edit' => 'rev_minor_edit', 'ar_rev_id' => 'rev_id', 'ar_text_id' => 'rev_text_id'), array('page_id' => $id, 'page_id = rev_page'), $fname);
     # Now that it's safely backed up, delete it
     $dbw->delete('revision', array('rev_page' => $id), $fname);
     $dbw->delete('page', array('page_id' => $id), $fname);
     if ($wgUseTrackbacks) {
         $dbw->delete('trackbacks', array('tb_page' => $id), $fname);
     }
     # Clean up recentchanges entries...
     $dbw->delete('recentchanges', array('rc_namespace' => $ns, 'rc_title' => $t), $fname);
     # Finally, clean up the link tables
     $t = $this->mTitle->getPrefixedDBkey();
     Article::onArticleDelete($this->mTitle);
     # Delete outgoing links
     $dbw->delete('pagelinks', array('pl_from' => $id));
     $dbw->delete('imagelinks', array('il_from' => $id));
     $dbw->delete('categorylinks', array('cl_from' => $id));
     # Log the deletion
     $log = new LogPage('delete');
     $log->addEntry('delete', $this->mTitle, $reason);
     # Clear the cached article id so the interface doesn't act like we exist
     $this->mTitle->resetArticleID(0);
     $this->mTitle->mArticleID = 0;
     return true;
 }
	function execute( $par ) {
		global $wgRequest, $wgOut,$wgUser;
		if ( !$this->userCanExecute($wgUser) ) {
			$this->displayRestrictionError();
			return;
		}
		$dbr = wfGetDB( DB_SLAVE );
		$dbw = wfGetDB( DB_MASTER );
		$page_row=array(
			'page_id',
		        'page_namespace'
		);
		$result=$dbr->select( 'page', $page_row );
		while ($myRow=$dbr->fetchRow($result)){
			$myId=$myRow['page_id'];
			$myNamespace=$myRow['page_namespace'];
			if ($myNamespace!=NS_FILE){
				$myRevision=Revision::loadFromPageId($dbr,$myId);
				$myText=$myRevision->getRawText();
				if ($myText==""){
					while ($myPrevious=$myRevision->getPrevious()){
						if ($myPrevious->getRawText()==''){
							$myRevision=$myPrevious;
						}
						else {
							break;
						}
					}
					$blank_row=array(
						'blank_page_id'		=> $myId,
						'blank_user_id'
							=> $myRevision->getRawUser(),
						'blank_user_name'
							=> $myRevision->getRawUserText(),
						'blank_timestamp'
							=> $myRevision->getTimeStamp(),
						'blank_summary'
							=> $myRevision->getRawComment(),
						'blank_parent_id'
							=> $myRevision->getParentId(),
					);
					$checkPresence=$dbr->selectRow('blanked_page',
						'blank_page_id'
						,array("blank_page_id" => $myId));
					if (!$checkPresence){
						$dbw->insert('blanked_page',$blank_row);
					$mTitle=Title::newFromID($myId);
					Article::onArticleDelete( $mTitle );
					$mTitle->resetArticleID( 0 );
					}
				}
			}
			
		}
		$output = wfMsg( 'purewikideletion-population-done' );
		$wgOut->addWikiText($output);
	}