Forums | Mahara Community

Support /
Unable to upgrade from 17.10.04 to 18.4.0


Peter Westebbe's profile picture
Posts: 18

17 May 2018, 9:49 PM

Hi,

I'm unable to upgrade Mahara to 18.4.0. I had no problem upgrading from 17.10.2 to 17.10.4.

This is the error code:

AH01071: Got error 'PHP message: [DBG] 83 (lib/db/upgrade.php:5532) Add an "useragent" field to usr_session table\nPHP message: [DBG] 83 (lib/db/upgrade.php:5543) Remove MaharaDroid configurations\nPHP message: [DBG] 83 (lib/db/upgrade.php:5552) Add Voki filters to DB\nPHP message: [INF] 83 (lib/upgrade.php:1410) Enabled 3 HTML filters.\nPHP message: [DBG] 83 (lib/db/upgrade.php:5557) Anonymising remaining deleted user data\nPHP message: [DBG] 83 (lib/db/upgrade.php:5566) Adding new event type "userleavesgroup"\nPHP message: [DBG] 83 (lib/db/upgrade.php:5574) Make site_content mauthor field have a user id by defaut\nPHP message: [DBG] 83 (lib/db/upgrade.php:5592) Create "site_content_version" table\nPHP message: [DBG] 83 (lib/mahara.php:2173) Table site_content_version exists. Create skipped\nPHP message: [DBG] 83 (lib/mahara.php:2173) Table site_content_version exists. Create skipped\nPHP message: [DBG] 83 (lib/db/upgrade.php:5613) Move the site and institution Privacy statement from the site_content table to the site_content_version table\nPHP message: [DBG] 83 (lib/db/upgrade.php:5635) Create "usr_agreement" table\nPHP message: [DBG] 83 (lib/mahara.php:2173) Table usr_agreement exists. Create skipped\nPHP message: [DBG] 83 (lib/db/upgrade.php:5653) Auto accept the privacy agreement for all site admins\nPHP message: [WAR] 83 (lib/errors.php:859) Failed to get a recordset: mysqli error: [1452: Cannot add or update a child row: a foreign key constraint fails ("mahara_x"."usr_agreement", CONSTRAINT "usragre_sit_fk" FOREIGN KEY ("sitecontentid") REFERENCES "site_content_version" ("id"))] in EXECUTE("INSERT INTO "usr_agreement" ("usr", "sitecontentid", "ctime", "agreed") VALUES ('1', 0, '2018-05-17 09:39:08', 1)")Command was: INSERT INTO "usr_agreement" ("usr", "sitecontentid", "ctime", "agreed") VALUES (?, ?, ?, ?) and values was (usr:1,sitecontentid:,ctime:2018-05-1709:39:08,agreed:1)\nPHP message: Call stack (most recent first):\nPHP message: * log_message("Failed to get a recordset: mysqli error: [1452: Ca...", 8, true, true) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/errors.php:95\nPHP message: * log_warn("Failed to get a recordset: mysqli error: [1452: Ca...") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/errors.php:859\nPHP message: * SQLException->__construct("Failed to get a recordset: mysqli error: [1452: Ca...") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/dml.php:1105\nPHP message: * insert_record("usr_agreement", object(stdClass)) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/user.php:3300\nPHP message: * save_user_reply_to_agreement("1", false, 1) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/db/upgrade.php:5657\nPHP message: * xmldb_core_upgrade("2017092615") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/upgrade.php:370\nPHP message: * upgrade_core(object(stdClass)) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/admin/upgrade.json.php:84\nPHP message: \n', referer: https://mahara.vhs-bayern.de/admin/upgrade.php

I cannot find a solution. Please help.

Regards

Peter

Cecilia Vela's profile picture
Posts: 56

21 May 2018, 9:51 AM

Hi Peter,

The only way this could happen is that you don't have a site privacy record in site_content before running the upgrade (SELECT * FROM site_content WHERE name='privacy'). Checking the code, there isn't a way to erase that record through mahara.

If you have a backup of the database, that you should make before doing upgrades, you can see if you have that record. If you do please restore the backup and try the upgrade again. If you have an issue again you can paste the error logs here so we can take a look at what could have gone wrong.

