Bugs after updating Mahara

Bug #1632717 reported by Antonella DC
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Invalid
Undecided
Unassigned

Bug Description

Hello,

After the update to the latest version of Mahara (16.04) I have problems with the display pages of the groups.

Here is an example :

[WAR] 1b (lib/group.php:2338) Trying to get property of non-object
Call stack (most recent first):

    log_message(string(size 36), integer, true, true, string(size 53), integer) at /mypath/maha/lib/errors.php:513
    error(integer, string(size 36), string(size 53), integer, array(size 2)) at /mypath/maha/lib/group.php:2338
    group_get_homepage_view(string(size 2)) at /mypath/maha/lib/view.php:5734
    View->display_author() at /mypath/maha/view/view.php:362

[WAR] 1b (lib/errors.php:820) Failed to get a recordset: mysqli error: [1452: Cannot add or update a child row: a foreign key constraint fails ("mybdd"."view", CONSTRAINT "view_ibfk_7" FOREIGN KEY ("type") REFERENCES "view_type" ("type"))] in EXECUTE("INSERT INTO "view" ("ctime", "mtime", "atime", "copynewuser", "anonymise") VALUES ('2016-10-12 15:32:22', '2016-10-12 15:32:22', '2016-10-12 15:32:22', 0, 0)")
Command was: INSERT INTO "view" ("ctime", "mtime", "atime", "copynewuser", "anonymise") VALUES (?, ?, ?, ?, ?) and values was (ctime:2016-10-1215:32:22,mtime:2016-10-1215:32:22,atime:2016-10-1215:32:22,copynewuser:0,anonymise:0)
Call stack (most recent first):

    log_message(string(size 618), integer, true, true) at /mypath/maha/lib/errors.php:95
    log_warn(string(size 618)) at /mypath/maha/lib/errors.php:820
    SQLException->__construct(string(size 618)) at /mypath/maha/lib/dml.php:1088
    insert_record(string(size 4), object(stdClass), string(size 2), true) at /mypath/maha/lib/view.php:728
    View->commit() at /mypath/maha/lib/view.php:702
    View->__destruct() at /mypath/maha/view/view.php:362
    View->display_author() at /mypath/maha/view/view.php:362

[WAR] 1b (lib/dml.php:1088) Failed to get a recordset: mysqli error: [1452: Cannot add or update a child row: a foreign key constraint fails ("mybdd"."view", CONSTRAINT "view_ibfk_7" FOREIGN KEY ("type") REFERENCES "view_type" ("type"))] in EXECUTE("INSERT INTO "view" ("ctime", "mtime", "atime", "copynewuser", "anonymise") VALUES ('2016-10-12 15:32:22', '2016-10-12 15:32:22', '2016-10-12 15:32:22', 0, 0)")
Command was: INSERT INTO "view" ("ctime", "mtime", "atime", "copynewuser", "anonymise") VALUES (?, ?, ?, ?, ?) and values was (ctime:2016-10-1215:32:22,mtime:2016-10-1215:32:22,atime:2016-10-1215:32:22,copynewuser:0,anonymise:0)
Call stack (most recent first):

    insert_record(string(size 4), object(stdClass), string(size 2), true) at /mypath/maha/lib/view.php:728
    View->commit() at /mypath/maha/lib/view.php:702
    View->__destruct() at /mypath/maha/view/view.php:362
    View->display_author() at /mypath/maha/view/view.php:362

Untitled
Mywebsite Mahara : Site unavailable
A nonrecoverable error occurred. This probably means you have encountered a bug in the system

Thank you for your help.

Tags: bug mysql update
Revision history for this message
Antonella DC (antonella88) wrote :
description: updated
Revision history for this message
Robert Lyon (robertl-9) wrote :

Hi Antonella,

The errors you are seeing comes from this scenario:

You visit a group owned page and that page tries to fetch the name of the group it belongs to so it can display that name as page's author by fetching the info from the group's homepage.

But for some reason in this instance the group's homepage can't be found, which is very strange as one shouldn't be able to delete the group's homepage via Mahara itself.

