<?php

final class PhabricatorProfilePanelPHIDType
  extends PhabricatorPHIDType {

  const TYPECONST = 'PANL';

  public function getTypeName() {
    return pht('Profile Panel');
  }

  public function newObject() {
    return new PhabricatorProfilePanelConfiguration();
  }

  public function getPHIDTypeApplicationClass() {
    return 'PhabricatorSearchApplication';
  }

  protected function buildQueryForObjects(
    PhabricatorObjectQuery $object_query,
    array $phids) {
    return id(new PhabricatorProfilePanelConfigurationQuery())
      ->withPHIDs($phids);
  }

  public function loadHandles(
    PhabricatorHandleQuery $query,
    array $handles,
    array $objects) {

    foreach ($handles as $phid => $handle) {
      $config = $objects[$phid];

      $handle->setName(pht('Profile Panel'));
      $handle->setURI($config->getURI());
    }
  }

}

<?php

final class PhabricatorProfilePanelPHIDType
  extends PhabricatorPHIDType {

  const TYPECONST = 'PANL';

  public function getTypeName() {
    return pht('Profile Panel');
  }

  public function newObject() {
    return new PhabricatorProfilePanelConfiguration();
  }

  public function getPHIDTypeApplicationClass() {
    return 'PhabricatorSearchApplication';
  }

  protected function buildQueryForObjects(
    PhabricatorObjectQuery $object_query,
    array $phids) {
    return id(new PhabricatorProfilePanelConfigurationQuery())
      ->withPHIDs($phids);
  }

  public function loadHandles(
    PhabricatorHandleQuery $query,
    array $handles,
    array $objects) {

    foreach ($handles as $phid => $handle) {
      $config = $objects[$phid];

      $handle->setName(pht('Profile Panel'));
    }
  }

}

Fix a bad getURI() call in Profile Panel handle construction
Fix a bad getURI() call in Profile Panel handle construction

Summary:
Fixes T11285. We can end up loading panel handles while processing edits (e.g., disabling menu items on a project). We probably started loading these after the modular transaction changes in T9789, which load the handle for the transaction object unconditionally.

The handles aren't too useful, but they currently fail to load/build because panels don't have a URI. We could give them some sort of method here, but just nuke it for now since they don't appear anywhere and this unclogs the daemon queue.

Test Plan:
  - Disabled a menu item on a project.
  - Ran publish task with `bin/worker execute --id <id>`.
  - Before patch: fatal on getURI() with stack trace similar to T11285.
  - After patch: clean execution.

Reviewers: chad, avivey

Reviewed By: avivey

Maniphest Tasks: T11285

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