本文整理汇总了PHP中wfDoUpdates函数的典型用法代码示例。如果您正苦于以下问题:PHP wfDoUpdates函数的具体用法?PHP wfDoUpdates怎么用?PHP wfDoUpdates使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfDoUpdates函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: migrateGroup
function migrateGroup($group)
{
$groups = parseGroupFile();
if (!isset($groups[$group])) {
return false;
}
$group = $groups[$group];
global $wgAuth;
$dbw = $wgAuth->getDB(DB_WRITE);
if (false == $dbw->insert('groups', array('grp_name' => $group['name'], 'grp_password' => $group['password'], 'grp_gid' => $group['gid']), __METHOD__)) {
return false;
}
foreach ($group['members'] as $user) {
$pwd = posix_getpwnam($user);
if (!$pwd) {
return false;
}
print "Migrating {$pwd['name']}\n";
if (false == $dbw->insert('group_membership', array('gm_group' => $group['name'], 'gm_user' => $pwd['uid']), __METHOD__)) {
$dbw->rollback();
return false;
}
}
$dbw->commit();
wfDoUpdates();
return true;
}
示例2: execute
public function execute()
{
wfProfileIn(__METHOD__);
//run the download:
Http::doSessionIdDownload($this->getOption('sid'), $this->getOption('usk'));
// close up shop:
// Execute any deferred updates
wfDoUpdates();
// Log what the user did, for book-keeping purposes.
wfLogProfilingData();
// Shut down the database before exit
wfGetLBFactory()->shutdown();
wfProfileOut(__METHOD__);
}
示例3: cleanupArticle
function cleanupArticle($id, $domain)
{
$title = Title::newFromID($id);
if (!$title) {
print "Internal error: no page for ID {$id}\n";
return;
}
print $title->getPrefixedDBkey() . " ...";
$rev = Revision::newFromTitle($title);
$reverted = false;
$revId = $rev->getId();
$currentRevId = $revId;
$regex = LinkFilter::makeRegex($domain);
while ($rev && preg_match($regex, $rev->getText())) {
# Revision::getPrevious can't be used in this way before MW 1.6 (Revision.php 1.26)
#$rev = $rev->getPrevious();
$revId = $title->getPreviousRevisionID($revId);
if ($revId) {
$rev = Revision::newFromTitle($title, $revId);
} else {
$rev = false;
}
}
if ($revId == $currentRevId) {
// The regex didn't match the current article text
// This happens e.g. when a link comes from a template rather than the page itself
print "False match\n";
} else {
$dbw =& wfGetDB(DB_MASTER);
$dbw->immediateBegin();
if (!$rev) {
// Didn't find a non-spammy revision, blank the page
print "blanking\n";
$article = new Article($title);
$article->updateArticle('', wfMsg('spam_blanking', $domain), false, false);
} else {
// Revert to this revision
print "reverting\n";
$article = new Article($title);
$article->updateArticle($rev->getText(), wfMsg('spam_reverting', $domain), false, false);
}
$dbw->immediateCommit();
wfDoUpdates();
}
}
示例4: migrateUser
function migrateUser($username, $email)
{
$pwd = posix_getpwnam($username);
if (!$pwd) {
return false;
}
// PHP sucks
list($password, $password_lastchange) = getspwd($username);
if (is_null($password) || is_null($password_lastchange)) {
return false;
}
global $wgAuth;
$dbw = $wgAuth->getDB(DB_WRITE);
if (false == $dbw->insert('passwd', array('pwd_uid' => $pwd['uid'], 'pwd_name' => $pwd['name'], 'pwd_password' => $password, 'pwd_password_lastchange' => $password_lastchange, 'pwd_gid' => $pwd['gid'], 'pwd_home' => $pwd['dir'], 'pwd_shell' => $pwd['shell'], 'pwd_active' => 'active', 'pwd_email' => $email), __METHOD__)) {
return false;
}
if (false == $dbw->insert('user_props', array('up_timestamp' => $dbw->timestamp(), 'up_user' => $username, 'up_name' => 'email', 'up_value' => $email), __METHOD__)) {
return false;
}
$dbw->commit();
wfDoUpdates();
return true;
}
示例5: cleanupArticle
/**
* Find the latest revision of the article that does not contain spam and revert to it
*/
function cleanupArticle($rev, $regex)
{
$title = $rev->getTitle();
$reverted = false;
$revId = $rev->getId();
while ($rev && preg_match($regex, $rev->getText())) {
# Revision::getPrevious can't be used in this way before MW 1.6 (Revision.php 1.26)
#$rev = $rev->getPrevious();
$revId = $title->getPreviousRevisionID($revId);
if ($revId) {
$rev = Revision::newFromTitle($title, $revId);
} else {
$rev = false;
}
}
$dbw =& wfGetDB(DB_MASTER);
$dbw->immediateBegin();
if (!$rev) {
// Didn't find a non-spammy revision, delete the page
/*
print "All revisions are spam, deleting...\n";
$article = new Article( $title );
$article->doDeleteArticle( "All revisions matched the spam blacklist" );
*/
// Too scary, blank instead
print "All revisions are spam, blanking...\n";
$article = new Article($title);
$article->updateArticle('', 'All revisions matched the spam blacklist, blanking', false, false);
} else {
// Revert to this revision
$article = new Article($title);
$article->updateArticle($rev->getText(), "Revert spam", false, false);
}
$dbw->immediateCommit();
wfDoUpdates();
}
示例6: wfHttpError
$url = $_SERVER['PHP_SELF'];
}
if (strcmp("{$wgScriptPath}/api{$wgScriptExtension}", $url)) {
wfHttpError(403, 'Forbidden', 'API must be accessed through the primary script entry point.');
return;
}
// Verify that the API has not been disabled
if (!$wgEnableAPI) {
echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
echo '<pre><b>$wgEnableAPI=true;</b></pre>';
die(1);
}
// So extensions can check whether they're running in API mode
define('MW_API', true);
// Set a dummy $wgTitle, because $wgTitle == null breaks various things
// In a perfect world this wouldn't be necessary
$wgTitle = Title::newFromText('API');
/* Construct an ApiMain with the arguments passed via the URL. What we get back
* is some form of an ApiMain, possibly even one that produces an error message,
* but we don't care here, as that is handled by the ctor.
*/
$processor = new ApiMain($wgRequest, $wgEnableWriteAPI);
// Process data & print results
$processor->execute();
// Execute any deferred updates
wfDoUpdates();
// Log what the user did, for book-keeping purposes.
wfProfileOut('api.php');
wfLogProfilingData();
// Shut down the database
wfGetLBFactory()->shutdown();
示例7: finalCleanup
/**
* Cleaning up request by doing:
** deferred updates, DB transaction, and the output
*
* @param $output OutputPage
*/
function finalCleanup(&$output)
{
wfProfileIn(__METHOD__);
// Now commit any transactions, so that unreported errors after
// output() don't roll back the whole DB transaction
$factory = wfGetLBFactory();
$factory->commitMasterChanges();
// Output everything!
$output->output();
// Do any deferred jobs
wfDoUpdates(true);
$this->doJobs();
wfProfileOut(__METHOD__);
}
示例8: doEdit
//.........这里部分代码省略.........
# Delete the invalid revision if the DB is not transactional
if (!$wgDBtransactions) {
$dbw->delete('revision', array('rev_id' => $revisionId), __METHOD__);
}
$revisionId = 0;
$dbw->rollback();
} else {
global $wgUseRCPatrol;
wfRunHooks('NewRevisionFromEditComplete', array($this, $revision, $baseRevId, $user));
# Update recentchanges
if (!($flags & EDIT_SUPPRESS_RC)) {
# Mark as patrolled if the user can do so
$patrolled = $wgUseRCPatrol && $this->mTitle->userCan('autopatrol');
# Add RC row to the DB
$rc = RecentChange::notifyEdit($now, $this->mTitle, $isminor, $user, $summary, $this->mLatest, $this->getTimestamp(), $bot, '', $oldsize, $newsize, $revisionId, $patrolled);
# Log auto-patrolled edits
if ($patrolled) {
PatrolLog::record($rc, true);
}
}
$user->incEditCount();
$dbw->commit();
}
} else {
$status->warning('edit-no-change');
$revision = null;
// Keep the same revision ID, but do some updates on it
$revisionId = $this->getRevIdFetched();
// Update page_touched, this is usually implicit in the page update
// Other cache updates are done in onArticleEdit()
$this->mTitle->invalidateCache();
}
if (!$wgDBtransactions) {
ignore_user_abort($userAbort);
}
// Now that ignore_user_abort is restored, we can respond to fatal errors
if (!$status->isOK()) {
wfProfileOut(__METHOD__);
return $status;
}
# Invalidate cache of this article and all pages using this article
# as a template. Partly deferred.
Article::onArticleEdit($this->mTitle);
# Update links tables, site stats, etc.
$this->editUpdates($text, $summary, $isminor, $now, $revisionId, $changed);
} else {
# Create new article
$status->value['new'] = true;
# Set statistics members
# We work out if it's countable after PST to avoid counter drift
# when articles are created with {{subst:}}
$this->mGoodAdjustment = (int) $this->isCountable($text);
$this->mTotalAdjustment = 1;
$dbw->begin();
# Add the page record; stake our claim on this title!
# This will return false if the article already exists
$newid = $this->insertOn($dbw);
if ($newid === false) {
$dbw->rollback();
$status->fatal('edit-already-exists');
wfProfileOut(__METHOD__);
return $status;
}
# Save the revision text...
$revision = new Revision(array('page' => $newid, 'comment' => $summary, 'minor_edit' => $isminor, 'text' => $text, 'user' => $user->getId(), 'user_text' => $user->getName()));
$revisionId = $revision->insertOn($dbw);
$this->mTitle->resetArticleID($newid);
# Update the page record with revision data
$this->updateRevisionOn($dbw, $revision, 0);
wfRunHooks('NewRevisionFromEditComplete', array($this, $revision, false, $user));
# Update recentchanges
if (!($flags & EDIT_SUPPRESS_RC)) {
global $wgUseRCPatrol, $wgUseNPPatrol;
# Mark as patrolled if the user can do so
$patrolled = ($wgUseRCPatrol || $wgUseNPPatrol) && $this->mTitle->userCan('autopatrol');
# Add RC row to the DB
$rc = RecentChange::notifyNew($now, $this->mTitle, $isminor, $user, $summary, $bot, '', strlen($text), $revisionId, $patrolled);
# Log auto-patrolled edits
if ($patrolled) {
PatrolLog::record($rc, true);
}
}
$user->incEditCount();
$dbw->commit();
# Update links, etc.
$this->editUpdates($text, $summary, $isminor, $now, $revisionId, true);
# Clear caches
Article::onArticleCreate($this->mTitle);
wfRunHooks('ArticleInsertComplete', array(&$this, &$user, $text, $summary, $flags & EDIT_MINOR, null, null, &$flags, $revision));
}
# Do updates right now unless deferral was requested
if (!($flags & EDIT_DEFER_UPDATES)) {
wfDoUpdates();
}
// Return the new revision (or null) to the caller
$status->value['revision'] = $revision;
wfRunHooks('ArticleSaveComplete', array(&$this, &$user, $text, $summary, $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $baseRevId));
wfProfileOut(__METHOD__);
return $status;
}
示例9: doEdit
//.........这里部分代码省略.........
$text = $this->preSaveTransform($text);
$newsize = strlen($text);
$dbw =& wfGetDB(DB_MASTER);
$now = wfTimestampNow();
if ($flags & EDIT_UPDATE) {
# Update article, but only if changed.
# Make sure the revision is either completely inserted or not inserted at all
if (!$wgDBtransactions) {
$userAbort = ignore_user_abort(true);
}
$lastRevision = 0;
$revisionId = 0;
if (0 != strcmp($text, $oldtext)) {
$this->mGoodAdjustment = (int) $this->isCountable($text) - (int) $this->isCountable($oldtext);
$this->mTotalAdjustment = 0;
$lastRevision = $dbw->selectField('page', 'page_latest', array('page_id' => $this->getId()));
if (!$lastRevision) {
# Article gone missing
wfDebug(__METHOD__ . ": EDIT_UPDATE specified but article doesn't exist\n");
wfProfileOut(__METHOD__);
return false;
}
$revision = new Revision(array('page' => $this->getId(), 'comment' => $summary, 'minor_edit' => $isminor, 'text' => $text));
$dbw->begin();
$revisionId = $revision->insertOn($dbw);
# Update page
$ok = $this->updateRevisionOn($dbw, $revision, $lastRevision);
if (!$ok) {
/* Belated edit conflict! Run away!! */
$good = false;
$dbw->rollback();
} else {
# Update recentchanges
if (!($flags & EDIT_SUPPRESS_RC)) {
$rcid = RecentChange::notifyEdit($now, $this->mTitle, $isminor, $wgUser, $summary, $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, $revisionId);
# Mark as patrolled if the user can do so
if ($wgUser->isAllowed('autopatrol')) {
RecentChange::markPatrolled($rcid);
}
}
$wgUser->incEditCount();
$dbw->commit();
}
} else {
// Keep the same revision ID, but do some updates on it
$revisionId = $this->getRevIdFetched();
// Update page_touched, this is usually implicit in the page update
// Other cache updates are done in onArticleEdit()
$this->mTitle->invalidateCache();
}
if (!$wgDBtransactions) {
ignore_user_abort($userAbort);
}
if ($good) {
# Invalidate cache of this article and all pages using this article
# as a template. Partly deferred.
Article::onArticleEdit($this->mTitle);
# Update links tables, site stats, etc.
$changed = strcmp($oldtext, $text) != 0;
$this->editUpdates($text, $summary, $isminor, $now, $revisionId, $changed);
}
} else {
# Create new article
# Set statistics members
# We work out if it's countable after PST to avoid counter drift
# when articles are created with {{subst:}}
$this->mGoodAdjustment = (int) $this->isCountable($text);
$this->mTotalAdjustment = 1;
$dbw->begin();
# Add the page record; stake our claim on this title!
# This will fail with a database query exception if the article already exists
$newid = $this->insertOn($dbw);
# Save the revision text...
$revision = new Revision(array('page' => $newid, 'comment' => $summary, 'minor_edit' => $isminor, 'text' => $text));
$revisionId = $revision->insertOn($dbw);
$this->mTitle->resetArticleID($newid);
# Update the page record with revision data
$this->updateRevisionOn($dbw, $revision, 0);
if (!($flags & EDIT_SUPPRESS_RC)) {
$rcid = RecentChange::notifyNew($now, $this->mTitle, $isminor, $wgUser, $summary, $bot, '', strlen($text), $revisionId);
# Mark as patrolled if the user can
if ($wgUser->isAllowed('autopatrol')) {
RecentChange::markPatrolled($rcid);
}
}
$wgUser->incEditCount();
$dbw->commit();
# Update links, etc.
$this->editUpdates($text, $summary, $isminor, $now, $revisionId, true);
# Clear caches
Article::onArticleCreate($this->mTitle);
wfRunHooks('ArticleInsertComplete', array(&$this, &$wgUser, $text, $summary, $flags & EDIT_MINOR, null, null, &$flags));
}
if ($good && !($flags & EDIT_DEFER_UPDATES)) {
wfDoUpdates();
}
wfRunHooks('ArticleSaveComplete', array(&$this, &$wgUser, $text, $summary, $flags & EDIT_MINOR, null, null, &$flags));
wfProfileOut(__METHOD__);
return $good;
}
示例10: cleanupArticle
function cleanupArticle($id, $domain, $link = "")
{
global $wgOut, $wgUser;
$username = wfMsg('spambot_username');
$fname = $username;
$title = Title::newFromID($id);
if (!$title) {
return;
}
/* switch the user here */
$OldUser = $wgUser;
$wgUser = User::newFromName($username);
/* Create the user if necessary */
if (!$wgUser->getID()) {
$wgUser->addToDatabase();
}
$rev = Revision::newFromTitle($title);
$reverted = false;
$revId = $rev->getId();
$currentRevId = $revId;
if ("" == $link) {
$regex = $this->makeRegex($domain);
} else {
/* we had a regex ready */
$regex = $domain;
$domain = $link;
}
while ($rev && preg_match($regex, $rev->getText())) {
$revId = $title->getPreviousRevisionID($revId);
if ($revId) {
$rev = Revision::newFromTitle($title, $revId);
} else {
$rev = false;
}
}
if ($revId == $currentRevId) {
/* ... */
} else {
$sk = $wgUser->getSkin();
$page_link = $sk->makeKnownLinkObj($title, $title->getText());
$dbw =& wfGetDB(DB_MASTER);
$dbw->immediateBegin();
if (!$rev) {
/* no clean revision found, blank the article */
$article = new SilentArticle($title);
$article->updateArticle('', wfMsg('spam_blanking', $domain), false, false);
$wgOut->addHTML("Article {$page_link} has been blanked.<br/>");
} else {
/* revert to last clean version */
$article = new SilentArticle($title);
$article->updateArticle($rev->getText(), wfMsg('spam_reverting', $domain), false, false);
$wgOut->addHTML("Article {$page_link} has been reverted to latest change not containing link to <b>" . $domain . "</b>.<br/>");
}
$dbw->commit();
wfDoUpdates();
}
$wgUser = $OldUser;
}
示例11: showReport
function showReport()
{
if ($this->mQuiet) {
$delta = wfTime() - $this->startTime;
if ($delta) {
$rate = sprintf("%.2f", $this->pageCount / $delta);
$revrate = sprintf("%.2f", $this->revCount / $delta);
} else {
$rate = '-';
$revrate = '-';
}
# Logs dumps don't have page tallies
if ($this->pageCount) {
$this->progress("{$this->pageCount} ({$rate} pages/sec {$revrate} revs/sec)");
} else {
$this->progress("{$this->revCount} ({$revrate} revs/sec)");
}
}
wfWaitForSlaves();
// XXX: Don't let deferred jobs array get absurdly large (bug 24375)
wfDoUpdates('commit');
}
示例12: cleanupArticle
private function cleanupArticle($id, $domain)
{
$title = Title::newFromID($id);
if (!$title) {
$this->error("Internal error: no page for ID {$id}");
return;
}
$this->output($title->getPrefixedDBkey() . " ...");
$rev = Revision::newFromTitle($title);
$revId = $rev->getId();
$currentRevId = $revId;
while ($rev && LinkFilter::matchEntry($rev->getText(), $domain)) {
# Revision::getPrevious can't be used in this way before MW 1.6 (Revision.php 1.26)
#$rev = $rev->getPrevious();
$revId = $title->getPreviousRevisionID($revId);
if ($revId) {
$rev = Revision::newFromTitle($title, $revId);
} else {
$rev = false;
}
}
if ($revId == $currentRevId) {
// The regex didn't match the current article text
// This happens e.g. when a link comes from a template rather than the page itself
$this->output("False match\n");
} else {
$dbw = wfGetDB(DB_MASTER);
$dbw->begin();
if (!$rev) {
// Didn't find a non-spammy revision, blank the page
$this->output("blanking\n");
$article = new Article($title);
$article->updateArticle('', wfMsg('spam_blanking', $domain), false, false);
} else {
// Revert to this revision
$this->output("reverting\n");
$article = new Article($title);
$article->updateArticle($rev->getText(), wfMsg('spam_reverting', $domain), false, false);
}
$dbw->commit();
wfDoUpdates();
}
}
示例13: poArticleProtectComplete
function poArticleProtectComplete(&$article, &$user, $protect, $reason)
{
// MediaWiki documentation indicates a fifth argument $moveonly (boolean whether it was
// for move only or not), but there are only four args
$title = $article->getTitle();
wfDebugLog('ProtectOwn', 'ArticleProtectComplete: purging title cache' . ' title="' . $title->getPrefixedDBkey() . '"[' . $title->getArticleId() . ']');
# purge page's restrictions
$article->getTitle()->mRestrictions = array();
$article->getTitle()->mRestrictionsLoaded = false;
//$article->getTitle()->loadRestrictions();
// Purge caches on page update etc
WikiPage::onArticleEdit($title);
// this put update in $wgDeferredUpdateList
wfDoUpdates();
// this execute all updates in $wgDeferredUpdateList
// Update page_touched, this is usually implicit in the page update
$title->invalidateCache();
// ask mediawiki to reload search engine cache
$u = new SearchUpdate($title->getArticleId(), $title->getPrefixedDBkey(), Revision::newFromTitle($title)->getText());
$u->doUpdate();
// will call wfRunHooks( 'SearchUpdate', array( $this->mId, $this->mNamespace, $this->mTitle, &$text ) );
// continue hook processing
return true;
}