summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-17 14:56:31 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-17 14:56:31 -0500
commite94c4cab7f79657f8b514b4af6c4e459e9b42961 (patch)
tree4986bdff7f1b1b401ff819642a1bab8d1d1c9a39
parent1259e911e4316f9f1ae401f4f293da69d9ba9e78 (diff)
Avoid automatic actions that change the color to fire subsequent events
-rw-r--r--ChangeLog1
-rw-r--r--app/Action/Base.php19
-rw-r--r--app/Action/TaskAssignColorCategory.php2
-rw-r--r--app/Action/TaskAssignColorColumn.php2
-rw-r--r--app/Action/TaskAssignColorLink.php2
-rw-r--r--app/Action/TaskAssignColorUser.php2
-rw-r--r--app/Model/TaskCreation.php3
-rw-r--r--app/Model/TaskModification.php8
-rw-r--r--app/Model/TaskPosition.php9
-rw-r--r--app/Model/TaskStatus.php6
10 files changed, 34 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 39394db6..b0d7ccd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,7 @@ Bug fixes:
* Automatic action listeners were using the same instance
* Fix wrong link for category in task footer
* Unable to set currency rate with Postgres database
+* Avoid automatic actions that change the color to fire subsequent events
Version 1.0.23
--------------
diff --git a/app/Action/Base.php b/app/Action/Base.php
index 1298aec2..efc52f04 100644
--- a/app/Action/Base.php
+++ b/app/Action/Base.php
@@ -119,7 +119,13 @@ abstract class Base extends \Kanboard\Core\Base
*/
public function __toString()
{
- return $this->getName();
+ $params = array();
+
+ foreach ($this->params as $key => $value) {
+ $params[] = $key.'='.var_export($value, true);
+ }
+
+ return $this->getName().'('.implode('|', $params).'])';
}
/**
@@ -246,16 +252,17 @@ abstract class Base extends \Kanboard\Core\Base
}
$data = $event->getAll();
- $result = false;
+ $executable = $this->isExecutable($data, $eventName);
+ $executed = false;
- if ($this->isExecutable($data, $eventName)) {
+ if ($executable) {
$this->called = true;
- $result = $this->doAction($data);
+ $executed = $this->doAction($data);
}
- $this->logger->debug('AutomaticAction '.$this->getName().' => '.($result ? 'true' : 'false'));
+ $this->logger->debug($this.' ['.$eventName.'] => executable='.var_export($executable, true).' exec_success='.var_export($executed, true));
- return $result;
+ return $executed;
}
/**
diff --git a/app/Action/TaskAssignColorCategory.php b/app/Action/TaskAssignColorCategory.php
index 3a15b15f..139c24cb 100644
--- a/app/Action/TaskAssignColorCategory.php
+++ b/app/Action/TaskAssignColorCategory.php
@@ -78,7 +78,7 @@ class TaskAssignColorCategory extends Base
'color_id' => $this->getParam('color_id'),
);
- return $this->taskModification->update($values);
+ return $this->taskModification->update($values, false);
}
/**
diff --git a/app/Action/TaskAssignColorColumn.php b/app/Action/TaskAssignColorColumn.php
index 7474045b..92412739 100644
--- a/app/Action/TaskAssignColorColumn.php
+++ b/app/Action/TaskAssignColorColumn.php
@@ -79,7 +79,7 @@ class TaskAssignColorColumn extends Base
'color_id' => $this->getParam('color_id'),
);
- return $this->taskModification->update($values);
+ return $this->taskModification->update($values, false);
}
/**
diff --git a/app/Action/TaskAssignColorLink.php b/app/Action/TaskAssignColorLink.php
index f71df70e..12ceabb3 100644
--- a/app/Action/TaskAssignColorLink.php
+++ b/app/Action/TaskAssignColorLink.php
@@ -78,7 +78,7 @@ class TaskAssignColorLink extends Base
'color_id' => $this->getParam('color_id'),
);
- return $this->taskModification->update($values);
+ return $this->taskModification->update($values, false);
}
/**
diff --git a/app/Action/TaskAssignColorUser.php b/app/Action/TaskAssignColorUser.php
index 6e56bdc5..6ec8ce95 100644
--- a/app/Action/TaskAssignColorUser.php
+++ b/app/Action/TaskAssignColorUser.php
@@ -79,7 +79,7 @@ class TaskAssignColorUser extends Base
'color_id' => $this->getParam('color_id'),
);
- return $this->taskModification->update($values);
+ return $this->taskModification->update($values, false);
}
/**
diff --git a/app/Model/TaskCreation.php b/app/Model/TaskCreation.php
index 88912d4d..975cc7a3 100644
--- a/app/Model/TaskCreation.php
+++ b/app/Model/TaskCreation.php
@@ -88,6 +88,9 @@ class TaskCreation extends Base
{
$event = new TaskEvent(array('task_id' => $task_id) + $values);
+ $this->logger->debug('Event fired: '.Task::EVENT_CREATE_UPDATE);
+ $this->logger->debug('Event fired: '.Task::EVENT_CREATE);
+
$this->dispatcher->dispatch(Task::EVENT_CREATE_UPDATE, $event);
$this->dispatcher->dispatch(Task::EVENT_CREATE, $event);
diff --git a/app/Model/TaskModification.php b/app/Model/TaskModification.php
index 781646b8..5f0fd074 100644
--- a/app/Model/TaskModification.php
+++ b/app/Model/TaskModification.php
@@ -17,16 +17,17 @@ class TaskModification extends Base
*
* @access public
* @param array $values
+ * @param boolean $fire_events
* @return boolean
*/
- public function update(array $values)
+ public function update(array $values, $fire_events = true)
{
$original_task = $this->taskFinder->getById($values['id']);
$this->prepare($values);
$result = $this->db->table(Task::TABLE)->eq('id', $original_task['id'])->update($values);
- if ($result) {
+ if ($fire_events && $result) {
$this->fireEvents($original_task, $values);
}
@@ -57,7 +58,8 @@ class TaskModification extends Base
}
foreach ($events as $event) {
- $this->container['dispatcher']->dispatch($event, new TaskEvent($event_data));
+ $this->logger->debug('Event fired: '.$event);
+ $this->dispatcher->dispatch($event, new TaskEvent($event_data));
}
}
diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php
index 762f7fe3..091d908d 100644
--- a/app/Model/TaskPosition.php
+++ b/app/Model/TaskPosition.php
@@ -177,11 +177,14 @@ class TaskPosition extends Base
);
if ($task['swimlane_id'] != $new_swimlane_id) {
- $this->container['dispatcher']->dispatch(Task::EVENT_MOVE_SWIMLANE, new TaskEvent($event_data));
+ $this->logger->debug('Event fired: '.Task::EVENT_MOVE_SWIMLANE);
+ $this->dispatcher->dispatch(Task::EVENT_MOVE_SWIMLANE, new TaskEvent($event_data));
} elseif ($task['column_id'] != $new_column_id) {
- $this->container['dispatcher']->dispatch(Task::EVENT_MOVE_COLUMN, new TaskEvent($event_data));
+ $this->logger->debug('Event fired: '.Task::EVENT_MOVE_COLUMN);
+ $this->dispatcher->dispatch(Task::EVENT_MOVE_COLUMN, new TaskEvent($event_data));
} elseif ($task['position'] != $new_position) {
- $this->container['dispatcher']->dispatch(Task::EVENT_MOVE_POSITION, new TaskEvent($event_data));
+ $this->logger->debug('Event fired: '.Task::EVENT_MOVE_POSITION);
+ $this->dispatcher->dispatch(Task::EVENT_MOVE_POSITION, new TaskEvent($event_data));
}
}
}
diff --git a/app/Model/TaskStatus.php b/app/Model/TaskStatus.php
index afb5ffb5..2b902815 100644
--- a/app/Model/TaskStatus.php
+++ b/app/Model/TaskStatus.php
@@ -113,10 +113,8 @@ class TaskStatus extends Base
));
if ($result) {
- $this->container['dispatcher']->dispatch(
- $event,
- new TaskEvent(array('task_id' => $task_id) + $this->taskFinder->getById($task_id))
- );
+ $this->logger->debug('Event fired: '.$event);
+ $this->dispatcher->dispatch($event, new TaskEvent(array('task_id' => $task_id) + $this->taskFinder->getById($task_id)));
}
return $result;