Views and collection list (in group) throws MySQL error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
High
|
Robert Lyon | ||
17.10 |
Fix Released
|
High
|
Unassigned | ||
18.04 |
Fix Released
|
High
|
Robert Lyon | ||
18.10 |
Fix Released
|
High
|
Robert Lyon |
Bug Description
If a normal group member tries to visit views and collections of the group, following warning/error is thrown under some conditions which are mentioned below:
SQL:
[WAR] 93 (lib/errors.
PHP:
Call stack (most recent first):
log_message("Failed to get a recordset: mysqli error: [1452: Ca...", 8, true, true) at /var/www/
log_warn("Failed to get a recordset: mysqli error: [1452: Ca...") at /var/www/
SQLException-
insert_
ensure_
View->_
View::get_
This happens if the group views and collections are readonly to members, a group collection exisits with at least one view inside and in the DB there is no view which has the same id as this collection.
I didn't went too deep inside the code, but it seems that this issue is somehow connected to the bug #1514608.
It further seems that Mahara interprets a collection as a view trying to get/set view related data using a collection id to avoid having no DB entry in table view_rows_columns for this erroneously supposed view so the actually error should be found in functions calling this code areas (get_extra_
Reproduce error:
Create a group in which views and collections are only editable by others that normal group members.
Create a view and a collection inside this group and assign the view to the collection.
Make sure, that in the DB there are no entries referring to a view which has the same id as the above created collection (e. g. by deleting a possibly existing view with this id inside Mahara).
As a normal group member call the tab views and collection of the group.
Greetings
Alex
The problem here stems from the htdocs/ view/groupviews .php file around these lines:
$data = View::view_ search( null, null, (object) array('group' => $group->id), null, $limit, $offset,
true, null, null, false, null, null,
null, null, true); get_extra_ view_info( $viewdata, false); get_extra_ collection_ info($viewdata, false, 'collid');
$viewdata = $data->data;
View::
View::
The issue is that $viewdata is an array of both collection and view data so when it gets to
View:: get_extra_ view_info( $viewdata, false);
it treats the collection 'id' like it is a view 'id' and if the collection has an 'id' that doesn't exist as an 'id' in the view table we get this error