Error when copying collection or editing collection title/description

Bug #1381811 reported by Eduardo
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Critical
Aaron Wells
1.10
Fix Released
Critical
Aaron Wells
15.04
Fix Released
Critical
Unassigned

Bug Description

Mahara 1.10rc1

Editing a collection's title or description produces an error.

1. Create a collection
2. Save it
3. Click the "Edit title and description" link for that collection
4. Click "save"

Copying of a collection produces the same error. Tested in Portfolio and groups.

1. Create a collection.
2. Copy the collection. Error (see below shows up). Collection is created though.

---------------

[WAR] 49 (lib/adodb/adodb-exceptions.inc.php:43) Array to string conversion
Call stack (most recent first):

    log_message("Array to string conversion", 8, true, true, "/var/www/html/maharatest/htdocs/lib/adodb/adodb-ex...", 43) at /var/www/html/maharatest/htdocs/lib/errors.php:439
    error(8, "Array to string conversion", "/var/www/html/maharatest/htdocs/lib/adodb/adodb-ex...", 43, array(size 7)) at /var/www/html/maharatest/htdocs/lib/adodb/adodb-exceptions.inc.php:43
    ADODB_Exception->__construct("postgres7", "adodb_throw", -1, "ERROR: null value in column "submittedstatus" vio...", "UPDATE "collection" SET "owner" = ? , "ctime" = ? ...", array(size 13), object(ADODB_postgres7)) at /var/www/html/maharatest/htdocs/lib/adodb/adodb-exceptions.inc.php:78
    adodb_throw("postgres7", "adodb_throw", -1, "ERROR: null value in column "submittedstatus" vio...", "UPDATE "collection" SET "owner" = ? , "ctime" = ? ...", array(size 13), object(ADODB_postgres7)) at /var/www/html/maharatest/htdocs/lib/adodb/adodb.inc.php:257
    ADODB_TransMonitor("postgres7", "EXECUTE", -1, "ERROR: null value in column "submittedstatus" vio...", "UPDATE "collection" SET "owner" = ? , "ctime" = ? ...", array(size 13), object(ADODB_postgres7)) at /var/www/html/maharatest/htdocs/lib/adodb/adodb.inc.php:1074
    ADOConnection->_Execute("UPDATE "collection" SET "owner" = ? , "ctime" = ? ...", array(size 13)) at /var/www/html/maharatest/htdocs/lib/adodb/adodb.inc.php:1045
    ADOConnection->Execute("UPDATE "collection" SET "owner" = ? , "ctime" = ? ...", array(size 13)) at /var/www/html/maharatest/htdocs/lib/dml.php:1256
    update_record("collection", object(stdClass), "id") at /var/www/html/maharatest/htdocs/lib/collection.php:163
    Collection->commit() at /var/www/html/maharatest/htdocs/lib/collection.php:100
    Collection::save(array(size 8)) at /var/www/html/maharatest/htdocs/collection/edit.php:130
    submit(object(Pieform), array(size 8)) at Unknown:0
    call_user_func_array("submit", array(size 2)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:527
    Pieform->__construct(array(size 5)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:162
    Pieform::process(array(size 5)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:71
    pieform(array(size 5)) at /var/www/html/maharatest/htdocs/collection/edit.php:113

[WAR] 49 (lib/errors.php:745) Failed to get a recordset: postgres7 error: [-1: ERROR: null value in column "submittedstatus" violates not-null constraint] in adodb_throw(UPDATE "collection" SET "owner" = ? , "ctime" = ? , "mtime" = ? , "name" = ? , "description" = ? , "navigation" = ? , "submittedgroup" = ? , "submittedhost" = ? , "submittedtime" = ? , "submittedstatus" = ? , "group" = ? , "institution" = ? WHERE "id" = ? , Array)
Command was: UPDATE "collection" SET "owner" = ? , "ctime" = ? , "mtime" = ? , "name" = ? , "description" = ? , "navigation" = ? , "submittedgroup" = ? , "submittedhost" = ? , "submittedtime" = ? , "submittedstatus" = ? , "group" = ? , "institution" = ? WHERE "id" = ? and values was (1,2014-10-16 12:20:51,2014-10-16 12:20:51,Testing,,1,,,,,,,3)
Call stack (most recent first):

    log_message("Failed to get a recordset: postgres7 error: [-1: E...", 8, true, true) at /var/www/html/maharatest/htdocs/lib/errors.php:95
    log_warn("Failed to get a recordset: postgres7 error: [-1: E...") at /var/www/html/maharatest/htdocs/lib/errors.php:745
    SQLException->__construct("Failed to get a recordset: postgres7 error: [-1: E...") at /var/www/html/maharatest/htdocs/lib/dml.php:1260
    update_record("collection", object(stdClass), "id") at /var/www/html/maharatest/htdocs/lib/collection.php:163
    Collection->commit() at /var/www/html/maharatest/htdocs/lib/collection.php:100
    Collection::save(array(size 8)) at /var/www/html/maharatest/htdocs/collection/edit.php:130
    submit(object(Pieform), array(size 8)) at Unknown:0
    call_user_func_array("submit", array(size 2)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:527
    Pieform->__construct(array(size 5)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:162
    Pieform::process(array(size 5)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:71
    pieform(array(size 5)) at /var/www/html/maharatest/htdocs/collection/edit.php:113

[WAR] 49 (lib/dml.php:1260) Failed to get a recordset: postgres7 error: [-1: ERROR: null value in column "submittedstatus" violates not-null constraint] in adodb_throw(UPDATE "collection" SET "owner" = ? , "ctime" = ? , "mtime" = ? , "name" = ? , "description" = ? , "navigation" = ? , "submittedgroup" = ? , "submittedhost" = ? , "submittedtime" = ? , "submittedstatus" = ? , "group" = ? , "institution" = ? WHERE "id" = ? , Array)
Command was: UPDATE "collection" SET "owner" = ? , "ctime" = ? , "mtime" = ? , "name" = ? , "description" = ? , "navigation" = ? , "submittedgroup" = ? , "submittedhost" = ? , "submittedtime" = ? , "submittedstatus" = ? , "group" = ? , "institution" = ? WHERE "id" = ? and values was (1,2014-10-16 12:20:51,2014-10-16 12:20:51,Testing,,1,,,,,,,3)
Call stack (most recent first):

    update_record("collection", object(stdClass), "id") at /var/www/html/maharatest/htdocs/lib/collection.php:163
    Collection->commit() at /var/www/html/maharatest/htdocs/lib/collection.php:100
    Collection::save(array(size 8)) at /var/www/html/maharatest/htdocs/collection/edit.php:130
    submit(object(Pieform), array(size 8)) at Unknown:0
    call_user_func_array("submit", array(size 2)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:527
    Pieform->__construct(array(size 5)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:162
    Pieform::process(array(size 5)) at /var/www/html/maharatest/htdocs/lib/pieforms/pieform.php:71
    pieform(array(size 5)) at /var/www/html/maharatest/htdocs/collection/edit.php:113

Tags: regression
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Using git bisect I've identified this change as the cause of the error: https://reviews.mahara.org/#/c/3463/

tags: added: regression
Changed in mahara:
status: New → Confirmed
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "1.10_STABLE" branch: https://reviews.mahara.org/3812

Aaron Wells (u-aaronw)
summary: - Copying collection throws error
+ Error when copying collection or editing collection title/description
description: updated
Revision history for this message
Eduardo (o-eduardo) wrote :

Tested under "Portfolio" and in a group. And as a Admin and a normal user. How to test:

1. Log in as admin
2. Go to Groups → Create a group
3. Go to Pages → Create a few pages
4. Go to Collections → New collection
5. Add all pages to collection → Done
6. Select Copy a collection → Select “Copy collection”
7. Click on “Next: Edit collection pages” → Done
8. This time no Error message should have appeared → Passed

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

Reviewed: https://reviews.mahara.org/3812
Committed: http://gitorious.org/mahara/mahara/commit/fc50c821c131fa357cb8b2306a44ad09645cadd9
Submitter: Aaron Wells (<email address hidden>)
Branch: 1.10_STABLE

commit fc50c821c131fa357cb8b2306a44ad09645cadd9
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

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/3819

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

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.