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

Not possible to search for '0' (zero) in database activity module

XMLWordPrintable

    • MOODLE_31_STABLE
    • git@github.com:jojoob/moodle.git
    • master-MDL-58243
    • Hide
      1. create a database activity module instance
      2. create a field for each core field type that allows any user input
        1. Text
        2. Number
        3. Checkbox (options: '0' and 'foo')
        4. Latlong
        5. Menu (options: '0' and 'foo')
        6. Multimenu (options: '0' and 'foo')
        7. Radio button (options: '0' and 'foo')
        8. Textarea
      3. create an entry and set or select the value '0' for each field
      4. create another entry and set or select 'foo' as the value for each field
      5. for each field use the search to try find the entry with value '0'
      6. EXPECTED: find only the searched entry when searching for '0'
        ACTUALLY: the search parameter is ignored and all entries are shown
      7. apply the patch and test the search again (step 5)
        EXPECTED: find only the searched entry when searching for '0'
      Show
      create a database activity module instance create a field for each core field type that allows any user input Text Number Checkbox (options: '0' and 'foo') Latlong Menu (options: '0' and 'foo') Multimenu (options: '0' and 'foo') Radio button (options: '0' and 'foo') Textarea create an entry and set or select the value '0' for each field create another entry and set or select 'foo' as the value for each field for each field use the search to try find the entry with value '0' EXPECTED: find only the searched entry when searching for '0' ACTUALLY: the search parameter is ignored and all entries are shown apply the patch and test the search again (step 5) EXPECTED: find only the searched entry when searching for '0'

      It is not possible for neither data field in a database activity module to search for the string or integer zero. The mod_data implementation of handling search parameters is using the empty() function to determine if a parameter is set. For the empty() function returns true also for the integer 0 and the string '0' mod_data will discard this values.

      Reproduce the behaviour:

      1. Create a database activity module instance
      2. create at least one field of type text or number
      3. create at least one test entry with the value 0
      4. use the search to try find the test entry
      5. EXPECTED: find only the searched entry when searching for 0 ACTUALLY: the search parameter is ignored and all entries are shown

       

      A patch is attached.

            Unassigned Unassigned
            jojoob Johannes Burk
            Adrian Greeve Adrian Greeve
            David Monllaó David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.