예제 #1
0
 /**
  * Returns an id for a redirect if no redirect is found 0 is returned
  *
  * @since 2.1
  *
  * @param string $title DB key
  * @param integer $namespace
  *
  * @return integer
  */
 public function findRedirectIdFor($title, $namespace)
 {
     $hash = HashBuilder::createHashIdFromSegments($title, $namespace);
     if ($this->cache->contains($hash)) {
         return $this->cache->fetch($hash);
     }
     $id = $this->select($title, $namespace);
     $this->cache->save($hash, $id);
     return $id;
 }
예제 #2
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));
 }