Cecilia

Peter Westebbe's profile picture
Posts: 18

25 May 2018, 2:13 AM

Hi Cecilia,

thank you for your advise. But it didn't solve the problem. The upgrade is still failing and I get the following error messages:

[WAR] 07 (lib/errors.php:859) Failed to get a recordset: mysqli error: [1452: Cannot add or update a child row: a foreign key constraint fails ("mahara_x"."usr_agreement", CONSTRAINT "usragre_sit_fk" FOREIGN KEY ("sitecontentid") REFERENCES "site_content_version" ("id"))] in EXECUTE("INSERT INTO "usr_agreement" ("usr", "sitecontentid", "ctime", "agreed") VALUES ('1', 0, '2018-05-24 09:24:59', 1)")Command was: INSERT INTO "usr_agreement" ("usr", "sitecontentid", "ctime", "agreed") VALUES (?, ?, ?, ?) and values was (usr:1,sitecontentid:,ctime:2018-05-2409:24:59,agreed:1)

Call stack (most recent first):

  • log_message("Failed to get a recordset: mysqli error: [1452: Ca...", 8, true, true) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/errors.php:95
  • log_warn("Failed to get a recordset: mysqli error: [1452: Ca...") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/errors.php:859
  • SQLException->__construct("Failed to get a recordset: mysqli error: [1452: Ca...") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/dml.php:1105
  • insert_record("usr_agreement", object(stdClass)) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/user.php:3300
  • save_user_reply_to_agreement("1", false, 1) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/db/upgrade.php:5657
  • xmldb_core_upgrade("2017092615") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/upgrade.php:370
  • upgrade_core(object(stdClass)) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/admin/upgrade.json.php:84

 We need the upgrade and I have no idea what to do. It seems to be a problem of the database.

Regards Peter

Cecilia Vela's profile picture
Posts: 56

30 May 2018, 10:24 AM

Hi Peter,

I can suggest an easy fix so you can finish running the upgrade:

Add following code in htdocs/lib/db/upgrade.php line 5654
just below the line log_debug('Auto accept the privacy agreement for all site admins');

if (!get_record('site_content_version', 'type', 'privacy', 'institution', 'mahara')) {
$record = new stdClass;
$record->type = 'privacy';
$record->content = get_string($record->type . 'defaultcontent', 'install', get_string('staticpageconfigdefaults', 'install'));
$record->author = 1;
$record->institution = 'mahara';
$record->version = '1.0';
$record->ctime = db_format_timestamp(time());
insert_record('site_content_version', $record);
}
and try again. If the upgrade is successful, please check the site privacy was generated correctly. To do this go to Admin menu -> Configure site -> Legal.

Regards,

Cecilia

Peter Westebbe's profile picture
Posts: 18

31 May 2018, 12:26 AM

Hi Cecilia,

i tried to follow your suggestion, but i still get the message update failed.

Maybe i made a mistake in copying the code:

if ($oldversion < 2018013000) {
log_debug('Auto accept the privacy agreement for all site admins');
if (!get_record('site_content_version', 'type', 'privacy', 'institution', 'mahara')) {
$record = new stdClass;
$record->type = 'privacy';
$record->content = get_string($record->type . 'defaultcontent', 'install',
get_string('staticpageconfigdefaults', 'install'));
$record->author = 1;
$record->institution = 'mahara';
$record->version = '1.0';
$record->ctime = db_format_timestamp(time());
insert_record('site_content_version', $record);
}
$sitecontentid = get_field('site_content_version', 'id', 'type', 'privacy', 'institution', 'mahara');
$admins = get_site_admins();
foreach ($admins as $admin) {
save_user_reply_to_agreement($admin->id, $sitecontentid, 1);
}}

 

This is the error message I get

