Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / files / favicon / PhabricatorFaviconRefQuery.php
blobf4e55561507b2040e4eb56994b68b2ea31d3271b
1 <?php
3 final class PhabricatorFaviconRefQuery extends Phobject {
5 private $refs;
7 public function withRefs(array $refs) {
8 assert_instances_of($refs, 'PhabricatorFaviconRef');
9 $this->refs = $refs;
10 return $this;
13 public function execute() {
14 $viewer = PhabricatorUser::getOmnipotentUser();
16 $refs = $this->refs;
18 $config_digest = PhabricatorFaviconRef::newConfigurationDigest();
20 $ref_map = array();
21 foreach ($refs as $ref) {
22 $ref_digest = $ref->newDigest();
23 $ref_key = "favicon({$config_digest},{$ref_digest},8)";
25 $ref
26 ->setViewer($viewer)
27 ->setCacheKey($ref_key);
29 $ref_map[$ref_key] = $ref;
32 $cache = PhabricatorCaches::getImmutableCache();
33 $ref_hits = $cache->getKeys(array_keys($ref_map));
35 foreach ($ref_hits as $ref_key => $ref_uri) {
36 $ref_map[$ref_key]->setURI($ref_uri);
37 unset($ref_map[$ref_key]);
40 if ($ref_map) {
41 $new_map = array();
42 foreach ($ref_map as $ref_key => $ref) {
43 $ref_uri = $ref->newURI();
44 $ref->setURI($ref_uri);
45 $new_map[$ref_key] = $ref_uri;
48 $cache->setKeys($new_map);
51 return $refs;