Fix negative block_instance sortorders before running upgrade

Bug #1613135 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Aaron Wells
15.04
Fix Released
Medium
Aaron Wells
15.10
Fix Released
Medium
Aaron Wells
16.04
Fix Released
Medium
Aaron Wells
16.10
Fix Released
Medium
Aaron Wells

Bug Description

See: https://mahara.org/interaction/forum/topic.php?id=7687&offset=0&limit=10#post30945

For Bug 1528351 we added an upgrade block that corrects the block_instance sortorder drift that had been created by Bug 1523719. As a workaround to the uniqueness constraint on that column, this block temporarily moves the sortorders into the negative integerspace, and then re-orders them as positive numbers.

However, we've had multiple reports of sites that have somehow got negative numbers already in their block_instance.sortorder column. These sites then error out during the upgrade, because the extant negative numbers turn into positive numbers, and then there's a uniqueness violation if another block being re-ordered overlaps with it.

Ghada has written up a block of code that can fix this, and we've shared it with some affected sites via the forum. It should be easy to add it to the basic upgrade script, though. In order to reduce complications, we could preface it with a check to see whether there are negative sortorders in the database, and only run this additional step if we find any negatives.

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

Patch for "16.04_STABLE" branch: https://reviews.mahara.org/6877

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "15.10_STABLE" branch: https://reviews.mahara.org/6878

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "15.04_STABLE" branch: https://reviews.mahara.org/6879

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

Reviewed: https://reviews.mahara.org/6878
Committed: https://git.mahara.org/mahara/mahara/commit/ef20550e60e7e1ced8f21ced1cbbdf6f73ef78e1
Submitter: Son Nguyen (<email address hidden>)
Branch: 15.10_STABLE

commit ef20550e60e7e1ced8f21ced1cbbdf6f73ef78e1
Author: Aaron Wells <email address hidden>
Date: Mon Aug 15 13:27:10 2016 +1200

Bug 1613135: Better handling for negative block sort on upgrade

If there are negative block_instance.order values in the database,
then we'll just drop and re-create the unique key on the column.

behatnotneeded: Covered by existing tests

Change-Id: I3ef1507f82ae3dc24244e6236e173b6649a95d3b

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/6877
Committed: https://git.mahara.org/mahara/mahara/commit/e7107840209c5f2d911307c13ad668054b5eabbb
Submitter: Son Nguyen (<email address hidden>)
Branch: 16.04_STABLE

commit e7107840209c5f2d911307c13ad668054b5eabbb
Author: Aaron Wells <email address hidden>
Date: Mon Aug 15 13:27:10 2016 +1200

Bug 1613135: Better handling for negative block sort on upgrade

If there are negative block_instance.order values in the database,
then we'll just drop and re-create the unique key on the column.

behatnotneeded: Covered by existing tests

Change-Id: I3ef1507f82ae3dc24244e6236e173b6649a95d3b

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/6879
Committed: https://git.mahara.org/mahara/mahara/commit/f6f2d95dcfce42cafaa58e8c3b5e34c3588cb76c
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.04_STABLE

commit f6f2d95dcfce42cafaa58e8c3b5e34c3588cb76c
Author: Aaron Wells <email address hidden>
Date: Mon Aug 15 13:27:10 2016 +1200

Bug 1613135: Better handling for negative block sort on upgrade

If there are negative block_instance.order values in the database,
then we'll just drop and re-create the unique key on the column.

behatnotneeded: Covered by existing tests

Change-Id: I3ef1507f82ae3dc24244e6236e173b6649a95d3b

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/6842
Committed: https://git.mahara.org/mahara/mahara/commit/69e9794e4905d0244c979e726ee2d204d10e5765
Submitter: Son Nguyen (<email address hidden>)
Branch: master

commit 69e9794e4905d0244c979e726ee2d204d10e5765
Author: Aaron Wells <email address hidden>
Date: Mon Aug 15 13:27:10 2016 +1200

Bug 1613135: Better handling for negative block sort on upgrade

If there are negative block_instance.order values in the database,
then we'll just drop and re-create the unique key on the column.

Change-Id: I3ef1507f82ae3dc24244e6236e173b6649a95d3b
behatnotneeded: Covered by existing tests

Robert Lyon (robertl-9)
Changed in mahara:
milestone: 16.10.0 → none
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.

Other bug subscribers

Remote bug watches

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