error upgrading from moodle 1.9 - 2.0

error upgrading from moodle 1.9 - 2.0

by Jayne Hepburn -
Number of replies: 9

I am trying to upgrade our Moodle from 1.9.7+ (Build: 20100217) (2009103000) to 2.0.10 (Build: 20120706) (2011033010) and receive the following error message. ( please see attached txt file)

I urgently need to perform this upgrade as our site needs to be moved onto a bigger server and we need the functionality that moodle 2.0 has to offer. I am using xampp on a windows 2012 standard server.

Many thanks for help in advance

 

 

Average of ratings: -
In reply to Jayne Hepburn

Re: error upgrading from moodle 1.9 - 2.0

by Luis de Vasconcelos -

Please paste the actual error message here. There's a lot of "mso" (MS Office???) rubbish in that text file.

And what database engine are you using?

In reply to Luis de Vasconcelos

Re: error upgrading from moodle 1.9 - 2.0

by Jayne Hepburn -

Hi Luis

this is the beginning and end of the error code:

system
Error writing to database
More information about this error
Debug info: Data too long for column 'summary' at row 1
UPDATE mdl_course SET summary = ?,summaryformat = ? WHERE id=?
[array (

1 => '1',
2 => '784',
)]
Stack trace:
    •    line 394 of \lib\dml\moodle_database.php: dml_write_exception thrown
    •    line 999 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
    •    line 1031 of \lib\dml\mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->update_record_raw()
    •    line 2390 of \lib\db\upgrade.php: call to mysqli_native_moodle_database->update_record()
    •    line 1393 of \lib\upgradelib.php: call to xmldb_main_upgrade()
    •    line 273 of \admin\index.php: call to upgrade_core()

Do you know how I can trace the MSO in the moodle courses?

I am using mysql

Many thanks

Jayne

In reply to Jayne Hepburn

Re: error upgrading from moodle 1.9 - 2.0

by Guillermo Madero -

Hi Jayne,

As mentioned in the error message: Data too long for column 'summary'.

You need to go into the course and clean up its summary. There is an unreasonable amount of useless Word formatting code in there.

People in charge of creating courses should really understand that they mustn't paste content from Word directly into the editor box.

In reply to Guillermo Madero

Re: error upgrading from moodle 1.9 - 2.0

by Jayne Hepburn -

Hi Guillermo

Do you think the MSO word is preventing the upgrade. Do you know how I can trace the word formatting in the Moodle courses, we have 100's of courses in our existing Moodle site and I don't know where to begin looking. Many thanks for your help

Jayne

In reply to Jayne Hepburn

Re: error upgrading from moodle 1.9 - 2.0

by Ken Task -
Picture of Particularly helpful Moodlers

As G said, lots of  junk and yes, it could affect upgrade.

You can see just how much/many courses you might have that has MSO summaries by using DB query on the db for moodle:

select id,fullname,summary from mdl_course;

id above is the course ID.  fullname will help find the course in the 1.9.

If you see a bunch of MSO references (like those in the text file you provided) those are the courses you need to edit/change.  Would be best to do this in the Moodle user interface of the copy of current 1.9 version you are running, I would think, but there's a work-around … that does involve work.

When using the above query, copy and paste the results of one reference/record out into NotePad. Anything you can use that will strip out the MSO tags - you, obviously, want to keep the text … even if it's NOT formatted (teachers could reformat their summary after site is migrated).

Then, using something like phpmyadmin, edit the record pasting the 'scrubbed text' back into the summary field.

Since you've already tried the upgrade, the DB for the 2.0.10 probably needs to be dumped and a new one used.  Hopefully, you've followed advice given on upgrades and have been working with a copy of the 1.9 site.  Use the edited 1.9 DB.

While the error doesn't specifically mention this it is, I think, related.  IF your users have been copying and pasting from MSO, might want to increase the max_allowed_packet setting for the DB server.

Under [mysqld] in my.cnf file add a line:
max_allowed_packet=500M

Restart mysqld for changes to take affect.

Default    1048576 or 1M

If one gets errors in debug concerning the DB like the one you got, have found this reference to be handy:

http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html

'spirit of sharing', Ken

In reply to Jayne Hepburn

Re: error upgrading from moodle 1.9 - 2.0

by Guillermo Madero -

Hi Jayne,

Definitely yes. Word-copied text includes insane amounts of code that are (usually) not needed anywhere but in Word itself (or in other MS applications).

