- Issue created by @a_z_official
- 🇵🇰Pakistan a_z_official
I've simplified the patch by removing absolute file paths, making it easier to apply regardless of project setup.
The module encounters a PHP deprecation warning and causes an error on the configuration page when running on newer PHP versions. This is due to the `explode()` function being called with a `null` value as the second parameter in the `js_confirm_pop_up_form_alter()` function. If `$form_ids` is empty or `null`, `explode(',', $form_ids)` triggers a warning because `explode()` expects a valid string.
1. Install the module on a Drupal 7 site running the latest PHP version.
2. Navigate to Configuration > User Interface > JS Confirm Pop Up Settings.
3. The configuration page shows a deprecation error due to the `explode()` function being called on a `null` value when `$form_ids` is empty or unset.
Update the `js_confirm_pop_up_form_alter()` function to handle cases where `$form_ids` is `null` or empty. Modify the line to ensure `$form_ids_arr` is assigned an empty array when `$form_ids` is not a valid string:
Replace:
$form_ids_arr = explode(',', $form_ids);
With:
$form_ids_arr = !empty($form_ids) ? explode(',', $form_ids) : [];
This prevents errors and warnings when `$form_ids` is empty or `null`.
No user interface changes are introduced by this fix.
No API changes are introduced by this fix.
No data model changes are introduced by this fix.
Needs review
1.3
Code
The issue particularly affects sites running on PHP version 8.1.0 or later.
I've simplified the patch by removing absolute file paths, making it easier to apply regardless of project setup.