Osticket: Tasks are created without body or assignee

Created on 12 Nov 2020  路  6Comments  路  Source: osTicket/osTicket

Prerequisites

  • [ ] Can you reproduce the problem in a fresh installation of the "develop" branch?

    • Can't get it to install, see #5697

  • [x] Do you have any errors in the PHP error log, or javascript console?
  • [x] Did you check the osTicket forums?
  • [x] Did you perform a cursory search to see if your bug or enhancement is already reported?

Description

When attempting to create a task (not based on thread entry) and the draft is saved, an XHR POST request is sent to /scp/ajax.php/draft/task.add with form field c2ab76ae11a00f as the body. osTicket complains in reply that {"error":"Draft body not found in request","code":422}. There is no PHP error or system log entry.
image

When submitting the task to /scp/ajax.php/tasks/add, the HTTP code returned is 201 Created, but the HTML response is the pjax container form with the msg_error message Error adding task - Please try again!. However, the message can't be seen as the page is immediately redirected to the new task ID.

The headers sent to add:
image

If I get a chance I will see what the last version was where task creation worked properly.

Could #5684 be part of this? I know task creation worked last month, at least.

Steps to Reproduce

  1. Log in to the staff CP and attempt to create a new task
  2. Attempt to save a draft of the task body
  3. Attempt to create the task

Expected behavior: New task to be created with body and assignee

Actual behavior: Error is returned while processing task creation and task is created without body or assignee.

Versions

image

Actual commit is 2a88796ec674f65e6eaa0037d1e01b9d885221a0

All 6 comments

@ds6

Two things:
1.) The draft saving issue is related to #5694 BUT I needed to update it to include the Task Description field. I did so only moments ago, so please re-apply the new changes and that should make the drafts work again.

2.) The reason the Assignment isn't being added is because you need #5696. Apply the changes from the above pull and see if that makes the Assignment work again.

As for the missing body, we still have to figure out the root cause of this and get back to you.

Cheers.

@JediKev I'd like to think the body issue would be because of the different form names, but I haven't looked much deeper than surface level so I can't be sure :)

I've applied #5694 and #5696 and while I still got an error when creating the task, the draft saved successfully and I got a draft_id back, and I was able to assign it.

Thank you.

Apply the patch below to address the body issue - we will add to the PR

diff --git a/include/ajax.tasks.php b/include/ajax.tasks.php
index 5ed2f782..07f1bba0 100644
--- a/include/ajax.tasks.php
+++ b/include/ajax.tasks.php
@@ -110,6 +110,7 @@ class TasksAjaxAPI extends AjaxController {
                 $vars['default_formdata'] = $form->getClean();
                 $vars['internal_formdata'] = $iform->getClean();
                 $desc = $form->getField('description');
+                $vars['description'] = $desc->getClean();
                 if ($desc
                         && $desc->isAttachmentsEnabled()
                         && ($attachments=$desc->getWidget()->getAttachments()))

Haven't looked at what getField can return, but since there's a check for $desc right below, should it be something like this?

--- a/include/ajax.tasks.php      2020-11-12 14:36:29.261623200 -0600
+++ b/include/ajax.tasks.php      2020-11-13 09:32:40.831174000 -0600
@@ -110,10 +110,12 @@
                 $vars['default_formdata'] = $form->getClean();
                 $vars['internal_formdata'] = $iform->getClean();
                 $desc = $form->getField('description');
-                if ($desc
-                        && $desc->isAttachmentsEnabled()
+                if ($desc) {
+                    $vars['description'] = $desc->getClean();
+                    if ($desc->isAttachmentsEnabled()
                         && ($attachments=$desc->getWidget()->getAttachments()))
                             $vars['files'] = $attachments->getFiles();
+                }
                 $vars['staffId'] = $thisstaff->getId();
                 $vars['poster'] = $thisstaff;
                 $vars['ip_address'] = $_SERVER['REMOTE_ADDR'];

Either way, tasks are fixed with this change. Thank you.

@ds6 - Check is not necessary - description field is a built in field that cannot changed or deleted. If someone managed to do so then the entire task will fail anyhow.

Fixed in 949acc687a6cf2fd1769df2cd5afc2fa0b5346c4, thanks!

Was this page helpful?
0 / 5 - 0 ratings