From aeae33b7d61fc11d1eff38f0fa96391f440dbcf1 Mon Sep 17 00:00:00 2001 From: hunterbridges Date: Mon, 25 Jul 2011 17:34:56 -0500 Subject: [PATCH] Key Value Store for ManiphestTask Test Plan: Look at a task detail. Some dummy attributes are automatically added in ManiphestTaskDetailController. Reviewed By: epriestley Differential Revision: 730 --- .gitignore | 3 ++ .../patches/068.maniphestauxiliarystorage.sql | 9 +++++ src/__phutil_library_map__.php | 2 + .../ManiphestTaskDetailController.php | 1 - .../ManiphestTaskAuxiliaryStorage.php | 28 ++++++++++++++ .../maniphest/storage/auxiliary/__init__.php | 12 ++++++ .../maniphest/storage/task/ManiphestTask.php | 38 +++++++++++++++++++ .../maniphest/storage/task/__init__.php | 1 + 8 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 resources/sql/patches/068.maniphestauxiliarystorage.sql create mode 100644 src/applications/maniphest/storage/auxiliary/ManiphestTaskAuxiliaryStorage.php create mode 100644 src/applications/maniphest/storage/auxiliary/__init__.php diff --git a/.gitignore b/.gitignore index 4b1b47df26..8e3a6a3135 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ *# *~ *.swp + +# NetBeans project files +/nbproject/ diff --git a/resources/sql/patches/068.maniphestauxiliarystorage.sql b/resources/sql/patches/068.maniphestauxiliarystorage.sql new file mode 100644 index 0000000000..df6978d731 --- /dev/null +++ b/resources/sql/patches/068.maniphestauxiliarystorage.sql @@ -0,0 +1,9 @@ +create table phabricator_maniphest.maniphest_taskauxiliarystorage + (id int unsigned not null auto_increment primary key, + taskPHID varchar(64) binary not null, + name varchar(255) not null, + value varchar(255) not null, + unique key (taskPHID,name), + dateCreated int unsigned not null, + dateModified int unsigned not null) + ENGINE = InnoDB; \ No newline at end of file diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index c82f070a3b..41c226eeb4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -268,6 +268,7 @@ phutil_register_library_map(array( 'ManiphestDAO' => 'applications/maniphest/storage/base', 'ManiphestReplyHandler' => 'applications/maniphest/replyhandler', 'ManiphestTask' => 'applications/maniphest/storage/task', + 'ManiphestTaskAuxiliaryStorage' => 'applications/maniphest/storage/auxiliary', 'ManiphestTaskDescriptionChangeController' => 'applications/maniphest/controller/descriptionchange', 'ManiphestTaskDetailController' => 'applications/maniphest/controller/taskdetail', 'ManiphestTaskEditController' => 'applications/maniphest/controller/taskedit', @@ -826,6 +827,7 @@ phutil_register_library_map(array( 'ManiphestDAO' => 'PhabricatorLiskDAO', 'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler', 'ManiphestTask' => 'ManiphestDAO', + 'ManiphestTaskAuxiliaryStorage' => 'ManiphestDAO', 'ManiphestTaskDescriptionChangeController' => 'ManiphestController', 'ManiphestTaskDetailController' => 'ManiphestController', 'ManiphestTaskEditController' => 'ManiphestController', diff --git a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php index 3029af60eb..f350929f2b 100644 --- a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php @@ -141,7 +141,6 @@ class ManiphestTaskDetailController extends ManiphestController { } } - $dict['Description'] = '
'. '
'. diff --git a/src/applications/maniphest/storage/auxiliary/ManiphestTaskAuxiliaryStorage.php b/src/applications/maniphest/storage/auxiliary/ManiphestTaskAuxiliaryStorage.php new file mode 100644 index 0000000000..d1d9fbdb8a --- /dev/null +++ b/src/applications/maniphest/storage/auxiliary/ManiphestTaskAuxiliaryStorage.php @@ -0,0 +1,28 @@ +removeAuxiliaryAttribute($key); + + $attribute = new ManiphestTaskAuxiliaryStorage(); + $attribute->setTaskPHID($this->phid); + $attribute->setName($key); + $attribute->setValue($val); + $attribute->save(); + } + + public function loadAuxiliaryAttribute($key) { + $attribute = id(new ManiphestTaskAuxiliaryStorage())->loadOneWhere( + 'taskPHID = %s AND name = %s', + $this->getPHID(), + $key); + + return $attribute; + } + + public function removeAuxiliaryAttribute($key) { + $attribute = id(new ManiphestTaskAuxiliaryStorage())->loadOneWhere( + 'taskPHID = %s AND name = %s', + $this->getPHID(), + $key); + + if ($attribute) { + $attribute->delete(); + } + } + + public function loadAuxiliaryAttributes() { + $attributes = id(new ManiphestTaskAuxiliaryStorage())->loadAllWhere( + 'taskPHID = %s', + $this->getPHID()); + + return $attributes; + } + public function save() { if (!$this->mailKey) { $this->mailKey = sha1(Filesystem::readRandomBytes(20)); diff --git a/src/applications/maniphest/storage/task/__init__.php b/src/applications/maniphest/storage/task/__init__.php index 42038f4e2d..ec466125bf 100644 --- a/src/applications/maniphest/storage/task/__init__.php +++ b/src/applications/maniphest/storage/task/__init__.php @@ -6,6 +6,7 @@ +phutil_require_module('phabricator', 'applications/maniphest/storage/auxiliary'); phutil_require_module('phabricator', 'applications/maniphest/storage/base'); phutil_require_module('phabricator', 'applications/maniphest/storage/subscriber'); phutil_require_module('phabricator', 'applications/maniphest/storage/taskproject');