public function getBuiltinFileKey()
 {
     $name = $this->getName();
     $desc = "disk(name={$name})";
     $hash = PhabricatorHash::digestToLength($desc, 40);
     return "builtin:{$hash}";
 }
 public function getBuiltinFileKey()
 {
     $icon = $this->getIcon();
     $color = $this->getColor();
     $desc = "compose(icon={$icon}, color={$color})";
     $hash = PhabricatorHash::digestToLength($desc, 40);
     return "builtin:{$hash}";
 }
 public static function newLock($name)
 {
     $namespace = PhabricatorLiskDAO::getStorageNamespace();
     $namespace = PhabricatorHash::digestToLength($namespace, 20);
     $full_name = 'ph:' . $namespace . ':' . $name;
     $length_limit = 64;
     if (strlen($full_name) > $length_limit) {
         throw new Exception(pht('Lock name "%s" is too long (full lock name is "%s"). The ' . 'full lock name must not be longer than %s bytes.', $name, $full_name, new PhutilNumber($length_limit)));
     }
     $lock = self::getLock($full_name);
     if (!$lock) {
         $lock = new PhabricatorGlobalLock($full_name);
         self::registerLock($lock);
     }
     return $lock;
 }
 public final function importFromSource()
 {
     if (!$this->shouldPullDataFromSource()) {
         return false;
     }
     $source = $this->getSource();
     $key = $this->getCursorKey();
     $parts = array('nsc', $source->getID(), PhabricatorHash::digestToLength($key, 20));
     $lock_name = implode('.', $parts);
     $lock = PhabricatorGlobalLock::newLock($lock_name);
     $lock->lock(1);
     try {
         $more_data = $this->pullDataFromSource();
     } catch (Exception $ex) {
         $lock->unlock();
         throw $ex;
     }
     $lock->unlock();
     return $more_data;
 }
 public function getFieldsForObject($object)
 {
     $field_list = PhabricatorCustomField::getObjectFields($object, PhabricatorCustomField::ROLE_HERALD);
     $field_list->setViewer(PhabricatorUser::getOmnipotentUser());
     $field_list->readFieldsFromStorage($object);
     $prefix = 'herald.custom/';
     $limit = self::getFieldConstantByteLimit();
     $map = array();
     foreach ($field_list->getFields() as $field) {
         $key = $field->getFieldKey();
         // NOTE: This use of digestToLength() isn't preferred (you should
         // normally digest a key unconditionally, so that it isn't possible to
         // arrange a collision) but preserves backward compatibility.
         $full_key = $prefix . $key;
         if (strlen($full_key) > $limit) {
             $full_key = PhabricatorHash::digestToLength($full_key, $limit);
         }
         $map[$full_key] = id(new PhabricatorCustomFieldHeraldField())->setCustomField($field);
     }
     return $map;
 }
 protected function getCacheKey($path)
 {
     return 'celerity:' . PhabricatorHash::digestToLength($path, 64);
 }