Problem with context paths in 1.9

Problem with context paths in 1.9

by Eric Merrill -
Number of replies: 10
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Im upgrading from 1.8.3+ to 1.9 Beta 3, but whenever I do the upgrade I can view course pages, and no all category pages will load. With debug info on, I get a ton of these:

Context id xxx does not have valid path, please use build_context_path()

Ok, that doesn't kill anything, but then it tries to do a SQL where it users the context path in a 'IN ()' statement, which of course fails, like:

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 () ) AND ra.roleid IN (3) AND c.category = 123 ORDER BY r.sortorder ASC, ctx.contextlevel ASC, ra.sortorder ASC

or

SELECT MIN(visible) FROM mdl_course_categories WHERE id IN ()


If I run:
SELECT c.id,c.category,c.sortorder,c.shortname,c.fullname,c.idnumber,c.teacher,c.teachers,c.student,c.students,c.guest,c.startdate,c.visible,c.newsitems,c.cost,c.enrol,c.groupmode,c.groupmodeforce,c.password,c.summary,c.currency, ctx.id AS ctxid, ctx.path AS ctxpath, ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel FROM mdl_course c JOIN mdl_context ctx ON (c.id=ctx.instanceid AND ctx.contextlevel=50) WHERE c.id != 1 AND c.category = 123 ORDER BY ctxpath ASC

All the courses have no ctxpath.

Any ideas?

Thanks
-eric
Average of ratings: -
In reply to Eric Merrill

Re: Problem with context paths in 1.9

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Eric,

could you please, add one report to the Tracker, with all the details (versions, DB...) upgrade process, course/categories... also, include a link back to this discussion. Yes

That way, some developer will try to reproduce the problem and, if found, fix it ASAP. cool

TIA and ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Problem with context paths in 1.9

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Yeah, I was just seeing if anybody knew what it was (like martin), since something very similar had come up already.

-eric
In reply to Eric Merrill

Re: Problem with context paths in 1.9

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
FIXED IT!!

Im working a ticket, but long story short:

During the upgrade top level course categories get assigned a depth of 0. This is not valid, it should be 1. This means that build_context_path() can't find a valid path through to a top level course categories.

All I had to do is assign a depth of 1 to my top level categories, and the build_context_path() worked like a charm and my entire site works again.

Ill make a ticket shortly. Im trying to best distill the problem.

-Eric
Average of ratings: Useful (1)
In reply to Eric Merrill

Re: Problem with context paths in 1.9

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
In reply to Eric Merrill

Re: Problem with context paths in 1.9

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Eric,

thanks a lot for being so proactive! cool

Bug in the tracker is, as you said: MDL-12585

(it seems that you have discovered another bug in your previous post, with the bug not being automatically linked) big grin

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Problem with context paths in 1.9

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
I was confused about that. I thought MDL- numbers were supposed to be auto linked. I even looked around to make sure I had the format right. Huh.

-eric
In reply to Eric Merrill

Re: Problem with context paths in 1.9

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The bug seems to be that MDL numbers are not hyperlinked if they are the first thing on a line. This will work: MDL-1234

MDL-1234, however, will not.
In reply to Eric Merrill

Re: Problem with context paths in 1.9

by Eric Merrill -
Picture of Core developers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Thanks to Petr, this is patched in 19_STABLE and HEAD.

Thanks all!

-eric