<?php

final class PhabricatorDashboardPanelCoreCustomField
  extends PhabricatorDashboardPanelCustomField
  implements PhabricatorStandardCustomFieldInterface {

  public function getStandardCustomFieldNamespace() {
    return 'dashboard:core';
  }

  public function createFields($object) {
    $impl = $object->requireImplementation();
    $specs = $impl->getFieldSpecifications();
    return PhabricatorStandardCustomField::buildStandardFields($this, $specs);
  }

  public function shouldUseStorage() {
    return false;
  }

  public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
    $key = $this->getProxy()->getRawStandardFieldKey();
    $this->setValueFromStorage($object->getProperty($key));
  }

  public function applyApplicationTransactionInternalEffects(
    PhabricatorApplicationTransaction $xaction) {
    $object = $this->getObject();
    $key = $this->getProxy()->getRawStandardFieldKey();

    $this->setValueFromApplicationTransactions($xaction->getNewValue());
    $value = $this->getValueForStorage();

    $object->setProperty($key, $value);
  }

  public function applyApplicationTransactionExternalEffects(
    PhabricatorApplicationTransaction $xaction) {
    return;
  }

}

<?php

final class PhabricatorDashboardPanelCoreCustomField
  extends PhabricatorDashboardPanelCustomField
  implements PhabricatorStandardCustomFieldInterface {

  public function getStandardCustomFieldNamespace() {
    return 'dashboard:core';
  }

  public function createFields($object) {
    $impl = $object->requireImplementation();
    $specs = $impl->getFieldSpecifications();
    return PhabricatorStandardCustomField::buildStandardFields($this, $specs);
  }

  public function shouldUseStorage() {
    return false;
  }

  public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
    $key = $this->getProxy()->getRawStandardFieldKey();
    $this->setValueFromStorage($object->getProperty($key));
    $this->didSetValueFromStorage();
  }

  public function applyApplicationTransactionInternalEffects(
    PhabricatorApplicationTransaction $xaction) {
    $object = $this->getObject();
    $key = $this->getProxy()->getRawStandardFieldKey();

    $this->setValueFromApplicationTransactions($xaction->getNewValue());
    $value = $this->getValueForStorage();

    $object->setProperty($key, $value);
  }

  public function applyApplicationTransactionExternalEffects(
    PhabricatorApplicationTransaction $xaction) {
    return;
  }

}

Fix overzealous transactions on dashboard panels
Fix overzealous transactions on dashboard panels

Summary: Fixes T10474. This had the same root cause as T10024 -- a missing call to `didSetValueFromStorage()` because of the way the fields work.

Test Plan:
  - Edited a text panel before change, without changing text: got silly transaction.
  - Made change, edited text panel without changing text, no transaction.
  - Made a real edit, got a good transaction.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10474

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