/**
  * Returns the value for the property info field specified in the constructor.
  *
  * @param PropertyId $propertyId
  *
  * @return mixed|null
  *
  * @throws StorageException
  */
 public function getPropertyInfo(PropertyId $propertyId)
 {
     $info = $this->infoStore->getPropertyInfo($propertyId);
     if ($info !== null && isset($info[$this->propertyInfoKey])) {
         return $info[$this->propertyInfoKey];
     } else {
         return null;
     }
 }
 /**
  * @see PropertyInfoStore::removePropertyInfo
  *
  * @param PropertyId $propertyId
  *
  * @return bool
  */
 public function removePropertyInfo(PropertyId $propertyId)
 {
     $id = $propertyId->getNumericId();
     // if we don't know it, don't delete it.
     if (is_array($this->propertyInfo) && !array_key_exists($id, $this->propertyInfo)) {
         return false;
     }
     // update primary store
     $ok = $this->store->removePropertyInfo($propertyId);
     if (!$ok) {
         // nothing changed, nothing to do
         return false;
     }
     // NOTE: Even if we don't have the propertyInfo locally, we still need to
     //       fully load it to update memcached.
     // Get local cached version.
     // NOTE: this may be stale at this point, if it was already loaded
     $propertyInfo = $this->getAllPropertyInfo();
     // update local cache
     unset($propertyInfo[$id]);
     $this->propertyInfo = $propertyInfo;
     // update external cache
     wfDebugLog(__CLASS__, __FUNCTION__ . ': updating cache after removing property ' . $id);
     $this->cache->set($this->cacheKey, $propertyInfo, $this->cacheDuration);
     return true;
 }
 /**
  * @return array[] An associative array mapping property IDs to info arrays.
  */
 private function getPropertyInfo()
 {
     if ($this->dataType === '') {
         $propertyInfo = $this->propertyInfoStore->getAllPropertyInfo();
     } else {
         $propertyInfo = $this->propertyInfoStore->getPropertyInfoForDataType($this->dataType);
     }
     // NOTE: $propertyInfo uses numerical property IDs as keys!
     ksort($propertyInfo);
     return $propertyInfo;
 }
 /**
  * @since 0.4
  *
  * @param PropertyId $propertyId
  *
  * @return string
  * @throws PropertyDataTypeLookupException
  */
 public function getDataTypeIdForProperty(PropertyId $propertyId)
 {
     $dataTypeId = null;
     $info = $this->infoStore->getPropertyInfo($propertyId);
     if ($info !== null && isset($info[PropertyInfoStore::KEY_DATA_TYPE])) {
         $dataTypeId = $info[PropertyInfoStore::KEY_DATA_TYPE];
     }
     if ($dataTypeId === null && $this->fallbackLookup !== null) {
         $dataTypeId = $this->fallbackLookup->getDataTypeIdForProperty($propertyId);
         if ($dataTypeId !== null) {
             wfDebugLog(__CLASS__, __FUNCTION__ . ': No property info found for ' . $propertyId . ', but property ID could be retrieved from fallback store!');
             //TODO: Automatically update the info store?
             //TODO: Suggest to run rebuildPropertyInfo.php
         }
     }
     if ($dataTypeId === null) {
         throw new PropertyDataTypeLookupException($propertyId);
     }
     return $dataTypeId;
 }