## General developer forum

### Threaded Mode Generating an Error Message

This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.
Threaded Mode Generating an Error Message
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: -
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: -
Re: Threaded Mode Generating an Error Message
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: -
Re: Threaded Mode Generating an Error Message

No idea!

Average of ratings: -
Re: Threaded Mode Generating an Error Message
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

Average of ratings: -
Re: Threaded Mode Generating an Error Message

Confirm, Penny!

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!

Average of ratings: -
Re: Threaded Mode Generating an Error Message

Average of ratings: -
Re: Threaded Mode Generating an Error Message
There's no need to show this error to students using the STABLE branch, Jon, it's more of a developer notice.

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

Average of ratings: -
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. But this makes me think that we really need to be able to log these things (health-center style). Objective acquired for 1.6.

Average of ratings: -