diff --git a/include/class.queue.php b/include/class.queue.php index 3d2c8f365db3692851d77867b4d493e50ae51254..e3212c502929ddbaa93785eca9f72a9f46007617 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -1349,11 +1349,10 @@ class CustomQueue extends VerySimpleModel { $nopath = !isset($this->path); $path_changed = isset($this->dirty['parent_id']); - if ($this->dirty) { + if ($this->dirty) $this->updated = SqlFunction::NOW(); - // Refetch the queue counts - SavedQueue::clearCounts(); - } + + $clearCounts = ($this->dirty || $this->__new__); if (!($rv = parent::save($refetch || $this->dirty))) return $rv; @@ -1372,6 +1371,11 @@ class CustomQueue extends VerySimpleModel { }; $move_children($this); } + + // Refetch the queue counts + if ($clearCounts) + SavedQueue::clearCounts(); + return $this->columns->saveAll() && $this->exports->saveAll() && $this->sorts->saveAll(); diff --git a/scp/autocron.php b/scp/autocron.php index 5f5da4fb29747af6e32e9c10533de6ea98c11527..cc124455f3a246ef97f37ce3fe7482d8d9797e93 100644 --- a/scp/autocron.php +++ b/scp/autocron.php @@ -47,7 +47,7 @@ require_once(INCLUDE_DIR.'class.cron.php'); // Run tickets count every 3rd run or so... force new count by skipping cached // results -if (mt_rand(1, 12) == 3) +if ((mt_rand(1, 12) % 3) == 0) SavedQueue::counts($thisstaff, array(), false); // Clear staff obj to avoid false credit internal notes & auto-assignment