Threaded Mode Generating an Error Message

Threaded Mode Generating an Error Message

by Mike Churchward -
Number of replies: 8
Picture of Core developers Picture of Plugin developers Picture of Testers
On 'moodle.org' if you view a discussion in threaded mode, you get the error message:
isteacher() should not be used without a valid course id as argument

Not sure when it got introduced.

mike
Average of ratings: -
In reply to Mike Churchward

Re: Threaded Mode Generating an Error Message

by John Papaioannou -
This is not actually an error, but a warning I put in recently to catch some "bad" uses of isteacher() that may have escaped us when we made a change to moodlelib.

Basically isteacher() or isteacher(0, ...) should now be isteacherinanycourse().

There are only three calls to isteacher() in discuss.php, but I can't repro the problem with my "basic" efforts on my home installation. Maybe it has something to do with groups? A little debugging diagnosis from The Man would help here.

Jon
In reply to John Papaioannou

Re: Threaded Mode Generating an Error Message

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers
I can't duplicate it either. I only see it on moodle.org. That's why I didn't put it into bug tracker. Is moodle.org using some special forum release?

mike
In reply to Mike Churchward

Re: Threaded Mode Generating an Error Message

by John Papaioannou -
No idea! smile
In reply to John Papaioannou

Re: Threaded Mode Generating an Error Message

by Penny Leach -
found it!

forum_print_posts_threaded gets called with $course->id:

forum/lib.php in the function forum_print_discussion:


case FORUM_MODE_THREADED :
if (forum_print_posts_threaded($post->id, $course->id, 0, $ratings, $reply)) {

but then calls
isteacher($course->id) which is the same as $course->id->id which is obviously bung.

line: 2672: $by->name = fullname($post, isteacher($course->id));

At least, I think that's what it could be from looking at the code but I'm right in the middle of merging something tricky so can't take too much time to confirm smile
In reply to Penny Leach

Re: Threaded Mode Generating an Error Message

by John Papaioannou -
Confirm, Penny! approve

I found this actually fixed in HEAD, and that's why I at least couldn't repro it.

You actually got that while in the middle of merging something tricky? Respect! wink
In reply to John Papaioannou

Re: Threaded Mode Generating an Error Message

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
There's no need to show this error to students using the STABLE branch, Jon, it's more of a developer notice.  wink

I've changed the function to only print the notify when debugging mode is on.
In reply to Martin Dougiamas

Re: Threaded Mode Generating an Error Message

by John Papaioannou -
On the one hand you are absolutely right. On the other hand, we found a couple of bugs that would have otherwise escaped us this way. On the third hand... no wait, we 're only human.

Seriously now, yes, sure. blush But this makes me think that we really need to be able to log these things (health-center style). Objective acquired for 1.6. wink