Use "getInlines()", not "_inlines", to access inlines on client Changeset objects
[phabricator/blender.git] / scripts / symbols / clear_repository_symbols.php
blob701034c6cc92a30b54715e06454e27b22aaf1f94
1 #!/usr/bin/env php
2 <?php
4 $root = dirname(dirname(dirname(__FILE__)));
5 require_once $root.'/scripts/__init_script__.php';
7 $args = new PhutilArgumentParser($argv);
8 $args->setSynopsis(<<<EOSYNOPSIS
9 **clear_repository_symbols.php** [__options__] __repository__
11 Clear repository symbols.
12 EOSYNOPSIS
14 $args->parseStandardArguments();
15 $args->parse(
16 array(
17 array(
18 'name' => 'repository',
19 'wildcard' => true,
21 ));
23 $identifiers = $args->getArg('repository');
24 if (count($identifiers) !== 1) {
25 $args->printHelpAndExit();
28 $identifier = head($identifiers);
29 $repository = id(new PhabricatorRepositoryQuery())
30 ->setViewer(PhabricatorUser::getOmnipotentUser())
31 ->withIdentifiers($identifiers)
32 ->executeOne();
34 if (!$repository) {
35 echo tsprintf(
36 "%s\n",
37 pht('Repository "%s" does not exist.', $identifier));
38 exit(1);
41 $input = file_get_contents('php://stdin');
42 $normalized = array();
43 foreach (explode("\n", trim($input)) as $path) {
44 // Emulate the behavior of the symbol generation scripts.
45 $normalized[] = '/'.ltrim($path, './');
47 $paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths(
48 $normalized);
50 $symbol = new PhabricatorRepositorySymbol();
51 $conn_w = $symbol->establishConnection('w');
53 foreach (array_chunk(array_values($paths), 128) as $chunk) {
54 queryfx(
55 $conn_w,
56 'DELETE FROM %T WHERE repositoryPHID = %s AND pathID IN (%Ld)',
57 $symbol->getTableName(),
58 $repository->getPHID(),
59 $chunk);