Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-45846

Invalid device type provided to set_user_device_type

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.2
    • Fix Version/s: 2.6.4, 2.7.1
    • Component/s: Libraries
    • Labels:
    • Testing Instructions:
      Hide

      In your site, go into Admin > Appearance > Themes > Theme Settings and scroll down to the bottom of the form. Ensure the enabledevicedetection setting is ticked. Add something in the devicedetectregex setup e.g. "(Symbian|MIDP-1.0|Maemo|Windows CE)" as the regular expression and "featurephone" as the return value.

      Now view your site on a mobile device. You should see a switch theme link in the footer. Activate it.

      Before the fix, you will get an error page "Coding error detected, it must be fixed by a programmer: Invalid device type provided to set_user_device_type". After the fix, the page should swap theme correctly.

      Test 2 - same setup, but instead of using the switch theme link, simply visit theme/index.php. Before the fix, you will see errors at the top, after, the page displays correctly.

      Test 3 - run the lib/tests/theme_config_test.php which has a new unit test checking that set_user_device_type returns appropriately both with and without custom regex in config.

      Show
      In your site, go into Admin > Appearance > Themes > Theme Settings and scroll down to the bottom of the form. Ensure the enabledevicedetection setting is ticked. Add something in the devicedetectregex setup e.g. "(Symbian|MIDP-1.0|Maemo|Windows CE)" as the regular expression and "featurephone" as the return value. Now view your site on a mobile device. You should see a switch theme link in the footer. Activate it. Before the fix, you will get an error page "Coding error detected, it must be fixed by a programmer: Invalid device type provided to set_user_device_type". After the fix, the page should swap theme correctly. Test 2 - same setup, but instead of using the switch theme link, simply visit theme/index.php. Before the fix, you will see errors at the top, after, the page displays correctly. Test 3 - run the lib/tests/theme_config_test.php which has a new unit test checking that set_user_device_type returns appropriately both with and without custom regex in config.
    • Affected Branches:
      MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE, MOODLE_27_STABLE
    • Pull Master Branch:
      wip-MDL45846

      Description

      I'm surprised this hasn't come up before. We've just updated the OU servers to 2.6.2, but the issue still occurs on the latest master.

      If you have something in the theme settings for devicedetectregex e.g. regular expression (Symbian|MIDP-1.0|Maemo|Windows CE) returns featurephone

      when you use the theme/switchdevice.php script, a set of PHP errors are created in the logs:

      [04-Jun-2014 00:17:01 Europe/London] PHP Warning: array_keys() expects parameter 1 to be array, object given in /vle/www_root/lib/classes/useragent.php on line 221
      [04-Jun-2014 00:17:01 Europe/London] PHP Warning: array_merge(): Argument #2 is not an array in /vle/www_root/lib/classes/useragent.php on line 221
      [04-Jun-2014 00:17:01 Europe/London] PHP Warning: in_array() expects parameter 2 to be array, null given in /vle/www_root/lib/classes/useragent.php on line 300
      [04-Jun-2014 00:17:01 Europe/London] Default exception handler: Coding error detected, it must be fixed by a programmer: Invalid device type provided to set_user_device_type Debug:
      Error code: codingerror

      • line 305 of /lib/classes/useragent.php: coding_exception thrown
      • line 34 of /theme/switchdevice.php: call to core_useragent::set_user_device_type()

      Ultimately then the user sees the "Invalid device type provided to set_user_device_type" error.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Jul/14