Page MenuHomePhabricator

Unable to query Diviner atoms by PHID
Closed, ResolvedPublic

Description

As discussed in IRC, I can't query Diviner atoms by PHID. To verify this, I used the following script:

<?php

require_once '/usr/src/phabricator/scripts/__init_script__.php';

$phid = 'PHID-ATOM-voo47pa4nqtyotr3hoag';

$atoms = id(new DivinerAtomQuery())
  ->setViewer(PhabricatorUser::getOmnipotentUser())
  ->withPHIDs(array($phid))
  ->execute();
echo pht('Returned %d results.', count($atoms))."\n";

$table  = new DivinerLiveSymbol();
$conn_r = $table->establishConnection('r');

$atoms = queryfx_all(
  $conn_r,
  'SELECT * FROM %T WHERE phid = %s',
  $table->getTableName(),
  $phid);
echo pht('Returned %d results.', count($atoms))."\n";

The output was as follows:

Returned 0 results.
Returned 1 results.

Revisions and Commits

Restricted Differential Revision

Event Timeline

joshuaspence raised the priority of this task from to Needs Triage.
joshuaspence updated the task description. (Show Details)
joshuaspence added a project: Diviner.
joshuaspence added subscribers: joshuaspence, epriestley.

Adding PhutilArgumentParser and --trace gives me the following output:

>>> [2] <connect> phabricator_diviner
<<< [2] <connect> 5,666 us
>>> [3] <query> SELECT * FROM `diviner_livesymbol` WHERE (phid IN ('PHID-ATOM-voo47pa4nqtyotr3hoag')) AND (isDocumentable = 1) AND (graphHash IS NOT NULL) ORDER BY `id` DESC 
<<< [3] <query> 535 us
Returned 0 results.
>>> [4] <query> SELECT * FROM `diviner_livesymbol` WHERE phid = 'PHID-ATOM-voo47pa4nqtyotr3hoag'
<<< [4] <query> 193 us
Returned 1 results.

So it seems that the issue is that the atom that I randomly chose for my test had isDocumentable = false.

@epriestley, could we simply invert the logic of DivinerAtomQuery so that it returns undocumentable atoms by default (and add withExcludeUndocumentable(true) to all existing callsites?

Yeah, that seems reasonable to me.

joshuaspence added a revision: Restricted Differential Revision.Jun 4 2015, 9:04 PM
joshuaspence closed this task as Resolved by committing Restricted Diffusion Commit.Jun 4 2015, 9:23 PM
joshuaspence added a commit: Restricted Diffusion Commit.