本文整理汇总了PHP中DeferredUpdates类的典型用法代码示例。如果您正苦于以下问题:PHP DeferredUpdates类的具体用法?PHP DeferredUpdates怎么用?PHP DeferredUpdates使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DeferredUpdates类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: autoreview_current
protected function autoreview_current(User $user)
{
$this->output("Auto-reviewing all current page versions...\n");
if (!$user->getID()) {
$this->output("Invalid user specified.\n");
return;
} elseif (!$user->isAllowed('review')) {
$this->output("User specified (id: {$user->getID()}) does not have \"review\" rights.\n");
return;
}
$db = wfGetDB(DB_MASTER);
$this->output("Reviewer username: " . $user->getName() . "\n");
$start = $db->selectField('page', 'MIN(page_id)', false, __METHOD__);
$end = $db->selectField('page', 'MAX(page_id)', false, __METHOD__);
if (is_null($start) || is_null($end)) {
$this->output("...page table seems to be empty.\n");
return;
}
# Do remaining chunk
$end += $this->mBatchSize - 1;
$blockStart = $start;
$blockEnd = $start + $this->mBatchSize - 1;
$count = 0;
$changed = 0;
$flags = FlaggedRevs::quickTags(FR_CHECKED);
// Assume basic level
while ($blockEnd <= $end) {
$this->output("...doing page_id from {$blockStart} to {$blockEnd}\n");
$res = $db->select(array('page', 'revision'), '*', array("page_id BETWEEN {$blockStart} AND {$blockEnd}", 'page_namespace' => FlaggedRevs::getReviewNamespaces(), 'rev_id = page_latest'), __METHOD__);
# Go through and autoreview the current version of every page...
foreach ($res as $row) {
$title = Title::newFromRow($row);
$rev = Revision::newFromRow($row);
# Is it already reviewed?
$frev = FlaggedRevision::newFromTitle($title, $row->page_latest, FR_MASTER);
# Rev should exist, but to be safe...
if (!$frev && $rev) {
$article = new Article($title);
$db->begin();
FlaggedRevs::autoReviewEdit($article, $user, $rev, $flags, true);
FlaggedRevs::HTMLCacheUpdates($article->getTitle());
$db->commit();
$changed++;
}
$count++;
}
$db->freeResult($res);
$blockStart += $this->mBatchSize - 1;
$blockEnd += $this->mBatchSize - 1;
// XXX: Don't let deferred jobs array get absurdly large (bug 24375)
DeferredUpdates::doUpdates('commit');
wfWaitForSlaves(5);
}
$this->output("Auto-reviewing of all pages complete ..." . "{$count} rows [{$changed} changed]\n");
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:55,代码来源:reviewAllPages.php
示例2: enableCXBetaFeature
public function enableCXBetaFeature()
{
$user = $this->getUser();
$out = $this->getOutput();
$user->setOption('cx', '1');
// Promise to persist the setting post-send
DeferredUpdates::addCallableUpdate(function () use($user) {
$user->saveSettings();
});
$out->addModules('ext.cx.beta.notification');
}
开发者ID:Rjaylyn,项目名称:mediawiki-extensions-ContentTranslation,代码行数:11,代码来源:SpecialContentTranslation.php
示例3: execute
public function execute()
{
$user = $this->getUser();
if ($this->getRequest()->wasPosted()) {
$user->setNewtalk(false);
} else {
DeferredUpdates::addCallableUpdate(function () use($user) {
$user->setNewtalk(false);
});
}
$this->getResult()->addValue(null, $this->getModuleName(), 'success');
}
开发者ID:paladox,项目名称:mediawiki,代码行数:12,代码来源:ApiClearHasMsg.php
示例4: execute
public function execute($par)
{
$this->useTransactionalTimeLimit();
$this->checkReadOnly();
$this->setHeaders();
$this->outputHeader();
$request = $this->getRequest();
$target = !is_null($par) ? $par : $request->getVal('target');
// Yes, the use of getVal() and getText() is wanted, see bug 20365
$oldTitleText = $request->getVal('wpOldTitle', $target);
$this->oldTitle = Title::newFromText($oldTitleText);
if (!$this->oldTitle) {
// Either oldTitle wasn't passed, or newFromText returned null
throw new ErrorPageError('notargettitle', 'notargettext');
}
if (!$this->oldTitle->exists()) {
throw new ErrorPageError('nopagetitle', 'nopagetext');
}
$newTitleTextMain = $request->getText('wpNewTitleMain');
$newTitleTextNs = $request->getInt('wpNewTitleNs', $this->oldTitle->getNamespace());
// Backwards compatibility for forms submitting here from other sources
// which is more common than it should be..
$newTitleText_bc = $request->getText('wpNewTitle');
$this->newTitle = strlen($newTitleText_bc) > 0 ? Title::newFromText($newTitleText_bc) : Title::makeTitleSafe($newTitleTextNs, $newTitleTextMain);
$user = $this->getUser();
# Check rights
$permErrors = $this->oldTitle->getUserPermissionsErrors('move', $user);
if (count($permErrors)) {
// Auto-block user's IP if the account was "hard" blocked
DeferredUpdates::addCallableUpdate(function () use($user) {
$user->spreadAnyEditBlock();
});
throw new PermissionsError('move', $permErrors);
}
$def = !$request->wasPosted();
$this->reason = $request->getText('wpReason');
$this->moveTalk = $request->getBool('wpMovetalk', $def);
$this->fixRedirects = $request->getBool('wpFixRedirects', $def);
$this->leaveRedirect = $request->getBool('wpLeaveRedirect', $def);
$this->moveSubpages = $request->getBool('wpMovesubpages', false);
$this->deleteAndMove = $request->getBool('wpDeleteAndMove') && $request->getBool('wpConfirm');
$this->moveOverShared = $request->getBool('wpMoveOverSharedFile', false);
$this->watch = $request->getCheck('wpWatch') && $user->isLoggedIn();
if ('submit' == $request->getVal('action') && $request->wasPosted() && $user->matchEditToken($request->getVal('wpEditToken'))) {
$this->doSubmit();
} else {
$this->showForm(array());
}
}
开发者ID:foxlog,项目名称:wiki,代码行数:49,代码来源:SpecialMovepage.php
示例5: doUpdate
public function doUpdate()
{
global $wgSiteStatsAsyncFactor;
$this->doUpdateContextStats();
$rate = $wgSiteStatsAsyncFactor;
// convenience
// If set to do so, only do actual DB updates 1 every $rate times.
// The other times, just update "pending delta" values in memcached.
if ($rate && ($rate < 0 || mt_rand(0, $rate - 1) != 0)) {
$this->doUpdatePendingDeltas();
} else {
// Need a separate transaction because this a global lock
DeferredUpdates::addCallableUpdate([$this, 'tryDBUpdateInternal']);
}
}
开发者ID:paladox,项目名称:mediawiki,代码行数:15,代码来源:SiteStatsUpdate.php
示例6: testDoUpdates
public function testDoUpdates()
{
$updates = array('1' => 'deferred update 1', '2' => 'deferred update 2', '3' => 'deferred update 3', '2-1' => 'deferred update 1 within deferred update 2');
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates['1'];
});
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates['2'];
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates['2-1'];
});
});
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates[3];
});
$this->expectOutputString(implode('', $updates));
DeferredUpdates::doUpdates();
}
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:18,代码来源:DeferredUpdatesTest.php
示例7: testDoUpdatesCLI
public function testDoUpdatesCLI()
{
$this->setMwGlobals('wgCommandLineMode', true);
$updates = array('1' => 'deferred update 1', '2' => 'deferred update 2', '2-1' => 'deferred update 1 within deferred update 2', '3' => 'deferred update 3');
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates['1'];
});
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates['2'];
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates['2-1'];
});
});
DeferredUpdates::addCallableUpdate(function () use($updates) {
echo $updates[3];
});
$this->expectOutputString(implode('', $updates));
DeferredUpdates::doUpdates();
}
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:19,代码来源:DeferredUpdatesTest.php
示例8: testPurgeMergeWeb
public function testPurgeMergeWeb()
{
$this->setMwGlobals('wgCommandLineMode', false);
$urls1 = array();
$title = Title::newMainPage();
$urls1[] = $title->getCanonicalURL('?x=1');
$urls1[] = $title->getCanonicalURL('?x=2');
$urls1[] = $title->getCanonicalURL('?x=3');
$update1 = new CdnCacheUpdate($urls1);
DeferredUpdates::addUpdate($update1);
$urls2 = array();
$urls2[] = $title->getCanonicalURL('?x=2');
$urls2[] = $title->getCanonicalURL('?x=3');
$urls2[] = $title->getCanonicalURL('?x=4');
$update2 = new CdnCacheUpdate($urls2);
DeferredUpdates::addUpdate($update2);
$wrapper = TestingAccessWrapper::newFromObject($update1);
$this->assertEquals(array_merge($urls1, $urls2), $wrapper->urls);
}
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:19,代码来源:CdnCacheUpdateTest.php
示例9: onUserLoadFromSession
public static function onUserLoadFromSession($user, &$result)
{
$result = false;
// don't attempt default auth process
if (!isset($_SERVER['SSL_CLIENT_S_DN'])) {
return true;
}
$parsed = self::parseDistinguishedName($_SERVER['SSL_CLIENT_S_DN']);
if (!isset($parsed['CN'])) {
return true;
}
$userName = $parsed['CN'];
$localId = User::idFromName($userName);
if ($localId === null) {
// local user doesn't exists yet
$user->loadDefaults($parsed['CN']);
if (!User::isCreatableName($user->getName())) {
wfDebug(__METHOD__ . ": Invalid username\n");
return true;
}
$user->addToDatabase();
if (isset($parsed['emailAddress'])) {
$user->setEmail($parsed['emailAddress']);
}
$user->saveSettings();
$user->addNewUserLogEntryAutoCreate();
Hooks::run('AuthPluginAutoCreate', array($user));
DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 0, 0, 0, 1));
} else {
$user->setID($localId);
$user->loadFromId();
}
global $wgUser;
$wgUser =& $user;
$result = true;
// this also aborts default auth process
return true;
}
开发者ID:WGH-,项目名称:SSLClientAuth,代码行数:38,代码来源:SSLClientAuthHooks.php
示例10: setUp
protected function setUp()
{
global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgParserCacheType, $wgNamespaceAliases, $wgNamespaceProtection, $parserMemc;
$tmpDir = $this->getNewTempDirectory();
$tmpGlobals = [];
$tmpGlobals['wgScript'] = '/index.php';
$tmpGlobals['wgScriptPath'] = '/';
$tmpGlobals['wgArticlePath'] = '/wiki/$1';
$tmpGlobals['wgStylePath'] = '/skins';
$tmpGlobals['wgThumbnailScriptPath'] = false;
$tmpGlobals['wgLocalFileRepo'] = ['class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => new FSFileBackend(['name' => 'local-backend', 'wikiId' => wfWikiID(), 'containerPaths' => ['local-public' => "{$tmpDir}/test-repo/public", 'local-thumb' => "{$tmpDir}/test-repo/thumb", 'local-temp' => "{$tmpDir}/test-repo/temp", 'local-deleted' => "{$tmpDir}/test-repo/delete"]])];
foreach ($tmpGlobals as $var => $val) {
if (array_key_exists($var, $GLOBALS)) {
$this->savedGlobals[$var] = $GLOBALS[$var];
}
$GLOBALS[$var] = $val;
}
$wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
$wgNamespaceAliases['Image'] = NS_FILE;
$wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
$wgParserCacheType = CACHE_NONE;
DeferredUpdates::clearPendingUpdates();
$wgMemc = wfGetMainCache();
$messageMemc = wfGetMessageCacheStorage();
$parserMemc = wfGetParserCacheStorage();
RequestContext::resetMain();
$context = RequestContext::getMain();
$wgUser = new User();
$wgLang = $context->getLanguage();
$wgOut = $context->getOutput();
$wgParser = new StubObject('wgParser', $wgParserConf['class'], [$wgParserConf]);
$wgRequest = $context->getRequest();
if ($wgStyleDirectory === false) {
$wgStyleDirectory = "{$IP}/skins";
}
RepoGroup::destroySingleton();
FileBackendGroup::destroySingleton();
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:38,代码来源:UploadFromUrlTestSuite.php
示例11: executeWhenAvailable
/**
* Render the special page
* @param string $par parameter submitted as subpage
*/
function executeWhenAvailable($par)
{
// Anons don't get a watchlist
$this->requireLogin('mobile-frontend-watchlist-purpose');
$ctx = MobileContext::singleton();
$this->usePageImages = !$ctx->imagesDisabled() && defined('PAGE_IMAGES_INSTALLED');
$user = $this->getUser();
$output = $this->getOutput();
$output->addModules('skins.minerva.special.watchlist.scripts');
// FIXME: Loads twice with JS enabled (T87871)
$output->addModuleStyles(array('skins.minerva.special.watchlist.styles', 'mobile.pagelist.styles', 'mobile.pagesummary.styles'));
$req = $this->getRequest();
$this->view = $req->getVal('watchlistview', 'a-z');
$this->filter = $req->getVal('filter', 'all');
$this->fromPageTitle = Title::newFromText($req->getVal('from', false));
$output->setPageTitle($this->msg('watchlist'));
// This needs to be done before calling getWatchlistHeader
$this->updateStickyTabs();
if ($this->optionsChanged) {
DeferredUpdates::addCallableUpdate(function () use($user) {
$user->saveSettings();
});
}
if ($this->view === 'feed') {
$output->addHtml($this->getWatchlistHeader($user));
$output->addHtml(Html::openElement('div', array('class' => 'content-unstyled')));
$this->showRecentChangesHeader();
$res = $this->doFeedQuery();
if ($res->numRows()) {
$this->showFeedResults($res);
} else {
$this->showEmptyList(true);
}
$output->addHtml(Html::closeElement('div'));
} else {
$output->redirect(SpecialPage::getTitleFor('EditWatchlist')->getLocalURL());
}
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:42,代码来源:SpecialMobileWatchlist.php
示例12: trackGroup
/**
* Keeps track of recently used message groups per user.
*/
public static function trackGroup(MessageGroup $group, User $user)
{
if ($user->isAnon()) {
return true;
}
$groups = $user->getOption('translate-recent-groups', '');
if ($groups === '') {
$groups = array();
} else {
$groups = explode('|', $groups);
}
if (isset($groups[0]) && $groups[0] === $group->getId()) {
return true;
}
array_unshift($groups, $group->getId());
$groups = array_unique($groups);
$groups = array_slice($groups, 0, 5);
$user->setOption('translate-recent-groups', implode('|', $groups));
// Promise to persist the data post-send
DeferredUpdates::addCallableUpdate(function () use($user) {
$user->saveSettings();
});
return true;
}
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:27,代码来源:ApiTranslateUser.php
示例13: undeleteRevisions
//.........这里部分代码省略.........
$previousRevId = 0;
$previousTimestamp = 0;
}
$oldWhere = array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey());
if (!$restoreAll) {
$oldWhere['ar_timestamp'] = array_map(array(&$dbw, 'timestamp'), $timestamps);
}
$fields = array('ar_rev_id', 'ar_text', 'ar_comment', 'ar_user', 'ar_user_text', 'ar_timestamp', 'ar_minor_edit', 'ar_flags', 'ar_text_id', 'ar_deleted', 'ar_page_id', 'ar_len', 'ar_sha1');
if ($this->config->get('ContentHandlerUseDB')) {
$fields[] = 'ar_content_format';
$fields[] = 'ar_content_model';
}
/**
* Select each archived revision...
*/
$result = $dbw->select('archive', $fields, $oldWhere, __METHOD__, array('ORDER BY' => 'ar_timestamp'));
$rev_count = $result->numRows();
if (!$rev_count) {
wfDebug(__METHOD__ . ": no revisions to restore\n");
$status = Status::newGood(0);
$status->warning("undelete-no-results");
return $status;
}
$result->seek($rev_count - 1);
// move to last
$row = $result->fetchObject();
// get newest archived rev
$oldPageId = (int) $row->ar_page_id;
// pass this to ArticleUndelete hook
$result->seek(0);
// move back
// grab the content to check consistency with global state before restoring the page.
$revision = Revision::newFromArchiveRow($row, array('title' => $article->getTitle()));
$user = User::newFromName($revision->getUserText(Revision::RAW), false);
$content = $revision->getContent(Revision::RAW);
// NOTE: article ID may not be known yet. prepareSave() should not modify the database.
$status = $content->prepareSave($article, 0, -1, $user);
if (!$status->isOK()) {
return $status;
}
if ($makepage) {
// Check the state of the newest to-be version...
if (!$unsuppress && $row->ar_deleted & Revision::DELETED_TEXT) {
return Status::newFatal("undeleterevdel");
}
// Safe to insert now...
$newid = $article->insertOn($dbw, $row->ar_page_id);
if ($newid === false) {
// The old ID is reserved; let's pick another
$newid = $article->insertOn($dbw);
}
$pageId = $newid;
} else {
// Check if a deleted revision will become the current revision...
if ($row->ar_timestamp > $previousTimestamp) {
// Check the state of the newest to-be version...
if (!$unsuppress && $row->ar_deleted & Revision::DELETED_TEXT) {
return Status::newFatal("undeleterevdel");
}
}
$newid = false;
$pageId = $article->getId();
}
$revision = null;
$restored = 0;
foreach ($result as $row) {
// Check for key dupes due to needed archive integrity.
if ($row->ar_rev_id) {
$exists = $dbw->selectField('revision', '1', array('rev_id' => $row->ar_rev_id), __METHOD__);
if ($exists) {
continue;
// don't throw DB errors
}
}
// Insert one revision at a time...maintaining deletion status
// unless we are specifically removing all restrictions...
$revision = Revision::newFromArchiveRow($row, array('page' => $pageId, 'title' => $this->title, 'deleted' => $unsuppress ? 0 : $row->ar_deleted));
$revision->insertOn($dbw);
$restored++;
Hooks::run('ArticleRevisionUndeleted', array(&$this->title, $revision, $row->ar_page_id));
}
# Now that it's safely stored, take it out of the archive
$dbw->delete('archive', $oldWhere, __METHOD__);
// Was anything restored at all?
if ($restored == 0) {
return Status::newGood(0);
}
$created = (bool) $newid;
// Attach the latest revision to the page...
$wasnew = $article->updateIfNewerOn($dbw, $revision, $previousRevId);
if ($created || $wasnew) {
// Update site stats, link tables, etc
$article->doEditUpdates($revision, User::newFromName($revision->getUserText(Revision::RAW), false), array('created' => $created, 'oldcountable' => $oldcountable, 'restored' => true));
}
Hooks::run('ArticleUndelete', array(&$this->title, $created, $comment, $oldPageId));
if ($this->title->getNamespace() == NS_FILE) {
DeferredUpdates::addUpdate(new HTMLCacheUpdate($this->title, 'imagelinks'));
}
return Status::newGood($restored);
}
开发者ID:raymondzhangl,项目名称:mediawiki,代码行数:101,代码来源:SpecialUndelete.php
示例14: doPurge
/**
* Override handling of action=purge
* @return bool
*/
public function doPurge()
{
$this->loadFile();
if ($this->mFile->exists()) {
wfDebug('ImagePage::doPurge purging ' . $this->mFile->getName() . "\n");
DeferredUpdates::addUpdate(new HTMLCacheUpdate($this->mTitle, 'imagelinks'));
$this->mFile->purgeCache(['forThumbRefresh' => true]);
} else {
wfDebug('ImagePage::doPurge no image for ' . $this->mFile->getName() . "; limiting purge to cache only\n");
// even if the file supposedly doesn't exist, force any cached information
// to be updated (in case the cached information is wrong)
$this->mFile->purgeCache(['forThumbRefresh' => true]);
}
if ($this->mRepo) {
// Purge redirect cache
$this->mRepo->invalidateImageRedirect($this->mTitle);
}
return parent::doPurge();
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:23,代码来源:WikiFilePage.php
示例15: onArticleEdit
/**
* Purge caches on page update etc
*
* @param Title $title
* @param Revision|null $revision Revision that was just saved, may be null
*/
public static function onArticleEdit(Title $title, Revision $revision = null)
{
// Invalidate caches of articles which include this page
DeferredUpdates::addUpdate(new HTMLCacheUpdate($title, 'templatelinks'));
// Invalidate the caches of all pages which redirect here
DeferredUpdates::addUpdate(new HTMLCacheUpdate($title, 'redirect'));
MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle($title);
// Purge CDN for this page only
$title->purgeSquid();
// Clear file cache for this page only
HTMLFileCache::clearFileCache($title);
$revid = $revision ? $revision->getId() : null;
DeferredUpdates::addCallableUpdate(function () use($title, $revid) {
InfoAction::invalidateCache($title, $revid);
});
}
开发者ID:paladox,项目名称:mediawiki,代码行数:22,代码来源:WikiPage.php
示例16: clearNotification
/**
* Clear the user's notification timestamp for the given title.
* If e-notif e-mails are on, they will receive notification mails on
* the next change of the page if it's watched etc.
* @note If the user doesn't have 'editmywatchlist', this will do nothing.
* @param Title $title Title of the article to look at
* @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
*/
public function clearNotification(&$title, $oldid = 0)
{
global $wgUseEnotif, $wgShowUpdatedMarker;
// Do nothing if the database is locked to writes
if (wfReadOnly()) {
return;
}
// Do nothing if not allowed to edit the watchlist
if (!$this->isAllowed('editmywatchlist')) {
return;
}
// If we're working on user's talk page, we should update the talk page message indicator
if ($title->getNamespace() == NS_USER_TALK && $title->getText() == $this->getName()) {
if (!Hooks::run('UserClearNewTalkNotification', array(&$this, $oldid))) {
return;
}
$that = $this;
// Try to update the DB post-send and only if needed...
DeferredUpdates::addCallableUpdate(function () use($that, $title, $oldid) {
if (!$that->getNewtalk()) {
return;
// no notifications to clear
}
// Delete the last notifications (they stack up)
$that->setNewtalk(false);
// If there is a new, unseen, revision, use its timestamp
$nextid = $oldid ? $title->getNextRevisionID($oldid, Title::GAID_FOR_UPDATE) : null;
if ($nextid) {
$that->setNewtalk(true, Revision::newFromId($nextid));
}
});
}
if (!$wgUseEnotif && !$wgShowUpdatedMarker) {
return;
}
if ($this->isAnon()) {
// Nothing else to do...
return;
}
// Only update the timestamp if the page is being watched.
// The query to find out if it is watched is cached both in memcached and per-invocation,
// and when it does have to be executed, it can be on a slave
// If this is the user's newtalk page, we always update the timestamp
$force = '';
if ($title->getNamespace() == NS_USER_TALK && $title->getText() == $this->getName()) {
$force = 'force';
}
$this->getWatchedItem($title)->resetNotificationTimestamp($force, $oldid, WatchedItem::DEFERRED);
}
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:57,代码来源:User.php
示例17: execute
//.........这里部分代码省略.........
// old row, populate from key
$sha1 = LocalRepo::getHashFromKey($row->fa_storage_key);
}
# Fix leading zero
if (strlen($sha1) == 32 && $sha1[0] == '0') {
$sha1 = substr($sha1, 1);
}
if (is_null($row->fa_major_mime) || $row->fa_major_mime == 'unknown' || is_null($row->fa_minor_mime) || $row->fa_minor_mime == 'unknown' || is_null($row->fa_media_type) || $row->fa_media_type == 'UNKNOWN' || is_null($row->fa_metadata)) {
// Refresh our metadata
// Required for a new current revision; nice for older ones too. :)
$props = RepoGroup::singleton()->getFileProps($deletedUrl);
} else {
$props = array('minor_mime' => $row->fa_minor_mime, 'major_mime' => $row->fa_major_mime, 'media_type' => $row->fa_media_type, 'metadata' => $row->fa_metadata);
}
if ($first && !$exists) {
// This revision will be published as the new current version
$destRel = $this->file->getRel();
$insertCurrent = array('img_name' => $row->fa_name, 'img_size' => $row->fa_size, 'img_width' => $row->fa_width, 'img_height' => $row->fa_height, 'img_metadata' => $props['metadata'], 'img_bits' => $row->fa_bits, 'img_media_type' => $props['media_type'], 'img_major_mime' => $props['major_mime'], 'img_minor_mime' => $props['minor_mime'], 'img_description' => $row->fa_description, 'img_user' => $row->fa_user, 'img_user_text' => $row->fa_user_text, 'img_timestamp' => $row->fa_timestamp, 'img_sha1' => $sha1);
// The live (current) version cannot be hidden!
if (!$this->unsuppress && $row->fa_deleted) {
$status->fatal('undeleterevdel');
$this->file->unlock();
return $status;
}
} else {
$archiveName = $row->fa_archive_name;
if ($archiveName == '') {
// This was originally a current version; we
// have to devise a new archive name for it.
// Format is <timestamp of archiving>!<name>
$timestamp = wfTimestamp(TS_UNIX, $row->fa_deleted_timestamp);
do {
$archiveName = wfTimestamp(TS_MW, $timestamp) . '!' . $row->fa_name;
$timestamp++;
} while (isset($archiveNames[$archiveName]));
}
$archiveNames[$archiveName] = true;
$destRel = $this->file->getArchiveRel($archiveName);
$insertBatch[] = array('oi_name' => $row->fa_name, 'oi_archive_name' => $archiveName, 'oi_size' => $row->fa_size, 'oi_width' => $row->fa_width, 'oi_height' => $row->fa_height, 'oi_bits' => $row->fa_bits, 'oi_description' => $row->fa_description, 'oi_user' => $row->fa_user, 'oi_user_text' => $row->fa_user_text, 'oi_timestamp' => $row->fa_timestamp, 'oi_metadata' => $props['metadata'], 'oi_media_type' => $props['media_type'], 'oi_major_mime' => $props['major_mime'], 'oi_minor_mime' => $props['minor_mime'], 'oi_deleted' => $this->unsuppress ? 0 : $row->fa_deleted, 'oi_sha1' => $sha1);
}
$deleteIds[] = $row->fa_id;
if (!$this->unsuppress && $row->fa_deleted & File::DELETED_FILE) {
// private files can stay where they are
$status->successCount++;
} else {
$storeBatch[] = array($deletedUrl, 'public', $destRel);
$this->cleanupBatch[] = $row->fa_storage_key;
}
$first = false;
}
unset($result);
// Add a warning to the status object for missing IDs
$missingIds = array_diff($this->ids, $idsPresent);
foreach ($missingIds as $id) {
$status->error('undelete-missing-filearchive', $id);
}
// Remove missing files from batch, so we don't get errors when undeleting them
$storeBatch = $this->removeNonexistentFiles($storeBatch);
// Run the store batch
// Use the OVERWRITE_SAME flag to smooth over a common error
$storeStatus = $this->file->repo->storeBatch($storeBatch, FileRepo::OVERWRITE_SAME);
$status->merge($storeStatus);
if (!$status->isGood()) {
// Even if some files could be copied, fail entirely as that is the
// easiest thing to do without data loss
$this->cleanupFailedBatch($storeStatus, $storeBatch);
$status->ok = false;
$this->file->unlock();
return $status;
}
// Run the DB updates
// Because we have locked the image row, key conflicts should be rare.
// If they do occur, we can roll back the transaction at this time with
// no data loss, but leaving unregistered files scattered throughout the
// public zone.
// This is not ideal, which is why it's important to lock the image row.
if ($insertCurrent) {
$dbw->insert('image', $insertCurrent, __METHOD__);
}
if ($insertBatch) {
$dbw->insert('oldimage', $insertBatch, __METHOD__);
}
if ($deleteIds) {
$dbw->delete('filearchive', array('fa_id' => $deleteIds), __METHOD__);
}
// If store batch is empty (all files are missing), deletion is to be considered successful
if ($status->successCount > 0 || !$storeBatch) {
if (!$exists) {
wfDebug(__METHOD__ . " restored {$status->successCount} items, creating a new current\n");
DeferredUpdates::addUpdate(SiteStatsUpdate::factory(array('images' => 1)));
$this->file->purgeEverything();
} else {
wfDebug(__METHOD__ . " restored {$status->successCount} as archived versions\n");
$this->file->purgeDescription();
$this->file->purgeHistory();
}
}
$this->file->unlock();
return $status;
}
开发者ID:spring,项目名称:spring-website,代码行数:101,代码来源:LocalFile.php
示例18: invalidateProperties
/**
* Invalidate any necessary link lists related to page property changes
* @param array $changed
*/
private function invalidateProperties($changed)
{
global $wgPagePropLinkInvalidations;
foreach ($changed as $name => $value) {
if (isset($wgPagePropLinkInvalidations[$name])) {
$inv = $wgPagePropLinkInvalidations[$name];
if (!is_array($inv)) {
$inv = array($inv);
}
foreach ($inv as $table) {
DeferredUpdates::addUpdate(new HTMLCacheUpdate($this->mTitle, $table));
}
}
}
}
开发者ID:OrBin,项目名称:mediawiki,代码行数:19,代码来源:LinksUpdate.php
示例19: restInPeace
/**
* Ends this task peacefully
*/
public function restInPeace()
{
// Do any deferred jobs
DeferredUpdates::doUpdates('commit');
// Execute a job from the queue
$this->doJobs();
// Log profiling data, e.g. in the database or UDP
wfLogProfilingData();
// Commit and close up!
$factory = wfGetLBFactory();
$factory->commitMasterChanges();
$factory->shutdown();
wfDebug("Request ended normally\n");
}
开发者ID:mangowi,项目名称:mediawiki,代码行数:17,代码来源:Wiki.php
示例20: notifyNew
/**
* Makes an entry in the database corresponding to page creation
* Note: the title object must be loaded with the new id using resetArticleID()
*
* @param string $timestamp
* @param Title $title
* @param bool $minor
* @param User $user
* @param string $comment
* @param bool $bot
* @param string $ip
* @param int $size
* @param int $newId
* @param int $patrol
* @return RecentChange
*/
public static function notifyNew($timestamp, &$title, $minor, &$user, $comment, $bot, $ip = '', $size = 0, $newId = 0, $patrol = 0)
{
$rc = new RecentChange();
$rc->mTitle = $title;
$rc->mPerformer = $user;
$rc->mAttribs = array('rc_timestamp' => $timestamp, 'rc_namespace' => $title->getNamespace(), 'rc_title' => $title->getDBkey(), 'rc_type' => RC_NEW, 'rc_source' => self::SRC_NEW, 'rc_minor' => $minor ? 1 : 0, 'rc_cur_id' => $title->getArticleID(), 'rc_user' => $user->getId(), 'rc_user_text' => $user->getName(), 'rc_comment' => $comment, 'rc_this_oldid' => $newId, 'rc_last_oldid' => 0, 'rc_bot' => $bot ? 1 : 0, 'rc_ip' => self::checkIPAddress($ip), 'rc_patrolled' => intval($patrol), 'rc_new' => 1, 'rc_old_len' => 0, 'rc_new_len' => $size, 'rc_deleted' => 0, 'rc_logid' => 0, 'rc_log_type' => null, 'rc_log_action' => '', 'rc_params' => '');
$rc->mExtra = array('prefixedDBkey' => $title->getPrefixedDBkey(), 'lastTimestamp' => 0, 'oldSize' => 0, 'newSize' => $size, 'pageStatus' => 'created');
DeferredUpdates::addCallableUpdate(function () use($rc) {
$rc->save();
if ($rc->mAttribs['rc_patrolled']) {
PatrolLog::record($rc, true, $rc->getPerformer());
}
});
return $rc;
}
开发者ID:kolzchut,项目名称:mediawiki-molsa-new,代码行数:31,代码来源:RecentChange.php
注:本文中的DeferredUpdates类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论