当前位置: 首页>>代码示例>>PHP>>正文


PHP LinkCache::forUpdate方法代码示例

本文整理汇总了PHP中LinkCache::forUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP LinkCache::forUpdate方法的具体用法?PHP LinkCache::forUpdate怎么用?PHP LinkCache::forUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinkCache的用法示例。


在下文中一共展示了LinkCache::forUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showArticle

 /**
  * After we've either updated or inserted the article, update
  * the link tables and redirect to the new page.
  */
 function showArticle($text, $subtitle, $sectionanchor = '')
 {
     global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
     global $wgUseEnotif;
     $fname = 'Article::showArticle';
     wfProfileIn($fname);
     $wgLinkCache = new LinkCache();
     if (!$wgUseDumbLinkUpdate) {
         # Preload links to reduce lock time
         if ($wgAntiLockFlags & ALF_PRELOAD_LINKS) {
             $wgLinkCache->preFill($this->mTitle);
             $wgLinkCache->clear();
         }
     }
     # Parse the text and replace links with placeholders
     $wgOut = new OutputPage();
     # Pass the current title along in case we're creating a wiki page
     # which is different than the currently displayed one (e.g. image
     # pages created on file uploads); otherwise, link updates will
     # go wrong.
     $wgOut->addWikiTextWithTitle($text, $this->mTitle);
     if (!$wgUseDumbLinkUpdate) {
         # Move the current links back to the second register
         $wgLinkCache->swapRegisters();
         # Get old version of link table to allow incremental link updates
         # Lock this data now since it is needed for an update
         $wgLinkCache->forUpdate(true);
         $wgLinkCache->preFill($this->mTitle);
         # Swap this old version back into its rightful place
         $wgLinkCache->swapRegisters();
     }
     if ($this->isRedirect($text)) {
         $r = 'redirect=no';
     } else {
         $r = '';
     }
     $wgOut->redirect($this->mTitle->getFullURL($r) . $sectionanchor);
     wfProfileOut($fname);
 }
开发者ID:BackupTheBerlios,项目名称:enotifwiki,代码行数:43,代码来源:Article.php

示例2: undelete

 /**
  * 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.
  * The deletion log will be updated with an undeletion notice.
  *
  * Returns true on success.
  *
  * @param array $timestamps Pass an empty array to restore all revisions, otherwise list the ones to undelete.
  * @return bool
  */
 function undelete($timestamps)
 {
     global $wgUser, $wgOut, $wgLang, $wgDeferredUpdateList;
     global $wgUseSquid, $wgInternalServer, $wgLinkCache;
     global $wgDBtype;
     $fname = "doUndeleteArticle";
     $restoreAll = empty($timestamps);
     $restoreRevisions = count($timestamps);
     $dbw =& wfGetDB(DB_MASTER);
     extract($dbw->tableNames('page', 'archive'));
     # Does this page already exist? We'll have to update it...
     $article = new Article($this->title);
     $options = $wgDBtype == 'PostgreSQL' ? '' : 'FOR UPDATE';
     $page = $dbw->selectRow('page', array('page_id', 'page_latest'), array('page_namespace' => $this->title->getNamespace(), 'page_title' => $this->title->getDBkey()), $fname, $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;
         $previousTimestamp = $page->rev_timestamp;
     } else {
         # Have to create a new article...
         $newid = $article->insertOn($dbw);
         $pageId = $newid;
         $previousRevId = 0;
         $previousTimestamp = 0;
     }
     if ($restoreAll) {
         $oldones = '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'), array('ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey(), $oldones), $fname, array('ORDER BY' => 'ar_timestamp'));
     $revision = null;
     while ($row = $dbw->fetchObject($result)) {
         $revision = new Revision(array('page' => $pageId, 'id' => $row->ar_rev_id, 'text' => Revision::getRevisionText($row, 'ar_'), '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));
         $revision->insertOn($dbw);
     }
     if ($revision) {
         # FIXME: Update latest if newer as well...
         if ($newid) {
             # FIXME: update article count if changed...
             $article->updateRevisionOn($dbw, $revision, $previousRevId);
             # Finally, clean up the link tables
             $wgLinkCache = new LinkCache();
             # Select for update
             $wgLinkCache->forUpdate(true);
             # Create a dummy OutputPage to update the outgoing links
             $dummyOut = new OutputPage();
             $dummyOut->addWikiText($revision->getText());
             $u = new LinksUpdate($newid, $this->title->getPrefixedDBkey());
             array_push($wgDeferredUpdateList, $u);
             #TODO: SearchUpdate, etc.
         }
         if ($newid) {
             Article::onArticleCreate($this->title);
         } else {
             Article::onArticleEdit($this->title);
         }
     } else {
         # Something went terribly worong!
     }
     # 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), $fname);
     # Touch the log!
     $log = new LogPage('delete');
     if ($restoreAll) {
         $reason = '';
     } else {
         $reason = wfMsgForContent('undeletedrevisions', $restoreRevisions);
     }
     $log->addEntry('restore', $this->title, $reason);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:blahtex,代码行数:91,代码来源:SpecialUndelete.php


注:本文中的LinkCache::forUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。