本文整理汇总了PHP中HTMLCacheUpdate::doUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLCacheUpdate::doUpdate方法的具体用法?PHP HTMLCacheUpdate::doUpdate怎么用?PHP HTMLCacheUpdate::doUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLCacheUpdate
的用法示例。
在下文中一共展示了HTMLCacheUpdate::doUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfTimestamp
/**
* Record a file upload in the upload log and the image table
*/
function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
{
if (is_null($user)) {
global $wgUser;
$user = $wgUser;
}
$dbw = $this->repo->getMasterDB();
$dbw->begin();
if (!$props) {
$props = $this->repo->getFileProps($this->getVirtualUrl());
}
$props['description'] = $comment;
$props['user'] = $user->getId();
$props['user_text'] = $user->getName();
$props['timestamp'] = wfTimestamp(TS_MW);
$this->setProps($props);
// Delete thumbnails and refresh the metadata cache
$this->purgeThumbnails();
$this->saveToCache();
SquidUpdate::purge(array($this->getURL()));
/* Wikia change begin - @author: Marooned, see RT#44185 */
global $wgLogo;
if ($this->url == $wgLogo) {
SquidUpdate::purge(array($this->url));
}
/* Wikia change end */
// Fail now if the file isn't there
if (!$this->fileExists) {
wfDebug(__METHOD__ . ": File " . $this->getPath() . " went missing!\n");
return false;
}
$reupload = false;
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
$reupload = true;
# Collision, this is an update of a file
# Insert previous contents into oldimage
$dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
# Update the current image row
$dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$site_stats = $dbw->tableName('site_stats');
$dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
}
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->commit();
# Invalidate cache for all pages using this file
$update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
$update->doUpdate();
return true;
}
示例2: updateSourceWLH
/**
* Callback function to update what-links-here
* @return bool must return true or other hooks don't get called
*/
function updateSourceWLH(&$article, &$user, &$text, &$summary, $minor, $dummy1, $dummy2, &$flags)
{
$ns = $article->getTitle()->getNamespace();
if ($ns == NS_SOURCE) {
// update people and families that link to this source, because source citation could have changed
$u = new HTMLCacheUpdate($article->getTitle(), 'pagelinks');
$u->doUpdate();
}
return true;
}
示例3: HTMLCacheUpdate
}
if ($revision) {
// Attach the latest revision to the page...
$wasnew = $article->updateIfNewerOn($dbw, $revision, $previousRevId);
if ($newid || $wasnew) {
// Update site stats, link tables, etc
$article->createUpdates($revision);
}
if ($newid) {
Article::onArticleCreate($page);
} else {
Article::onArticleEdit($page);
}
if ($page->getNamespace() == NS_IMAGE) {
$update = new HTMLCacheUpdate($page, 'imagelinks');
$update->doUpdate();
}
} else {
// Revision couldn't be created. This is very weird
print "We got an unknown error\n";
exit(1);
}
# Now that it's safely stored, take it out of the archive
$dbw->delete('archive', array('ar_namespace' => $page->getNamespace(), 'ar_title' => $page->getDBkey(), $oldones), __METHOD__);
print $page->getPrefixedText();
if ($restored) {
print "\n";
} else {
print " FAILED\n";
}
if ($interval) {
示例4: 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) {
$update = new HTMLCacheUpdate($this->mTitle, $table);
$update->doUpdate();
}
}
}
}
示例5: touchLinks
/**
* Update page_touched timestamps and send squid purge messages for
* pages linking to this title. May be sent to the job queue depending
* on the number of links. Typically called on create and delete.
*/
public function touchLinks()
{
$u = new HTMLCacheUpdate($this, 'pagelinks');
$u->doUpdate();
if ($this->getNamespace() == NS_CATEGORY) {
$u = new HTMLCacheUpdate($this, 'categorylinks');
$u->doUpdate();
}
}
示例6: touch
function touch(&$title)
{
wfProfileIn(__METHOD__);
$update = new HTMLCacheUpdate($title, 'imagelinks');
$update->doUpdate();
wfProfileOut(__METHOD__);
}
示例7: doPurge
/**
* Override handling of action=purge
*/
function doPurge()
{
$this->img = new Image($this->mTitle);
if ($this->img->exists()) {
wfDebug("ImagePage::doPurge purging " . $this->img->getName() . "\n");
$update = new HTMLCacheUpdate($this->mTitle, 'imagelinks');
$update->doUpdate();
$this->img->purgeCache();
} else {
wfDebug("ImagePage::doPurge no image\n");
}
parent::doPurge();
}
示例8: undeleteRevisions
//.........这里部分代码省略.........
# Have to create a new article...
$makepage = true;
$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);
$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 shitty 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
$user = User::newFromName($revision->getUserText(Revision::RAW), false);
$article->doEditUpdates($revision, $user, array('created' => $created, 'oldcountable' => $oldcountable));
}
Hooks::run('ArticleUndelete', array(&$this->title, $created, $comment, $oldPageId));
if ($this->title->getNamespace() == NS_FILE) {
$update = new HTMLCacheUpdate($this->title, 'imagelinks');
$update->doUpdate();
}
return Status::newGood($restored);
}
示例9: undeleteRevisions
/**
* This is the meaty bit -- restores archived revisions of the given page
* to the cur/old tables. If the page currently exists, all revisions will
* be stuffed into old, otherwise the most recent will go into cur.
*
* @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete.
* @param string $comment
* @param array $fileVersions
*
* @return mixed number of revisions restored or false on failure
*/
private function undeleteRevisions($timestamps)
{
if (wfReadOnly()) {
return false;
}
$restoreAll = empty($timestamps);
$dbw = wfGetDB(DB_MASTER);
# Does this page already exist? We'll have to update it...
$article = new Article($this->title);
$options = 'FOR UPDATE';
$page = $dbw->selectRow('page', array('page_id', 'page_latest'), array('page_namespace' => $this->title->getNamespace(), 'page_title' => $this->title->getDBkey()), __METHOD__, $options);
if ($page) {
# Page already exists. Import the history, and if necessary
# we'll update the latest revision field in the record.
$newid = 0;
$pageId = $page->page_id;
$previousRevId = $page->page_latest;
} else {
# Have to create a new article...
$newid = $article->insertOn($dbw);
$pageId = $newid;
$previousRevId = 0;
}
if ($restoreAll) {
$oldones = '1 = 1';
# All revisions...
} else {
$oldts = implode(',', array_map(array(&$dbw, 'addQuotes'), array_map(array(&$dbw, 'timestamp'), $timestamps)));
$oldones = "ar_timestamp IN ( {$oldts} )";
}
/**
* Restore each revision...
*/
$result = $dbw->select('archive', array('ar_rev_id', 'ar_text', 'ar_comment', 'ar_user', 'ar_user_text', 'ar_timestamp', 'ar_minor_edit', 'ar_flags', 'ar_text_id', 'ar_page_id', 'ar_len'), array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), $oldones), __METHOD__, array('ORDER BY' => 'ar_timestamp'));
if ($dbw->numRows($result) < count($timestamps)) {
wfDebug(__METHOD__ . ": couldn't find all requested rows\n");
return false;
}
$revision = null;
$restored = 0;
while ($row = $dbw->fetchObject($result)) {
if ($row->ar_text_id) {
// Revision was deleted in 1.5+; text is in
// the regular text table, use the reference.
// Specify null here so the so the text is
// dereferenced for page length info if needed.
$revText = null;
} else {
// Revision was deleted in 1.4 or earlier.
// Text is squashed into the archive row, and
// a new text table entry will be created for it.
$revText = Revision::getRevisionText($row, 'ar_');
}
$revision = new Revision(array('page' => $pageId, 'id' => $row->ar_rev_id, 'text' => $revText, 'comment' => $row->ar_comment, 'user' => $row->ar_user, 'user_text' => $row->ar_user_text, 'timestamp' => $row->ar_timestamp, 'minor_edit' => $row->ar_minor_edit, 'text_id' => $row->ar_text_id, 'len' => $row->ar_len));
$revision->insertOn($dbw);
$restored++;
wfRunHooks('ArticleRevisionUndeleted', array(&$this->title, $revision, $row->ar_page_id));
}
// Was anything restored at all?
if ($restored == 0) {
return 0;
}
if ($revision) {
// Attach the latest revision to the page...
$wasnew = $article->updateIfNewerOn($dbw, $revision, $previousRevId);
if ($newid || $wasnew) {
// Update site stats, link tables, etc
$article->createUpdates($revision);
}
if ($newid) {
wfRunHooks('ArticleUndelete', array(&$this->title, true));
Article::onArticleCreate($this->title);
} else {
wfRunHooks('ArticleUndelete', array(&$this->title, false));
Article::onArticleEdit($this->title);
}
if ($this->title->getNamespace() == NS_IMAGE) {
$update = new HTMLCacheUpdate($this->title, 'imagelinks');
$update->doUpdate();
}
} else {
// Revision couldn't be created. This is very weird
return self::UNDELETE_UNKNOWNERR;
}
# Now that it's safely stored, take it out of the archive
$dbw->delete('archive', array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), $oldones), __METHOD__);
return $restored;
}
示例10: recordDownload
/**
* Record a file upload in the upload log and the image table
*/
private function recordDownload($comment = '', $timestamp = false)
{
global $wgUser;
$dbw = $this->repo->getMasterDB();
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
list($major, $minor) = self::splitMime($this->mime);
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('ic_image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
# Collision, this is an update of a file
# Update the current image row
$dbw->update('ic_image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$site_stats = $dbw->tableName('site_stats');
$dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
}
$descTitle = $this->getTitle();
$article = new Article($descTitle);
# Add the log entry
$log = new LogPage('icdownload');
$log->addEntry('InstantCommons download', $descTitle, $comment);
if ($descTitle->exists()) {
# Create a null revision
$nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleId(), $log->getRcComment(), false);
$nullRevision->insertOn($dbw);
$article->updateRevisionOn($dbw, $nullRevision);
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$descTitle->purgeSquid();
}
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->immediateCommit();
# Invalidate cache for all pages using this file
$update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
$update->doUpdate();
return true;
}
示例11: onArticleDelete
public static function onArticleDelete($title)
{
global $wgMessageCache;
# Update existence markers on article/talk tabs...
if ($title->isTalkPage()) {
$other = $title->getSubjectPage();
} else {
$other = $title->getTalkPage();
}
$other->invalidateCache();
$other->purgeSquid();
$title->touchLinks();
$title->purgeSquid();
# File cache
HTMLFileCache::clearFileCache($title);
# Messages
if ($title->getNamespace() == NS_MEDIAWIKI) {
$wgMessageCache->replace($title->getDBkey(), false);
}
# Images
if ($title->getNamespace() == NS_FILE) {
$update = new HTMLCacheUpdate($title, 'imagelinks');
$update->doUpdate();
}
# User talk pages
if ($title->getNamespace() == NS_USER_TALK) {
$user = User::newFromName($title->getText(), false);
$user->setNewtalk(false);
}
}
示例12: propagateMySourceMove
/**
* Callback function to propagate data
* @return bool must return true or other hooks don't get called
*/
function propagateMySourceMove(&$title, &$newTitle, &$user, $pageId, $redirPageId)
{
$ns = $title->getNamespace();
if ($ns == NS_MYSOURCE) {
// update people and families that link to this mysource, because source citation has changed
$u = new HTMLCacheUpdate($title, 'pagelinks');
$u->doUpdate();
$u = new HTMLCacheUpdate($newTitle, 'pagelinks');
$u->doUpdate();
StructuredData::copyPageLinks($title, $newTitle);
}
return true;
}
示例13: purge
/**
* Purges memcache entry and articles having current poll transcluded
*/
public function purge()
{
global $wgMemc;
wfProfileIn(__METHOD__);
// clear data cache
$wgMemc->delete($this->mMemcacheKey);
$this->mData = null;
$article = Article::newFromId($this->mPollId);
if (!empty($article)) {
// purge poll page
$article->doPurge();
// purge articles embedding this poll
$updateJob = new HTMLCacheUpdate($article->getTitle(), 'templatelinks');
$updateJob->doUpdate();
// apply changes to page_touched fields
$dbw = wfGetDB(DB_MASTER);
$dbw->commit();
}
wfDebug(__METHOD__ . ": purged poll #{$this->mPollId}\n");
wfProfileOut(__METHOD__);
}
示例14: onArticleDelete
static function onArticleDelete($title)
{
global $wgUseFileCache, $wgMessageCache;
$title->touchLinks();
$title->purgeSquid();
# File cache
if ($wgUseFileCache) {
$cm = new HTMLFileCache($title);
@unlink($cm->fileCacheName());
}
if ($title->getNamespace() == NS_MEDIAWIKI) {
$wgMessageCache->replace($title->getDBkey(), false);
}
if ($title->getNamespace() == NS_IMAGE) {
$update = new HTMLCacheUpdate($title, 'imagelinks');
$update->doUpdate();
}
}
示例15: touchLinks
/**
* Update page_touched timestamps and send squid purge messages for
* pages linking to this title. May be sent to the job queue depending
* on the number of links. Typically called on create and delete.
*/
public function touchLinks()
{
$u = new HTMLCacheUpdate($this, 'pagelinks');
$u->doUpdate();
// Invalidate caches of articles which include this page
if ($this->getNamespace() != NS_VIDEO) {
// typically the main namespace video gets purged anyway when it gets updated
// this could cause a small bug on boundary cases of the page staying in the cache
$u = new HTMLCacheUpdate($this, 'templatelinks');
$u->doUpdate();
}
if ($this->getNamespace() == NS_CATEGORY) {
$u = new HTMLCacheUpdate($this, 'categorylinks');
$u->doUpdate();
}
}