From 6a7b8ec60f265413ca88878dba6180456257d370 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 16 Jan 2016 21:06:36 -0500 Subject: Make sure that some event subscribers are not executed multiple times --- .../ProjectModificationDateSubscriber.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'app/Subscriber/ProjectModificationDateSubscriber.php') diff --git a/app/Subscriber/ProjectModificationDateSubscriber.php b/app/Subscriber/ProjectModificationDateSubscriber.php index 1f99840d..ea102910 100644 --- a/app/Subscriber/ProjectModificationDateSubscriber.php +++ b/app/Subscriber/ProjectModificationDateSubscriber.php @@ -6,25 +6,26 @@ use Kanboard\Event\GenericEvent; use Kanboard\Model\Task; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class ProjectModificationDateSubscriber extends \Kanboard\Core\Base implements EventSubscriberInterface +class ProjectModificationDateSubscriber extends BaseSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() { return array( - Task::EVENT_CREATE_UPDATE => array('execute', 0), - Task::EVENT_CLOSE => array('execute', 0), - Task::EVENT_OPEN => array('execute', 0), - Task::EVENT_MOVE_SWIMLANE => array('execute', 0), - Task::EVENT_MOVE_COLUMN => array('execute', 0), - Task::EVENT_MOVE_POSITION => array('execute', 0), - Task::EVENT_MOVE_PROJECT => array('execute', 0), - Task::EVENT_ASSIGNEE_CHANGE => array('execute', 0), + Task::EVENT_CREATE_UPDATE => 'execute', + Task::EVENT_CLOSE => 'execute', + Task::EVENT_OPEN => 'execute', + Task::EVENT_MOVE_SWIMLANE => 'execute', + Task::EVENT_MOVE_COLUMN => 'execute', + Task::EVENT_MOVE_POSITION => 'execute', + Task::EVENT_MOVE_PROJECT => 'execute', + Task::EVENT_ASSIGNEE_CHANGE => 'execute', ); } public function execute(GenericEvent $event) { - if (isset($event['project_id'])) { + if (isset($event['project_id']) && !$this->isExecuted()) { + $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); $this->project->updateModificationDate($event['project_id']); } } -- cgit v1.2.3 From 47e427457930db38030e1a10e0f3d97a71473371 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 16 Jan 2016 21:48:33 -0500 Subject: Remove __CLASS__ from debug logs --- app/Subscriber/AuthSubscriber.php | 6 +++--- app/Subscriber/BootstrapSubscriber.php | 2 +- app/Subscriber/NotificationSubscriber.php | 2 +- app/Subscriber/ProjectDailySummarySubscriber.php | 2 +- app/Subscriber/ProjectModificationDateSubscriber.php | 2 +- app/Subscriber/RecurringTaskSubscriber.php | 4 ++-- app/Subscriber/SubtaskTimeTrackingSubscriber.php | 4 ++-- app/Subscriber/TransitionSubscriber.php | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) (limited to 'app/Subscriber/ProjectModificationDateSubscriber.php') diff --git a/app/Subscriber/AuthSubscriber.php b/app/Subscriber/AuthSubscriber.php index 250c1fd3..e839385f 100644 --- a/app/Subscriber/AuthSubscriber.php +++ b/app/Subscriber/AuthSubscriber.php @@ -40,7 +40,7 @@ class AuthSubscriber extends BaseSubscriber implements EventSubscriberInterface */ public function afterLogin(AuthSuccessEvent $event) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $userAgent = $this->request->getUserAgent(); $ipAddress = $this->request->getIpAddress(); @@ -71,7 +71,7 @@ class AuthSubscriber extends BaseSubscriber implements EventSubscriberInterface */ public function afterLogout() { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $credentials = $this->rememberMeCookie->read(); if ($credentials !== false) { @@ -92,7 +92,7 @@ class AuthSubscriber extends BaseSubscriber implements EventSubscriberInterface */ public function onLoginFailure(AuthFailureEvent $event) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $username = $event->getUsername(); if (! empty($username)) { diff --git a/app/Subscriber/BootstrapSubscriber.php b/app/Subscriber/BootstrapSubscriber.php index a65cf651..ef0215f3 100644 --- a/app/Subscriber/BootstrapSubscriber.php +++ b/app/Subscriber/BootstrapSubscriber.php @@ -15,7 +15,7 @@ class BootstrapSubscriber extends BaseSubscriber implements EventSubscriberInter public function execute() { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $this->config->setupTranslations(); $this->config->setupTimezone(); $this->actionManager->attachEvents(); diff --git a/app/Subscriber/NotificationSubscriber.php b/app/Subscriber/NotificationSubscriber.php index d3afc13a..07660050 100644 --- a/app/Subscriber/NotificationSubscriber.php +++ b/app/Subscriber/NotificationSubscriber.php @@ -35,7 +35,7 @@ class NotificationSubscriber extends BaseSubscriber implements EventSubscriberIn public function handleEvent(GenericEvent $event, $event_name) { if (! $this->isExecuted($event_name)) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $event_data = $this->getEventData($event); if (! empty($event_data)) { diff --git a/app/Subscriber/ProjectDailySummarySubscriber.php b/app/Subscriber/ProjectDailySummarySubscriber.php index b70eaf71..44138f43 100644 --- a/app/Subscriber/ProjectDailySummarySubscriber.php +++ b/app/Subscriber/ProjectDailySummarySubscriber.php @@ -22,7 +22,7 @@ class ProjectDailySummarySubscriber extends BaseSubscriber implements EventSubsc public function execute(TaskEvent $event) { if (isset($event['project_id']) && !$this->isExecuted()) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $this->projectDailyColumnStats->updateTotals($event['project_id'], date('Y-m-d')); $this->projectDailyStats->updateTotals($event['project_id'], date('Y-m-d')); } diff --git a/app/Subscriber/ProjectModificationDateSubscriber.php b/app/Subscriber/ProjectModificationDateSubscriber.php index ea102910..62804a84 100644 --- a/app/Subscriber/ProjectModificationDateSubscriber.php +++ b/app/Subscriber/ProjectModificationDateSubscriber.php @@ -25,7 +25,7 @@ class ProjectModificationDateSubscriber extends BaseSubscriber implements EventS public function execute(GenericEvent $event) { if (isset($event['project_id']) && !$this->isExecuted()) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $this->project->updateModificationDate($event['project_id']); } } diff --git a/app/Subscriber/RecurringTaskSubscriber.php b/app/Subscriber/RecurringTaskSubscriber.php index a300483d..6d5aee89 100644 --- a/app/Subscriber/RecurringTaskSubscriber.php +++ b/app/Subscriber/RecurringTaskSubscriber.php @@ -18,7 +18,7 @@ class RecurringTaskSubscriber extends BaseSubscriber implements EventSubscriberI public function onMove(TaskEvent $event) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); if ($event['recurrence_status'] == Task::RECURRING_STATUS_PENDING) { if ($event['recurrence_trigger'] == Task::RECURRING_TRIGGER_FIRST_COLUMN && $this->board->getFirstColumn($event['project_id']) == $event['src_column_id']) { @@ -31,7 +31,7 @@ class RecurringTaskSubscriber extends BaseSubscriber implements EventSubscriberI public function onClose(TaskEvent $event) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); if ($event['recurrence_status'] == Task::RECURRING_STATUS_PENDING && $event['recurrence_trigger'] == Task::RECURRING_TRIGGER_CLOSE) { $this->taskDuplication->duplicateRecurringTask($event['task_id']); diff --git a/app/Subscriber/SubtaskTimeTrackingSubscriber.php b/app/Subscriber/SubtaskTimeTrackingSubscriber.php index 5e4b2225..c0852bc8 100644 --- a/app/Subscriber/SubtaskTimeTrackingSubscriber.php +++ b/app/Subscriber/SubtaskTimeTrackingSubscriber.php @@ -23,7 +23,7 @@ class SubtaskTimeTrackingSubscriber extends BaseSubscriber implements EventSubsc public function updateTaskTime(SubtaskEvent $event) { if (isset($event['task_id'])) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $this->subtaskTimeTracking->updateTaskTimeTracking($event['task_id']); } } @@ -31,7 +31,7 @@ class SubtaskTimeTrackingSubscriber extends BaseSubscriber implements EventSubsc public function logStartEnd(SubtaskEvent $event) { if (isset($event['status']) && $this->config->get('subtask_time_tracking') == 1) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $subtask = $this->subtask->getById($event['id']); if (empty($subtask['user_id'])) { diff --git a/app/Subscriber/TransitionSubscriber.php b/app/Subscriber/TransitionSubscriber.php index df59aa72..bd537484 100644 --- a/app/Subscriber/TransitionSubscriber.php +++ b/app/Subscriber/TransitionSubscriber.php @@ -17,7 +17,7 @@ class TransitionSubscriber extends BaseSubscriber implements EventSubscriberInte public function execute(TaskEvent $event) { - $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__); + $this->logger->debug('Subscriber executed: '.__METHOD__); $user_id = $this->userSession->getId(); -- cgit v1.2.3