When an entry is logged to Watchdog, display link to BatchOpLog in Operations column

Created on 27 March 2024, 9 months ago
Updated 29 March 2024, 9 months ago

Problem/Motivation

Currently when something is logged to watchdog, the link to the BatchOpLog is included. It would be helpful to surface that link in the "operations" column on the "recent log messages" display.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States swirt Florida

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @swirt
  • πŸ‡ΊπŸ‡ΈUnited States dmundra Eugene, OR
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida

    Crediting dmundra for the suggestion.

  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida
  • Assigned to dmundra
  • πŸ‡ΊπŸ‡ΈUnited States dmundra Eugene, OR
  • Status changed to Needs review 9 months ago
  • πŸ‡ΊπŸ‡Έ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 9 months ago
  • πŸ‡ΊπŸ‡Έ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 TestDo10ThingsWithError

    However 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 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States dmundra Eugene, OR

    Thanks @swirt. Made the changes including adding the edge case. 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.
    8. Run drush codit-batch-operations:run TestDo10ThingsWithError --allow-skip.
    9. Repeat steps 3 to 5.

  • Status changed to Fixed 9 months ago
  • πŸ‡ΊπŸ‡Έ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 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States swirt Florida
Production build 0.71.5 2024