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

dmlwriteexception on upgrade to new version

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Enrolments
    • Labels:
      None
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Testing upgrade from 1.9.9 to 2.0 Preview 3 (Build: 20100625), with change suggested in MDL-22941, getting the following error:

      Error writing to database

      Debug info: Column 'timecreated' cannot be null
      INSERT INTO mdl_enrol (courseid,enrol,timecreated,timemodified,status) VALUES(?,?,?,?,?)
      [array (
      0 => '58',
      1 => 'flatfile',
      2 => NULL,
      3 => '1186360061',
      4 => 1,
      )]
      Stack trace:

      • line 381 of /lib/dml/moodle_database.php: dml_write_exception thrown
      • line 716 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      • line 759 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      • line 4417 of /lib/db/upgrade.php: call to mysqli_native_moodle_database->insert_record()
      • line 1241 of /lib/upgradelib.php: call to xmldb_main_upgrade()
      • line 248 of /admin/index.php: call to upgrade_core()

      Looking at revision 1.426 up /lib/db/upgrade.php, thinking this may have something to do with the sql query starting at line 4407:

      $sql = "SELECT DISTINCT c.id AS courseid, ra.enrol, e.timecreated, c.timemodified
      FROM

      {course}

      c
      JOIN

      {context}

      ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = 50)
      JOIN

      {role_assignments}

      ra ON (ra.contextid = ctx.id AND ra.enrol <> '$sqlempty')
      LEFT JOIN

      {enrol}

      e ON (e.courseid = c.id AND e.enrol = ra.enrol)
      WHERE c.id <> :siteid AND e.id IS NULL";

      Is this possibly specific to flatfile? Should we select c.timecreated instead of e.timecreated?

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            mcampbell Matt Campbell
            Tester:
            Nobody
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              24/Nov/10