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

Adding a Resource of Type directory leads to SQL errors

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.1
    • Component/s: Resource
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE

      Description

      Adding a resource of type "Display a directory" fails in both 1.8.x (It has issues in 1.9 too).

      In 1.8.x, course/moedit.php fails with the error message: "Could not add a new instance of resource"

      The problem is that the resource tries to add a row in RESOURCE with NULL values in the columns POPUP and ALLTEXT.

      Additionally, if the default choice for "Display a Directory" is chosen (Main files Directory), the REFERENCE column is improperly set to 0.

      Adding this code to line 9 of mod/resource/type/directory/resource.class.php fixes the problem:
      function add_instance($resource) {
      $this->_postprocess($resource);
      return parent::add_instance($resource);
      }

      function update_instance($resource) {
      $this->_postprocess($resource);
      return parent::update_instance($resource);
      }

      function _postprocess(&$resource) {
      if($resource->reference=='0')
      $resource->reference = '';

      $resource->popup = '';
      $resource->alltext = '';
      }

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            andrewschmadeke Andrew Schmadeke
            Tester:
            Nobody Nobody
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Jun/07