Page MenuHomePhabricator

D8151.diff
No OneTemporary

D8151.diff

Index: resources/sql/autopatches/20140205.cal.2.phid-col.sql
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140205.cal.2.phid-col.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_calendar.calendar_event
+ ADD phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id;
Index: resources/sql/autopatches/20140205.cal.3.phid-mig.php
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140205.cal.3.phid-mig.php
@@ -0,0 +1,22 @@
+<?php
+
+$table = new PhabricatorCalendarEvent();
+$conn_w = $table->establishConnection('w');
+
+echo "Assigning PHIDs to events...\n";
+foreach (new LiskMigrationIterator($table) as $event) {
+ $id = $event->getID();
+
+ echo "Updating event {$id}...\n";
+ if ($event->getPHID()) {
+ continue;
+ }
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET phid = %s WHERE id = %d',
+ $table->getTableName(),
+ $table->generatePHID(),
+ $id);
+}
+echo "Done.\n";
Index: resources/sql/autopatches/20140205.cal.4.phid-key.sql
===================================================================
--- /dev/null
+++ resources/sql/autopatches/20140205.cal.4.phid-key.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_calendar.calendar_event
+ ADD UNIQUE KEY `key_phid` (phid);
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1271,6 +1271,7 @@
'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php',
'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php',
'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php',
+ 'PhabricatorCalendarPHIDTypeEvent' => 'applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php',
'PhabricatorCampfireProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorCampfireProtocolAdapter.php',
'PhabricatorChangeParserTestCase' => 'applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php',
'PhabricatorChangesetResponse' => 'infrastructure/diff/PhabricatorChangesetResponse.php',
@@ -3920,6 +3921,7 @@
'PhabricatorCalendarEventViewController' => 'PhabricatorDashboardController',
'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO',
'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase',
+ 'PhabricatorCalendarPHIDTypeEvent' => 'PhabricatorPHIDType',
'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter',
'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase',
'PhabricatorChangesetResponse' => 'AphrontProxyResponse',
Index: src/applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php
===================================================================
--- /dev/null
+++ src/applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php
@@ -0,0 +1,41 @@
+<?php
+
+final class PhabricatorCalendarPHIDTypeEvent extends PhabricatorPHIDType {
+
+ const TYPECONST = 'CEVT';
+
+ public function getTypeConstant() {
+ return self::TYPECONST;
+ }
+
+ public function getTypeName() {
+ return pht('Event');
+ }
+
+ public function newObject() {
+ return new PhabricatorCalendarEvent();
+ }
+
+ protected function buildQueryForObjects(
+ PhabricatorObjectQuery $query,
+ array $phids) {
+
+ return id(new PhabricatorCalendarEventQuery())
+ ->withPHIDs($phids);
+ }
+
+ public function loadHandles(
+ PhabricatorHandleQuery $query,
+ array $handles,
+ array $objects) {
+
+ foreach ($handles as $phid => $handle) {
+ $event = $objects[$phid];
+
+ $id = $event->getID();
+
+ $handle->setName(pht('Event %d', $id));
+ }
+ }
+
+}
Index: src/applications/calendar/query/PhabricatorCalendarEventQuery.php
===================================================================
--- src/applications/calendar/query/PhabricatorCalendarEventQuery.php
+++ src/applications/calendar/query/PhabricatorCalendarEventQuery.php
@@ -4,6 +4,7 @@
extends PhabricatorCursorPagedPolicyAwareQuery {
private $ids;
+ private $phids;
private $rangeBegin;
private $rangeEnd;
private $invitedPHIDs;
@@ -14,6 +15,11 @@
return $this;
}
+ public function withPHIDs(array $phids) {
+ $this->phids = $phids;
+ return $this;
+ }
+
public function withDateRange($begin, $end) {
$this->rangeBegin = $begin;
$this->rangeEnd = $end;
@@ -55,6 +61,13 @@
$this->ids);
}
+ if ($this->phids) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'phid IN (%Ls)',
+ $this->phids);
+ }
+
if ($this->rangeBegin) {
$where[] = qsprintf(
$conn_r,
Index: src/applications/calendar/storage/PhabricatorCalendarEvent.php
===================================================================
--- src/applications/calendar/storage/PhabricatorCalendarEvent.php
+++ src/applications/calendar/storage/PhabricatorCalendarEvent.php
@@ -34,6 +34,17 @@
return $options[$this->status];
}
+ public function getConfiguration() {
+ return array(
+ self::CONFIG_AUX_PHID => true,
+ ) + parent::getConfiguration();
+ }
+
+ public function generatePHID() {
+ return PhabricatorPHID::generateNewPHID(
+ PhabricatorCalendarPHIDTypeEvent::TYPECONST);
+ }
+
public function getTerseSummary(PhabricatorUser $viewer) {
$until = phabricator_date($this->dateTo, $viewer);
if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) {

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 3:44 AM (17 h, 55 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6791796
Default Alt Text
D8151.diff (5 KB)

Event Timeline