Artefacts not locked in in submitted view

Bug #1281787 reported by Robert Lyon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Robert Lyon

Bug Description

This looks to be problem with data on older sites. I've marked as high as bad data should be sorted asap

Looking in the database there are views submitted for review but artefacts used in the view are not locked.

To find the rows:
SELECT a.id
FROM view_artefact va
LEFT JOIN view v on v.id = va.view
LEFT JOIN artefact a on a.id = va.artefact
WHERE v.submittedgroup IS NOT NULL AND a.locked = 0

And to fix them:
UPDATE artefact SET locked = 1
FROM (SELECT a.id
FROM view_artefact va
LEFT JOIN view v on v.id = va.view
LEFT JOIN artefact a on a.id = va.artefact
WHERE v.submittedgroup IS NOT NULL AND a.locked = 0) AS subquery
WHERE artefact.id = subquery.id;

More investigation into how the databases ended up with bad data is needed and then a db upgrade change will need to be added to /lib/db/upgrade.php if needed.

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

Robert Lyon (robertl-9)
Changed in mahara:
status: Confirmed → In Progress
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Did you figure out what caused these to not get locked? As I just commented on the bug, I'd prefer not to push a data fix for this condition until we know for sure that it's not going to happen again; and the only way to know that, is to know what bug caused this and that we've fixed that bug.

Revision history for this message
Robert Lyon (robertl-9) wrote :

Ok, now I've figured out what is going on.

In v1.3 onwards there is a function called update_locked that correctly locks the related artefacts for the submitted view, in fact it takes the user id and makes sure all the things that need to be locked are and anything that doesn't need to be locked is unlocked.

In v1.2 the form submit function in view/submit.php only updated the view table and did not lock any artefacts at all.

So if a site has come from pre 1.3 and a user had submitted a view (or views) then but had not submitted anything post upgrade to 1.3 (or higher) then the submitted pages would not have the artefacts correctly locked.

The db update will check for any users that fall into this category and apply the locks for them (due to the probability they are old, not currently used accounts).

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

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

commit 30891a616ebc51a8283db2fb41052ba30509c6b5
Author: Robert Lyon <email address hidden>
Date: Mon Feb 24 10:43:10 2014 +1300

Making sure artefacts are locked for submitted views (Bug #1281787)

This can be a problem for older sites.

Should update any that are not locked but should be and do nothing if
all is fine.

Change-Id: Ie5fd71ab76b24009450987681a4800ccc3a8f496
Signed-off-by: Robert Lyon <email address hidden>

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