public function setAuxiliaryAttribute($key, $val)
 {
     $this->removeAuxiliaryAttribute($key);
     $attribute = new ManiphestTaskAuxiliaryStorage();
     $attribute->setTaskPHID($this->phid);
     $attribute->setName($key);
     $attribute->setValue($val);
     $attribute->save();
 }
Example #2
0
 private function writeAuxiliaryUpdates()
 {
     $table = new ManiphestTaskAuxiliaryStorage();
     $conn_w = $table->establishConnection('w');
     $update = array();
     $remove = array();
     foreach ($this->auxiliaryDirty as $key => $dirty) {
         $value = $this->getAuxiliaryAttribute($key);
         if ($value === null) {
             $remove[$key] = true;
         } else {
             $update[$key] = $value;
         }
     }
     if ($remove) {
         queryfx($conn_w, 'DELETE FROM %T WHERE taskPHID = %s AND name IN (%Ls)', $table->getTableName(), $this->getPHID(), array_keys($remove));
     }
     if ($update) {
         $sql = array();
         foreach ($update as $key => $val) {
             $sql[] = qsprintf($conn_w, '(%s, %s, %s)', $this->getPHID(), $key, $val);
         }
         queryfx($conn_w, 'INSERT INTO %T (taskPHID, name, value) VALUES %Q
       ON DUPLICATE KEY UPDATE value = VALUES(value)', $table->getTableName(), implode(', ', $sql));
     }
 }