diff --git a/bin/cache b/bin/cache new file mode 120000 index 0000000000..f3b182e818 --- /dev/null +++ b/bin/cache @@ -0,0 +1 @@ +../scripts/cache/manage_cache.php \ No newline at end of file diff --git a/scripts/cache/manage_cache.php b/scripts/cache/manage_cache.php new file mode 100755 index 0000000000..20c4bc1d84 --- /dev/null +++ b/scripts/cache/manage_cache.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +setTagline('manage mail'); +$args->setSynopsis(<<parseStandardArguments(); + +$workflows = array( + new PhabricatorCacheManagementPurgeWorkflow(), + new PhutilHelpArgumentWorkflow(), +); + +$args->parseWorkflows($workflows); diff --git a/scripts/repository/discover.php b/scripts/repository/discover.php deleted file mode 100755 index e5f2df166b..0000000000 --- a/scripts/repository/discover.php +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env php - --message --change\n\n". - "See that script for more options.\n"; -exit(1); diff --git a/scripts/repository/pull.php b/scripts/repository/pull.php deleted file mode 100755 index 5f716e77d4..0000000000 --- a/scripts/repository/pull.php +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env php - --message\n\n". - "See that script for more options.\n"; -exit(1); - diff --git a/scripts/search/index_one_commit.php b/scripts/search/index_one_commit.php deleted file mode 100755 index 7803caccef..0000000000 --- a/scripts/search/index_one_commit.php +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env php -establishConnection('w'), - 'DELETE FROM %T WHERE id IN (%Ld)', - DifferentialChangeset::TABLE_CACHE, - $changesets); - } else { - echo "Purging changeset cache...\n"; - queryfx( - $table->establishConnection('w'), - 'TRUNCATE TABLE %T', - DifferentialChangeset::TABLE_CACHE); - } - echo "Done.\n"; -} - -if ($purge_differential) { - echo "Purging Differential comment cache...\n"; - $table = new DifferentialComment(); - queryfx( - $table->establishConnection('w'), - 'UPDATE %T SET cache = NULL', - $table->getTableName()); - echo "Purging Differential inline comment cache...\n"; - $table = new DifferentialInlineComment(); - queryfx( - $table->establishConnection('w'), - 'UPDATE %T SET cache = NULL', - $table->getTableName()); - echo "Done.\n"; -} - -echo "Ok, caches purged.\n"; - -function usage($message) { - echo "Usage Error: {$message}"; - echo "\n\n"; - echo "Run 'purge_cache.php --help' for detailed help.\n"; - exit(1); -} - -function help() { - $help = << 'infrastructure/storage/patch/PhabricatorBuiltinPatchList.php', 'PhabricatorButtonsExample' => 'applications/uiexample/examples/PhabricatorButtonsExample.php', 'PhabricatorCacheDAO' => 'applications/cache/storage/PhabricatorCacheDAO.php', + 'PhabricatorCacheManagementPurgeWorkflow' => 'applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php', + 'PhabricatorCacheManagementWorkflow' => 'applications/cache/management/PhabricatorCacheManagementWorkflow.php', 'PhabricatorCaches' => 'applications/cache/PhabricatorCaches.php', 'PhabricatorCalendarBrowseController' => 'applications/calendar/controller/PhabricatorCalendarBrowseController.php', 'PhabricatorCalendarController' => 'applications/calendar/controller/PhabricatorCalendarController.php', @@ -2575,6 +2577,8 @@ phutil_register_library_map(array( 'PhabricatorBuiltinPatchList' => 'PhabricatorSQLPatchList', 'PhabricatorButtonsExample' => 'PhabricatorUIExample', 'PhabricatorCacheDAO' => 'PhabricatorLiskDAO', + 'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorSearchManagementWorkflow', + 'PhabricatorCacheManagementWorkflow' => 'PhutilArgumentWorkflow', 'PhabricatorCalendarBrowseController' => 'PhabricatorCalendarController', 'PhabricatorCalendarController' => 'PhabricatorController', 'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO', diff --git a/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php b/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php new file mode 100644 index 0000000000..cfa29c0b5e --- /dev/null +++ b/src/applications/cache/management/PhabricatorCacheManagementPurgeWorkflow.php @@ -0,0 +1,99 @@ +setName('purge') + ->setSynopsis('Drop data from caches.') + ->setArguments( + array( + array( + 'name' => 'purge-all', + 'help' => 'Purge all caches.', + ), + array( + 'name' => 'purge-remarkup', + 'help' => 'Purge the remarkup cache.', + ), + array( + 'name' => 'purge-changeset', + 'help' => 'Purge the Differential changeset cache.', + ), + array( + 'name' => 'purge-general', + 'help' => 'Purge the general cache.', + ), + )); + } + + public function execute(PhutilArgumentParser $args) { + $console = PhutilConsole::getConsole(); + + $purge_all = $args->getArg('purge-all'); + + $purge = array( + 'remarkup' => $purge_all || $args->getArg('purge-remarkup'), + 'changeset' => $purge_all || $args->getArg('purge-changeset'), + 'general' => $purge_all || $args->getArg('purge-general'), + ); + + if (!array_filter($purge)) { + $list = array(); + foreach ($purge as $key => $ignored) { + $list[] = "'--purge-".$key."'"; + } + + throw new PhutilArgumentUsageException( + "Specify which cache or caches to purge, or use '--purge-all'. ". + "Available caches are: ".implode(', ', $list).". Use '--help' ". + "for more information."); + } + + if ($purge['remarkup']) { + $console->writeOut("Purging remarkup cache..."); + $this->purgeRemarkupCache(); + $console->writeOut("done.\n"); + } + + if ($purge['changeset']) { + $console->writeOut("Purging changeset cache..."); + $this->purgeChangesetCache(); + $console->writeOut("done.\n"); + } + + if ($purge['general']) { + $console->writeOut("Purging general cache..."); + $this->purgeGeneralCache(); + $console->writeOut("done.\n"); + } + } + + private function purgeRemarkupCache() { + $conn_w = id(new PhabricatorMarkupCache())->establishConnection('w'); + + queryfx( + $conn_w, + 'TRUNCATE TABLE %T', + id(new PhabricatorMarkupCache())->getTableName()); + } + + private function purgeChangesetCache() { + $conn_w = id(new DifferentialChangeset())->establishConnection('w'); + queryfx( + $conn_w, + 'TRUNCATE TABLE %T', + DifferentialChangeset::TABLE_CACHE); + } + + private function purgeGeneralCache() { + $conn_w = id(new PhabricatorMarkupCache())->establishConnection('w'); + + queryfx( + $conn_w, + 'TRUNCATE TABLE %T', + 'cache_general'); + } + +} diff --git a/src/applications/cache/management/PhabricatorCacheManagementWorkflow.php b/src/applications/cache/management/PhabricatorCacheManagementWorkflow.php new file mode 100644 index 0000000000..661a1ee359 --- /dev/null +++ b/src/applications/cache/management/PhabricatorCacheManagementWorkflow.php @@ -0,0 +1,10 @@ +