Moodle
  1. Moodle
  2. MDL-31807

bug in cohort_update_cohort with component as NULL line 75

    Details

    • Rank:
      38434

      Description

      Manually created cohorts (these cohorts have their component set to empty string '' and not NULL) can be updated via code to add members, or remove members.

      Yet when using the cohort_update_cohort function for a manually created cohort it takes empty string component values and sets to NULL. Null values are not allowed for this in the DB which produces an error.

      !!! Error writing to database !!!
      Default exception handler: Error writing to database Debug: Column 'component' cannot be null
      UPDATE mdl_cohort SET contextid = ?,name = ?,idnumber = ?,description = ?,descriptionformat = ?,component = ?,timecreated = ?,timemodified = ? WHERE id=?
      [array (
      0 => '1',
      1 => 'All_Laws_Students',
      2 => 'All_Laws_Students',
      3 => 'Created:2012-02-27-153626 and updated 2012-02-28-003204',
      4 => '1',
      5 => NULL,
      6 => '1330353386',
      7 => 1330385524,
      8 => '1250',
      )]

      • line 397 of \lib\dml\moodle_database.php: dml_write_exception thrown
      • line 999 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
      • line 1031 of \lib\dml\mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->update_record_raw()
      • line 78 of \cohort\lib.php: call to mysqli_native_moodle_database->update_record()
      • line 427 of \auth\ldap\cli\sync_cohorts.php: call to cohort_update_cohort()

      Code says (approx lines 74-76):
      if (isset($cohort->component) and empty($cohort->component))

      { $cohort->component = NULL; }

      This should instead be:
      if (isset($cohort->component) and empty($cohort->component))

      { $cohort->component = ''; }

      This will match with cohort_add_cohort which does (lines 50-52):
      if (empty($cohort->component)) { $cohort->component = ''; }

        Activity

        Hide
        Petr Škoda added a comment -

        thanks for the report

        Show
        Petr Škoda added a comment - thanks for the report
        Hide
        Eloy Lafuente (stronk7) added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        Petr Škoda added a comment -

        rebased, thanks

        Show
        Petr Škoda added a comment - rebased, thanks
        Hide
        Sam Hemelryk added a comment -

        Hi Petr, this has been integrated now thanks

        Show
        Sam Hemelryk added a comment - Hi Petr, this has been integrated now thanks
        Hide
        Ankit Agarwal added a comment -

        works as expected
        Passing
        Thanks

        Show
        Ankit Agarwal added a comment - works as expected Passing Thanks
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Your changes are now upstream and will be included in the next minor released scheduled for March 13th (next Monday!).

        icao_reverse('arreis olik rebemevon afla letoh ognat');
        

        Closing, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Your changes are now upstream and will be included in the next minor released scheduled for March 13th (next Monday!). icao_reverse('arreis olik rebemevon afla letoh ognat'); Closing, ciao

          People

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

            Dates

            • Created:
              Updated:
              Resolved: