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

Reindex dashboards and panels (allow migrations to queue a job to queue other indexing jobs)

Summary:
Depends on D20411. Ref T13272. Dashboards and panels have new indexes (Ferret and usage edges) that need a rebuild.

For large datasets like commits we have the "activity" flow in T11932, but realistically these rebuilds won't take more than a few minutes on any realistic install so we should be able to just queue them up as migrations.

Let migrations insert a job to basically run `bin/search index --type SomeObjectType`, then do that for dashboards and panels.

(I'll do Herald rules in a followup too, but I want to tweak one indexing thing there.)

Test Plan: Ran the migration, ran `bin/phd debug task`, saw everything get indexed with no manual intervention.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13272

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

+67
+7
resources/sql/autopatches/20190412.dashboard.13.rebuild.php
··· 1 + <?php 2 + 3 + PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery( 4 + 'PhabricatorDashboardQuery'); 5 + 6 + PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery( 7 + 'PhabricatorDashboardPanelQuery');
+2
src/__phutil_library_map__.php
··· 4294 4294 'PhabricatorQueryOrderVector' => 'infrastructure/query/order/PhabricatorQueryOrderVector.php', 4295 4295 'PhabricatorQuickSearchEngineExtension' => 'applications/search/engineextension/PhabricatorQuickSearchEngineExtension.php', 4296 4296 'PhabricatorRateLimitRequestExceptionHandler' => 'aphront/handler/PhabricatorRateLimitRequestExceptionHandler.php', 4297 + 'PhabricatorRebuildIndexesWorker' => 'applications/search/worker/PhabricatorRebuildIndexesWorker.php', 4297 4298 'PhabricatorRecaptchaConfigOptions' => 'applications/config/option/PhabricatorRecaptchaConfigOptions.php', 4298 4299 'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php', 4299 4300 'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php', ··· 10503 10504 ), 10504 10505 'PhabricatorQuickSearchEngineExtension' => 'PhabricatorDatasourceEngineExtension', 10505 10506 'PhabricatorRateLimitRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 10507 + 'PhabricatorRebuildIndexesWorker' => 'PhabricatorWorker', 10506 10508 'PhabricatorRecaptchaConfigOptions' => 'PhabricatorApplicationConfigOptions', 10507 10509 'PhabricatorRedirectController' => 'PhabricatorController', 10508 10510 'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController',
+44
src/applications/search/worker/PhabricatorRebuildIndexesWorker.php
··· 1 + <?php 2 + 3 + final class PhabricatorRebuildIndexesWorker extends PhabricatorWorker { 4 + 5 + public static function rebuildObjectsWithQuery($query_class) { 6 + parent::scheduleTask( 7 + __CLASS__, 8 + array( 9 + 'queryClass' => $query_class, 10 + ), 11 + array( 12 + 'priority' => parent::PRIORITY_INDEX, 13 + )); 14 + } 15 + 16 + protected function doWork() { 17 + $viewer = PhabricatorUser::getOmnipotentUser(); 18 + 19 + $data = $this->getTaskData(); 20 + $query_class = idx($data, 'queryClass'); 21 + 22 + try { 23 + $query = newv($query_class, array()); 24 + } catch (Exception $ex) { 25 + throw new PhabricatorWorkerPermanentFailureException( 26 + pht( 27 + 'Unable to instantiate query class "%s": %s', 28 + $query_class, 29 + $ex->getMessage())); 30 + } 31 + 32 + $query->setViewer($viewer); 33 + 34 + $iterator = new PhabricatorQueryIterator($query); 35 + foreach ($iterator as $object) { 36 + PhabricatorSearchWorker::queueDocumentForIndexing( 37 + $object->getPHID(), 38 + array( 39 + 'force' => true, 40 + )); 41 + } 42 + } 43 + 44 + }
+14
src/infrastructure/daemon/workers/__tests__/PhabricatorWorkerTestCase.php
··· 8 8 ); 9 9 } 10 10 11 + protected function willRunOneTest($test) { 12 + parent::willRunOneTest($test); 13 + 14 + // Before we run these test cases, clear the queue. After D20412, we may 15 + // have queued tasks from migrations. 16 + $task_table = new PhabricatorWorkerActiveTask(); 17 + $conn = $task_table->establishConnection('w'); 18 + 19 + queryfx( 20 + $conn, 21 + 'TRUNCATE %R', 22 + $task_table); 23 + } 24 + 11 25 public function testLeaseTask() { 12 26 $task = $this->scheduleTask(); 13 27 $this->expectNextLease($task, pht('Leasing should work.'));