@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.

at upstream/main 84 lines 2.2 kB view raw
1<?php 2 3final class PhabricatorCacheManagementPurgeWorkflow 4 extends PhabricatorCacheManagementWorkflow { 5 6 protected function didConstruct() { 7 $this 8 ->setName('purge') 9 ->setSynopsis(pht('Drop data from readthrough caches.')) 10 ->setArguments( 11 array( 12 array( 13 'name' => 'all', 14 'help' => pht('Purge all caches.'), 15 ), 16 array( 17 'name' => 'caches', 18 'param' => 'keys', 19 'help' => pht('Purge a specific set of caches.'), 20 ), 21 )); 22 } 23 24 public function execute(PhutilArgumentParser $args) { 25 $all_purgers = PhabricatorCachePurger::getAllPurgers(); 26 27 $is_all = $args->getArg('all'); 28 $key_list = $args->getArg('caches'); 29 30 if ($is_all && phutil_nonempty_string($key_list)) { 31 throw new PhutilArgumentUsageException( 32 pht( 33 'Specify either "--all" or "--caches", not both.')); 34 } else if (!$is_all && !phutil_nonempty_string($key_list)) { 35 throw new PhutilArgumentUsageException( 36 pht( 37 'Select caches to purge with "--all" or "--caches". Available '. 38 'caches are: %s.', 39 implode(', ', array_keys($all_purgers)))); 40 } 41 42 if ($is_all) { 43 $purgers = $all_purgers; 44 } else { 45 $key_list = preg_split('/[\s,]+/', $key_list); 46 $purgers = array(); 47 foreach ($key_list as $key) { 48 if (isset($all_purgers[$key])) { 49 $purgers[$key] = $all_purgers[$key]; 50 } else { 51 throw new PhutilArgumentUsageException( 52 pht( 53 'Cache purger "%s" is not recognized. Available caches '. 54 'are: %s.', 55 $key, 56 implode(', ', array_keys($all_purgers)))); 57 } 58 } 59 if (!$purgers) { 60 throw new PhutilArgumentUsageException( 61 pht( 62 'When using "--caches", you must select at least one valid '. 63 'cache to purge.')); 64 } 65 } 66 67 $viewer = $this->getViewer(); 68 69 foreach ($purgers as $key => $purger) { 70 $purger->setViewer($viewer); 71 72 echo tsprintf( 73 "%s\n", 74 pht( 75 'Purging "%s" cache...', 76 $key)); 77 78 $purger->purgeCache(); 79 } 80 81 return 0; 82 } 83 84}