/** * wfSetWikiaNewtalk * * Hook, set new wikia shared message * * @author * @author Krzysztof Krzyżaniak <*****@*****.**> (changes) * @access public * * @param Article $article: edited article * * @return false: don't go to next hook */ function wfSetWikiaNewtalk(&$article) { global $wgMemc, $wgWikiaNewtalkExpiry, $wgExternalSharedDB; $name = $article->mTitle->getDBkey(); $other = User::newFromName($name); if (!$other instanceof User && User::isIP($name)) { // An anonymous user $other = new User(); $other->setName($name); } if ($other instanceof User) { $other->setNewtalk(true); $other->load(); $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB); $dbw->begin(); /** * first delete */ $dbw->delete("shared_newtalks", array('sn_wiki' => wfWikiID(), 'sn_user_id' => $other->getID(), 'sn_user_ip' => $other->getName()), __METHOD__); /** * then insert */ $dbw->insert("shared_newtalks", array('sn_wiki' => wfWikiID(), 'sn_user_id' => $other->getID(), 'sn_user_ip' => $other->getName()), __METHOD__); $dbw->commit(); $key = 'wikia:shared_newtalk:' . $other->getID() . ':' . str_replace(' ', '_', $other->getName()); $wgMemc->delete($key); } return false; }
/** * 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__); }
/** * 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); } } }
/** * Do standard deferred updates after page edit. * Update links tables, site stats, search index and message cache. * Every 100th 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, $wgEnableParserCache; wfProfileIn(__METHOD__); # Parse the text # Be careful not to double-PST: $text is usually already PST-ed once if (!$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag('vary-revision')) { wfDebug(__METHOD__ . ": No prepared edit or vary-revision is set...\n"); $editInfo = $this->prepareTextForEdit($text, $newid); } else { wfDebug(__METHOD__ . ": No vary-revision, using prepared edit...\n"); $editInfo = $this->mPreparedEdit; } # Save it to the parser cache if ($wgEnableParserCache) { $parserCache =& ParserCache::singleton(); $parserCache->save($editInfo->output, $this, $wgUser); } # Update the links tables $u = new LinksUpdate($this->mTitle, $editInfo->output); $u->doUpdate(); if (wfRunHooks('ArticleEditUpdatesDeleteFromRecentchanges', array(&$this))) { if (0 == mt_rand(0, 99)) { // Flush old entries from the `recentchanges` table; we do this on // random requests so as to avoid an increase in writes for no good reason 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); } } } //XXADDED if ($this->mTitle->getNamespace() == NS_USER_KUDOS && $shortTitle != $wgUser->getName()) { 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->setNewkudos(true); } } } if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { $wgMessageCache->replace($shortTitle, $text); } wfProfileOut(__METHOD__); }