Settings form: Fix PHP Warning : Undefined array key 'mobile'

Created on 23 September 2023, about 1 year ago
Updated 25 September 2023, about 1 year ago

Problem/Motivation

PHP Warning error message when saving module's settings form at /admin/config/system/browser-update:

Warning : Undefined array key "mobile" dans Drupal\bu\Form\SettingsForm->submitForm() (line 232 in /var/www/html/web/modules/contrib/bu/src/Form/SettingsForm.php). =>
array:23 [▼
  "22: Drupal\bu\Form\SettingsForm->submitForm()" => array:2 [▶]
  "21: call_user_func_array()" => array:1 [▶]
  "20: Drupal\Core\Form\FormSubmitter->executeSubmitHandlers()" => array:2 [▶]
  "19: Drupal\Core\Form\FormSubmitter->doSubmitForm()" => array:2 [▶]
  "18: Drupal\Core\Form\FormBuilder->processForm()" => array:2 [▶]
  "17: Drupal\Core\Form\FormBuilder->buildForm()" => array:2 [▶]
  "16: Drupal\Core\Controller\FormController->getContentResult()" => array:2 [▶]
  "15: call_user_func_array()" => array:1 [▶]
  "14: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()" => array:1 [▶]
  "13: Drupal\Core\Render\Renderer->executeInRenderContext()" => array:2 [▶]
  "12: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()" => array:2 [▶]
  "11: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()" => array:1 [▶]
  "10: Symfony\Component\HttpKernel\HttpKernel->handleRaw()" => array:2 [▶]
  "\u{A0}9: Symfony\Component\HttpKernel\HttpKernel->handle()" => array:2 [▶]
  "\u{A0}8: Drupal\Core\StackMiddleware\Session->handle()" => array:2 [▶]
  "\u{A0}7: Drupal\Core\StackMiddleware\KernelPreHandle->handle()" => array:2 [▶]
  "\u{A0}6: Drupal\page_cache\StackMiddleware\PageCache->pass()" => array:2 [▶]
  "\u{A0}5: Drupal\page_cache\StackMiddleware\PageCache->handle()" => array:2 [▶]
  "\u{A0}4: Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()" => array:2 [▶]
  "\u{A0}3: Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()" => array:2 [▶]
  "\u{A0}2: Drupal\Core\StackMiddleware\StackedHttpKernel->handle()" => array:2 [▶]
  "\u{A0}1: Drupal\Core\DrupalKernel->handle()" => array:2 [▶]
  "\u{A0}0: main()" => array:2 [▶]

 
Corresponding to undefined 'mobile' key here:
https://git.drupalcode.org/project/bu/-/blob/2.1.1/src/Form/SettingsForm...
Since the field doesn't exist in the form, it couldn't be submitted and therefore isn't present in form values array.
 

Steps to reproduce

  1. Go to module's admin settings page at : /admin/config/system/browser-update.
  2. Save the page by clicking on the "Save"/"Submit" button at the bottom of the form page.
  3. See the error message, either in the logs or on the page if errors are displayed.

 

Proposed resolution

This issue seems to be due to a missing field on the configuration page: 'mobile', which seems to be defined everywhere but in the form:

 
According to the documentation at: http://browser-update.org/customize.html
The option mobile doesn't seem to exist anymore, therefore, the simplest solution would be to remove it from the files where it is currently defined and used.

Additionally: Evaluate the use of other properties passed in module's JS file:
https://git.drupalcode.org/project/bu/-/blob/2.1.1/js/bu.js?ref_type=tag...
For example: insecure and unsupported also don't seem to be options that could be passed to browserUpdate JS, see: http://browser-update.org/customize.html
(All other options seem to be supported though)
 

Any feedback, patches, questions, comments, suggestions or comments would be greatly appreciated.
Feel free to let us know if you have any questions or would need additional information on this ticket, we would surely be glad to help.
Thanks in advance!

🐛 Bug report
Status

Needs review

Version

2.1

Component

Code

Created by

🇫🇷France dydave

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

Comments & Activities

Production build 0.71.5 2024