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

[database module] SQL error when you edit an entry after having added a new picture/file field

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Add a database activity
      2. Add a text field
      3. Add a new entry
      4. Add a file and a picture field
      5. Edit the existing entry and try to save it

      Expectation: The new file and picture are saved properly.

      Show
      Add a database activity Add a text field Add a new entry Add a file and a picture field Edit the existing entry and try to save it Expectation: The new file and picture are saved properly.
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE, MOODLE_33_STABLE
    • Pull Master Branch:
      MDL-54965-master

      Description

      Moodle 3.1
      Postgresql

      1- I created a database activity with a picture (or file) field.
      2- I added an entry with a picture (set as not required)
      3- I added a second picture field (set as not required)
      4- I updated the List, Single and Add template so I can use the second picture field
      5- I edited the first entry
      6- I didn't add a second picture in this first entry (leaving it empty) and I clicked on save:

      Debug info: ERROR: invalid input syntax for integer: ""
      SELECT f.id AS id, f.contenthash, f.pathnamehash, f.contextid, f.component, f.filearea, f.itemid, f.filepath, f.filename, f.userid, f.filesize, f.mimetype, f.status, f.source, f.author, f.license, f.timecreated, f.timemodified, f.sortorder, f.referencefileid, r.repositoryid AS repositoryid, r.reference AS reference, r.lastsync AS referencelastsync
      FROM mdl_files f
      LEFT JOIN mdl_files_reference r
      ON f.referencefileid = r.id
      WHERE f.contextid = $1
      AND f.component = $2
      AND f.filearea = $3
      AND f.itemid = $4 ORDER BY itemid, filepath, filename
      [array (
      0 => 5,
      1 => 'user',
      2 => 'draft',
      3 => '',
      )]
      Error code: dmlreadexception
      ×Stack trace:
      line 474 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 244 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      line 794 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      line 810 of /lib/filestorage/file_storage.php: call to pgsql_native_moodle_database->get_records_sql()
      line 320 of /mod/data/field/picture/field.class.php: call to file_storage->get_area_files()
      line 3934 of /mod/data/lib.php: call to data_field_picture->notemptyfield()
      line 176 of /mod/data/edit.php: call to data_process_submission()

        Attachments

        1. Screen Shot 2016-06-20 at 2.22.57 PM.png
          Screen Shot 2016-06-20 at 2.22.57 PM.png
          249 kB
        2. after.png
          after.png
          59 kB
        3. before.png
          before.png
          54 kB

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  11/Sep/17