Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When checking for open task items in a local task, the query refers to task_item->id() instead of task->id().
Any correct result in the past has been pure coincidence.
$unclosed_tasks = \Drupal::entityQuery('tmgmt_local_task_item')
->condition('tltid', $task_item->id())
->condition('status', LocalTaskItemInterface::STATUS_CLOSED, '<>')
->count()
->execute();
Comment | File | Size | Author |
---|---|---|---|
#14 | tmgmt_2772807_task_14_test_only.patch | 969 bytes | miro_dietiker |
| |||
#12 | unclosed_query_2772807_12_0.patch | 1.61 KB | cgalli |
| |||
#10 | unclosed_query_2772807_7.patch | 1.61 KB | cgalli |
#3 | unclosed_query_2772807.patch | 680 bytes | cgalli |
|
Comments
Comment #2
cgalli CreditAttribution: cgalli commentedComment #3
cgalli CreditAttribution: cgalli as a volunteer commentedCorrection patch
Comment #4
BerdirI don't think that's enough, the condition is still on the task item id?
Will also need tests.
Comment #5
cgalli CreditAttribution: cgalli as a volunteer commentedhmm. it takes the task from task_item and then the id of the task...
$task_item->getTask() returns the task to which the item belongs.
Comment #6
cgalli CreditAttribution: cgalli as a volunteer commentedyes, I see...
will look at tests
Comment #7
miro_dietiker@Berdir isn't tltid the task ID? I think it is...
Comment #8
Berdirright, the other is iid or so, I hate those ids :)
Comment #9
BerdirHowever, as mentioned, the whole code block is the in the wrong place, just like job_item/job, this second part should live in a hook that listens on task items being closed. If there is ever another scenario where a task item can be closed then it wouldn't work.
Comment #10
cgalli CreditAttribution: cgalli as a volunteer commentedWith the patch, the query gets all task items that have the same task (tltid) and are not yet closed, then counts them. If none left, then the complete task can be closed. Correct?
The test checks that the task is not closed after saving only the first task item as completed. I am unsure if that is sufficient.
Comment #12
cgalli CreditAttribution: cgalli as a volunteer commentedCorrect Syntax for the test....
Comment #13
cgalli CreditAttribution: cgalli as a volunteer commentedComment #14
miro_dietikerSubmitting a test-only patch, hopefully see it fail.
Comment #15
miro_dietikerA test-only patch needs to fail. otherwise it doesn't check what it's supposed to check: the current bug!
Plus yeah, the Berdir refactoring. :-)
Comment #16
Berdirlikely just needs to clear static cache and re-load the task to see the change.
If we don't already, we should also confirm that the task is closed at the end, but I hope we do that already
Comment #17
cgalli CreditAttribution: cgalli as a volunteer commentedIt depends.
The bug is such that it does not occur in all circumstances (see miros and christophes manual testing on 26 Jul), so the test will not always fail. But the test will make sure that the bug does not lead to false results.
IMHO there is no other possible test as the bug falsely closes the task without touching the items.
As berdir said, testing the task in the end for being closed. This is covered by: