Upgrade to 1.9 - Fatal error

Upgrade to 1.9 - Fatal error

by Nick Gault -
Number of replies: 7
We have been upgrading our Moodle install which is running on Windows Server 2003 from version 1.6 to 1.9 (in stages).

All has been well until the last step up to 1.9.

We now see the following error in place of the right hand blocks on the front page:

Fatal error: Call to a member function Close() on a non-object in D:\websites\Moodle\lib\dmllib.php on line 853

Turning on debugging yields:

Unknown column 'g.courseid' in 'where clause'

SELECT ctx.* FROM mdl_context ctx WHERE ctx.path LIKE '/1/28/113/142/%' AND ctx.contextlevel IN (70,80) UNION SELECT ctx.* FROM mdl_context ctx JOIN mdl_groups g ON (ctx.instanceid=g.id AND ctx.contextlevel=60) WHERE g.courseid=1311 UNION SELECT ctx.* FROM mdl_context ctx JOIN mdl_block_pinned b ON (ctx.instanceid=b.blockid AND ctx.contextlevel=80) WHERE b.pagetype='course-view'
line 686 of lib\dmllib.php: call to debugging()
line 3790 of lib\accesslib.php: call to get_recordset_sql()
line 348 of lib\pagelib.php: call to get_child_contexts()
line 364 of lib\pagelib.php: call to page_course->init_full()
line 94 of course\view.php: call to page_course->user_allowed_editing()
Incorrect rs used!
line 814 of lib\dmllib.php: call to debugging()
line 3792 of lib\accesslib.php: call to rs_fetch_next_record()
line 348 of lib\pagelib.php: call to get_child_contexts()
line 364 of lib\pagelib.php: call to page_course->init_full()
line 94 of course\view.php: call to page_course->user_allowed_editing()


Anyone have any idea how to troubleshoot this?

Thanks in advance,

Nick
Average of ratings: -
In reply to Nick Gault

Re: Upgrade to 1.9 - Fatal error

by Mike Mike -
We are upgrading from 1.8.4 to 1.9-latest and experienced the same problem. Header is displayed and then the message from above.

We have not enabled debugging to see if the same lines are causing the problem.

Anyone else experiencing this or have an idea how to fix?
In reply to Nick Gault

Re: Upgrade to 1.9 - Fatal error

by Matt Campbell -
Would you take a look at mdl_groups and give us a list of all the columns? Groupings was introduced in Moodle 1.8 and then pulled back in Moodle 1.8.1, and the columns for mdl_groups are different depending on what version you are using. What version numbers (1.6.x, 1.7.x, 1.8.x) are you using to get to 1.9? I think that this will be your culprit in this issue.

I would recommend that you use the highest version number available when upgrading from one version to the next.

Thanks,
Matt
In reply to Nick Gault

Re: Upgrade to 1.9 - Fatal error

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
Hello,

please make sure you followed steps described in
http://docs.moodle.org/en/Upgrade

Did you go to http://yourmoodle/admin/ in order to trigger the upgrade?

Petr
In reply to Petr Skoda

Re: Upgrade to 1.9 - Fatal error

by Mike Mike -
Upgrading to a newer 1.8 seemed to work for me.  Either I made a mistake in the 1.9 upgrade process to begin with, or something in the intermediary helped.  Regardless, thanks.
In reply to Mike Mike

Re: Upgrade to 1.9 - Fatal error

by Jamie Chandler -

I have the same problem before I went from version 1.8.3 to 1.9 and it would not update to the new version.

I then updated to version 1.8.4 before going to 1.9 and it went through the update procedure.  However at the end I am getting the message below.  This is with debugging turned on:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1,6,3403,5355,80,3539,3404,82,72,84,5,9,38,18,8,30,50,41,4,13,24,22,33,26,54,441' at line 15

SELECT ctx.path, ctx.instanceid, ctx.contextlevel, ra.hidden, r.id AS roleid, r.name as rolename, u.id AS userid, u.firstname, u.lastname FROM mdl_role_assignments ra JOIN mdl_context ctx ON ra.contextid = ctx.id JOIN mdl_user u ON ra.userid = u.id JOIN mdl_role r ON ra.roleid = r.id LEFT OUTER JOIN mdl_course c ON (ctx.instanceid=c.id AND ctx.contextlevel=50) WHERE ( c.id IS NOT NULL OR ra.contextid IN (,1,6,3403,5355,80,3539,3404,82,72,84,5,9,38,18,8,30,50,41,4,13,24,22,33,26,54,4413,78,77,1298,3538,185,3609,3610,3405,3540,3566,3765,11,1385,35,5289) ) AND ra.roleid IN (3) ORDER BY r.sortorder ASC, ctx.contextlevel ASC, ra.sortorder ASC
  • line 686 of lib\dmllib.php: call to debugging()
  • line 727 of lib\datalib.php: call to get_recordset_sql()
  • line 1796 of course\lib.php: call to get_courses_wmanagers()
  • line 223 of index.php: call to print_courses()
Incorrect rs used!
  • line 814 of lib\dmllib.php: call to debugging()
  • line 731 of lib\datalib.php: call to rs_fetch_next_record()
  • line 1796 of course\lib.php: call to get_courses_wmanagers()
  • line 223 of index.php: call to print_courses()


Fatal error: Call to a member function Close() on a non-object in C:\AppServer\xampp\htdocs\moodle\lib\dmllib.php on line 853

In reply to Jamie Chandler

Re: Upgrade to 1.9 - Fatal error

by Richard Enison -
JC,

The SQL syntax error is indicated as being near the long list of numbers of context id's; that list is immediately preceded by a comma, which is preceded by a left parenthesis, in the SQL query. That initial comma could be the problem. The php code that generates that query is buggy. I don't know exactly where it is, because I don't have 1.9. I've got enough problems trying to understand 1.8.3! But my guess would be it's in one of the php files listed in your error msg. (dmlib.php, datalib.php, etc.).

RLE
In reply to Richard Enison

Re: Upgrade to 1.9 - Fatal error

by Jamie Chandler -

thanks i had to go into datalib.php and change this;

if (count($managerroles)) {
        if ($allcats === true) {
            $catpaths  = array_unique($catpaths);
            $ctxids = array();

            foreach ($catpaths as $cpath) {
                $ctxids = array_merge($ctxids, explode('/',substr($cpath,1)));
            }
            $ctxids = array_unique($ctxids);
            $catctxids = implode( ',' , $ctxids);
            unset($catpaths);unset($cpath);

to this

if (count($managerroles)) {
        if ($allcats === true) {
            $catpaths  = array_unique($catpaths);
            $ctxids = array();

            foreach ($catpaths as $cpath) {
                $ctxids = array_merge($ctxids, explode('/',substr($cpath,1)));
            }
            $ctxids = array_unique($ctxids);
            $catctxids = implode( ',' , $ctxids);
            $catctxids = substr($catctxids, 1);
            unset($catpaths);unset($cpath);

Trimming the substring to get rid of a leading comma.  What a palava.  Is this a bug which needs to be fixed or something wrong with my installation?