Page MenuHomePhabricator

PhrictionDocumentQuery still has a project-respecting hunk of code
Closed, ResolvedPublic

Description

I think we can nuke this thing, but you're more familiar with the code now than I am:

foreach ($documents as $document) {
  $document->attachProject(null);
}

$project_slugs = array();
foreach ($documents as $key => $document) {
  $slug = $document->getSlug();
  if (!PhrictionDocument::isProjectSlug($slug)) {
    continue;
  }
  $project_slugs[$key] = PhrictionDocument::getProjectSlugIdentifier($slug);
}

if ($project_slugs) {
  $projects = id(new PhabricatorProjectQuery())
    ->setViewer($this->getViewer())
    ->withPhrictionSlugs($project_slugs)
    ->execute();
  $projects = mpull($projects, null, 'getPhrictionSlug');
  foreach ($documents as $key => $document) {
    $slug = idx($project_slugs, $key);
    if ($slug) {
      $project = idx($projects, $slug);
      if (!$project) {
        unset($documents[$key]);
        continue;
      }
      $document->attachProject($project);
    }
  }
}

Specifically, this means that project pages still have an aura of magic to them -- for example, I can't view this page:

https://secure.phabricator.com/w/projects/private11/

...even though the document has public/users policies.