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.
Problem/Motivation
When an exception occurs meanwhile a VBO operation is processing the following error screen is visible and its content is not too meaningful. A simple user has no clue what went wrong and how it could be fixed.
Background story: I added some custom logic to a hook_node_delete() implementation to prevent removal of certain nodes.
Proposed resolution
Catch exceptions meanwhile a VBO operation is processing items and report them to user after operation is finished.
Comment | File | Size | Author |
---|---|---|---|
#4 | interdiff-2-4.txt | 988 bytes | mxr576 |
#4 | views_bulk_operations-properly-report-exceptions-2856207-4.patch | 2.62 KB | mxr576 |
Comments
Comment #2
mxr576My patch also fixes how $log variable's type checked in multiple places. The original implementation also handled $log = array() than $log = NULL therefore almost always watchdog() was in use to log messages.
Comment #3
joelpittetHere's a quick review, this looks like an interesting idea, I agree with it on some angles but need to consider it and get a bit more reviews before accepting the patch.
This looks like an unrelated change.
Though the the idea is correct, the parser that reads
t()
doesn't work with variables because it statically reads the PHP source to build the translations, so you have to duplicate the message.Probably shouldn't be calling Drupal core internal functions and if so maybe _drupal_render_exception_safe() would be better for security
Comment #4
mxr576Thanks for the quick review.
1. It is not completely unrelated, because without this fix VBO sends almost every messages to watchdog instead of displaying them on the UI as messages.
2. Yes you are correct, but I've just re-used this "pattern" from VBO's current codebase. Similar issues in the current codebase should be fixed independently, I've fixed the related lines in my patch.
http://cgit.drupalcode.org/views_bulk_operations/tree/views_bulk_operati...
3. I do not want to render a full exception to a user as a message. I choosed to use _drupal_decode_exception() (just as watchdog_exception() does) to generate a proper !message variable from an exception (the same way as Drupal core does) and display only the "human readable" part of an exception to a user as a message on the UI.