Unverified Commit 34fb7588 authored by yllen's avatar yllen Committed by GitHub
Browse files

Prevent creation of a task having an empty content; fixes #7737 (#7738)

parent 3eb33b89
......@@ -239,6 +239,12 @@ abstract class CommonITILTask extends CommonDBTM implements CalDAVCompatibleItem
function prepareInputForUpdate($input) {
if (array_key_exists('content', $input) && empty($input['content'])) {
Session::addMessageAfterRedirect(__("You can't remove description of a task."),
false, ERROR);
return false;
}
Toolbox::manageBeginAndEndPlanDates($input['plan']);
if (isset($input['_planningrecall'])) {
......@@ -395,8 +401,15 @@ abstract class CommonITILTask extends CommonDBTM implements CalDAVCompatibleItem
function prepareInputForAdd($input) {
$itemtype = $this->getItilObjectItemType();
if (empty($input['content'])) {
Session::addMessageAfterRedirect(__("You can't add a task without description."),
false, ERROR);
return false;
}
if (!isset($input['uuid'])) {
$input['uuid'] = \Ramsey\Uuid\Uuid::uuid4();
}
......
......@@ -105,6 +105,7 @@ class PlanningCsv extends \DbTestCase {
$edate = clone $date;
$edate->add(new \DateInterval('P2D'));
$input = [
'content' => sprintf('Task with "%s" state', $taskstate),
'state' => $taskstate,
'tickets_id' => $tid,
'users_id_tech' => \Session::getLoginUserID(),
......
......@@ -172,6 +172,7 @@ class ProjectTask extends DbTestCase {
$ttask = new \TicketTask();
$ttask_id = (int)$ttask->add([
'name' => 'A ticket task in bounds',
'content' => 'A ticket task in bounds',
'tickets_id' => $tid,
'plan' => [
'begin' => '2019-08-11',
......
......@@ -200,6 +200,7 @@ class TicketTask extends DbTestCase {
foreach ($tasksstates as $taskstate) {
$this->integer(
$task->add([
'content' => sprintf('Task with "%s" state', $taskstate),
'state' => $taskstate,
'tickets_id' => $ticketId,
'users_id_tech'=> $uid
......@@ -237,6 +238,7 @@ class TicketTask extends DbTestCase {
foreach ($tasksstates as $taskstate) {
$this->integer(
$task->add([
'content' => sprintf('Task with "%s" state', $taskstate),
'state' => $taskstate,
'tickets_id' => $ticketId,
'users_id_tech'=> $uid
......@@ -278,6 +280,7 @@ class TicketTask extends DbTestCase {
$this->integer(
(int)$ttask->add([
'name' => 'first test, whole period',
'content' => 'first test, whole period',
'tickets_id' => $tid,
'plan' => [
'begin' => '2019-08-10',
......@@ -292,6 +295,7 @@ class TicketTask extends DbTestCase {
$this->integer(
(int)$ttask->add([
'name' => 'test, subperiod',
'content' => 'test, subperiod',
'tickets_id' => $tid,
'plan' => [
'begin' => '2019-08-13',
......@@ -316,6 +320,7 @@ class TicketTask extends DbTestCase {
$this->integer(
(int)$ttask->add([
'name' => 'first test, whole period',
'content' => 'first test, whole period',
'tickets_id' => $tid,
'plan' => [
'begin' => '2018-08-10',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment