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


PHP LinksUpdate::doUpdate方法代码示例

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


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

示例1: testDoUpdateUsingUserdefinedAnnotations

 /**
  * @depends testUpdateToSetPredefinedAnnotations
  */
 public function testDoUpdateUsingUserdefinedAnnotations()
 {
     $this->pageCreator->createPage($this->title)->doEdit('[[HasFirstLinksUpdatetest::testDoUpdate]] [[HasSecondLinksUpdatetest::testDoUpdate]]');
     $parserData = $this->applicationFactory->newParserData($this->title, $this->pageCreator->getEditInfo()->output);
     $contentParser = $this->applicationFactory->newContentParser($this->title);
     $contentParser->parse();
     $parsedParserData = $this->applicationFactory->newParserData($this->title, $contentParser->getOutput());
     $this->assertCount(4, $parserData->getSemanticData()->getProperties());
     $this->assertCount(4, $this->getStore()->getSemanticData(DIWikiPage::newFromTitle($this->title))->getProperties());
     /**
      * See #347 and LinksUpdateConstructed
      */
     $linksUpdate = new \LinksUpdate($this->title, new \ParserOutput());
     $linksUpdate->doUpdate();
     $this->testEnvironment->executePendingDeferredUpdates();
     /**
      * Asserts that before and after the update, the SemanticData container
      * holds the same amount of properties despite the fact that the ParserOutput
      * was invoked empty
      */
     $semanticData = $this->getStore()->getSemanticData(DIWikiPage::newFromTitle($this->title));
     $this->assertCount(4, $semanticData->getProperties());
     $expected = array('propertyKeys' => array('_SKEY', '_MDAT', 'HasFirstLinksUpdatetest', 'HasSecondLinksUpdatetest'));
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $semanticData);
     return $this->pageCreator->getPage()->getRevision();
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:29,代码来源:LinksUpdateTest.php

