Problem/Motivation

image_widget_crop_requirements() implements a renderable array to display errors:

if (!empty($error)) {
    $requirements['iwc_libraries']['severity'] = REQUIREMENT_ERROR;
    $requirements['iwc_libraries']['description'][] = [
      '#theme' => 'item_list',
      '#items' => $error,
    ];
  }

However, renderable arrays are only supported during runtime:

hook_requirements() messages currently work with render arrays for runtime requirements messages. However, the documentation does not explicitly state that render arrays are allowed. Additionally, install phase requirements do not support render arrays because in drupal_check_module()they are passed to drupal_set_message(), and also to a placeholder in a t() following #2501639: Remove SafeMarkup::set in drupal_check_module().

#2505499: Explicitly support render arrays in hook_requirements()

Proposed resolution

Only return a renderable array in hook_requirements during the 'runtime' phase.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
StatusFileSize
new4.35 KB

Attached patch implements a conditional on $phase === 'runtime', so image_widget_crop_requirements() only returns a renderable array in hook_requirements during the 'runtime' phase.

woprrr’s picture

Status: Needs review » Reviewed & tested by the community

You totally right ! RTBC to me !

Thank a lot for this contribution !! I hope see you again in other issue if this module help you he need you too :)

  • woprrr committed 89ade88 on 8.x-2.x authored by idebr
    Issue #2988156 by idebr, woprrr: hook_requirements uses a renderable...
woprrr’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.