To determine which courses have summary texts with Word formatting code, run the following SQL query (use phpMyAdmin, if you have it):

SELECT `id`, `shortname`, `fullname`
FROM `mdl_course`
WHERE `summary`
LIKE '%<w:WordDocument>%';

 In the SQL statement I selected a common Word formatting string (<w:WordDocument>), but you can use any of the ones that appear in your report. You could also search for several strings at the same time:

SELECT `id`, `shortname`, `fullname`
FROM `mdl_course`
WHERE `summary`
LIKE '%<w:WordDocument>%'
OR '%mso-style-name%';

You would then:

1. go to each listed course;

2. select the edit icon of the summary;

3. copy the text from the editor box and either:

a. paste it into notepad (or any plain text editor); copy it once again from notepad and then paste it into your Moodle summary editor box; or

b. run use a program like GetPlainText and then paste it back into the editor box.

4. save your changes.

Repeat these steps for each course listed by the SQL SELECT query.

In reply to Guillermo Madero

Re: error upgrading from moodle 1.9 - 2.0

by Jayne Hepburn -

Thank you v much Guillermo and Ken smile that worked a treat and I managed to get rid of the MSO in 1 course.

However I am getting another error message

Debug info: Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='
SELECT DISTINCT c.id AS courseid, ra.enrol, c.timecreated, c.timemodified
FROM mdl_course c
JOIN mdl_context ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = 50)
JOIN mdl_role_assignments ra ON (ra.contextid = ctx.id AND ra.enrol <> '')
LEFT JOIN mdl_enrol e ON (e.courseid = c.id AND e.enrol = ra.enrol)
WHERE c.id <> ? AND e.id IS NULL
[array (
0 => '1',
)]
Stack trace:
  • line 391 of \lib\dml\moodle_database.php: dml_read_exception thrown
  • line 768 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 4093 of \lib\db\upgrade.php: call to mysqli_native_moodle_database->get_recordset_sql()
  • line 1393 of \lib\upgradelib.php: call to xmldb_main_upgrade()
  • line 273 of \admin\index.php: call to upgrade_core()
Your help is much appreciated as I'm running out of time to migrate.Ken I am using a testing server for all this. Wanted to get the upgrade steps correct before I work on the live site. Thanks Jayne
In reply to Jayne Hepburn

Re: error upgrading from moodle 1.9 - 2.0

by Guillermo Madero -

Lucky you it was only one course!

That collation problem is another issue and you create a new post. I'll answer it here for the time being.

The following three SQL statements are to set the character set (must be utf8) and collation (could be ut8_unicode_ci, slower but more precise; or ut8_general_ci, faster but less precise) for 1) the database 2) a table 3) a column in a table.

ALTER DATABASE database_name DEFAULT CHARACTER SET utf8 COLLATE new_collation

ALTER TABLE table_name DEFAULT CHARACTER SET utf8 COLLATE new_collation

ALTER TABLE table_name MODIFY column_name column_type CHARACTER SET utf8 COLLATE new_collation

In phpMyAdmin check what collation is using your db, your tables and the text-type columns of each table, and use the previous statements to fix them as needed.

Another, easier and faster option, is to use the mysql_collation.php script included in Moodle 2.2 (not sure if also in M 2.1) under the moodle/admin/cli path. You could download a M 2.2 package, uncompress it, put that script in your own installation (your-moodle-directory/admin/cli) and run it via shell access (see the script).

--- edit

Here it is:

https://github.com/moodle/moodle/blob/master/admin/cli/mysql_collation.php

In reply to Jayne Hepburn

Re: error upgrading from moodle 1.9 - 2.0

by Ken Task -
Picture of Particularly helpful Moodlers

Dang it!  That was the other thought I had but failed to mention sad ... character set and collation as well as engine now have to be particular.  Character set: utf8 with collation utf8_general_ci and Engine must be Innodb.

In 2.1 code (scripts don't exist in 2.0.x), there should be a couple of scripts you can run from the command line to take care of all that:

in moodlecode/admin/cli/

Run like (shows linux - adjust for Winders):

sudo -u www-data /usr/bin/php admin/cli/mysql_collation.php --collation=utf8_general_ci

And

sudo -u www-data /usr/bin/php admin/cli/mysql_engine.php --engine=InnoDB

Reason for using the scripts, normally such changes require one to do so on each table.  Too many tables!  The scripts make those changes to *ALL* tables. ;)

'spirit of sharing', Ken

Average of ratings: Useful (1)