示例2: run

 /**
  * Run a refreshLinks job
  * @return boolean success
  */
 function run()
 {
     global $wgParser;
     wfProfileIn(__METHOD__);
     $linkCache =& LinkCache::singleton();
     $linkCache->clear();
     if (is_null($this->title)) {
         $this->error = "refreshLinks: Invalid title";
         wfProfileOut(__METHOD__);
         return false;
     }
     $revision = Revision::newFromTitle($this->title);
     if (!$revision) {
         $this->error = 'refreshLinks: Article not found "' . $this->title->getPrefixedDBkey() . '"';
         wfProfileOut(__METHOD__);
         return false;
     }
     wfProfileIn(__METHOD__ . '-parse');
     $options = new ParserOptions();
     $parserOutput = $wgParser->parse($revision->getText(), $this->title, $options, true, true, $revision->getId());
     wfProfileOut(__METHOD__ . '-parse');
     wfProfileIn(__METHOD__ . '-update');
     $update = new LinksUpdate($this->title, $parserOutput, false);
     $update->doUpdate();
     wfProfileOut(__METHOD__ . '-update');
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:32,代码来源:RefreshLinksJob.php

示例3: updateLinksAfterEdit

 /**
  * Call LinksUpdate on the text of this page's approved revision,
  * if there is one.
  */
 public static function updateLinksAfterEdit(&$page, &$editInfo, $changed)
 {
     $title = $page->getTitle();
     if (!ApprovedRevs::pageIsApprovable($title)) {
         return true;
     }
     // If this user's revisions get approved automatically,
     // exit now, because this will be the approved
     // revision anyway.
     if (self::userRevsApprovedAutomatically($title)) {
         return true;
     }
     $text = '';
     $approvedText = ApprovedRevs::getApprovedContent($title);
     if (!is_null($approvedText)) {
         $text = $approvedText;
     }
     // If there's no approved revision, and 'blank if
     // unapproved' is set to true, set the text to blank.
     if (is_null($approvedText)) {
         global $egApprovedRevsBlankIfUnapproved;
         if ($egApprovedRevsBlankIfUnapproved) {
             $text = '';
         } else {
             // If it's an unapproved page and there's no
             // page blanking, exit here.
             return true;
         }
     }
     $editInfo = $page->prepareTextForEdit($text);
     $u = new LinksUpdate($page->mTitle, $editInfo->output);
     $u->doUpdate();
     return true;
 }
开发者ID:emanspeaks,项目名称:ApprovedRevs,代码行数:38,代码来源:ApprovedRevs.hooks.php

示例4: fixLinksFromArticle

function fixLinksFromArticle( $id ) {
	global $wgTitle, $wgParser;

	$wgTitle = Title::newFromID( $id );
	$dbw = wfGetDB( DB_MASTER );

	$linkCache =& LinkCache::singleton();
	$linkCache->clear();

	if ( is_null( $wgTitle ) ) {
		return;
	}
	$dbw->begin();

	$revision = Revision::newFromTitle( $wgTitle );
	if ( !$revision ) {
		return;
	}

	$options = new ParserOptions;
	$parserOutput = $wgParser->parse( $revision->getText(), $wgTitle, $options, true, true, $revision->getId() );
	$update = new LinksUpdate( $wgTitle, $parserOutput, false );
	$update->doUpdate();
	$dbw->commit();
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:25,代码来源:videoCleanup.php

示例5: execute

 /**
  * Purges the cache of a page
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     if (!$wgUser->isAllowed('purge') && !$this->getMain()->isInternalMode() && !$this->getMain()->getRequest()->wasPosted()) {
         $this->dieUsageMsg(array('mustbeposted', $this->getModuleName()));
     }
     $forceLinkUpdate = $params['forcelinkupdate'];
     $result = array();
     foreach ($params['titles'] as $t) {
         $r = array();
         $title = Title::newFromText($t);
         if (!$title instanceof Title) {
             $r['title'] = $t;
             $r['invalid'] = '';
             $result[] = $r;
             continue;
         }
         ApiQueryBase::addTitleInfo($r, $title);
         if (!$title->exists()) {
             $r['missing'] = '';
             $result[] = $r;
             continue;
         }
         $context = $this->createContext();
         $context->setTitle($title);
         $article = Article::newFromTitle($title, $context);
         $article->doPurge();
         // Directly purge and skip the UI part of purge().
         $r['purged'] = '';
         if ($forceLinkUpdate) {
             if (!$wgUser->pingLimiter()) {
                 global $wgParser, $wgEnableParserCache;
                 $popts = new ParserOptions();
                 $p_result = $wgParser->parse($article->getContent(), $title, $popts);
                 # Update the links tables
                 $u = new LinksUpdate($title, $p_result);
                 $u->doUpdate();
                 $r['linkupdate'] = '';
                 if ($wgEnableParserCache) {
                     $pcache = ParserCache::singleton();
                     $pcache->save($p_result, $article, $popts);
                 }
             } else {
                 $this->setWarning($this->parseMsg(array('actionthrottledtext')));
                 $forceLinkUpdate = false;
             }
         }
         $result[] = $r;
     }
     $apiResult = $this->getResult();
     $apiResult->setIndexedTagName($result, 'page');
     $apiResult->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:tuxmania87,项目名称:GalaxyAdventures,代码行数:57,代码来源:ApiPurge.php

示例6: assertLinksUpdate

 protected function assertLinksUpdate(Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows)
 {
     $update = new LinksUpdate($title, $parserOutput);
     $update->doUpdate();
     $this->assertSelect($table, $fields, $condition, $expectedRows);
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:6,代码来源:LinksUpdateTest.php

示例7: doCascadeProtectionUpdates

	/**
	 * Updates cascading protections
	 *
	 * @param $parserOutput ParserOutput object for the current version
	 */
	public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) {
		if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
			return;
		}

		// templatelinks table may have become out of sync,
		// especially if using variable-based transclusions.
		// For paranoia, check if things have changed and if
		// so apply updates to the database. This will ensure
		// that cascaded protections apply as soon as the changes
		// are visible.

		// Get templates from templatelinks
		$id = $this->getId();

		$tlTemplates = array();

		$dbr = wfGetDB( DB_SLAVE );
		$res = $dbr->select( array( 'templatelinks' ),
			array( 'tl_namespace', 'tl_title' ),
			array( 'tl_from' => $id ),
			__METHOD__
		);

		foreach ( $res as $row ) {
			$tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
		}

		// Get templates from parser output.
		$poTemplates = array();
		foreach ( $parserOutput->getTemplates() as $ns => $templates ) {
			foreach ( $templates as $dbk => $id ) {
				$poTemplates["$ns:$dbk"] = true;
			}
		}

		// Get the diff
		$templates_diff = array_diff_key( $poTemplates, $tlTemplates );

		if ( count( $templates_diff ) > 0 ) {
			// Whee, link updates time.
			// Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
			$u = new LinksUpdate( $this->mTitle, $parserOutput, false );
			$u->doUpdate();
		}
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:51,代码来源:WikiPage.php

示例8: editUpdates

 /**
  * Do standard deferred updates after page edit.
  * Update links tables, site stats, search index and message cache.
  * Every 1000th edit, prune the recent changes table.
  * 
  * @private
  * @param $text New text of the article
  * @param $summary Edit summary
  * @param $minoredit Minor edit
  * @param $timestamp_of_pagechange Timestamp associated with the page change
  * @param $newid rev_id value of the new revision
  * @param $changed Whether or not the content actually changed
  */
 function editUpdates($text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true)
 {
     global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgParser;
     wfProfileIn(__METHOD__);
     # Parse the text
     $options = new ParserOptions();
     $options->setTidy(true);
     $poutput = $wgParser->parse($text, $this->mTitle, $options, true, true, $newid);
     # Save it to the parser cache
     $parserCache =& ParserCache::singleton();
     $parserCache->save($poutput, $this, $wgUser);
     # Update the links tables
     $u = new LinksUpdate($this->mTitle, $poutput);
     $u->doUpdate();
     if (wfRunHooks('ArticleEditUpdatesDeleteFromRecentchanges', array(&$this))) {
         wfSeedRandom();
         if (0 == mt_rand(0, 999)) {
             # Periodically flush old entries from the recentchanges table.
             global $wgRCMaxAge;
             $dbw =& wfGetDB(DB_MASTER);
             $cutoff = $dbw->timestamp(time() - $wgRCMaxAge);
             $recentchanges = $dbw->tableName('recentchanges');
             $sql = "DELETE FROM {$recentchanges} WHERE rc_timestamp < '{$cutoff}'";
             $dbw->query($sql);
         }
     }
     $id = $this->getID();
     $title = $this->mTitle->getPrefixedDBkey();
     $shortTitle = $this->mTitle->getDBkey();
     if (0 == $id) {
         wfProfileOut(__METHOD__);
         return;
     }
     $u = new SiteStatsUpdate(0, 1, $this->mGoodAdjustment, $this->mTotalAdjustment);
     array_push($wgDeferredUpdateList, $u);
     $u = new SearchUpdate($id, $title, $text);
     array_push($wgDeferredUpdateList, $u);
     # If this is another user's talk page, update newtalk
     # Don't do this if $changed = false otherwise some idiot can null-edit a
     # load of user talk pages and piss people off, nor if it's a minor edit
     # by a properly-flagged bot.
     if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getTitleKey() && $changed && !($minoredit && $wgUser->isAllowed('nominornewtalk'))) {
         if (wfRunHooks('ArticleEditUpdateNewTalk', array(&$this))) {
             $other = User::newFromName($shortTitle);
             if (is_null($other) && User::isIP($shortTitle)) {
                 // An anonymous user
                 $other = new User();
                 $other->setName($shortTitle);
             }
             if ($other) {
                 $other->setNewtalk(true);
             }
         }
     }
     if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
         $wgMessageCache->replace($shortTitle, $text);
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:72,代码来源:Article.php

示例9: assertLinksUpdate

 protected function assertLinksUpdate(Title $title, ParserOutput $parserOutput, $table, $fields, $condition, array $expectedRows)
 {
     $update = new LinksUpdate($title, $parserOutput);
     // NOTE: make sure LinksUpdate does not generate warnings when called inside a transaction.
     $update->beginTransaction();
     $update->doUpdate();
     $update->commitTransaction();
     $this->assertSelect($table, $fields, $condition, $expectedRows);
     return $update;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:10,代码来源:LinksUpdateTest.php

示例10: fixLinksFromArticle

 /**
  * Run LinksUpdate for all links on a given page_id
  * @param $id int The page_id
  */
 public static function fixLinksFromArticle($id)
 {
     global $wgParser, $wgContLang;
     $page = WikiPage::newFromID($id);
     LinkCache::singleton()->clear();
     if ($page === null) {
         return;
     }
     $text = $page->getRawText();
     if ($text === false) {
         return;
     }
     $dbw = wfGetDB(DB_MASTER);
     $dbw->begin(__METHOD__);
     $options = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
     $parserOutput = $wgParser->parse($text, $page->getTitle(), $options, true, true, $page->getLatest());
     $update = new LinksUpdate($page->getTitle(), $parserOutput, false);
     $update->doUpdate();
     $dbw->commit(__METHOD__);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:24,代码来源:refreshLinks.php

示例11: updateLinks

 public function updateLinks($parserOutput)
 {
     $update = new \LinksUpdate($this->title, $parserOutput, false);
     $update->doUpdate();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:5,代码来源:RefreshLinksForTitleTask.class.php

示例12: doCascadeProtectionUpdates

 protected function doCascadeProtectionUpdates($parserOutput)
 {
     if (!$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading()) {
         return;
     }
     // templatelinks table may have become out of sync,
     // especially if using variable-based transclusions.
     // For paranoia, check if things have changed and if
     // so apply updates to the database. This will ensure
     // that cascaded protections apply as soon as the changes
     // are visible.
     # Get templates from templatelinks
     $id = $this->mTitle->getArticleID();
     $tlTemplates = array();
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array('templatelinks'), array('tl_namespace', 'tl_title'), array('tl_from' => $id), __METHOD__);
     global $wgContLang;
     foreach ($res as $row) {
         $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
     }
     # Get templates from parser output.
     $poTemplates = array();
     foreach ($parserOutput->getTemplates() as $ns => $templates) {
         foreach ($templates as $dbk => $id) {
             $poTemplates["{$ns}:{$dbk}"] = true;
         }
     }
     # Get the diff
     # Note that we simulate array_diff_key in PHP <5.0.x
     $templates_diff = array_diff_key($poTemplates, $tlTemplates);
     if (count($templates_diff) > 0) {
         # Whee, link updates time.
         $u = new LinksUpdate($this->mTitle, $parserOutput, false);
         $u->doUpdate();
     }
 }
开发者ID:BackupTheBerlios,项目名称:swahili-dict,代码行数:36,代码来源:Article.php

示例13: run

 /**
  * Run a refreshLinks2 job
  * @return boolean success
  */
 function run()
 {
     global $wgParser;
     wfProfileIn(__METHOD__);
     $linkCache = LinkCache::singleton();
     $linkCache->clear();
     if (is_null($this->title)) {
         $this->error = "refreshLinks2: Invalid title";
         wfProfileOut(__METHOD__);
         return false;
     }
     if (!isset($this->params['start']) || !isset($this->params['end'])) {
         $this->error = "refreshLinks2: Invalid params";
         wfProfileOut(__METHOD__);
         return false;
     }
     $start = intval($this->params['start']);
     $end = intval($this->params['end']);
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array('templatelinks', 'page'), array('page_namespace', 'page_title'), array('page_id=tl_from', "tl_from >= '{$start}'", "tl_from <= '{$end}'", 'tl_namespace' => $this->title->getNamespace(), 'tl_title' => $this->title->getDBkey()), __METHOD__);
     # Not suitable for page load triggered job running!
     # Gracefully switch to refreshLinks jobs if this happens.
     if (php_sapi_name() != 'cli') {
         $jobs = array();
         while ($row = $dbr->fetchObject($res)) {
             $title = Title::makeTitle($row->page_namespace, $row->page_title);
             $jobs[] = new RefreshLinksJob($title, '');
         }
         Job::batchInsert($jobs);
         return true;
     }
     # Re-parse each page that transcludes this page and update their tracking links...
     while ($row = $dbr->fetchObject($res)) {
         $title = Title::makeTitle($row->page_namespace, $row->page_title);
         $revision = Revision::newFromTitle($title);
         if (!$revision) {
             $this->error = 'refreshLinks: Article not found "' . $title->getPrefixedDBkey() . '"';
             wfProfileOut(__METHOD__);
             return false;
         }
         wfProfileIn(__METHOD__ . '-parse');
         $options = new ParserOptions();
         $parserOutput = $wgParser->parse($revision->getText(), $title, $options, true, true, $revision->getId());
         wfProfileOut(__METHOD__ . '-parse');
         wfProfileIn(__METHOD__ . '-update');
         $update = new LinksUpdate($title, $parserOutput, false);
         $update->doUpdate();
         wfProfileOut(__METHOD__ . '-update');
         wfProfileOut(__METHOD__);
     }
     return true;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:56,代码来源:RefreshLinksJob.php

示例14: refreshLinks

 /**
  * Run a refreshLinks job
  * @return boolean success
  */
 function refreshLinks()
 {
     global $wgParser;
     $fname = 'Job::refreshLinks';
     wfProfileIn($fname);
     $dbw =& wfGetDB(DB_MASTER);
     $linkCache =& LinkCache::singleton();
     $linkCache->clear();
     if (is_null($this->title)) {
         $this->error = "refreshLinks: Invalid title";
         wfProfileOut($fname);
         return false;
     }
     $revision = Revision::newFromTitle($this->title);
     if (!$revision) {
         $this->error = 'refreshLinks: Article not found "' . $this->title->getPrefixedDBkey() . '"';
         wfProfileOut($fname);
         return false;
     }
     wfProfileIn("{$fname}-parse");
     $options = new ParserOptions();
     $parserOutput = $wgParser->parse($revision->getText(), $this->title, $options, true, true, $revision->getId());
     wfProfileOut("{$fname}-parse");
     wfProfileIn("{$fname}-update");
     $update = new LinksUpdate($this->title, $parserOutput, false);
     $update->doUpdate();
     wfProfileOut("{$fname}-update");
     wfProfileOut($fname);
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:blahtex,代码行数:34,代码来源:JobQueue.php

示例15: run

 /**
  * Run a refreshLinks2 job
  * @return boolean success
  */
 function run()
 {
     global $wgParser, $wgContLang;
     wfProfileIn(__METHOD__);
     $linkCache = LinkCache::singleton();
     $linkCache->clear();
     if (is_null($this->title)) {
         $this->error = "refreshLinks2: Invalid title";
         wfProfileOut(__METHOD__);
         return false;
     }
     if (!isset($this->params['start']) || !isset($this->params['end'])) {
         $this->error = "refreshLinks2: Invalid params";
         wfProfileOut(__METHOD__);
         return false;
     }
     // Back compat for pre-r94435 jobs
     $table = isset($this->params['table']) ? $this->params['table'] : 'templatelinks';
     $titles = $this->title->getBacklinkCache()->getLinks($table, $this->params['start'], $this->params['end']);
     # Not suitable for page load triggered job running!
     # Gracefully switch to refreshLinks jobs if this happens.
     if (php_sapi_name() != 'cli') {
         $jobs = array();
         foreach ($titles as $title) {
             $jobs[] = new RefreshLinksJob($title, '');
         }
         Job::batchInsert($jobs);
         wfProfileOut(__METHOD__);
         return true;
     }
     $options = ParserOptions::newFromUserAndLang(new User(), $wgContLang);
     # Re-parse each page that transcludes this page and update their tracking links...
     foreach ($titles as $title) {
         $revision = Revision::newFromTitle($title);
         if (!$revision) {
             $this->error = 'refreshLinks: Article not found "' . $title->getPrefixedDBkey() . '"';
             wfProfileOut(__METHOD__);
             return false;
         }
         wfProfileIn(__METHOD__ . '-parse');
         $parserOutput = $wgParser->parse($revision->getText(), $title, $options, true, true, $revision->getId());
         wfProfileOut(__METHOD__ . '-parse');
         wfProfileIn(__METHOD__ . '-update');
         $update = new LinksUpdate($title, $parserOutput, false);
         $update->doUpdate();
         wfProfileOut(__METHOD__ . '-update');
         wfWaitForSlaves();
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:55,代码来源:RefreshLinksJob.php


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