Duplicate primary key upgrading from Mahara 1.1

Bug #1338410 reported by Aaron Wells
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Aaron Wells

Bug Description

[DBG] a2 (lib/db/upgrade.php:2881) Correcting custom layout table structures.
[WAR] a2 (lib/errors.php:739) Failed to get a recordset: postgres7 error: [-5: ERROR: duplicate key value violates unique constraint "blocinst_vierowcolord_uk"
[WAR] a2 (lib/errors.php:739) DETAIL: Key (view, "row", "column", "order")=(1, 1, 1, 3) already exists.] in adodb_throw(INSERT INTO "block_instance" ("id", "blocktype", "title", "configdata", "view", "column", "order", "row") VALUES (?, ?, ?, ?, ?, ?, ?, ?), Array)
[WAR] a2 (lib/errors.php:739) Command was: INSERT INTO "block_instance" ("id", "blocktype", "title", "configdata", "view", "column", "order", "row") VALUES (?, ?, ?, ?, ?, ?, ?, ?) and values was (13,profileinfo,About me,a:0:{},1,1,3,1)
Call stack (most recent first):
  * log_message("Failed to get a recordset: postgres7 error: [-5: E...", 8, true, true) at /home/aaronw/www/mahara/htdocs/lib/errors.php:95
  * log_warn("Failed to get a recordset: postgres7 error: [-5: E...") at /home/aaronw/www/mahara/htdocs/lib/errors.php:739
  * SQLException->__construct("Failed to get a recordset: postgres7 error: [-5: E...") at /home/aaronw/www/mahara/htdocs/lib/dml.php:1046
  * insert_record("block_instance", object(stdClass), "id", true) at /home/aaronw/www/mahara/htdocs/blocktype/lib.php:1029
  * BlockInstance->commit() at /home/aaronw/www/mahara/htdocs/lib/db/upgrade.php:3245
  * xmldb_core_upgrade("2009022600") at /home/aaronw/www/mahara/htdocs/lib/upgrade.php:325
  * upgrade_core(object(stdClass)) at /home/aaronw/www/mahara/htdocs/lib/mahara.php:253
  * upgrade_mahara(array(size 20)) at /home/aaronw/www/mahara/htdocs/admin/cli/upgrade.php:50

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

Problem is the code that inserts the "about me" block, is not correctly determining what value should go in the "block_instance.order" column. It counts the number of blocks in that row and adds 1. That would work if the contents of the "order" column are always correct, but in instances upgraded from Mahara 1.1, the values of that column are "2, 3", so the count method doesn't work because it also gives you "3".

A more robust solution is to get the maximum "order" value and add 1 to that.

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/3482

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

Reviewed: https://reviews.mahara.org/3482
Committed: http://gitorious.org/mahara/mahara/commit/7e3aabe131f7ed16f73bad6e0f7914effa2c9fe5
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 7e3aabe131f7ed16f73bad6e0f7914effa2c9fe5
Author: Aaron Wells <email address hidden>
Date: Mon Jul 7 14:55:53 2014 +1200

More robust fetching of next block order

Bug 1338410

Change-Id: I5a15029b9c7fdaccd76072f632ef59234c22e835

Robert Lyon (robertl-9)
Changed in mahara:
status: In Progress → Fix Committed
Changed in mahara:
assignee: nobody → Aaron Wells (u-aaronw)
Aaron Wells (u-aaronw)
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.