- Issue created by @swirt
- Assigned to dmundra
- Merge request !4Switching out hardcoded link in logger with a link that appears in operations.... β (Merged) created by dmundra
- Status changed to Needs review
8 months ago 10:38pm 27 March 2024 - πΊπΈUnited States dmundra Eugene, OR
@swirt MR https://git.drupalcode.org/project/codit_batch_operations/-/merge_reques... is ready for you review. QA steps:
1. Pull down changes.
2. Run drush codit-batch-operations:run TestDo10Things
3. Navigate to 'Reports' -> 'Recent log messages'.
4. Confirm you see 'BatchOpLog' under the 'Operations' column.
5. Click 'BatchOpLog' and confirm it takes you to the log page for that batch operation.
6. Run drush codit-batch-operations:run TestDo10ThingsWithError.
7. Repeat steps 3 to 5. - Status changed to Needs work
8 months ago 1:58am 28 March 2024 - πΊπΈUnited States swirt Florida
@dmundra, This is looking quite good. Thank you for working on this.
It works perfectly for the use of both
Run drush codit-batch-operations:run TestDo10Things
Run drush codit-batch-operations:run TestDo10ThingsWithErrorHowever I am getting a fatal error when trying to run the latter with the `--allow-skip` option
ddev drush codit-batch-operations:run TestDo10ThingsWithError --allow-skip Codit Batch Operations: Parameter "batch_op_log" for route "entity.batch_op_log.canonical" must match "[^/]++" ("" given) to generate a corresponding URL.
When the error happens, the log is never even saved initially. This would makes sense because it does not have the BatchOpLog id to make part of the link.
Edge case / perfect storm
I think the cause is a really odd edge case that was there before, but was not really detectable because it just created a bad link and failed silently. Your code did not cause it, just revealed it by failing loudly. If `TestDo10ThingsWithError` is run first prior, it errors at item item 6. Everything is fine because the BatchOpLog has already been saved several times by the time there is an error that falls into the catch, where the $vars are set. However following up with a `TestDo10ThingsWithError --allow-skip` means it picks up at item_6 which is an immediate error and falls into the catch, without the new BatchOpLog ever being saved, so it has no id to create the link from.
I think the solution that would avoid a bunch of unecessary saves, in BatchOpLog::getUri() have it check for the id() and if the id does not exists, call $this->save() then get the id. It is a little odd to put it there, but is the safest and at most would only ever lead to one extra save, as opposed to putting it in the catch where it would lead to one extra per error.
- Status changed to Needs review
8 months ago 9:31pm 28 March 2024 - πΊπΈUnited States dmundra Eugene, OR
Thanks @swirt. Made the changes including adding the edge case. QA steps:
1. Pull down changes.
2. Rundrush codit-batch-operations:run TestDo10Things
3. Navigate to 'Reports' -> 'Recent log messages'.
4. Confirm you see 'BatchOpLog' under the 'Operations' column.
5. Click 'BatchOpLog' and confirm it takes you to the log page for that batch operation.
6. Rundrush codit-batch-operations:run TestDo10ThingsWithError
.
7. Repeat steps 3 to 5.
8. Rundrush codit-batch-operations:run TestDo10ThingsWithError --allow-skip
.
9. Repeat steps 3 to 5. - Status changed to Fixed
8 months ago 3:30am 29 March 2024 - πΊπΈUnited States swirt Florida
This has been merged. It will go out with Beta3
Thank you so much @dmundra for your work on this.
- Status changed to Fixed
8 months ago 3:49am 29 March 2024 - πΊπΈUnited States swirt Florida
This is has been released https://www.drupal.org/node/add/project-release/3424985 β
[#3424985]