I could replicate getting the same errors when I changed one of my groups homepage view (via db) from type = 'grouphomepage' to type = 'portfolio'.

Can I get you to find the page you are trying to view in the database and therefore find out it's group id number.

 SELECT title,`group` FROM view WHERE id = [ID];

where you replace the [ID] with the view id of the page.

Once you find the group id then do a query like:

SELECT id,title,type FROM view where `group` = [ID];

where you replace the [ID] with the group id number you found.

Normally it should show something similar to:

 id | title | type
----+----------------+----------------
 62 | Group page 1 | portfolio
 53 | Group page 2 | portfolio
 51 | Group homepage | grouphomepage

where one (and only one) of the group's pages is the type grouphomepage

If there are no pages with type = grouphomepage then can you either set one of the existing pages (via db) for the group to be type = grouphomepage

Or you can go to the group (via browser) and on the Pages tab click 'create page', give it a title and save (no need to edit content yet). Get it's id by looking at the url in browser and then (via db) update that page to be type grouphomepage.

 UPDATE view SET type = 'grouphomepage' WHERE id = [ID];

where you replace the [ID] with the page's id number you want to use.

Then reload the page in browser and you should see the title of the page has changed to 'Group homepage' and you will be able to add group homepage blocks to it now.

Add what you need and then click 'Return to group pages'.

So now when you go to view the page that was broken before it should display fine.

If you are able to shed any light into how the grouphomepage got removed that would be very helpful too

Cheers

Robert

Changed in mahara:
status: New → Incomplete
Revision history for this message
Robert Lyon (robertl-9) wrote :

Another thing you can do is check to see if there are any other broken groups

SELECT id, name FROM `group` WHERE id NOT IN (SELECT `group` FROM view WHERE `group` > 0 AND type = 'grouphomepage') AND deleted = 0;

It should return an empty set if all groups are fine.

Revision history for this message
Antonella DC (antonella88) wrote :

Hello,

Thank you for your response !

Unfortunately the error doesn't concern the 'grouphomepage' page but the 'portfolio' page of the groups (only the view).

So, I add this code to raw2/pieforms/viewlaytout.php because I want to have the page edit + layout in the same layout (in view I also create editlayout.php and editlaytout.tpl in raw2) :

// Code Anto
$output .= '<div class="modifiertoutensemble">';
$output .= $elements['title']['labelhtml'] . $elements['title']['html'];
// $output .= $elements['urlid']['html'];
$output .= $elements['description']['labelhtml'] .'<br/>'. $elements['description']['html'];
$output .= $elements['description']['tags'] . $elements['tags']['html'] .'<br/><span style="font-style:italic">'. $elements['tags']['description'] . '</span>';
$output .= $elements['ownerformat']['labelhtml'] . $elements['ownerformat']['html'] .'<br/><span style="font-style:italic">'. $elements['ownerformat']['description'] . '</span>';
$output .= $elements['locked']['labelhtml'] . $elements['locked']['html'] .'<br/><span style="font-style:italic">'. $elements['locked']['description'] . '</span>';
$output .= $elements['anonymise']['labelhtml'] .'<br/>'. $elements['anonymise']['html'];
$output .= '<br/></div>';
// Fin code Anto

In localhost and in a new Mahara with a new database it works, but after the migration, in two others mahara it doesn't work.

Here an example of the form in the database :

title : Test
description : <p>&nbsp;</p><div id="kpm_content_wrapper" class...
group : 1
ctime : 2016-09-28 11:50:05
mtime : 2016-09-28 11:51:10
atime : 2016-10-13 10:04:34
theme : NewMedZone
type : portfolio
urlid : untitled

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

Hi Antonella,

The error does concern the 'grouphomepage' page as shown by the error information you pasted in, these lines in particular:

    group_get_homepage_view(string(size 2)) at /mypath/maha/lib/view.php:5734
    View->display_author() at /mypath/maha/view/view.php:362

What is happening is the group's 'portfolio' page is trying to get it's author name, via View->display_author(), from the name of the 'grouphomepage', via group_get_homepage_view(), but it can't find the 'grouphomepage'.