[WAR] e8 (lib/errors.php:859) Failed to get a recordset: mysqli error: [1452: Cannot add or update a child row: a foreign key constraint fails ("mahara_x"."usr_agreement", CONSTRAINT "usragre_sit_fk" FOREIGN KEY ("sitecontentid") REFERENCES "site_content_version" ("id"))] in EXECUTE("INSERT INTO "usr_agreement" ("usr", "sitecontentid", "ctime", "agreed") VALUES ('1', 0, '2018-05-30 12:12:48', 1)")Command was: INSERT INTO "usr_agreement" ("usr", "sitecontentid", "ctime", "agreed") VALUES (?, ?, ?, ?) and values was (usr:1,sitecontentid:,ctime:2018-05-3012:12:48,agreed:1)
Call stack (most recent first):
  • log_message("Failed to get a recordset: mysqli error: [1452: Ca...", 8, true, true) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/errors.php:95
  • log_warn("Failed to get a recordset: mysqli error: [1452: Ca...") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/errors.php:859
  • SQLException->__construct("Failed to get a recordset: mysqli error: [1452: Ca...") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/dml.php:1105
  • insert_record("usr_agreement", object(stdClass)) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/user.php:3300
  • save_user_reply_to_agreement("1", false, 1) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/db/upgrade.php:5668
  • xmldb_core_upgrade("2017092615") at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/lib/upgrade.php:370
  • upgrade_core(object(stdClass)) at /var/www/vhosts/mahara.vhs-bayern.de/httpdocs/admin/upgrade.json.php:84

 

Regards 

Peter

Peter Westebbe's profile picture
Posts: 18

31 May 2018, 2:58 AM

Hi Cecilia,

I found not data entry site_content name=privacy. Maybe this is the problem? 

Regards

Peter

Cecilia Vela's profile picture
Posts: 56

05 June 2018, 10:43 AM

Hi Peter,

In this upgrade we are moving 'privacy' and 'terms and conditions' records from the site_content table to the site_content_version table.
At the point of the code that you have the exception the records for privacy have already been moved. That's why you should not see any row in site_content table for name=privacy but instead you should have a row in site_content_version for type=privacy.
At first I thought that the site_content_version was missing but it looks like that's not the case. The record must be there but with id=0, and somehow the system sees 0 as NULL when trying to insert into usr_agreement table.
Can you confirm if you have any data in site_content_version?
I tried to replicate the error but I couldn't. What version of mysql and php are you using? That could give us a clue to understand why this is happening.

Regards,

Cecilia

Peter Westebbe's profile picture
Posts: 18

06 June 2018, 12:27 AM

Hi Cecilia,

yes there is data in site_content_version

SELECT * FROM `site_content_version`

 

 

id         type     contentauthor  institution       versionctime  

1          privacy<p><a href="https://ttwportal.vhs-bayern.de/web/tt...                       1.0       2018-05-13 09:02:28  

2          termsandconditions     <h1>Terms and conditions</h1>

 

<p>[<i>This is a de...                            1.0       2018-05-13 09:02:28  

3          privacy<p><a href="https://ttwportal.vhs-bayern.de/web/tt...                       1.0       2018-05-16 15:11:20  

Privacy has two entries. 

Does this help? And thank your for your patience with me.

regards Peter

Peter Westebbe's profile picture
Posts: 18

11 June 2018, 4:46 AM

Hi Cecilia,

I'm thinking about two possible solution.

First: could it be that we run out of space? and does augmenting the storage space help?

Second: How about installing Mahara new and after installing changing the new database to the old one?

Help is definitely needed, because of the GDPR.

 

Regards 

Peter

Cecilia Vela's profile picture
Posts: 56

11 June 2018, 10:31 AM

Hi Peter,

Looking at the content of your "site_content_version" table, it looks like on May 13 there was an upgrade and the first 2 rows were inserted correctly.
Later on May 16 the third row was inserted, that is not supposed to be there, I can't think of how this happened.

I was wrong about the id being 0, I'm sorry about that. This is actually not working because there are 2 duplicated rows.

I'd recommend deleting the third row from "site_content_version", the one with id=3 that was inserted on 2018-05-16

id type content author institution version ctime
3 privacy <p><a href="https://ttwportal.vhs-bayern.de/web/tt... 1.0 2018-05-16 15:11:20

and try the upgrade again.

You should also remove the code I sent you before from the upgrade.php file, it actually doesn't do anything in this case.

I hope this time it will work.
Regards,
Cecilia

10 results