In Drupal 9, on the Hotjar settings form, no roles are listed in the "Roles" section and the following PHP warnings are shown:
Warning: array_map() expects parameter 1 to be a valid callback, class '\Drupal\Component\Utility\SafeMarkup' not found in Drupal\hotjar\Form\HotjarAdminSettingsForm->buildForm() (line 211 of ./web/modules/contrib/hotjar/src/Form/HotjarAdminSettingsForm.php)
Warning: count(): Parameter must be an array or an object that implements Countable in Drupal\Core\Render\Element\Checkboxes::processCheckboxes() (line 58 of ./web/core/lib/Drupal/Core/Render/Element/Checkboxes.php)
This is because \Drupal\Component\Utility\SafeMarkup
was deprecated in Drupal 8 and removed in Drupal 9. I'd guess that the automated Deprecated Code Report missed this because it was in quoted text rather than straight code here:
$role_options = array_map(['\Drupal\Component\Utility\SafeMarkup', 'checkPlain'], user_role_names());
Per the link above, that can be replaced with a call to \Drupal\Component\Utility\Html::escape()
. Patch to follow.
Comment | File | Size | Author |
---|---|---|---|
#2 | 3155704-2.hotjar-d9-warnings.patch | 714 bytes | jrb |
Comments
Comment #2
jrbPatch to fix PHP warnings.
Comment #3
jrbComment #5
tikaszvince CreditAttribution: tikaszvince at Integral Vision Ltd commentedHi @jrb,
Thank you the contribution. This is part of the new 2.0-rc4 release of Hotar module.