Пример #1
0
 public function testPredefinedProperty()
 {
     $instance = new HashBuilder();
     $property = new DIProperty('_MDAT');
     $dataItem = $property->getDiWikiPage();
     $this->assertEquals($dataItem, $instance->newDiWikiPageFromHash($instance->getHashIdForDiWikiPage($dataItem)));
     $this->assertEquals($dataItem, $instance->newDiWikiPageFromHash($instance->createHashIdFromSegments($property->getKey(), SMW_NS_PROPERTY)));
 }
 /**
  * The subobject is attached to a root subject therefore using the root as
  * identifier to allow it to be invalidated at once with all other subobjects
  * that relate to a subject
  */
 private function getHashFrom(DIWikiPage $subject, $suffix = '')
 {
     return md5(HashBuilder::createHashIdFromSegments($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki()) . $suffix);
 }
Пример #3
0
 /**
  * Remove any cache entry for the given data. The key consists of the
  * parameters $title, $namespace, $interwiki, and $subobject. The
  * cached data is $id and $sortkey.
  *
  * @since 1.8
  * @param string $title
  * @param integer $namespace
  * @param string $interwiki
  * @param string $subobject
  */
 public function deleteCache($title, $namespace, $interwiki, $subobject)
 {
     if ($namespace == SMW_NS_PROPERTY && $interwiki === '' && $subobject === '') {
         $id = isset($this->prop_ids[$title]) ? $this->prop_ids[$title] : 0;
         unset($this->prop_ids[$title]);
         unset($this->prop_sortkeys[$title]);
     } else {
         $hashKey = HashBuilder::createHashIdFromSegments($title, $namespace, $interwiki, $subobject);
         $id = isset($this->regular_ids[$hashKey]) ? $this->regular_ids[$hashKey] : 0;
         unset($this->regular_ids[$hashKey]);
         unset($this->regular_sortkeys[$hashKey]);
     }
     $this->dataItemByIdFinder->deleteFromCache($id);
 }
 private function doBuildUniqueTargetLinksHashList(array $targetLinksHashList)
 {
     $uniqueTargetLinksHashList = array();
     foreach ($targetLinksHashList as $targetLinkHash) {
         list($title, $namespace, $iw) = explode('#', $targetLinkHash, 4);
         // We make an assumption (as we avoid to query the DB) about that a
         // query is bind to its subject by simply removing the subobject
         // identifier (_QUERY*) and creating the base (or root) subject for
         // the selected target (embedded query)
         $uniqueTargetLinksHashList[HashBuilder::createHashIdFromSegments($title, $namespace, $iw)] = true;
     }
     return array_keys($uniqueTargetLinksHashList);
 }
 /**
  * @since 2.1
  *
  * @param string $title
  * @param integer $namespace
  */
 public function deleteRedirectEntry($title, $namespace)
 {
     $this->delete($title, $namespace);
     $hash = HashBuilder::createHashIdFromSegments($title, $namespace);
     $this->inMemoryPoolCache->getPoolCacheFor('sql.store.redirect.infostore')->delete($hash);
 }
 private function canMatchById($id)
 {
     $row = $this->connection->selectRow(\SMWSQLStore3::ID_TABLE, array('smw_title', 'smw_namespace', 'smw_iw', 'smw_subobject'), array('smw_id' => $id), __METHOD__);
     if ($row === false) {
         return false;
     }
     $hash = HashBuilder::createHashIdFromSegments($row->smw_title, $row->smw_namespace, $row->smw_iw, $row->smw_subobject);
     $this->saveToCache($id, $hash);
     return true;
 }
 /**
  * @since 2.1
  *
  * @param string $title
  * @param integer $namespace
  */
 public function deleteRedirectEntry($title, $namespace)
 {
     $this->delete($title, $namespace);
     $hash = HashBuilder::createHashIdFromSegments($title, $namespace);
     $this->cache->delete($hash);
 }
 /**
  * @since 2.1
  *
  * @param integer $id
  *
  * @return DIWikiPage|null
  */
 public function getDataItemForId($id)
 {
     $poolCache = $this->inMemoryPoolCache->getPoolCacheFor('sql.store.dataitem.finder');
     if (!$poolCache->contains($id)) {
         $row = $this->connection->selectRow(\SMWSQLStore3::ID_TABLE, array('smw_title', 'smw_namespace', 'smw_iw', 'smw_subobject'), array('smw_id' => $id), __METHOD__);
         if ($row === false) {
             return null;
         }
         $hash = HashBuilder::createHashIdFromSegments($row->smw_title, $row->smw_namespace, $row->smw_iw, $row->smw_subobject);
         $this->saveToCache($id, $hash);
     }
     return HashBuilder::newDiWikiPageFromHash($poolCache->fetch($id));
 }
Пример #9
0
 /**
  * @since 2.1
  *
  * @param integer $id
  *
  * @return DIWikiPage|null
  */
 public function getDataItemForId($id)
 {
     if (!$this->cache->contains($id)) {
         $row = $this->connection->selectRow($this->tableName, array('smw_title', 'smw_namespace', 'smw_iw', 'smw_subobject'), array('smw_id' => $id), __METHOD__);
         if ($row === false) {
             return null;
         }
         $hash = HashBuilder::createHashIdFromSegments($row->smw_title, $row->smw_namespace, $row->smw_iw, $row->smw_subobject);
         $this->saveToCache($id, $hash);
     }
     return HashBuilder::newDiWikiPageFromHash($this->cache->fetch($id));
 }
 private function doBuildUniqueTargetLinksHashList($targetLinksHashList)
 {
     $uniqueTargetLinksHashList = array();
     $uniqueQueryList = array();
     foreach ($targetLinksHashList as $targetLinkHash) {
         list($title, $namespace, $iw, $subobjectname) = explode('#', $targetLinkHash, 4);
         // QueryResultCache stores queries with they queryID = $subobjectname
         if (strpos($subobjectname, Query::ID_PREFIX) !== false) {
             $uniqueQueryList[$subobjectname] = true;
         }
         // We make an assumption (as we avoid to query the DB) about that a
         // query is bind to its subject by simply removing the subobject
         // identifier (_QUERY*) and creating the base (or root) subject for
         // the selected target (embedded query)
         $uniqueTargetLinksHashList[HashBuilder::createHashIdFromSegments($title, $namespace, $iw)] = true;
     }
     return array(array_keys($uniqueTargetLinksHashList), array_keys($uniqueQueryList));
 }