protected function getMessageParameters() { if (isset($this->parsedParametersDeleteLog)) { return $this->parsedParametersDeleteLog; } $params = parent::getMessageParameters(); $subtype = $this->entry->getSubtype(); if (in_array($subtype, ['event', 'revision'])) { // $params[3] here is 'revision' or 'archive' for page revisions, 'oldimage' or // 'filearchive' for file versions, or a comma-separated list of log_ids for log // entries. $subtype here is 'revision' for page revisions and file // versions, or 'event' for log entries. if ($subtype === 'event' && count($params) === 6 || $subtype === 'revision' && isset($params[3]) && in_array($params[3], ['revision', 'archive', 'oldimage', 'filearchive'])) { // See RevDelList::getLogParams()/RevDelLogList::getLogParams() $paramStart = $subtype === 'revision' ? 4 : 3; $old = $this->parseBitField($params[$paramStart + 1]); $new = $this->parseBitField($params[$paramStart + 2]); list($hid, $unhid, $extra) = RevisionDeleter::getChanges($new, $old); $changes = []; // messages used: revdelete-content-hid, revdelete-summary-hid, revdelete-uname-hid foreach ($hid as $v) { $changes[] = $this->msg("{$v}-hid")->plain(); } // messages used: revdelete-content-unhid, revdelete-summary-unhid, // revdelete-uname-unhid foreach ($unhid as $v) { $changes[] = $this->msg("{$v}-unhid")->plain(); } foreach ($extra as $v) { $changes[] = $this->msg($v)->plain(); } $changeText = $this->context->getLanguage()->listToText($changes); $newParams = array_slice($params, 0, 3); $newParams[3] = $changeText; $ids = is_array($params[$paramStart]) ? $params[$paramStart] : explode(',', $params[$paramStart]); $newParams[4] = $this->context->getLanguage()->formatNum(count($ids)); $this->parsedParametersDeleteLog = $newParams; return $this->parsedParametersDeleteLog; } else { $this->parsedParametersDeleteLog = array_slice($params, 0, 3); return $this->parsedParametersDeleteLog; } } $this->parsedParametersDeleteLog = $params; return $this->parsedParametersDeleteLog; }
protected function getMessageParameters() { if ( isset( $this->parsedParametersDeleteLog ) ) { return $this->parsedParametersDeleteLog; } $params = parent::getMessageParameters(); $subtype = $this->entry->getSubtype(); if ( in_array( $subtype, array( 'event', 'revision' ) ) ) { // $params[3] here is 'revision' for page revisions, 'oldimage' for file versions, or a comma-separated list of log_ids for log entries. // $subtype here is 'revision' for page revisions and file versions, or 'event' for log entries. if ( ( $subtype === 'event' && count( $params ) === 6 ) || ( $subtype === 'revision' && isset( $params[3] ) && ( $params[3] === 'revision' || $params[3] === 'oldimage' ) ) ) { $paramStart = $subtype === 'revision' ? 4 : 3; $old = $this->parseBitField( $params[$paramStart + 1] ); $new = $this->parseBitField( $params[$paramStart + 2] ); list( $hid, $unhid, $extra ) = RevisionDeleter::getChanges( $new, $old ); $changes = array(); foreach ( $hid as $v ) { $changes[] = $this->msg( "$v-hid" )->plain(); } foreach ( $unhid as $v ) { $changes[] = $this->msg( "$v-unhid" )->plain(); } foreach ( $extra as $v ) { $changes[] = $this->msg( $v )->plain(); } $changeText = $this->context->getLanguage()->listToText( $changes ); $newParams = array_slice( $params, 0, 3 ); $newParams[3] = $changeText; $count = count( explode( ',', $params[$paramStart] ) ); $newParams[4] = $this->context->getLanguage()->formatNum( $count ); return $this->parsedParametersDeleteLog = $newParams; } else { return $this->parsedParametersDeleteLog = array_slice( $params, 0, 3 ); } } return $this->parsedParametersDeleteLog = $params; }
protected function doDBUpdates() { $db = $this->getDB(DB_MASTER); if (!$db->tableExists('log_search')) { $this->error("log_search does not exist"); return false; } $start = $db->selectField('logging', 'MIN(log_id)', false, __FUNCTION__); if (!$start) { $this->output("Nothing to do.\n"); return true; } $end = $db->selectField('logging', 'MAX(log_id)', false, __FUNCTION__); # Do remaining chunk $end += $this->mBatchSize - 1; $blockStart = $start; $blockEnd = $start + $this->mBatchSize - 1; $delTypes = array('delete', 'suppress'); // revisiondelete types while ($blockEnd <= $end) { $this->output("...doing log_id from {$blockStart} to {$blockEnd}\n"); $cond = "log_id BETWEEN {$blockStart} AND {$blockEnd}"; $res = $db->select('logging', '*', $cond, __FUNCTION__); foreach ($res as $row) { // RevisionDelete logs - revisions if (LogEventsList::typeAction($row, $delTypes, 'revision')) { $params = LogPage::extractParams($row->log_params); // Param format: <urlparam> <item CSV> [<ofield> <nfield>] if (count($params) < 2) { continue; // bad row? } $field = RevisionDeleter::getRelationType($params[0]); // B/C, the params may start with a title key (<title> <urlparam> <CSV>) if ($field == null) { array_shift($params); // remove title param $field = RevisionDeleter::getRelationType($params[0]); if ($field == null) { $this->output("Invalid param type for {$row->log_id}\n"); continue; // skip this row } else { // Clean up the row... $db->update('logging', array('log_params' => implode(',', $params)), array('log_id' => $row->log_id)); } } $items = explode(',', $params[1]); $log = new LogPage($row->log_type); // Add item relations... $log->addRelations($field, $items, $row->log_id); // Determine what table to query... $prefix = substr($field, 0, strpos($field, '_')); // db prefix if (!isset(self::$tableMap[$prefix])) { continue; // bad row? } $table = self::$tableMap[$prefix]; $userField = $prefix . '_user'; $userTextField = $prefix . '_user_text'; // Add item author relations... $userIds = $userIPs = array(); $sres = $db->select($table, array($userField, $userTextField), array($field => $items)); foreach ($sres as $srow) { if ($srow->{$userField} > 0) { $userIds[] = intval($srow->{$userField}); } elseif ($srow->{$userTextField} != '') { $userIPs[] = $srow->{$userTextField}; } } // Add item author relations... $log->addRelations('target_author_id', $userIds, $row->log_id); $log->addRelations('target_author_ip', $userIPs, $row->log_id); } elseif (LogEventsList::typeAction($row, $delTypes, 'event')) { // RevisionDelete logs - log events $params = LogPage::extractParams($row->log_params); // Param format: <item CSV> [<ofield> <nfield>] if (count($params) < 1) { continue; // bad row } $items = explode(',', $params[0]); $log = new LogPage($row->log_type); // Add item relations... $log->addRelations('log_id', $items, $row->log_id); // Add item author relations... $userIds = $userIPs = array(); $sres = $db->select('logging', array('log_user', 'log_user_text'), array('log_id' => $items)); foreach ($sres as $srow) { if ($srow->log_user > 0) { $userIds[] = intval($srow->log_user); } elseif (IP::isIPAddress($srow->log_user_text)) { $userIPs[] = $srow->log_user_text; } } $log->addRelations('target_author_id', $userIds, $row->log_id); $log->addRelations('target_author_ip', $userIPs, $row->log_id); } } $blockStart += $this->mBatchSize; $blockEnd += $this->mBatchSize; wfWaitForSlaves(); } $this->output("Done populating log_search table.\n"); return true; }
/** * @return string HTML */ protected function buildCheckBoxes() { $html = '<table>'; // If there is just one item, use checkboxes $list = $this->getList(); if ($list->length() == 1) { $list->reset(); $bitfield = $list->current()->getBits(); // existing field if ($this->submitClicked) { $bitfield = RevisionDeleter::extractBitfield($this->extractBitParams(), $bitfield); } foreach ($this->checks as $item) { // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name, // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted list($message, $name, $field) = $item; $innerHTML = Xml::checkLabel($this->msg($message)->text(), $name, $name, $bitfield & $field); if ($field == Revision::DELETED_RESTRICTED) { $innerHTML = "<b>{$innerHTML}</b>"; } $line = Xml::tags('td', array('class' => 'mw-input'), $innerHTML); $html .= "<tr>{$line}</tr>\n"; } } else { // Otherwise, use tri-state radios $html .= '<tr>'; $html .= '<th class="mw-revdel-checkbox">' . $this->msg('revdelete-radio-same')->escaped() . '</th>'; $html .= '<th class="mw-revdel-checkbox">' . $this->msg('revdelete-radio-unset')->escaped() . '</th>'; $html .= '<th class="mw-revdel-checkbox">' . $this->msg('revdelete-radio-set')->escaped() . '</th>'; $html .= "<th></th></tr>\n"; foreach ($this->checks as $item) { // Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name, // revdelete-hide-comment, revdelete-hide-user, revdelete-hide-restricted list($message, $name, $field) = $item; // If there are several items, use third state by default... if ($this->submitClicked) { $selected = $this->getRequest()->getInt($name, 0); } else { $selected = -1; // use existing field } $line = '<td class="mw-revdel-checkbox">' . Xml::radio($name, -1, $selected == -1) . '</td>'; $line .= '<td class="mw-revdel-checkbox">' . Xml::radio($name, 0, $selected == 0) . '</td>'; $line .= '<td class="mw-revdel-checkbox">' . Xml::radio($name, 1, $selected == 1) . '</td>'; $label = $this->msg($message)->escaped(); if ($field == Revision::DELETED_RESTRICTED) { $label = "<b>{$label}</b>"; } $line .= "<td>{$label}</td>"; $html .= "<tr>{$line}</tr>\n"; } } $html .= '</table>'; return $html; }
/** * Generate text for a log entry * * @param $type String: log type * @param $action String: log action * @param $title Mixed: Title object or null * @param $skin Mixed: Skin object or null. If null, we want to use the wiki * content language, since that will go to the IRC feed. * @param $params Array: parameters * @param $filterWikilinks Boolean: whether to filter wiki links * @return HTML string */ public static function actionText($type, $action, $title = null, $skin = null, $params = array(), $filterWikilinks = false) { global $wgLang, $wgContLang, $wgLogActions; if (is_null($skin)) { $langObj = $wgContLang; $langObjOrNull = null; } else { $langObj = $wgLang; $langObjOrNull = $wgLang; } $key = "{$type}/{$action}"; # Defer patrol log to PatrolLog class if ($key == 'patrol/patrol') { return PatrolLog::makeActionText($title, $params, $langObjOrNull); } if (isset($wgLogActions[$key])) { if (is_null($title)) { $rv = wfMsgExt($wgLogActions[$key], array('parsemag', 'escape', 'language' => $langObj)); } else { $titleLink = self::getTitleLink($type, $langObjOrNull, $title, $params); if (preg_match('/^rights\\/(rights|autopromote)/', $key)) { $rightsnone = wfMsgExt('rightsnone', array('parsemag', 'language' => $langObj)); if ($skin) { foreach ($params as &$param) { $groupArray = array_map('trim', explode(',', $param)); $groupArray = array_map(array('User', 'getGroupMember'), $groupArray); $param = $wgLang->listToText($groupArray); } } if (!isset($params[0]) || trim($params[0]) == '') { $params[0] = $rightsnone; } if (!isset($params[1]) || trim($params[1]) == '') { $params[1] = $rightsnone; } } if (count($params) == 0) { $rv = wfMsgExt($wgLogActions[$key], array('parsemag', 'escape', 'replaceafter', 'language' => $langObj), $titleLink); } else { $details = ''; array_unshift($params, $titleLink); // User suppression if (preg_match('/^(block|suppress)\\/(block|reblock)$/', $key)) { if ($skin) { $params[1] = '<span class="blockExpiry" dir="ltr" title="' . htmlspecialchars($params[1]) . '">' . $wgLang->translateBlockExpiry($params[1]) . '</span>'; } else { $params[1] = $wgContLang->translateBlockExpiry($params[1]); } $params[2] = isset($params[2]) ? self::formatBlockFlags($params[2], $langObj) : ''; // Page protections } elseif ($type == 'protect' && count($params) == 3) { // Restrictions and expiries if ($skin) { $details .= $wgLang->getDirMark() . htmlspecialchars(" {$params[1]}"); } else { $details .= " {$params[1]}"; } // Cascading flag... if ($params[2]) { $details .= ' [' . wfMsgExt('protect-summary-cascade', array('parsemag', 'language' => $langObj)) . ']'; } // Page moves } elseif ($type == 'move' && count($params) == 3) { if ($params[2]) { $details .= ' [' . wfMsgExt('move-redirect-suppressed', array('parsemag', 'language' => $langObj)) . ']'; } // Revision deletion } elseif (preg_match('/^(delete|suppress)\\/revision$/', $key) && count($params) == 5) { $count = substr_count($params[2], ',') + 1; // revisions $ofield = intval(substr($params[3], 7)); // <ofield=x> $nfield = intval(substr($params[4], 7)); // <nfield=x> $details .= ': ' . RevisionDeleter::getLogMessage($count, $nfield, $ofield, $langObj, false); // Log deletion } elseif (preg_match('/^(delete|suppress)\\/event$/', $key) && count($params) == 4) { $count = substr_count($params[1], ',') + 1; // log items $ofield = intval(substr($params[2], 7)); // <ofield=x> $nfield = intval(substr($params[3], 7)); // <nfield=x> $details .= ': ' . RevisionDeleter::getLogMessage($count, $nfield, $ofield, $langObj, true); } $rv = wfMsgExt($wgLogActions[$key], array('parsemag', 'escape', 'replaceafter', 'language' => $langObj), $params) . $details; } } } else { global $wgLogActionsHandlers; if (isset($wgLogActionsHandlers[$key])) { $args = func_get_args(); $rv = call_user_func_array($wgLogActionsHandlers[$key], $args); } else { wfDebug("LogPage::actionText - unknown action {$key}\n"); $rv = "{$action}"; } } // For the perplexed, this feature was added in r7855 by Erik. // The feature was added because we liked adding [[$1]] in our log entries // but the log entries are parsed as Wikitext on RecentChanges but as HTML // on Special:Log. The hack is essentially that [[$1]] represented a link // to the title in question. The first parameter to the HTML version (Special:Log) // is that link in HTML form, and so this just gets rid of the ugly [[]]. // However, this is a horrible hack and it doesn't work like you expect if, say, // you want to link to something OTHER than the title of the log entry. // The real problem, which Erik was trying to fix (and it sort-of works now) is // that the same messages are being treated as both wikitext *and* HTML. if ($filterWikilinks) { $rv = str_replace('[[', '', $rv); $rv = str_replace(']]', '', $rv); } return $rv; }
private function save($bitfield, $reason, $title) { $dbw = wfGetDB(DB_MASTER); // Don't allow simply locking the interface for no reason if ($bitfield == Revision::DELETED_RESTRICTED) { $bitfield = 0; } $deleter = new RevisionDeleter($dbw); // By this point, only one of the below should be set if (isset($this->revisions)) { return $deleter->setRevVisibility($title, $this->revisions, $bitfield, $reason); } else { if (isset($this->archrevs)) { return $deleter->setArchiveVisibility($title, $this->archrevs, $bitfield, $reason); } else { if (isset($this->ofiles)) { return $deleter->setOldImgVisibility($title, $this->ofiles, $bitfield, $reason); } else { if (isset($this->afiles)) { return $deleter->setArchFileVisibility($title, $this->afiles, $bitfield, $reason); } else { if (isset($this->events)) { return $deleter->setEventVisibility($title, $this->events, $bitfield, $reason); } } } } } }
/** * Record a log entry on the action * @param $params array Associative array of parameters: * newBits: The new value of the *_deleted bitfield * oldBits: The old value of the *_deleted bitfield. * title: The target title * ids: The ID list * comment: The log comment * authorsIds: The array of the user IDs of the offenders * authorsIPs: The array of the IP/anon user offenders */ protected function updateLog($params) { // Get the URL param's corresponding DB field $field = RevisionDeleter::getRelationType($this->getType()); if (!$field) { throw new MWException("Bad log URL param type!"); } // Put things hidden from sysops in the oversight log if (($params['newBits'] | $params['oldBits']) & $this->getSuppressBit()) { $logType = 'suppress'; } else { $logType = 'delete'; } // Add params for effected page and ids $logParams = $this->getLogParams($params); // Actually add the deletion log entry $log = new LogPage($logType); $logid = $log->addEntry($this->getLogAction(), $params['title'], $params['comment'], $logParams); // Allow for easy searching of deletion log items for revision/log items $log->addRelations($field, $params['ids'], $logid); $log->addRelations('target_author_id', $params['authorIds'], $logid); $log->addRelations('target_author_ip', $params['authorIPs'], $logid); }
public function execute($par) { $this->checkPermissions(); $this->checkReadOnly(); $output = $this->getOutput(); $user = $this->getUser(); $request = $this->getRequest(); // Check blocks if ($user->isBlocked()) { throw new UserBlockedError($user->getBlock()); } $this->setHeaders(); $this->outputHeader(); $this->getOutput()->addModules(['mediawiki.special.edittags', 'mediawiki.special.edittags.styles']); $this->submitClicked = $request->wasPosted() && $request->getBool('wpSubmit'); // Handle our many different possible input types $ids = $request->getVal('ids'); if (!is_null($ids)) { // Allow CSV from the form hidden field, or a single ID for show/hide links $this->ids = explode(',', $ids); } else { // Array input $this->ids = array_keys($request->getArray('ids', [])); } $this->ids = array_unique(array_filter($this->ids)); // No targets? if (count($this->ids) == 0) { throw new ErrorPageError('tags-edit-nooldid-title', 'tags-edit-nooldid-text'); } $this->typeName = $request->getVal('type'); $this->targetObj = Title::newFromText($request->getText('target')); // sanity check of parameter switch ($this->typeName) { case 'logentry': case 'logging': $this->typeName = 'logentry'; break; default: $this->typeName = 'revision'; break; } // Allow the list type to adjust the passed target // Yuck! Copied straight out of SpecialRevisiondelete, but it does exactly // what we want $this->targetObj = RevisionDeleter::suggestTarget($this->typeName === 'revision' ? 'revision' : 'logging', $this->targetObj, $this->ids); $this->isAllowed = $user->isAllowed('changetags'); $this->reason = $request->getVal('wpReason'); // We need a target page! if (is_null($this->targetObj)) { $output->addWikiMsg('undelete-header'); return; } // Give a link to the logs/hist for this page $this->showConvenienceLinks(); // Either submit or create our form if ($this->isAllowed && $this->submitClicked) { $this->submit(); } else { $this->showForm(); } // Show relevant lines from the tag log $tagLogPage = new LogPage('tag'); $output->addHTML("<h2>" . $tagLogPage->getName()->escaped() . "</h2>\n"); LogEventsList::showLogExtract($output, 'tag', $this->targetObj, '', ['lim' => 25, 'conds' => [], 'useMaster' => $this->wasSaved]); }
/** * @TODO: split up! * * @param $row * @param Title $title * @param Array $paramArray * @param $comment * @return String */ private function logActionLinks($row, $title, $paramArray, &$comment) { global $wgUser; if ($this->flags & self::NO_ACTION_LINK || self::isDeleted($row, LogPage::DELETED_ACTION)) { return ''; } $revert = ''; if (self::typeAction($row, 'move', 'move', 'move') && !empty($paramArray[0])) { $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . Linker::link(SpecialPage::getTitleFor('Movepage'), $this->message['revertmove'], array(), array('wpOldTitle' => $destTitle->getPrefixedDBkey(), 'wpNewTitle' => $title->getPrefixedDBkey(), 'wpReason' => wfMsgForContent('revertmove'), 'wpMovetalk' => 0), array('known', 'noclasses')) . ')'; } // Show undelete link } elseif (self::typeAction($row, array('delete', 'suppress'), 'delete', 'deletedhistory')) { if (!$wgUser->isAllowed('undelete')) { $viewdeleted = $this->message['undeleteviewlink']; } else { $viewdeleted = $this->message['undeletelink']; } $revert = '(' . Linker::link(SpecialPage::getTitleFor('Undelete'), $viewdeleted, array(), array('target' => $title->getPrefixedDBkey()), array('known', 'noclasses')) . ')'; // Show unblock/change block link } elseif (self::typeAction($row, array('block', 'suppress'), array('block', 'reblock'), 'block')) { $revert = '(' . Linker::link(SpecialPage::getTitleFor('Unblock', $row->log_title), $this->message['unblocklink'], array(), array(), 'known') . $this->message['pipe-separator'] . Linker::link(SpecialPage::getTitleFor('Block', $row->log_title), $this->message['change-blocklink'], array(), array(), 'known') . ')'; // Show change protection link } elseif (self::typeAction($row, 'protect', array('modify', 'protect', 'unprotect'))) { $revert .= ' (' . Linker::link($title, $this->message['hist'], array(), array('action' => 'history', 'offset' => $row->log_timestamp)); if ($wgUser->isAllowed('protect')) { $revert .= $this->message['pipe-separator'] . Linker::link($title, $this->message['protect_change'], array(), array('action' => 'protect'), 'known'); } $revert .= ')'; // Show unmerge link } elseif (self::typeAction($row, 'merge', 'merge', 'mergehistory')) { $revert = '(' . Linker::link(SpecialPage::getTitleFor('MergeHistory'), $this->message['revertmerge'], array(), array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(), 'mergepoint' => $paramArray[1]), array('known', 'noclasses')) . ')'; // If an edit was hidden from a page give a review link to the history } elseif (self::typeAction($row, array('delete', 'suppress'), 'revision', 'deletedhistory')) { $revert = RevisionDeleter::getLogLinks($title, $paramArray, $this->skin, $this->message); // Hidden log items, give review link } elseif (self::typeAction($row, array('delete', 'suppress'), 'event', 'deletedhistory')) { if (count($paramArray) >= 1) { $revdel = SpecialPage::getTitleFor('Revisiondelete'); // $paramArray[1] is a CSV of the IDs $query = $paramArray[0]; // Link to each hidden object ID, $paramArray[1] is the url param $revert = '(' . Linker::link($revdel, $this->message['revdel-restore'], array(), array('target' => $title->getPrefixedText(), 'type' => 'logging', 'ids' => $query), array('known', 'noclasses')) . ')'; } // Self-created users } elseif (self::typeAction($row, 'newusers', 'create2')) { if (isset($paramArray[0])) { $revert = Linker::userToolLinks($paramArray[0], $title->getDBkey(), true); } else { # Fall back to a blue contributions link $revert = Linker::userToolLinks(1, $title->getDBkey()); } if (wfTimestamp(TS_MW, $row->log_timestamp) < '20080129000000') { # Suppress $comment from old entries (before 2008-01-29), # not needed and can contain incorrect links $comment = ''; } // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters. } else { wfRunHooks('LogLine', array($row->log_type, $row->log_action, $title, $paramArray, &$comment, &$revert, $row->log_timestamp)); } if ($revert != '') { $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>'; } return $revert; }
/** * Get the condition used for fetching log snippets * @return array */ protected function getLogQueryCond() { $conds = array(); // Revision delete logs for these item $conds['log_type'] = array('delete', 'suppress'); $conds['log_action'] = $this->getList()->getLogAction(); $conds['ls_field'] = RevisionDeleter::getRelationType($this->typeName); $conds['ls_value'] = $this->ids; return $conds; }
public function getAllowedParams() { return array('type' => array(ApiBase::PARAM_TYPE => RevisionDeleter::getTypes(), ApiBase::PARAM_REQUIRED => true), 'target' => null, 'ids' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_REQUIRED => true), 'hide' => array(ApiBase::PARAM_TYPE => array('content', 'comment', 'user'), ApiBase::PARAM_ISMULTI => true), 'show' => array(ApiBase::PARAM_TYPE => array('content', 'comment', 'user'), ApiBase::PARAM_ISMULTI => true), 'suppress' => array(ApiBase::PARAM_TYPE => array('yes', 'no', 'nochange'), ApiBase::PARAM_DFLT => 'nochange'), 'reason' => null); }
function save($bitfield, $reason) { $dbw = wfGetDB(DB_MASTER); $deleter = new RevisionDeleter($dbw); $ok = $deleter->setVisibility($this->revisions, $bitfield, $reason); }
/** * Record a log entry on the action * @param array $params Associative array of parameters: * newBits: The new value of the *_deleted bitfield * oldBits: The old value of the *_deleted bitfield. * title: The target title * ids: The ID list * comment: The log comment * authorsIds: The array of the user IDs of the offenders * authorsIPs: The array of the IP/anon user offenders * @throws MWException */ protected function updateLog($params) { // Get the URL param's corresponding DB field $field = RevisionDeleter::getRelationType($this->getType()); if (!$field) { throw new MWException("Bad log URL param type!"); } // Put things hidden from sysops in the suppression log if (($params['newBits'] | $params['oldBits']) & $this->getSuppressBit()) { $logType = 'suppress'; } else { $logType = 'delete'; } // Add params for affected page and ids $logParams = $this->getLogParams($params); // Actually add the deletion log entry $logEntry = new ManualLogEntry($logType, $this->getLogAction()); $logEntry->setTarget($params['title']); $logEntry->setComment($params['comment']); $logEntry->setParameters($logParams); $logEntry->setPerformer($this->getUser()); // Allow for easy searching of deletion log items for revision/log items $logEntry->setRelations(array($field => $params['ids'], 'target_author_id' => $params['authorIds'], 'target_author_ip' => $params['authorIPs'])); $logId = $logEntry->insert(); $logEntry->publish($logId); }
/** * Put together a rev_deleted bitfield * @deprecated since 1.22, use RevisionDeleter::extractBitfield instead * @param array $bitPars extractBitParams() params * @param int $oldfield current bitfield * @return array */ public static function extractBitfield( $bitPars, $oldfield ) { return RevisionDeleter::extractBitfield( $bitPars, $oldfield ); }
protected function getMessageParameters() { if (isset($this->parsedParametersDeleteLog)) { return $this->parsedParametersDeleteLog; } $params = parent::getMessageParameters(); $subtype = $this->entry->getSubtype(); if (in_array($subtype, array('event', 'revision'))) { if ($subtype === 'event' && count($params) === 6 || $subtype === 'revision' && isset($params[3]) && $params[3] === 'revision') { $paramStart = $subtype === 'revision' ? 4 : 3; $old = $this->parseBitField($params[$paramStart + 1]); $new = $this->parseBitField($params[$paramStart + 2]); list($hid, $unhid, $extra) = RevisionDeleter::getChanges($new, $old); $changes = array(); foreach ($hid as $v) { $changes[] = $this->msg("{$v}-hid")->plain(); } foreach ($unhid as $v) { $changes[] = $this->msg("{$v}-unhid")->plain(); } foreach ($extra as $v) { $changes[] = $this->msg($v)->plain(); } $changeText = $this->context->getLanguage()->listToText($changes); $newParams = array_slice($params, 0, 3); $newParams[3] = $changeText; $count = count(explode(',', $params[$paramStart])); $newParams[4] = $this->context->getLanguage()->formatNum($count); return $this->parsedParametersDeleteLog = $newParams; } else { return $this->parsedParametersDeleteLog = array_slice($params, 0, 3); } } return $this->parsedParametersDeleteLog = $params; }
/** * Record a log entry on the action * @param string $logType One of (delete,suppress) * @param array $params Associative array of parameters: * newBits: The new value of the *_deleted bitfield * oldBits: The old value of the *_deleted bitfield. * title: The target title * ids: The ID list * comment: The log comment * authorsIds: The array of the user IDs of the offenders * authorsIPs: The array of the IP/anon user offenders * @throws MWException */ private function updateLog($logType, $params) { // Get the URL param's corresponding DB field $field = RevisionDeleter::getRelationType($this->getType()); if (!$field) { throw new MWException("Bad log URL param type!"); } // Add params for affected page and ids $logParams = $this->getLogParams($params); // Actually add the deletion log entry $logEntry = new ManualLogEntry($logType, $this->getLogAction()); $logEntry->setTarget($params['title']); $logEntry->setComment($params['comment']); $logEntry->setParameters($logParams); $logEntry->setPerformer($this->getUser()); // Allow for easy searching of deletion log items for revision/log items $logEntry->setRelations([$field => $params['ids'], 'target_author_id' => $params['authorIds'], 'target_author_ip' => $params['authorIPs']]); $logId = $logEntry->insert(); $logEntry->publish($logId); }