protected function createDocumentsByHash(array $hashes) { foreach ($hashes as $hash) { $atom = $this->getAtomFromGraphHash($hash); $ref = $atom->getRef(); $symbol = $this->loadSymbolForAtom($atom); $is_documentable = $this->shouldGenerateDocumentForAtom($atom); $symbol->setRepositoryPHID($this->getRepositoryPHID())->setGraphHash($hash)->setIsDocumentable((int) $is_documentable)->setTitle($ref->getTitle())->setGroupName($ref->getGroup())->setNodeHash($atom->getHash()); if ($atom->getType() !== DivinerAtom::TYPE_FILE) { $renderer = $this->getRenderer(); $summary = $renderer->getAtomSummary($atom); $symbol->setSummary($summary); } else { $symbol->setSummary(''); } $symbol->save(); PhabricatorSearchWorker::queueDocumentForIndexing($symbol->getPHID()); // TODO: We probably need a finer-grained sense of what "documentable" // atoms are. Neither files nor methods are currently considered // documentable, but for different reasons: files appear nowhere, while // methods just don't appear at the top level. These are probably // separate concepts. Since we need atoms in order to build method // documentation, we insert them here. This also means we insert files, // which are unnecessary and unused. Make sure this makes sense, but then // probably introduce separate "isTopLevel" and "isDocumentable" flags? // TODO: Yeah do that soon ^^^ if ($atom->getType() !== DivinerAtom::TYPE_FILE) { $storage = $this->loadAtomStorageForSymbol($symbol)->setAtomData($atom->toDictionary())->setContent(null)->save(); } } }
protected function finishParse() { $commit = $this->commit; $commit->writeImportStatusFlag(PhabricatorRepositoryCommit::IMPORTED_CHANGE); PhabricatorSearchWorker::queueDocumentForIndexing($commit->getPHID()); if ($this->shouldQueueFollowupTasks()) { $this->queueTask('PhabricatorRepositoryCommitOwnersWorker', array('commitID' => $commit->getID())); } }
public function execute(PhutilArgumentParser $args) { $console = PhutilConsole::getConsole(); $is_all = $args->getArg('all'); $is_type = $args->getArg('type'); $is_force = $args->getArg('force'); $obj_names = $args->getArg('objects'); if ($obj_names && ($is_all || $is_type)) { throw new PhutilArgumentUsageException(pht("You can not name objects to index alongside the '%s' or '%s' flags.", '--all', '--type')); } else { if (!$obj_names && !($is_all || $is_type)) { throw new PhutilArgumentUsageException(pht("Provide one of '%s', '%s' or a list of object names.", '--all', '--type')); } } if ($obj_names) { $phids = $this->loadPHIDsByNames($obj_names); } else { $phids = $this->loadPHIDsByTypes($is_type); } if (!$phids) { throw new PhutilArgumentUsageException(pht('Nothing to index!')); } if ($args->getArg('background')) { $is_background = true; } else { PhabricatorWorker::setRunAllTasksInProcess(true); $is_background = false; } if (!$is_background) { $console->writeOut("%s\n", pht('Run this workflow with "%s" to queue tasks for the daemon workers.', '--background')); } $groups = phid_group_by_type($phids); foreach ($groups as $group_type => $group) { $console->writeOut("%s\n", pht('Indexing %d object(s) of type %s.', count($group), $group_type)); } $bar = id(new PhutilConsoleProgressBar())->setTotal(count($phids)); $parameters = array('force' => $is_force); $any_success = false; foreach ($phids as $phid) { try { PhabricatorSearchWorker::queueDocumentForIndexing($phid, $parameters); $any_success = true; } catch (Exception $ex) { phlog($ex); } $bar->update(1); } $bar->done(); if (!$any_success) { throw new Exception(pht('Failed to rebuild search index for any documents.')); } }
protected function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit) { $this->log("%s\n", pht('Parsing "%s"...', $commit->getMonogram())); if ($this->isBadCommit($commit)) { $this->log(pht('This commit is marked bad!')); return; } if (!$this->shouldSkipImportStep()) { $results = $this->parseCommitChanges($repository, $commit); if ($results) { $this->writeCommitChanges($repository, $commit, $results); } $commit->writeImportStatusFlag($this->getImportStepFlag()); PhabricatorSearchWorker::queueDocumentForIndexing($commit->getPHID()); } $this->finishParse(); }
<?php $table = new AlmanacNetwork(); foreach (new LiskMigrationIterator($table) as $network) { PhabricatorSearchWorker::queueDocumentForIndexing($network->getPHID(), array('force' => true)); }
public function publishTransactions(PhabricatorLiskDAO $object, array $xactions) { $this->object = $object; $this->xactions = $xactions; // Hook for edges or other properties that may need (re-)loading $object = $this->willPublish($object, $xactions); // The object might have changed, so reassign it. $this->object = $object; $messages = array(); if (!$this->getDisableEmail()) { if ($this->shouldSendMail($object, $xactions)) { $messages = $this->buildMail($object, $xactions); } } if ($this->supportsSearch()) { PhabricatorSearchWorker::queueDocumentForIndexing($object->getPHID(), array('transactionPHIDs' => mpull($xactions, 'getPHID'))); } if ($this->shouldPublishFeedStory($object, $xactions)) { $mailed = array(); foreach ($messages as $mail) { foreach ($mail->buildRecipientList() as $phid) { $mailed[$phid] = $phid; } } $this->publishFeedStory($object, $xactions, $mailed); } // NOTE: This actually sends the mail. We do this last to reduce the chance // that we send some mail, hit an exception, then send the mail again when // retrying. foreach ($messages as $mail) { $mail->save(); } return $xactions; }
public function save() { if (!$this->getConduitCertificate()) { $this->setConduitCertificate($this->generateConduitCertificate()); } if (!strlen($this->getAccountSecret())) { $this->setAccountSecret(Filesystem::readRandomCharacters(64)); } $result = parent::save(); if ($this->profile) { $this->profile->save(); } $this->updateNameTokens(); PhabricatorSearchWorker::queueDocumentForIndexing($this->getPHID()); return $result; }