/** * Hook function for RecentChange_save * Saves user data into the cu_changes table */ function efUpdateCheckUserData($rc) { global $wgUser; // Extract params extract($rc->mAttribs); // Get IP $ip = wfGetIP(); // Get XFF header $xff = wfGetForwardedFor(); list($xff_ip, $trusted) = efGetClientIPfromXFF($xff); // Our squid XFFs can flood this up sometimes $isSquidOnly = efXFFChainIsSquid($xff); // Get agent $agent = wfGetAgent(); // Store the log action text for log events // $rc_comment should just be the log_comment // BC: check if log_type and log_action exists // If not, then $rc_comment is the actiontext and comment if (isset($rc_log_type) && $rc_type == RC_LOG) { $target = Title::makeTitle($rc_namespace, $rc_title); $actionText = LogPage::actionText($rc_log_type, $rc_log_action, $target, NULL, explode('\\n', $rc_params)); } else { $actionText = ''; } $dbw = wfGetDB(DB_MASTER); $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq'); $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => $rc_namespace, 'cuc_title' => $rc_title, 'cuc_minor' => $rc_minor, 'cuc_user' => $rc_user, 'cuc_user_text' => $rc_user_text, 'cuc_actiontext' => $actionText, 'cuc_comment' => $rc_comment, 'cuc_this_oldid' => $rc_this_oldid, 'cuc_last_oldid' => $rc_last_oldid, 'cuc_type' => $rc_type, 'cuc_timestamp' => $rc_timestamp, 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => !$isSquidOnly ? $xff : '', 'cuc_xff_hex' => $xff_ip && !$isSquidOnly ? IP::toHex($xff_ip) : null, 'cuc_agent' => $agent); ## On PG, MW unsets cur_id due to schema incompatibilites. So it may not be set! if (isset($rc_cur_id)) { $rcRow['cuc_page_id'] = $rc_cur_id; } $dbw->insert('cu_changes', $rcRow, __METHOD__); # Every 100th edit, prune the checkuser changes table. wfSeedRandom(); if (0 == mt_rand(0, 99)) { # Periodically flush old entries from the recentchanges table. global $wgCUDMaxAge; $cutoff = $dbw->timestamp(time() - $wgCUDMaxAge); $recentchanges = $dbw->tableName('cu_changes'); $sql = "DELETE FROM {$recentchanges} WHERE cuc_timestamp < '{$cutoff}'"; $dbw->query($sql); } return true; }
/** * Do standard deferred updates after page edit. * Update links tables, site stats, search index and message cache. * Every 1000th edit, prune the recent changes table. * * @private * @param $text New text of the article * @param $summary Edit summary * @param $minoredit Minor edit * @param $timestamp_of_pagechange Timestamp associated with the page change * @param $newid rev_id value of the new revision * @param $changed Whether or not the content actually changed */ function editUpdates($text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true) { global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser; wfProfileIn(__METHOD__); # Parse the text $options = new ParserOptions(); $options->setTidy(true); $poutput = $wgParser->parse($text, $this->mTitle, $options, true, true, $newid); # Save it to the parser cache $parserCache =& ParserCache::singleton(); $parserCache->save($poutput, $this, $wgUser); # Update the links tables $u = new LinksUpdate($this->mTitle, $poutput); $u->doUpdate(); if (wfRunHooks('ArticleEditUpdatesDeleteFromRecentchanges', array(&$this))) { wfSeedRandom(); if (0 == mt_rand(0, 999)) { # Periodically flush old entries from the recentchanges table. global $wgRCMaxAge; $dbw =& wfGetDB(DB_MASTER); $cutoff = $dbw->timestamp(time() - $wgRCMaxAge); $recentchanges = $dbw->tableName('recentchanges'); $sql = "DELETE FROM {$recentchanges} WHERE rc_timestamp < '{$cutoff}'"; $dbw->query($sql); } } $id = $this->getID(); $title = $this->mTitle->getPrefixedDBkey(); $shortTitle = $this->mTitle->getDBkey(); if (0 == $id) { wfProfileOut(__METHOD__); return; } $u = new SiteStatsUpdate(0, 1, $this->mGoodAdjustment, $this->mTotalAdjustment); array_push($wgDeferredUpdateList, $u); $u = new SearchUpdate($id, $title, $text); array_push($wgDeferredUpdateList, $u); # If this is another user's talk page, update newtalk # Don't do this if $changed = false otherwise some idiot can null-edit a # load of user talk pages and piss people off, nor if it's a minor edit # by a properly-flagged bot. if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed && !($minoredit && $wgUser->isAllowed('nominornewtalk'))) { if (wfRunHooks('ArticleEditUpdateNewTalk', array(&$this))) { $other = User::newFromName($shortTitle); if (is_null($other) && User::isIP($shortTitle)) { // An anonymous user $other = new User(); $other->setName($shortTitle); } if ($other) { $other->setNewtalk(true); } } } if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { $wgMessageCache->replace($shortTitle, $text); } wfProfileOut(__METHOD__); }
wfProfileIn($fname . '-misc2'); $wgDeferredUpdateList = array(); $wgPostCommitUpdateList = array(); if ($wgAjaxSearch) { $wgAjaxExportList[] = 'wfSajaxSearch'; } if ($wgAjaxWatch) { $wgAjaxExportList[] = 'wfAjaxWatch'; } if ($wgAjaxUploadDestCheck) { $wgAjaxExportList[] = 'UploadForm::ajaxGetExistsWarning'; } if ($wgAjaxLicensePreview) { $wgAjaxExportList[] = 'UploadForm::ajaxGetLicensePreview'; } wfSeedRandom(); # Placeholders in case of DB error $wgTitle = null; $wgArticle = null; wfProfileOut($fname . '-misc2'); wfProfileIn($fname . '-extensions'); # Extension setup functions for extensions other than skins # Entries should be added to this variable during the inclusion # of the extension file. This allows the extension to perform # any necessary initialisation in the fully initialised environment foreach ($wgExtensionFunctions as $func) { $profName = $fname . '-extensions-' . strval($func); wfProfileIn($profName); call_user_func($func); wfProfileOut($profName); }
/** * Do standard deferred updates after page edit. * Every 1000th edit, prune the recent changes table. * @private * @param string $text */ function editUpdates($text) { global $wgDeferredUpdateList, $wgDBname, $wgMemc; global $wgMessageCache, $wgUser, $wgUseEnotif; wfSeedRandom(); if (0 == mt_rand(0, 999)) { # Periodically flush old entries from the recentchanges table. global $wgRCMaxAge; $dbw =& wfGetDB(DB_MASTER); $cutoff = $dbw->timestamp(time() - $wgRCMaxAge); $recentchanges = $dbw->tableName('recentchanges'); $sql = "DELETE FROM {$recentchanges} WHERE rc_timestamp < '{$cutoff}'"; //$dbw->query( $sql ); // HACK: disabled for now, slowness // re-enabled for commit of unrelated live changes -- TS $dbw->query($sql); } $id = $this->getID(); $title = $this->mTitle->getPrefixedDBkey(); $shortTitle = $this->mTitle->getDBkey(); if (0 != $id) { $u = new LinksUpdate($id, $title); array_push($wgDeferredUpdateList, $u); $u = new SiteStatsUpdate(0, 1, $this->mGoodAdjustment, $this->mTotalAdjustment); array_push($wgDeferredUpdateList, $u); $u = new SearchUpdate($id, $title, $text); array_push($wgDeferredUpdateList, $u); # If this is another user's page or talk page, update newtalk global $wgShowNewtalkForUserOrUserTalkPage; if (($this->mTitle->getNamespace() == NS_USER_TALK || $wgShowNewtalkForUserOrUserTalkPage && $this->mTitle->getNamespace() == NS_USER) && $shortTitle != $wgUser->getName()) { $other = User::newFromName($shortTitle); if (is_null($other) && User::isIP($shortTitle)) { // An anonymous user $other = new User(); $other->setName($shortTitle); } if ($other) { $other->addWatch($this->mTitle); $other->setNewtalk(1); $other->saveNewtalk(); } } if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { $wgMessageCache->replace($shortTitle, $text); } } }