If you look at a normal profile page there is a 'by [user]' below title of the page. That link shows the name of the user that created the page. So in the case of a group's 'portfolio' page it is trying to show the author as the name of the group, eg 'by [groupname]' and it does this by fetching the group's 'grouphomepage' so that it can A) get the title and B) make sure the user viewing the page has permission to see the author's name.

Cheers

Robert

Revision history for this message
Lilian HUGUES (lilian-hugues) wrote :

Hi Robert,
Many thanks for your diagnose.
It is exactly the issue, it happens when the grouphomepage for the group does not exist. If we manually create one in the base, it fixes the issue.
Actually, the issue is when a user creates a new group.
It show the message :
"
Medzone.fr: Site unavailable
Something in the way you're interacting with Medzone.fr is causing an error.
Details if any, follow:

User with id "0" is not known"

The group is however created but without any grouphomepage. Moreover, if we want to reenter in the parameters of the groupe, it drives us to a error 500.

Do you have any idea to fix it ?

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Lilian and Antonella, did you customize the group creation process? Normally, when you create a group, a group homepage is always added by default because without it, the group couldn't exist.

Also, maybe a long shot, do you still see the "Group homepage" page under Administration -> configure site -> Pages? That's the default group homepage.

Revision history for this message
Antonella DC (antonella88) wrote :

Hi Kristina,

No, the group file has not been touched, however I have changed the view/edit.php file.

Revision history for this message
Antonella DC (antonella88) wrote :

It's exactly the same problem : https://bugs.launchpad.net/mahara/+bug/1156559

But how danbuntu fix it ?

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

He hasn't fixed it. He had the problem at some point, but nobody complained about it anymore for 3 years, so it must have gone away with an update or upgrade. I wonder if there is an issue with a missing or corrupt file in your codebase. We can't really say without further investigation.

Revision history for this message
Antonella DC (antonella88) wrote :

[WAR] 72 (artefact/file/lib.php:2545) Undefined variable: type
Call stack (most recent first):

    log_message(string(size 24), integer, true, true, string(size 61), integer) at /mymahara/lib/errors.php:521
    error(integer, string(size 24), string(size 61), integer, array(size 8)) at /mymahara/artefact/file/lib.php:2545
    ArtefactTypeProfileIcon::download_thumbnail(integer) at /mymahara/thumb.php:32

[WAR] 0d (artefact/file/lib.php:2545) Undefined variable: type
Call stack (most recent first):

    log_message(string(size 24), integer, true, true, string(size 61), integer) at /mymahara/lib/errors.php:521
    error(integer, string(size 24), string(size 61), integer, array(size 8)) at /mymahara/artefact/file/lib.php:2545
    ArtefactTypeProfileIcon::download_thumbnail(integer) at /mymahara/thumb.php:32

Revision history for this message
Antonella DC (antonella88) wrote :

The problem is surely in the database : with a new db it works, so the bug is not in the files of mahara.
Maybe after the update the database has been damaged ?

Revision history for this message
Antonella DC (antonella88) wrote :

Could we send you the database ?

Revision history for this message
Lilian HUGUES (lilian-hugues) wrote :

Kristina, Robert,
our issue seems coming from our database.
It is very annoying because it not possible for user to create a well working group.
As I've written before, the group edit page of every group drives us to an error 500.

Is it possible for you to have a look on our data base (previous message from antonella) and try to reproduce the bug ?

Many thanks in advance for your help.

My best regards,

Revision history for this message
Antonella DC (antonella88) wrote :

For those who have the same problem, we solved by adding a user with id 0.

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Oh, the root user was missing? Do you remember if you deleted that at some point? Mahara sets up the user with id 0 during the initial set up and it is not present on the user interface.

The user is required for some actions and thus shouldn't be deleted. I'll spin off the wishlist item bug #1636286 to implement a check that the user exists and set this issue to "Invalid" as it's not a problem in Mahara but in the data.

Changed in mahara:
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

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