General developer forum

Threaded Mode Generating an Error Message

 
 
Picture of Mike Churchward
Threaded Mode Generating an Error Message
Group DevelopersGroup Particularly helpful MoodlersGroup 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: -
Picture of John Papaioannou
Re: Threaded Mode Generating an Error Message
 
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
 
Average of ratings: -
Picture of Mike Churchward
Re: Threaded Mode Generating an Error Message
Group DevelopersGroup Particularly helpful MoodlersGroup 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
 
Average of ratings: -
Picture of John Papaioannou
Re: Threaded Mode Generating an Error Message
 
No idea! smile
 
Average of ratings: -
Picture of Penny Leach
Re: Threaded Mode Generating an Error Message
Group Developers
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
 
Average of ratings: -
Picture of John Papaioannou
Re: Threaded Mode Generating an Error Message
 
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
 
Average of ratings: -
Picture of Penny Leach
Re: Threaded Mode Generating an Error Message
Group Developers
smile
 
Average of ratings: -
Martin in black and white
Re: Threaded Mode Generating an Error Message
Group DevelopersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup 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.
 
Average of ratings: -
Picture of John Papaioannou
Re: Threaded Mode Generating an Error Message
 
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
 
Average of ratings: -