本文整理汇总了PHP中Title::invalidateCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::invalidateCache方法的具体用法?PHP Title::invalidateCache怎么用?PHP Title::invalidateCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::invalidateCache方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doModify
/**
* @param Content $content Pre-save transform content
* @param integer $flags
* @param User $user
* @param string $summary
* @param array $meta
* @return Status
* @throws DBUnexpectedError
* @throws Exception
* @throws FatalError
* @throws MWException
*/
private function doModify(Content $content, $flags, User $user, $summary, array $meta)
{
global $wgUseRCPatrol;
// Update article, but only if changed.
$status = Status::newGood(['new' => false, 'revision' => null]);
// Convenience variables
$now = wfTimestampNow();
$oldid = $meta['oldId'];
/** @var $oldContent Content|null */
$oldContent = $meta['oldContent'];
$newsize = $content->getSize();
if (!$oldid) {
// Article gone missing
$status->fatal('edit-gone-missing');
return $status;
} elseif (!$oldContent) {
// Sanity check for bug 37225
throw new MWException("Could not find text for current revision {$oldid}.");
}
// @TODO: pass content object?!
$revision = new Revision(['page' => $this->getId(), 'title' => $this->mTitle, 'comment' => $summary, 'minor_edit' => $meta['minor'], 'text' => $meta['serialized'], 'len' => $newsize, 'parent_id' => $oldid, 'user' => $user->getId(), 'user_text' => $user->getName(), 'timestamp' => $now, 'content_model' => $content->getModel(), 'content_format' => $meta['serialFormat']]);
$changed = !$content->equals($oldContent);
$dbw = wfGetDB(DB_MASTER);
if ($changed) {
$prepStatus = $content->prepareSave($this, $flags, $oldid, $user);
$status->merge($prepStatus);
if (!$status->isOK()) {
return $status;
}
$dbw->startAtomic(__METHOD__);
// Get the latest page_latest value while locking it.
// Do a CAS style check to see if it's the same as when this method
// started. If it changed then bail out before touching the DB.
$latestNow = $this->lockAndGetLatest();
if ($latestNow != $oldid) {
$dbw->endAtomic(__METHOD__);
// Page updated or deleted in the mean time
$status->fatal('edit-conflict');
return $status;
}
// At this point we are now comitted to returning an OK
// status unless some DB query error or other exception comes up.
// This way callers don't have to call rollback() if $status is bad
// unless they actually try to catch exceptions (which is rare).
// Save the revision text
$revisionId = $revision->insertOn($dbw);
// Update page_latest and friends to reflect the new revision
if (!$this->updateRevisionOn($dbw, $revision, null, $meta['oldIsRedirect'])) {
throw new MWException("Failed to update page row to use new revision.");
}
Hooks::run('NewRevisionFromEditComplete', [$this, $revision, $meta['baseRevId'], $user]);
// Update recentchanges
if (!($flags & EDIT_SUPPRESS_RC)) {
// Mark as patrolled if the user can do so
$patrolled = $wgUseRCPatrol && !count($this->mTitle->getUserPermissionsErrors('autopatrol', $user));
// Add RC row to the DB
RecentChange::notifyEdit($now, $this->mTitle, $revision->isMinor(), $user, $summary, $oldid, $this->getTimestamp(), $meta['bot'], '', $oldContent ? $oldContent->getSize() : 0, $newsize, $revisionId, $patrolled, $meta['tags']);
}
$user->incEditCount();
$dbw->endAtomic(__METHOD__);
$this->mTimestamp = $now;
} else {
// Bug 32948: revision ID must be set to page {{REVISIONID}} and
// related variables correctly. Likewise for {{REVISIONUSER}} (T135261).
$revision->setId($this->getLatest());
$revision->setUserIdAndName($this->getUser(Revision::RAW), $this->getUserText(Revision::RAW));
}
if ($changed) {
// Return the new revision to the caller
$status->value['revision'] = $revision;
} else {
$status->warning('edit-no-change');
// Update page_touched as updateRevisionOn() was not called.
// Other cache updates are managed in onArticleEdit() via doEditUpdates().
$this->mTitle->invalidateCache($now);
}
// Do secondary updates once the main changes have been committed...
DeferredUpdates::addUpdate(new AtomicSectionUpdate($dbw, __METHOD__, function () use($revision, &$user, $content, $summary, &$flags, $changed, $meta, &$status) {
// Update links tables, site stats, etc.
$this->doEditUpdates($revision, $user, ['changed' => $changed, 'oldcountable' => $meta['oldCountable'], 'oldrevision' => $meta['oldRevision']]);
// Trigger post-save hook
$params = [&$this, &$user, $content, $summary, $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $meta['baseRevId']];
ContentHandler::runLegacyHooks('ArticleSaveComplete', $params);
Hooks::run('PageContentSaveComplete', $params);
}), DeferredUpdates::PRESEND);
return $status;
}
示例2: doEditContent
//.........这里部分代码省略.........
$rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
$oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
$revisionId, $patrolled
);
// Log auto-patrolled edits
if ( $patrolled ) {
PatrolLog::record( $rc, true, $user );
}
}
$user->incEditCount();
$dbw->commit( __METHOD__ );
} else {
// Bug 32948: revision ID must be set to page {{REVISIONID}} and
// related variables correctly
$revision->setId( $this->getLatest() );
}
// Update links tables, site stats, etc.
$this->doEditUpdates(
$revision,
$user,
array(
'changed' => $changed,
'oldcountable' => $oldcountable
)
);
if ( !$changed ) {
$status->warning( 'edit-no-change' );
$revision = null;
// Update page_touched, this is usually implicit in the page update
// Other cache updates are done in onArticleEdit()
$this->mTitle->invalidateCache();
}
} else {
// Create new article
$status->value['new'] = true;
$dbw->begin( __METHOD__ );
$prepStatus = $content->prepareSave( $this, $flags, $baseRevId, $user );
$status->merge( $prepStatus );
if ( !$status->isOK() ) {
$dbw->rollback( __METHOD__ );
wfProfileOut( __METHOD__ );
return $status;
}
$status->merge( $prepStatus );
// 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( __METHOD__ );
$status->fatal( 'edit-already-exists' );
wfProfileOut( __METHOD__ );
return $status;
}
// Save the revision text...
示例3: updatePage
/**
* Touch the page's cache invalidation timestamp; this forces cached
* history views to refresh, so any newly hidden or shown fields will
* update properly.
* @param Title $title
*/
function updatePage($title)
{
$title->invalidateCache();
$title->purgeSquid();
$title->touchLinks();
// Extensions that require referencing previous revisions may need this
wfRunHooks('ArticleRevisionVisiblitySet', array(&$title));
}
示例4: doEdit
//.........这里部分代码省略.........
$ok = $this->updateRevisionOn($dbw, $revision, $this->mLatest);
if (!$ok) {
/* Belated edit conflict! Run away!! */
$status->fatal('edit-conflict');
# 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 && !count($this->mTitle->getUserPermissionsErrors('autopatrol', $user));
# 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();
}
}
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;
}
# Update links tables, site stats, etc.
$this->doEditUpdates($revision, $user, array('changed' => $changed, 'oldcountable' => $oldcountable));
if (!$changed) {
$status->warning('edit-no-change');
$revision = null;
// Keep the same revision ID, but do some updates on it
$revisionId = $this->getLatest();
// Update page_touched, this is usually implicit in the page update
// Other cache updates are done in onArticleEdit()
$this->mTitle->invalidateCache();
}
} else {
# Create new article
$status->value['new'] = true;
$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(), 'timestamp' => $now));
$revisionId = $revision->insertOn($dbw);
$this->mTitle->resetArticleID($newid);
# Update the LinkCache. Resetting the Title ArticleID means it will rely on having that already cached
# @todo FIXME?
LinkCache::singleton()->addGoodLinkObj($newid, $this->mTitle, strlen($text), (bool) Title::newFromRedirect($text), $revisionId);
# 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) && !count($this->mTitle->getUserPermissionsErrors('autopatrol', $user));
# 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->doEditUpdates($revision, $user, array('created' => true));
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));
# Promote user to any groups they meet the criteria for
$user->addAutopromoteOnceGroups('onEdit');
wfProfileOut(__METHOD__);
return $status;
}
示例5: doEditContent
//.........这里部分代码省略.........
// At this point we are now comitted to returning an OK
// status unless some DB query error or other exception comes up.
// This way callers don't have to call rollback() if $status is bad
// unless they actually try to catch exceptions (which is rare).
$revisionId = $revision->insertOn($dbw);
// Update page_latest and friends to reflect the new revision
if (!$this->updateRevisionOn($dbw, $revision, null, $oldIsRedirect)) {
$dbw->rollback(__METHOD__);
throw new MWException("Failed to update page row to use new revision.");
}
Hooks::run('NewRevisionFromEditComplete', array($this, $revision, $baseRevId, $user));
// Update recentchanges
if (!($flags & EDIT_SUPPRESS_RC)) {
// Mark as patrolled if the user can do so
$patrolled = $wgUseRCPatrol && !count($this->mTitle->getUserPermissionsErrors('autopatrol', $user));
// Add RC row to the DB
RecentChange::notifyEdit($now, $this->mTitle, $isminor, $user, $summary, $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize, $revisionId, $patrolled);
}
$user->incEditCount();
$dbw->commit(__METHOD__);
$this->mTimestamp = $now;
} else {
// Bug 32948: revision ID must be set to page {{REVISIONID}} and
// related variables correctly
$revision->setId($this->getLatest());
}
// Update links tables, site stats, etc.
$this->doEditUpdates($revision, $user, array('changed' => $changed, 'oldcountable' => $oldcountable, 'oldrevision' => $old_revision));
if (!$changed) {
$status->warning('edit-no-change');
$revision = null;
// Update page_touched, this is usually implicit in the page update
// Other cache updates are done in onArticleEdit()
$this->mTitle->invalidateCache($now);
}
} else {
// Create new article
$status->value['new'] = true;
$prepStatus = $content->prepareSave($this, $flags, $oldid, $user);
$status->merge($prepStatus);
if (!$status->isOK()) {
return $status;
}
$dbw->begin(__METHOD__);
// Add the page record unless one already exists for the title
$newid = $this->insertOn($dbw);
if ($newid === false) {
$dbw->commit(__METHOD__);
// nothing inserted
$status->fatal('edit-already-exists');
return $status;
// nothing done
}
// At this point we are now comitted to returning an OK
// status unless some DB query error or other exception comes up.
// This way callers don't have to call rollback() if $status is bad
// unless they actually try to catch exceptions (which is rare).
// Save the revision text...
$revision = new Revision(array('page' => $newid, 'title' => $this->getTitle(), 'comment' => $summary, 'minor_edit' => $isminor, 'text' => $serialized, 'len' => $newsize, 'user' => $user->getId(), 'user_text' => $user->getName(), 'timestamp' => $now, 'content_model' => $content->getModel(), 'content_format' => $serialFormat));
$revisionId = $revision->insertOn($dbw);
// Bug 37225: use accessor to get the text as Revision may trim it
$content = $revision->getContent();
// sanity; get normalized version
if ($content) {
$newsize = $content->getSize();
}
示例6: updatePage
/**
* Touch the page's cache invalidation timestamp; this forces cached
* history views to refresh, so any newly hidden or shown fields will
* update properly.
* @param Title $title
*/
function updatePage($title)
{
$title->invalidateCache();
}
示例7: saveUserEditing
/**
*
* @param string $sText
* @param string $sUsername
* @param Title $oTitle
* @param integer $iSection
* @return boolean
*/
public static function saveUserEditing($sUsername, $oTitle, $iSection = -1)
{
if (BsCore::checkAccessAdmission('edit') === false) {
return true;
}
$db = wfGetDB(DB_MASTER);
$sTable = 'bs_saferedit';
$aFields = array("se_timestamp" => wfTimestamp(TS_MW, time()));
$aConditions = array("se_user_name" => $sUsername, "se_page_title" => $oTitle->getDBkey(), "se_page_namespace" => $oTitle->getNamespace(), "se_edit_section" => $iSection);
$aOptions = array('ORDER BY' => 'se_id DESC', 'LIMIT' => 1);
if ($oRow = $db->selectRow($sTable, array('se_id'), $aConditions, __METHOD__, $aOptions)) {
$oTitle->invalidateCache();
return $db->update($sTable, $aFields, array("se_id" => $oRow->se_id));
}
$oTitle->invalidateCache();
return $db->insert($sTable, $aConditions + $aFields);
}