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


PHP DIWikiPage::getHash方法代码示例

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


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

示例1: testResetCache

 public function testResetCache()
 {
     $subject = new DIWikiPage('Foo', NS_MAIN);
     $poolCache = $this->inMemoryPoolCache->getPoolCacheFor('exporter.dataitem.resource.encoder');
     $poolCache->save($subject->getHash(), true);
     $poolCache->save($subject->getHash() . DataItemToExpResourceEncoder::AUX_MARKER, true);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $instance = new DataItemToExpResourceEncoder($store);
     $instance->resetCacheFor($subject);
     $this->assertFalse($poolCache->contains($subject->getHash()));
 }
开发者ID:jdforrester,项目名称:SemanticMediaWiki,代码行数:11,代码来源:DataItemToExpResourceEncoderTest.php

示例2: testGetRedirectTargetFromInMemoryCache

 public function testGetRedirectTargetFromInMemoryCache()
 {
     $inMemoryPoolCache = InMemoryPoolCache::getInstance();
     $instance = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $wikipage = new DIWikiPage('Foo', NS_MAIN);
     $expected = new DIWikiPage('Bar', NS_MAIN);
     $inMemoryPoolCache->getPoolCacheFor('store.redirectTarget.lookup')->save($wikipage->getHash(), $expected);
     $this->assertEquals($expected, $instance->getRedirectTarget($wikipage));
     $inMemoryPoolCache->resetPoolCacheFor('store.redirectTarget.lookup');
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:10,代码来源:StoreTest.php

示例3: mapWikiPageToResourceElement

 /**
  * Create an ExpElement for some internal resource, given by an
  * DIWikiPage object. This is the one place in the code where URIs
  * of wiki pages and user-defined properties are determined. A modifier
  * can be given to make variants of a URI, typically done for
  * auxiliary properties. In this case, the URI is modiied by appending
  * "-23$modifier" where "-23" is the URI encoding of "#" (a symbol not
  * occuring in MW titles).
  *
  * @param DIWikiPage $diWikiPage
  * @param boolean $markForAuxiliaryUsage
  *
  * @return ExpResource
  */
 public function mapWikiPageToResourceElement(DIWikiPage $diWikiPage, $markForAuxiliaryUsage = false)
 {
     $modifier = $markForAuxiliaryUsage ? self::AUX_MARKER : '';
     $hash = $this->cachePrefix . $diWikiPage->getHash() . $modifier;
     // If a persistent cache is injected use the ExpElement serializer because
     // not all cache layers support object de/serialization
     // ExpElement::newFromSerialization
     if ($this->cache->contains($hash)) {
         return $this->cache->fetch($hash);
     }
     if ($diWikiPage->getSubobjectName() !== '') {
         $modifier = $diWikiPage->getSubobjectName();
     }
     $importDataItem = $this->tryToFindImportDataItem($diWikiPage, $modifier);
     if ($importDataItem instanceof DataItem) {
         list($localName, $namespace, $namespaceId) = $this->defineElementsForImportDataItem($importDataItem);
     } else {
         list($localName, $namespace, $namespaceId) = $this->defineElementsForDiWikiPage($diWikiPage, $modifier);
     }
     $resource = new ExpNsResource($localName, $namespace, $namespaceId, $diWikiPage);
     $this->cache->save($hash, $resource);
     return $resource;
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:37,代码来源:CachedDataItemToExpResourceEncoder.php

示例4: initSemanticDataCache

 /**
  * Helper method to make sure there is a cache entry for the data about
  * the given subject with the given ID.
  *
  * @todo The management of this cache should be revisited.
  *
  * @since 1.8
  *
  * @param int $subjectId
  * @param DIWikiPage $subject
  */
 private function initSemanticDataCache($subjectId, DIWikiPage $subject)
 {
     // *** Prepare the cache ***//
     if (!array_key_exists($subjectId, $this->store->m_semdata)) {
         // new cache entry
         $this->store->m_semdata[$subjectId] = new SMWSql3StubSemanticData($subject, $this->store, false);
         $this->store->m_sdstate[$subjectId] = array();
     }
     // Issue #622
     // If a redirect was cached preceding this request and points to the same
     // subject id ensure that in all cases the requested subject matches with
     // the selected DB id
     if ($this->store->m_semdata[$subjectId]->getSubject()->getHash() !== $subject->getHash()) {
         $this->store->m_semdata[$subjectId] = new SMWSql3StubSemanticData($subject, $this->store, false);
         $this->store->m_sdstate[$subjectId] = array();
     }
     if (count($this->store->m_semdata) > 20 && self::$in_getSemanticData == 1) {
         // prevent memory leak;
         // It is not so easy to find the sweet spot between cache size and performance gains (both memory and time),
         // The value of 20 was chosen by profiling runtimes for large inline queries and heavily annotated pages.
         // However, things might have changed in the meantime ...
         $this->store->m_semdata = array($subjectId => $this->store->m_semdata[$subjectId]);
         $this->store->m_sdstate = array($subjectId => $this->store->m_sdstate[$subjectId]);
     }
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:36,代码来源:SMW_SQLStore3_Readers.php

示例5: doMatchSubcategory

 private function doMatchSubcategory(&$subjects, DIWikiPage $category)
 {
     $hash = $category->getHash();
     $subcategories = array();
     // #1713
     // Safeguard against a possible category (or redirect thereof) to point
     // to itself by relying on tracking the hash of already inserted objects
     if (!isset($subjects[$hash])) {
         $subcategories = $this->propertyHierarchyLookup->findSubcategoryListFor($category);
     }
     foreach ($subcategories as $subcategory) {
         $subjects[$subcategory->getHash()] = $subcategory;
         if ($this->propertyHierarchyLookup->hasSubcategoryFor($subcategory)) {
             $this->doMatchSubcategory($subjects, $subcategory);
         }
     }
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:17,代码来源:QueryResultDependencyListResolver.php

示例6: pruneOutdatedTargetLinks

 /**
  * This method is called from the `SMW::SQLStore::AfterDataUpdateComplete` hook and
  * removes outdated query ID's from the table if the diff contains a `delete`
  * entry for the _ask table.
  *
  * @since 2.3
  *
  * @param CompositePropertyTableDiffIterator $compositePropertyTableDiffIterator
  */
 public function pruneOutdatedTargetLinks(DIWikiPage $subject, CompositePropertyTableDiffIterator $compositePropertyTableDiffIterator)
 {
     if (!$this->isEnabled()) {
         return null;
     }
     $start = microtime(true);
     $tableName = $this->store->getPropertyTableInfoFetcher()->findTableIdForProperty(new DIProperty('_ASK'));
     $tableChangeOps = $compositePropertyTableDiffIterator->getTableChangeOps($tableName);
     // Remove any dependency for queries that are no longer used
     foreach ($tableChangeOps as $tableChangeOp) {
         if (!$tableChangeOp->hasChangeOp('delete')) {
             continue;
         }
         $deleteIdList = array();
         foreach ($tableChangeOp->getFieldChangeOps('delete') as $fieldChangeOp) {
             $deleteIdList[] = $fieldChangeOp->get('o_id');
         }
         $this->dependencyLinksTableUpdater->deleteDependenciesFromList($deleteIdList);
     }
     wfDebugLog('smw', __METHOD__ . ' finished on ' . $subject->getHash() . ' with procTime (sec): ' . round(microtime(true) - $start, 7));
     return true;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:31,代码来源:QueryDependencyLinksStore.php

示例7: createId

 /**
  * @since 2.4
  *
  * @param DIWikiPage $subject, $subobjectName
  * @param string $subobjectName
  */
 public function createId(DIWikiPage $subject, $subobjectName = '')
 {
     $id = $this->store->getObjectIds()->makeSMWPageID($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subobjectName, false);
     wfDebugLog('smw', __METHOD__ . " add new {$id} ID for " . $subject->getHash() . " {$subobjectName}");
     return $id;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:12,代码来源:DependencyLinksTableUpdater.php

示例8: mapWikiPageToResourceElement

 /**
  * Create an ExpElement for some internal resource, given by an
  * DIWikiPage object. This is the one place in the code where URIs
  * of wiki pages and user-defined properties are determined. A modifier
  * can be given to make variants of a URI, typically done for
  * auxiliary properties. In this case, the URI is modiied by appending
  * "-23$modifier" where "-23" is the URI encoding of "#" (a symbol not
  * occuring in MW titles).
  *
  * @param DIWikiPage $diWikiPage
  * @param boolean $useAuxiliaryModifier
  *
  * @return ExpResource
  */
 public function mapWikiPageToResourceElement(DIWikiPage $diWikiPage, $useAuxiliaryModifier = false)
 {
     $modifier = $useAuxiliaryModifier ? self::AUX_MARKER : '';
     $hash = $diWikiPage->getHash() . $modifier;
     $poolCache = $this->inMemoryPoolCache->getPoolCacheFor('exporter.dataitem.resource.encoder');
     if ($poolCache->contains($hash)) {
         return $poolCache->fetch($hash);
     }
     if ($diWikiPage->getSubobjectName() !== '') {
         $modifier = $diWikiPage->getSubobjectName();
     }
     $importDataItem = $this->tryToFindImportDataItem($diWikiPage, $modifier);
     if ($importDataItem instanceof DataItem) {
         list($localName, $namespace, $namespaceId) = $this->defineElementsForImportDataItem($importDataItem);
     } else {
         list($localName, $namespace, $namespaceId) = $this->defineElementsForDiWikiPage($diWikiPage, $modifier);
     }
     $resource = new ExpNsResource($localName, $namespace, $namespaceId, $diWikiPage);
     $poolCache->save($hash, $resource);
     return $resource;
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:35,代码来源:DataItemToExpResourceEncoder.php

示例9: mapWikiPageToResourceElement

 /**
  * Create an ExpElement for some internal resource, given by an
  * DIWikiPage object. This is the one place in the code where URIs
  * of wiki pages and user-defined properties are determined. A modifier
  * can be given to make variants of a URI, typically done for
  * auxiliary properties. In this case, the URI is modiied by appending
  * "-23$modifier" where "-23" is the URI encoding of "#" (a symbol not
  * occuring in MW titles).
  *
  * @param DIWikiPage $diWikiPage
  * @param boolean $useAuxiliaryModifier
  *
  * @return ExpResource
  */
 public function mapWikiPageToResourceElement(DIWikiPage $diWikiPage, $useAuxiliaryModifier = false)
 {
     $modifier = $useAuxiliaryModifier ? self::AUX_MARKER : '';
     $hash = $diWikiPage->getHash() . $modifier;
     $poolCache = $this->inMemoryPoolCache->getPoolCacheFor('exporter.dataitem.resource.encoder');
     if ($poolCache->contains($hash)) {
         return $poolCache->fetch($hash);
     }
     if ($diWikiPage->getSubobjectName() !== '') {
         $modifier = $diWikiPage->getSubobjectName();
     }
     $resource = $this->newExpNsResource($diWikiPage, $modifier);
     $poolCache->save($hash, $resource);
     return $resource;
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:29,代码来源:DataItemToExpResourceEncoder.php

示例10: tryToMakeIdForSubject

 /**
  * @since 2.3
  *
  * @param DIWikiPage $subject, $subobjectName
  * @param string $subobjectName
  */
 public function tryToMakeIdForSubject(DIWikiPage $subject, $subobjectName = '')
 {
     if ($subject->getNamespace() !== NS_CATEGORY && $subject->getNamespace() !== SMW_NS_PROPERTY) {
         return 0;
     }
     $id = $this->store->getObjectIds()->makeSMWPageID($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $subobjectName, false);
     wfDebugLog('smw', __METHOD__ . " add new {$id} ID for " . $subject->getHash() . " \n");
     return $id;
 }
开发者ID:jdforrester,项目名称:SemanticMediaWiki,代码行数:15,代码来源:EmbeddedQueryDependencyLinksStore.php

示例11: getHash

 /**
  * @since 2.5
  *
  * @return string
  */
 public function getHash()
 {
     return md5($this->hash . ($this->subject !== null ? $this->subject->getHash() : ''));
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:9,代码来源:CompositePropertyTableDiffIterator.php


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