unable to create group home page

Bug #1287262 reported by jo matthews
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Aaron Wells
1.8
Fix Released
Medium
Aaron Wells

Bug Description

mahara version 1.8.1
mysql 5.6
Since upgrading from 1.7.2 to 1.8.1 we are unable to create new group home pages. After selecting 'create group', adding a group and selecting 'save group', the 'About' tab displays 'A nonrecoverable error occurred.' the error log displays:

[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] [WAR] ba (lib/view.php:2725) Unknown view layout (id=), referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] Call stack (most recent first):, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] * View->get_layout() at /data/mahara-vhosts/v181/lib/view.php:1776, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] * View->build_column_datastructure(1, false) at /data/mahara-vhosts/v181/lib/view.php:1828, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] * View->get_column_datastructure(1, 1) at /data/mahara-vhosts/v181/lib/view.php:1911, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] * View->build_column(1, 1, false) at /data/mahara-vhosts/v181/lib/view.php:1886, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] * View->build_columns(1, false) at /data/mahara-vhosts/v181/lib/view.php:1871, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] * View->build_rows() at /data/mahara-vhosts/v181/group/view.php:68, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php
[Mon Mar 03 16:46:57 2014] [error] [client 128.40.192.7] , referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php

If I select the 'my groups' tab, the group is displayed but I get the same error message if I try and edit it. If I select the group, the same error is displayed on the 'about' tab but all other tabs work correctly.

I suspect that something went wrong during the upgrade, although no error messages were reported in the error log. 9 new tables were created and the correct schema changes appear to have been applied according to the lib/db/upgrade.php. We didn't test creating groups on our uat instance before upgrading production and have now rolled back production to 1.7.2. However the problem exists on our dev and uat environments and we won't upgrade production until we can fix it on dev and uat. The dev and uat databases are a clone of production. I'm not sure if it's worth mentioning but the auto-increment is set to 2 on production and 1 on dev and uat. I'm wondering if something is going wrong during the upgrade when the new tables are populated.
Please let me know if I can provide any more information.

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

I'm unable to replicate the issue. It is a bit strange that the auto-increment is 2 rather than 1, but we wrote the code in a way that does not make any assumption about the automatically generated ID numbers, so that shouldn't pose a problem.

Looking at your error stack, one thing that makes me scratch my head is that the warning message "Unknown view layout (id=)" is from line 2725 of lib/view.php. In the code for release 1.8.1 (and 1.8.2dev) that warning should be on line 2721.

Do you have custom code in lib/view.php?

Cheers,
Aaron

Changed in mahara:
status: New → Incomplete
assignee: nobody → Aaron Wells (u-aaronw)
Revision history for this message
jo matthews (jo-matthews) wrote :

Thanks for looking in to this. I added some print statements to view.php on our dev environment to try and debug the issue which is why it's reporting a different line no. We have not customise the code at all. I'm not surprised that you can't replicate it because I think it's a database related issue.

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

Too bad, that was the only lead I had! ;)

Hm, well based on the fact that it says "(id=)", we know the $layoutid variable is null or an empty string. That means the only code path it could have followed was that $this->get_layout() returned null, and $numrows == 1.

That's not too surprising. New pages start out with a NULL layout and numrows set to 1. This changes if the user picks a different layout from the layouts tab, in which case it changes to point to the chosen layout. If the user adds or removes columns by using the optional account setting that lets you add/remove columns from the layout page using buttons, then it goes back to NULL.

When the layout is NULL, the number of columns on each row, and their widths, is meant to be determined by looking in the view_rows_columns table (which in turn maps to the view_layout_columns table to get the widths of the columns).

Now, with a $layoutid of NULL and a $numrows of 1, the code is going to go through the series of loops inside the if statement "if ($numrows == 1)". Based on the fact that it throws that exception, it means that it made it out without finding a suitable layout, and hence never assigned a value to $layout->id. So that means you're missing records from one or more of these tables: "view_layout_rows_columns", "view_layout", or "usr_custom_layout".

Since this happens with newly created groups, probably what happened is that the group homepage template page didn't get its layout information properly updated to the new layout format.

