@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Convert `bin/files` to ObjectQuery

Summary: Ref T603. This has some custom logic which ObjectQuery can now perform more simply and more correctly.

Test Plan: Ran `bin/files purge F1`, `bin/files purge D1`, `bin/files purge --all`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D7180

+24 -26
+15 -26
src/applications/files/management/PhabricatorFilesManagementWorkflow.php
··· 8 8 } 9 9 10 10 protected function buildIterator(PhutilArgumentParser $args) { 11 + $names = $args->getArg('names'); 12 + 11 13 if ($args->getArg('all')) { 12 - if ($args->getArg('names')) { 14 + if ($names) { 13 15 throw new PhutilArgumentUsageException( 14 16 "Specify either a list of files or `--all`, but not both."); 15 17 } 16 18 return new LiskMigrationIterator(new PhabricatorFile()); 17 19 } 18 20 19 - if ($args->getArg('names')) { 20 - $iterator = array(); 21 + if ($names) { 22 + $query = id(new PhabricatorObjectQuery()) 23 + ->setViewer(PhabricatorUser::getOmnipotentUser()) 24 + ->withNames($names) 25 + ->withTypes(array(PhabricatorFilePHIDTypeFile::TYPECONST)); 21 26 22 - // TODO: (T603) Convert this to ObjectNameQuery. 23 - 24 - foreach ($args->getArg('names') as $name) { 25 - $name = trim($name); 27 + $query->execute(); 28 + $files = $query->getNamedResults(); 26 29 27 - $id = preg_replace('/^F/i', '', $name); 28 - if (ctype_digit($id)) { 29 - $file = id(new PhabricatorFile())->loadOneWhere( 30 - 'id = %d', 31 - $id); 32 - if (!$file) { 33 - throw new PhutilArgumentUsageException( 34 - "No file exists with ID '{$name}'."); 35 - } 36 - } else { 37 - $file = id(new PhabricatorFile())->loadOneWhere( 38 - 'phid = %s', 39 - $name); 40 - if (!$file) { 41 - throw new PhutilArgumentUsageException( 42 - "No file exists with PHID '{$name}'."); 43 - } 30 + foreach ($names as $name) { 31 + if (empty($files[$name])) { 32 + throw new PhutilArgumentUsageException( 33 + "No file '{$name}' exists!"); 44 34 } 45 - $iterator[] = $file; 46 35 } 47 36 48 - return $iterator; 37 + return array_values($files); 49 38 } 50 39 51 40 return null;
+9
src/applications/phid/query/PhabricatorObjectQuery.php
··· 5 5 6 6 private $phids = array(); 7 7 private $names = array(); 8 + private $types; 8 9 9 10 private $namedResults; 10 11 ··· 18 19 return $this; 19 20 } 20 21 22 + public function withTypes(array $types) { 23 + $this->types = $types; 24 + return $this; 25 + } 26 + 21 27 public function loadPage() { 22 28 if ($this->namedResults === null) { 23 29 $this->namedResults = array(); 24 30 } 25 31 26 32 $types = PhabricatorPHIDType::getAllTypes(); 33 + if ($this->types) { 34 + $types = array_select_keys($types, $this->types); 35 + } 27 36 28 37 $names = array_unique($this->names); 29 38 $phids = $this->phids;