protected function loadPage()
 {
     $table = new HarbormasterBuildable();
     $conn_r = $table->establishConnection('r');
     $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
     return $table->loadAllFromArray($data);
 }
 protected function applyCustomExternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case DifferentialTransaction::TYPE_ACTION:
             return;
         case DifferentialTransaction::TYPE_INLINE:
             $reply = $xaction->getComment()->getReplyToComment();
             if ($reply && !$reply->getHasReplies()) {
                 $reply->setHasReplies(1)->save();
             }
             return;
         case DifferentialTransaction::TYPE_UPDATE:
             // Now that we're inside the transaction, do a final check.
             $diff = $this->requireDiff($xaction->getNewValue());
             // TODO: It would be slightly cleaner to just revalidate this
             // transaction somehow using the same validation code, but that's
             // not easy to do at the moment.
             $revision_id = $diff->getRevisionID();
             if ($revision_id && $revision_id != $object->getID()) {
                 throw new Exception(pht('Diff is already attached to another revision. You lost ' . 'a race?'));
             }
             // TODO: This can race with diff updates, particularly those from
             // Harbormaster. See discussion in T8650.
             $diff->setRevisionID($object->getID());
             $diff->save();
             // Update Harbormaster to set the containerPHID correctly for any
             // existing buildables. We may otherwise have buildables stuck with
             // the old (`null`) container.
             // TODO: This is a bit iffy, maybe we can find a cleaner approach?
             // In particular, this could (rarely) be overwritten by Harbormaster
             // workers.
             $table = new HarbormasterBuildable();
             $conn_w = $table->establishConnection('w');
             queryfx($conn_w, 'UPDATE %T SET containerPHID = %s WHERE buildablePHID = %s', $table->getTableName(), $object->getPHID(), $diff->getPHID());
             return;
     }
     return parent::applyCustomExternalTransaction($object, $xaction);
 }