Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncating ta_tasks and ta_task_executions leads to an error in the admin area #49

Open
PatrickJuergens opened this issue May 1, 2021 · 4 comments
Assignees
Labels

Comments

@PatrickJuergens
Copy link

Q A
Bug? yes
New Feature? no
Bundle Version b91b731
Sulu Version 2.1.8
Browser Version Browser name and version

Actual Behavior

If the two tables ta_tasks and ta_task_executions are truncated via the database, there are still references left in the content that lead to a 500:

The identifier uuid is missing for a query of Task\TaskBundle\Entity\Task in vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php (line 315) in vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php :: missingIdentifierField (line 422) in vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php -> find (line 151) in vendor/php-task/task-bundle/src/Entity/TaskRepository.php -> find (line 37) in vendor/sulu/automation-bundle/Controller/TaskController.php -> findByUuid (line 179) in vendor/sulu/automation-bundle/Controller/TaskController.php -> extendResponseItem (line 143) in vendor/symfony/http-kernel/HttpKernel.php -> cgetAction (line 158) in vendor/symfony/http-kernel/HttpKernel.php -> handleRaw (line 80) in vendor/symfony/http-kernel/Kernel.php -> handle (line 201)

Expected Behavior

If the tables are empty and there are references in the content, this should not lead to an error.

Steps to Reproduce

Create a task for a specific content
Execute the task
Empty the two tables ta_tasks, ta_task_executions
Call the automation overview via the admin area for the specific content

Possible Solutions

        try {
            $task = $this->taskRepository->findByUuid($item['taskId']);
            $executions = $this->taskExecutionRepository->findByTask($task);
            if (0 < count($executions)) {
                $item['status'] = $executions[0]->getStatus();
            }
        } catch (\Exception $exception) {
        }
@alexander-schranz
Copy link
Member

alexander-schranz commented May 1, 2021

@PatrickJuergens Thanks for reporting!

Something like the ORMException is unexpected and is not something we should use catch on it. If I understand correctly the $item['taskId'] returns a uuid which is not longer in the database. Then I think the TaskRepository should throw a TaskNotFoundException we could catch here as we should not run into a ORMException in any case. /cc @wachterjohannes what do you think?

@PatrickJuergens
Copy link
Author

Yes, $item['taskId'] returns an ID that no longer exists in the database, a TaskNotFoundException caught in this case should solve the problem.

@alexander-schranz
Copy link
Member

I think this need then be implemented here: https://github.com/php-task/TaskBundle/blob/dec507fa2143cf6205267f382cb053bf1b42a4c8/src/Entity/TaskRepository.php#L35-L38 that it throws a exception when the entity does not exist. So I think instead of using find which just returns a proxy reference object. It actually should query and then throw the new Exception. Which we then can catch in the automationbundle. Do you wan to create a PR for this?

@PatrickJuergens
Copy link
Author

Yes, I'll try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants