本文整理汇总了PHP中LinkCache类的典型用法代码示例。如果您正苦于以下问题:PHP LinkCache类的具体用法?PHP LinkCache怎么用?PHP LinkCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LinkCache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
global $wgCityId;
$db = wfGetDB(DB_MASTER);
(new WikiaSQL())->SELECT('*')->FROM('page')->WHERE('page_is_redirect')->EQUAL_TO(1)->runLoop($db, function ($a, $row) use($db) {
$title = Title::newFromID($row->page_id);
if (!$title->isDeleted()) {
$rev = Revision::newFromTitle($title);
$text = $rev->getText();
$rt = Title::newFromRedirectRecurse($text);
if (!$rt) {
// page is marked as redirect but $text is not valid redirect
$this->output('Fixed ID: ' . $title->getArticleID() . ' Title: ' . $title->getText() . "\n");
// Fix page table
(new WikiaSQL())->UPDATE('page')->SET('page_is_redirect', 0)->WHERE('page_id')->EQUAL_TO($row->page_id)->RUN($db);
// remove redirect from redirect table
(new WikiaSQL())->DELETE('redirect')->WHERE('rd_from')->EQUAL_TO($row->page_id)->RUN($db);
// clear cache
LinkCache::singleton()->addGoodLinkObj($row->page_id, $title, strlen($text), 0, $rev->getId());
if ($title->getNamespace() == NS_FILE) {
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect($title);
}
}
}
});
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:26,代码来源:fixFalseRedirects.php
示例2: setUp
protected function setUp()
{
parent::setUp();
$this->pages_to_delete = array();
LinkCache::singleton()->clear();
# avoid cached redirect status, etc
}
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:7,代码来源:WikiPageTest.php
示例3: 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
示例4: 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
示例5: run
/**
* Run job
* @return boolean success
*/
function run()
{
wfProfileIn('SMWUpdateJob::run (SMW)');
global $wgParser;
LinkCache::singleton()->clear();
if (is_null($this->title)) {
$this->error = "SMWUpdateJob: Invalid title";
wfProfileOut('SMWUpdateJob::run (SMW)');
return false;
} elseif (!$this->title->exists()) {
smwfGetStore()->deleteSubject($this->title);
// be sure to clear the data
wfProfileOut('SMWUpdateJob::run (SMW)');
return true;
}
$revision = Revision::newFromTitle($this->title);
if (!$revision) {
$this->error = 'SMWUpdateJob: Page exists but no revision was found for "' . $this->title->getPrefixedDBkey() . '"';
wfProfileOut('SMWUpdateJob::run (SMW)');
return false;
}
wfProfileIn(__METHOD__ . '-parse');
$options = new ParserOptions();
$output = $wgParser->parse($revision->getText(), $this->title, $options, true, true, $revision->getID());
wfProfileOut(__METHOD__ . '-parse');
wfProfileIn(__METHOD__ . '-update');
SMWParseData::storeData($output, $this->title, false);
wfProfileOut(__METHOD__ . '-update');
wfProfileOut('SMWUpdateJob::run (SMW)');
return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SMW_UpdateJob.php
示例6: testEditUserTalkFlyoutSectionLinkFragment
/**
* @dataProvider provider_editUserTalk
*/
public function testEditUserTalkFlyoutSectionLinkFragment($pattern, $sectionTitle, $format)
{
// Required hack so parser doesnt turn the links into redlinks which contain no fragment
global $wgUser;
LinkCache::singleton()->addGoodLinkObj(42, $wgUser->getTalkPage());
$event = $this->mockEvent('edit-user-talk', array('section-title' => $sectionTitle));
$this->assertRegExp($pattern, $this->format($event, $format));
}
开发者ID:biribogos,项目名称:wikihow-src,代码行数:11,代码来源:NotificationFormatterTest.php
示例7: runParser
/**
* Parse the text from a given Revision
*
* @param Revision $revision
*/
function runParser(Revision $revision)
{
$content = $revision->getContent();
$content->getParserOutput($revision->getTitle(), $revision->getId());
if ($this->clearLinkCache) {
$this->linkCache->clear();
}
}
开发者ID:paladox,项目名称:mediawiki,代码行数:13,代码来源:benchmarkParse.php
示例8: testGetLinkClasses
public function testGetLinkClasses()
{
$wanCache = ObjectCache::getMainWANInstance();
$titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
$linkCache = new LinkCache($titleFormatter, $wanCache);
$foobarTitle = new TitleValue(NS_MAIN, 'FooBar');
$redirectTitle = new TitleValue(NS_MAIN, 'Redirect');
$userTitle = new TitleValue(NS_USER, 'Someuser');
$linkCache->addGoodLinkObj(1, $foobarTitle, 10, 0);
$linkCache->addGoodLinkObj(2, $redirectTitle, 10, 1);
$linkCache->addGoodLinkObj(3, $userTitle, 10, 0);
$linkRenderer = new LinkRenderer($titleFormatter, $linkCache);
$linkRenderer->setStubThreshold(0);
$this->assertEquals('', $linkRenderer->getLinkClasses($foobarTitle));
$linkRenderer->setStubThreshold(20);
$this->assertEquals('stub', $linkRenderer->getLinkClasses($foobarTitle));
$linkRenderer->setStubThreshold(0);
$this->assertEquals('mw-redirect', $linkRenderer->getLinkClasses($redirectTitle));
$linkRenderer->setStubThreshold(20);
$this->assertEquals('', $linkRenderer->getLinkClasses($userTitle));
}
开发者ID:paladox,项目名称:mediawiki,代码行数:21,代码来源:LinkRendererTest.php
示例9: 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
示例10: 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
示例11: run
/**
* Run method
* @return boolean success
*/
function run()
{
global $wgParser, $wgContLang;
$linkCache =& LinkCache::singleton();
$linkCache->clear();
smwLog("start", "RF", "category refactoring");
$article = new Article($this->updatetitle);
$latestrevision = Revision::newFromTitle($this->updatetitle);
smwLog("oldtitle: " . $this->oldtitle, "RF", "category refactoring");
smwLog("newtitle: " . $this->newtitle, "RF", "category refactoring");
if (!$latestrevision) {
$this->error = "SMW_UpdateCategoriesAfterMoveJob: Article not found " . $this->updatetitle->getPrefixedDBkey() . " ";
wfDebug($this->error);
return false;
}
$oldtext = $latestrevision->getRawText();
//Category X moved to Y
// Links changed accordingly:
$cat = $wgContLang->getNsText(NS_CATEGORY);
$catlcfirst = strtolower(substr($cat, 0, 1)) . substr($cat, 1);
$oldtitlelcfirst = strtolower(substr($this->oldtitle, 0, 1)) . substr($this->oldtitle, 1);
// [[[C|c]ategory:[S|s]omeCategory]] -> [[[C|c]ategory:[S|s]omeOtherCategory]]
$search[0] = '(\\[\\[(\\s*)' . $cat . '(\\s*):(\\s*)' . $this->oldtitle . '(\\s*)\\]\\])';
$replace[0] = '[[${1}' . $cat . '${2}:${3}' . $this->newtitle . '${4}]]';
$search[1] = '(\\[\\[(\\s*)' . $catlcfirst . '(\\s*):(\\s*)' . $this->oldtitle . '(\\s*)\\]\\])';
$replace[1] = '[[${1}' . $catlcfirst . '${2}:${3}' . $this->newtitle . '${4}]]';
$search[2] = '(\\[\\[(\\s*)' . $cat . '(\\s*):(\\s*)' . $oldtitlelcfirst . '(\\s*)\\]\\])';
$replace[2] = '[[${1}' . $cat . '${2}:${3}' . $this->newtitle . '${4}]]';
$search[3] = '(\\[\\[(\\s*)' . $catlcfirst . '(\\s*):(\\s*)' . $oldtitlelcfirst . '(\\s*)\\]\\])';
$replace[3] = '[[${1}' . $catlcfirst . '${2}:${3}' . $this->newtitle . '${4}]]';
// [[[C|c]ategory:[S|s]omeCategory | m]] -> [[[C|c]ategory:[S|s]omeOtherCategory | m ]]
$search[4] = '(\\[\\[(\\s*)' . $cat . '(\\s*):(\\s*)' . $this->oldtitle . '(\\s*)\\|([^]]*)\\]\\])';
$replace[4] = '[[${1}' . $cat . '${2}:${3}' . $this->newtitle . '${4}|${5}]]';
$search[5] = '(\\[\\[(\\s*)' . $catlcfirst . '(\\s*):(\\s*)' . $this->oldtitle . '(\\s*)\\|([^]]*)\\]\\])';
$replace[5] = '[[${1}' . $catlcfirst . '${2}:${3}' . $this->newtitle . '${4}|${5}]]';
$search[6] = '(\\[\\[(\\s*)' . $cat . '(\\s*):(\\s*)' . $oldtitlelcfirst . '(\\s*)\\|([^]]*)\\]\\])';
$replace[6] = '[[${1}' . $cat . '${2}:${3}' . $this->newtitle . '${4}|${5}]]';
$search[7] = '(\\[\\[(\\s*)' . $catlcfirst . '(\\s*):(\\s*)' . $oldtitlelcfirst . '(\\s*)\\|([^]]*)\\]\\])';
$replace[7] = '[[${1}' . $catlcfirst . '${2}:${3}' . $this->newtitle . '${4}|${5}]]';
$newtext = preg_replace($search, $replace, $oldtext);
$summary = 'Link(s) to ' . $this->newtitle . ' updated after page move by SMW_UpdateCategoriesAfterMoveJob. ' . $this->oldtitle . ' has been moved to ' . $this->newtitle;
$article->doEdit($newtext, $summary, EDIT_FORCE_BOT);
smwLog("finished editing article", "RF", "category refactoring");
$options = new ParserOptions();
$wgParser->parse($newtext, $this->updatetitle, $options, true, true, $latestrevision->getId());
smwLog("finished parsing semantic data", "RF", "category refactoring");
return true;
}
开发者ID:seedbank,项目名称:old-repo,代码行数:52,代码来源:SMW_UpdateCategoriesAfterMoveJob.php
示例12: run
/**
* Run a refreshLinks2 job
* @return boolean success
*/
function run()
{
global $wgUpdateRowsPerJob;
$linkCache = LinkCache::singleton();
$linkCache->clear();
if (is_null($this->title)) {
$this->error = "refreshLinks2: Invalid title";
return false;
}
// Back compat for pre-r94435 jobs
$table = isset($this->params['table']) ? $this->params['table'] : 'templatelinks';
// Avoid slave lag when fetching templates.
// When the outermost job is run, we know that the caller that enqueued it must have
// committed the relevant changes to the DB by now. At that point, record the master
// position and pass it along as the job recursively breaks into smaller range jobs.
// Hopefully, when leaf jobs are popped, the slaves will have reached that position.
if (isset($this->params['masterPos'])) {
$masterPos = $this->params['masterPos'];
} elseif (wfGetLB()->getServerCount() > 1) {
$masterPos = wfGetLB()->getMasterPos();
} else {
$masterPos = false;
}
$tbc = $this->title->getBacklinkCache();
$jobs = array();
// jobs to insert
if (isset($this->params['start']) && isset($this->params['end'])) {
# This is a partition job to trigger the insertion of leaf jobs...
$jobs = array_merge($jobs, $this->getSingleTitleJobs($table, $masterPos));
} else {
# This is a base job to trigger the insertion of partitioned jobs...
if ($tbc->getNumLinks($table, $wgUpdateRowsPerJob + 1) <= $wgUpdateRowsPerJob) {
# Just directly insert the single per-title jobs
$jobs = array_merge($jobs, $this->getSingleTitleJobs($table, $masterPos));
} else {
# Insert the partition jobs to make per-title jobs
foreach ($tbc->partition($table, $wgUpdateRowsPerJob) as $batch) {
list($start, $end) = $batch;
$jobs[] = new RefreshLinksJob2($this->title, array('table' => $table, 'start' => $start, 'end' => $end, 'masterPos' => $masterPos) + $this->getRootJobParams());
}
}
}
if (count($jobs)) {
JobQueueGroup::singleton()->push($jobs);
}
return true;
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:51,代码来源:RefreshLinksJob2.php
示例13: run
/**
* Run method
* @return boolean success
*/
function run()
{
global $wgParser;
$linkCache =& LinkCache::singleton();
$linkCache->clear();
smwLog("start", "RF", "property refactoring");
$article = new Article($this->updatetitle);
$latestrevision = Revision::newFromTitle($this->updatetitle);
smwLog("oldtitle: " . $this->oldtitle, "RF", "property refactoring");
smwLog("newtitle: " . $this->newtitle, "RF", "property refactoring");
if (!$latestrevision) {
$this->error = "SMW_UpdatePropertiesAfterMoveJob: Article not found " . $this->updatetitle->getPrefixedDBkey() . " ";
wfDebug($this->error);
return false;
}
$oldtext = $latestrevision->getRawText();
//Page X moved to Y
// Links changed accordingly:
// [[X::m]] -> [[Y::m]]
$search[0] = '(\\[\\[(\\s*)' . $this->oldtitle . '(\\s*)::([^]]*)\\]\\])';
$replace[0] = '[[${1}' . $this->newtitle . '${2}::${3}]]';
// [[X:=m]] -> [[Y:=m]]
$search[1] = '(\\[\\[(\\s*)' . $this->oldtitle . '(\\s*):=([^]]*)\\]\\])';
$replace[1] = '[[${1}' . $this->newtitle . '${2}:=${3}]]';
// TODO check if the wiki is case sensitive on the first letter
// This is not the case for the Halo wikis
$oldtitlelcfirst = strtolower(substr($this->oldtitle, 0, 1)) . substr($this->oldtitle, 1);
// [[x::m]] -> [[Y::m]]
$search[2] = '(\\[\\[(\\s*)' . $oldtitlelcfirst . '(\\s*)::([^]]*)\\]\\])';
$replace[2] = '[[${1}' . $this->newtitle . '${2}::${3}]]';
// [[x:=m]] -> [[Y:=m]]
$search[3] = '(\\[\\[(\\s*)' . $oldtitlelcfirst . '(\\s*):=([^]]*)\\]\\])';
$replace[3] = '[[${1}' . $this->newtitle . '${2}:=${3}]]';
$newtext = preg_replace($search, $replace, $oldtext);
$summary = 'Link(s) to ' . $this->newtitle . ' updated after page move by SMW_UpdatePropertiesAfterMoveJob. ' . $this->oldtitle . ' has been moved to ' . $this->newtitle;
$article->doEdit($newtext, $summary, EDIT_FORCE_BOT);
smwLog("finished editing article", "RF", "property refactoring");
$options = new ParserOptions();
$wgParser->parse($newtext, $this->updatetitle, $options, true, true, $latestrevision->getId());
smwLog("finished parsing semantic data", "RF", "property refactoring");
return true;
}
开发者ID:seedbank,项目名称:old-repo,代码行数:46,代码来源:SMW_UpdatePropertiesAfterMoveJob.php
示例14: statelessFetchTemplate
/**
* Static function to get a template
* Can be overridden via ParserOptions::setTemplateCallback().
*
* @param Title $title
* @param Parser $parser
*
* @return array
*/
static function statelessFetchTemplate($title, $parser = false)
{
$text = $skip = false;
$finalTitle = $title;
$deps = array();
# Loop to fetch the article, with up to 1 redirect
for ($i = 0; $i < 2 && is_object($title); $i++) {
# Give extensions a chance to select the revision instead
$id = false;
# Assume current
wfRunHooks('BeforeParserFetchTemplateAndtitle', array($parser, $title, &$skip, &$id));
if ($skip) {
$text = false;
$deps[] = array('title' => $title, 'page_id' => $title->getArticleID(), 'rev_id' => null);
break;
}
# Get the revision
$rev = $id ? Revision::newFromId($id) : Revision::newFromTitle($title, false, Revision::READ_NORMAL);
$rev_id = $rev ? $rev->getId() : 0;
# If there is no current revision, there is no page
if ($id === false && !$rev) {
$linkCache = LinkCache::singleton();
$linkCache->addBadLinkObj($title);
}
$deps[] = array('title' => $title, 'page_id' => $title->getArticleID(), 'rev_id' => $rev_id);
if ($rev && !$title->equals($rev->getTitle())) {
# We fetched a rev from a different title; register it too...
$deps[] = array('title' => $rev->getTitle(), 'page_id' => $rev->getPage(), 'rev_id' => $rev_id);
}
if ($rev) {
$content = $rev->getContent();
$text = $content ? $content->getWikitextForTransclusion() : null;
if ($text === false || $text === null) {
$text = false;
break;
}
} elseif ($title->getNamespace() == NS_MEDIAWIKI) {
global $wgContLang;
$message = wfMessage($wgContLang->lcfirst($title->getText()))->inContentLanguage();
if (!$message->exists()) {
$text = false;
break;
}
$content = $message->content();
$text = $message->plain();
} else {
break;
}
if (!$content) {
break;
}
# Redirect?
$finalTitle = $title;
$title = $content->getRedirectTarget();
}
return array('text' => $text, 'finalTitle' => $finalTitle, 'deps' => $deps);
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:66,代码来源:Parser.php
示例15: updateRevisionOn
/**
* Update the page record to point to a newly saved revision.
*
* @param IDatabase $dbw
* @param Revision $revision For ID number, and text used to set
* length and redirect status fields
* @param int $lastRevision If given, will not overwrite the page field
* when different from the currently set value.
* Giving 0 indicates the new page flag should be set on.
* @param bool $lastRevIsRedirect If given, will optimize adding and
* removing rows in redirect table.
* @return bool Success; false if the page row was missing or page_latest changed
*/
public function updateRevisionOn($dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null)
{
global $wgContentHandlerUseDB;
// Assertion to try to catch T92046
if ((int) $revision->getId() === 0) {
throw new InvalidArgumentException(__METHOD__ . ': Revision has ID ' . var_export($revision->getId(), 1));
}
$content = $revision->getContent();
$len = $content ? $content->getSize() : 0;
$rt = $content ? $content->getUltimateRedirectTarget() : null;
$conditions = ['page_id' => $this->getId()];
if (!is_null($lastRevision)) {
// An extra check against threads stepping on each other
$conditions['page_latest'] = $lastRevision;
}
$row = ['page_latest' => $revision->getId(), 'page_touched' => $dbw->timestamp($revision->getTimestamp()), 'page_is_new' => $lastRevision === 0 ? 1 : 0, 'page_is_redirect' => $rt !== null ? 1 : 0, 'page_len' => $len];
if ($wgContentHandlerUseDB) {
$row['page_content_model'] = $revision->getContentModel();
}
$dbw->update('page', $row, $conditions, __METHOD__);
$result = $dbw->affectedRows() > 0;
if ($result) {
$this->updateRedirectOn($dbw, $rt, $lastRevIsRedirect);
$this->setLastEdit($revision);
$this->mLatest = $revision->getId();
$this->mIsRedirect = (bool) $rt;
// Update the LinkCache.
LinkCache::singleton()->addGoodLinkObj($this->getId(), $this->mTitle, $len, $this->mIsRedirect, $this->mLatest, $revision->getContentModel());
}
return $result;
}
开发者ID:paladox,项目名称:mediawiki,代码行数:44,代码来源:WikiPage.php
示例16: getLinksTo
/**
* Get an array of Title objects which are articles which use this file
* Also adds their IDs to the link cache
*
* This is mostly copied from Title::getLinksTo()
*
* @deprecated Use HTMLCacheUpdate, this function uses too much memory
*/
function getLinksTo($options = '')
{
wfProfileIn(__METHOD__);
// Note: use local DB not repo DB, we want to know local links
if ($options) {
$db = wfGetDB(DB_MASTER);
} else {
$db = wfGetDB(DB_SLAVE);
}
$linkCache = LinkCache::singleton();
list($page, $imagelinks) = $db->tableNamesN('page', 'imagelinks');
$encName = $db->addQuotes($this->getName());
$sql = "SELECT page_namespace,page_title,page_id,page_len,page_is_redirect,\n\t\t\tFROM {$page},{$imagelinks} WHERE page_id=il_from AND il_to={$encName} {$options}";
$res = $db->query($sql, __METHOD__);
$retVal = array();
if ($db->numRows($res)) {
while ($row = $db->fetchObject($res)) {
if ($titleObj = Title::newFromRow($row)) {
$linkCache->addGoodLinkObj($row->page_id, $titleObj, $row->page_len, $row->page_is_redirect);
$retVal[] = $titleObj;
}
}
}
$db->freeResult($res);
wfProfileOut(__METHOD__);
return $retVal;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:35,代码来源:File.php
示例17: getLinksTo
/**
* Get an array of Title objects which are articles which use this file
* Also adds their IDs to the link cache
*
* This is mostly copied from Title::getLinksTo()
*
* @deprecated Use HTMLCacheUpdate, this function uses too much memory
*/
function getLinksTo($options = array())
{
wfProfileIn(__METHOD__);
// Note: use local DB not repo DB, we want to know local links
if (count($options) > 0) {
$db = wfGetDB(DB_MASTER);
} else {
$db = wfGetDB(DB_SLAVE);
}
$linkCache = LinkCache::singleton();
$encName = $db->addQuotes($this->getName());
$res = $db->select(array('page', 'imagelinks'), array('page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect'), array('page_id' => 'il_from', 'il_to' => $encName), __METHOD__, $options);
$retVal = array();
if ($db->numRows($res)) {
while ($row = $db->fetchObject($res)) {
if ($titleObj = Title::newFromRow($row)) {
$linkCache->addGoodLinkObj($row->page_id, $titleObj, $row->page_len, $row->page_is_redirect);
$retVal[] = $titleObj;
}
}
}
$db->freeResult($res);
wfProfileOut(__METHOD__);
return $retVal;
}
开发者ID:rocLv,项目名称:conference,代码行数:33,代码来源:File.php
示例18: updateRevisionOn
/**
* Update the page record to point to a newly saved revision.
*
* @param $dbw DatabaseBase: object
* @param $revision Revision: For ID number, and text used to set
* length and redirect status fields
* @param $lastRevision Integer: if given, will not overwrite the page field
* when different from the currently set value.
* Giving 0 indicates the new page flag should be set
* on.
* @param $lastRevIsRedirect Boolean: if given, will optimize adding and
* removing rows in redirect table.
* @return bool true on success, false on failure
* @private
*/
public function updateRevisionOn( $dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) {
global $wgContentHandlerUseDB;
wfProfileIn( __METHOD__ );
$content = $revision->getContent();
$len = $content ? $content->getSize() : 0;
$rt = $content ? $content->getUltimateRedirectTarget() : null;
$conditions = array( 'page_id' => $this->getId() );
if ( !is_null( $lastRevision ) ) {
// An extra check against threads stepping on each other
$conditions['page_latest'] = $lastRevision;
}
$now = wfTimestampNow();
$row = array( /* SET */
'page_latest' => $revision->getId(),
'page_touched' => $dbw->timestamp( $now ),
'page_is_new' => ( $lastRevision === 0 ) ? 1 : 0,
'page_is_redirect' => $rt !== null ? 1 : 0,
'page_len' => $len,
);
if ( $wgContentHandlerUseDB ) {
$row['page_content_model'] = $revision->getContentModel();
}
$dbw->update( 'page',
$row,
$conditions,
__METHOD__ );
$result = $dbw->affectedRows() > 0;
if ( $result ) {
$this->updateRedirectOn( $dbw, $rt, $lastRevIsRedirect );
$this->setLastEdit( $revision );
$this->setCachedLastEditTime( $now );
$this->mLatest = $revision->getId();
$this->mIsRedirect = (bool)$rt;
// Update the LinkCache.
LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect,
$this->mLatest, $revision->getContentModel() );
}
wfProfileOut( __METHOD__ );
return $result;
}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:64,代码来源:WikiPage.php
示例19: pageid
/**
* Get the pageid of a specified page
* @param Parser $parser
* @param string $title Title to get the pageid from
* @return int|null|string
* @since 1.23
*/
public static function pageid($parser, $title = null)
{
$t = Title::newFromText($title);
if (is_null($t)) {
return '';
}
// Use title from parser to have correct pageid after edit
if ($t->equals($parser->getTitle())) {
$t = $parser->getTitle();
return $t->getArticleID();
}
// These can't have ids
if (!$t->canExist() || $t->isExternal()) {
return 0;
}
// Check the link cache, maybe something already looked it up.
$linkCache = LinkCache::singleton();
$pdbk = $t->getPrefixedDBkey();
$id = $linkCache->getGoodLinkID($pdbk);
if ($id != 0) {
$parser->mOutput->addLink($t, $id);
return $id;
}
if ($linkCache->isBadLink($pdbk)) {
$parser->mOutput->addLink($t, 0);
return $id;
}
// We need to load it from the DB, so mark expensive
if ($parser->incrementExpensiveFunctionCount()) {
$id = $t->getArticleID();
$parser->mOutput->addLink($t, $id);
return $id;
}
return null;
}
开发者ID:claudinec,项目名称:galan-wiki,代码行数:42,代码来源:CoreParserFunctions.php
示例20: insertPage
/**
* Insert a new page
*
* @param string $pageName Page name
* @param string $text Page's content
* @param int $ns Unused
*/
protected function insertPage($pageName, $text, $ns)
{
$title = Title::newFromText($pageName, $ns);
$user = User::newFromName('WikiSysop');
$comment = 'Search Test';
// avoid memory leak...?
LinkCache::singleton()->clear();
$page = WikiPage::factory($title);
$page->doEditContent(ContentHandler::makeContent($text, $title), $comment, 0, false, $user);
$this->pageList[] = array($title, $page->getId());
return true;
}
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:19,代码来源:SearchEngineTest.php
注:本文中的LinkCache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论