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

Undefined variable: type in /lib/dataformatlib.php

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2 regressions, 3.3, 3.4
    • Fix Version/s: 3.3.4, 3.4.1
    • Component/s: Libraries
    • Labels:
    • Testing Instructions:
      Hide
      1. Ensure that developer mode is turned on. (If you're running MDK, just run "mdk run mindev")
      2. Navigate to "Site administration / Users / Accounts / Bulk user actions"
      3. Add oneor more users to selection.
      4. From "With selected users..." select "Download" and click "Go"
      5. On the Download page, add the parameter "dataformat=xls" to the URL and press enter.
        e.g.

        http://localhost/integration_master/admin/user/user_bulk_download.php?dataformat=xls
        

        • Confirm that you get a coding exception error.
      6. Now, replace the dataformat value of xls to csv end press enter.
        e.g.

        http://localhost/integration_master/admin/user/user_bulk_download.php?dataformat=csv
        

        • Confirm that the selected users are downloaded into a CSV file.
      Show
      Ensure that developer mode is turned on. (If you're running MDK, just run " mdk run mindev ") Navigate to " Site administration / Users / Accounts / Bulk user actions " Add oneor more users to selection. From "With selected users..." select "Download" and click "Go" On the Download page, add the parameter "dataformat=xls" to the URL and press enter. e.g. http://localhost/integration_master/admin/user/user_bulk_download.php?dataformat=xls Confirm that you get a coding exception error. Now, replace the dataformat value of xls to csv end press enter. e.g. http://localhost/integration_master/admin/user/user_bulk_download.php?dataformat=csv Confirm that the selected users are downloaded into a CSV file.
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull Master Branch:
      MDL-60443_dataformat_lib_wrong_variable

      Description

      When a required dataformat doesn't exist, the next error is showed:

      Undefined variable: type in /<moodle-path>/lib/dataformatlib.php

      It is a small developer bug and affect developers principally.

      The error occurred because the variable name is wrong, the variable $type really is $dataformat.

      To reproduce:
      0. Set "Debug messages" to "Developer" and "Display debug messages" to "Yes".

      1. Go to "Bulk user actions" and select users

      2. From "With selected users..." select "Download" and "Go"

      3. In the URL, add the parameter "dataformat" equal to "xls"
      Something like: http://<moodle-host>/admin/user/user_bulk_download.php?dataformat=xls
      If replace xls by csv the error not happen, the download is successfull.
      Something like: http://<moodle-host>/admin/user/user_bulk_download.php?dataformat=csv

      4. The error is printed in the page.
      Note: the error can be hide below the main bar.

      5. The message "Coding error detected, it must be fixed by a programmer: Unable to locate dataformat//classes/writer.php" is incomplete.

      The solution is easy, change this line:

      throw new coding_exception("Unable to locate dataformat/$type/classes/writer.php");
      

      By this line

      throw new coding_exception("Unable to locate dataformat/$dataformat/classes/writer.php");

      into lib/dataformatlib.php, function download_as_dataformat.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jan/18