Hm... all that code inside the "else if (!$layoutid) {" part of that function is pretty wonky, especially the part for $numrows == 1. Perhaps, rather than trying to fix the layout records for the group homepage by hand, you could just delete the special block for handling pages with just 1 row, so that they're handled the same as pages with multiple rows? And get rid of the part where it checks the $layout->id and throws an exception. So then it'll look like this:

        else if (!$layoutid) {
                // multiple rows
                // get widths for each row, based on equal spacing of columns
                $layoutid = 0;
                $layout->id = $layoutid;
                foreach ($columnsperrow as $row) {
                    $numcolumns = $row->columns;
                    $widths = self::$defaultcolumnlayouts[$numcolumns];
                    $layout->rows[$row->row]['widths'] = $widths;
                    $layout->rows[$row->row]['columns'] = $numcolumns;
                }
        }

        return $layout;

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

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

I've pushed a patch to gerrit that strips out the code I was talking about: https://reviews.mahara.org/3067

Changed in mahara:
importance: Undecided → Medium
milestone: none → 1.8.2
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Lol, one more update. I was wrong when I mentioned that the "view_rows_columns" table maps to the "view_layout_columns" table. It does not. It simply says how many columns there in each row, and then the columns are made to be evenly spaced.

There actually is another (minor) bug there, unrelated to jo's issue. If you create a page, give it a multi-row layout where the columns are not evenly spaced, and then you go back to the "edit content" tab and use the add/remove buttons to drop a column from one row, all of the rows will be changed to make their columns evenly spaced.

The workaround to this, is to use the "edit layout" tab to specifically engineer your layout.

Revision history for this message
jo matthews (jo-matthews) wrote :

Thanks for your comprehensive explanation Aaron. Do you need me to test this patch? If so, do I just need to download the new view.php script and replace the current lib/view.php in my 1.8.1 version? Sorry, I'm not familiar with testing patches.

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

Hi jo,

Yes, if you could test it that would be helpful. If you're not comfortable with git or with patch files, then just downloading the new view.php file and replacing your existing one should work. There are a few different ways you can download that file from gerrit. Here's a link that should do the job. Just unzip this, rename the file to view.php, and replace your lib/view.php with it.

https://reviews.mahara.org/cat/3067%2C1%2Chtdocs/lib/view.php%5E0

Cheers,

Aaron

Revision history for this message
jo matthews (jo-matthews) wrote :

Ok, I've replaced view.php and tried creating a new group. I get the following error:
[Thu Mar 06 09:41:04 2014] [error] [client 128.40.192.7] PHP Fatal error: Call to undefined function check_case_sensitive() in /data/mahara-vhosts/v181/lib/view.php on line 717, referer: https://v181.myportfolio-dev.ucl.ac.uk/group/edit.php

If I log in as another user and select an existing group, I get the following error:
[Thu Mar 06 09:47:50 2014] [error] [client 128.40.192.7] [WAR] 53 (lib/errors.php:736) Failed to get a recordset: mysqli error: [1054: Unknown column 'ucl.group' in 'on clause'] in EXECUTE(", referer: https://v181.myportfolio-dev.ucl.ac.uk/

Thanks

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

Oh, right, you're on Mahara 1.8.1, and that gerrit patch is on master (Mahara 1.9dev), which has other changes to view.php that are not compatible with 1.8.1.

I will attach to this comment, a copy of the 1.8.1 view.php with this patch applied to it. Please try that.

Cheers,
Aaron

Revision history for this message
jo matthews (jo-matthews) wrote :

Brilliant. Your a star. I've done some basic testing on dev and installed your fix on uat for user testing. I'll let you know how it goes but thanks for a speedy resolution.

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

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

commit 41d6d46cbe57e37de58ee2cc84bd3e597f57d3ee
Author: Aaron Wells <email address hidden>
Date: Wed Mar 5 13:51:35 2014 +1300

Remove unnecessary code for single-row NULL layout views

Bug 1287262

Change-Id: I95dc1c1c9551ecceac4de852f7ca23ce8ac1c5cd

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

Patch for "1.8_STABLE" branch: https://reviews.mahara.org/3090

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

Reviewed: https://reviews.mahara.org/3090
Committed: http://gitorious.org/mahara/mahara/commit/e60bde4a82b4a0d7be1ac4688410cef1e3946f00
Submitter: Aaron Wells (<email address hidden>)
Branch: 1.8_STABLE

commit e60bde4a82b4a0d7be1ac4688410cef1e3946f00
Author: Aaron Wells <email address hidden>
Date: Wed Mar 5 13:51:35 2014 +1300

Remove unnecessary code for single-row NULL layout views

Bug 1287262

Change-Id: I95dc1c1c9551ecceac4de852f7ca23ce8ac1c5cd

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
no longer affects: mahara/1.9
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.