Duplicate records in usr_custom_layout cause fatal crash when copying a collection
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
High
|
Unassigned | ||
1.10 |
Fix Released
|
High
|
Unassigned | ||
15.04 |
Fix Released
|
High
|
Unassigned | ||
15.10 |
Fix Released
|
High
|
Unassigned |
Bug Description
When creating a collection by copying a previous collection we are getting an error of:
Site unavailable
A nonrecoverable error occurred. This probably means you have encountered a bug in the system
PHP is reporting the following error and we are on the latest version of Mahara to date 15.10.0:
2015/11/13 09:02:51 [error] 1077#0: *7505 FastCGI sent in stderr: "PHP message: [WAR] 0a (lib/errors.
PHP message: Call stack (most recent first):
PHP message: * log_message(
PHP message: * log_warn(
PHP message: * SQLException-
PHP message: * get_record_
PHP message: * get_record(
PHP message: * View::create_
PHP message: * Collection:
PHP message: * createview_
PHP message: * call_user_
PHP message: * Pieform-
PHP message: * Pieform:
PHP message: * pieform(array(size 8)) at /scratch/
PHP message:
PHP message: [WAR] 0a (lib/dml.php:327) get_record_sql found more than one row. If you meant to retrieve more than one record, use get_records_*, otherwise check your code or database for inconsistencies
PHP message: Ca
Cheers,
Ed
Changed in mahara: | |
milestone: | none → 15.10.1 |
status: | New → Incomplete |
no longer affects: | mahara/16.04 |
Changed in mahara: | |
status: | Fix Committed → Fix Released |
Hi Ed,
This error is due to your database having duplicate rows in the usr_custom_layout table for the user before they try to copy the collection, of which at least one page has the same layout.
The code is expecting to retrieve only one row to match against the current page being copied.
A few users of mahara have reported this problem but I've yet not been able to replicate how they got duplicate rows in the usr_custom_layout table in the first place.
If you could shed some light on that it would be great.
Anyway a fix for the problem is to remove by first finding them:
SELECT * FROM usr_custom_layout WHERE usr IS NOT NULL AND usr > 0 ORDER BY usr, layout;
The problem rows should show the same 'usr' id and 'layout' id in pairs.
You just need to pick one of the pair and delete id
Cheers
Robert