Comment 6 for bug 1381811

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/3819
Committed: http://gitorious.org/mahara/mahara/commit/1f779bdd6486b802eca218ee750dc0077283535c
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit 1f779bdd6486b802eca218ee750dc0077283535c
Author: Aaron Wells <email address hidden>
Date: Thu Oct 16 13:39:27 2014 +1300

Make Collection::save() play well with existing collections & non-null columns

Bug 1381811: Collection::save() would create a new (empty) collection by
passing 0 as the id to the Collection constructor, even if the supplied
$data included an "id" field. Since the id was not supplied to the
constructor, it does not pull the collection's current data from the
database.

It would then call Collection->commit(), which would notice the "id"
field and do an update instead of an insert into the database. But due to
the way the Collection class is written, it would try to populate every
field of the collection table, rather than just those supplied in $data.

This means that all the database fields not supplied in $data, would
attempt to be filled with NULL. This threw an error because of the new
collection.submittedstatus NOT-NULL column.

Change-Id: I6a2927892459bd25d51bd58de1bd3e3584df0793