print_header bombs sometimes

print_header bombs sometimes

by Sarah King -
Number of replies: 7

Hi Everyone

I've got a semi-upgraded version of Moodle in progress. Installed last year but never went live. I've upgraded it to 1.2 and was very impressed by that process.

I have a problem (just the one? ) where sometimes print_header doesn't complete.

I've converted most of it to pure PHP rather than escaping to HTML all the time but at the very end I've left the final pure HTML comment in:

<!-- END OF HEADER -->

On 99% of the pages the whole thing prints and there are no problems but on some it stops at the end of the last PHP, doesn't print the comment or anything else. It's like it's got an exit in there.

The main problem is with Quiz but not on all of the pages.

I can get in, by a round about way to do all of this but I need to get it working properly. Any ideas what is going on?

Average of ratings: -
In reply to Sarah King

Re: print_header bombs sometimes

by Sarah King -

I've made some progress but am not sure of the consequences.

I identified that in mod/quiz/question.php the print_header was called and then later a redirect. I commented out that print statement and copied it down to line 160

I'm still getting a few errors so will check them out.

But, if you read this and are thinking, Oh No, she shouldn't do that , then please let me know

In reply to Sarah King

Re: print_header bombs sometimes

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
I'm not seeing anything like this on the 100 or so sites I maintain (otherwise it would be fixed) so I'm not sure what is going on here in your installation ...
In reply to Martin Dougiamas

Re: print_header bombs sometimes

by Sarah King -

I've done the session test and that's ok, I've added a phpinfo script just incase that might help. I'm getting the same problem from attempt.php

I think the redirects are causing some sort of problem and if I identify the real problem then the fix might be easier.

I'd really appreciate your thoughts.

Sarah

In reply to Sarah King

Re: print_header bombs sometimes - STILL

by Sarah King -

A friend (who doesn't know Moodle) took a look at the phpinfo script and suggested that any of the following might be the problem

HTTP Response Headers
X-Powered-By PHP/4.2.2
X-Accelerated-By PHPA/1.3.3r2
Connection close
Content-Type text/html

expose_php On

extension_dir ./


I'll tackle this again today. Let it brew for a couple of days in the hope I might get a lead.

quote: What I'm seeing is that a page banner is output, then some database work is done and then, all being well, a redirect is issued.
Sometimes it works, sometimes it doesn't.

When it doesn't the banner doesn't complete parsing, it's almost like it's threaded - because allthough the banner isn't complete the save will be done and that code is after the print header.

The same banner is used all over the place and I'd be very surprised if the problem lay there. However if the redirect function was the problem I'd expect to see it when I viewed the source. Instead there's nothing there.


In reply to Sarah King

Re: print_header bombs sometimes - STILL

by Sarah King -

been playing a bit more. This might turn into a diary of a debugging exercise smile

print_navigation is failing in the phase when I've completed a quiz and am going to the next page. It works fine most of the time. The string which is passed to the function is

string(252) "<A HREF="http://www.goodreturns.co.nz/education/course/view.php?id=3">T101</A> -> <A HREF=index.php?id=3>Quizzes</A> -> <A HREF="http://www.goodreturns.co.nz/education/mod/quiz/view.php?id=14">Test Your Understanding</A> -> Attempt 4"

And there doesn't seem anything wrong with that. I've even got an echo "<!-- nav finished -->";  in the function and it doesn't print on the times it fails.

In reply to Sarah King

Re: print_header bombs sometimes - STILL

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
These errors are all very unusual. I can't help thinking you are jumping into editing the code a little too quickly. Perhaps you should start over with a clean 1.2.1 and a standard theme to make sure everything works, then make your changes slowly.

Have you tried switching "secureforms" off in the admin variables page?
In reply to Martin Dougiamas

Re: print_header bombs sometimes - STILL

by Sarah King -

Hi Martin

I'll copy the files over again and try with the clean theme.

Secureforms was set to No

The code edits were more to try to identify the cause of the problem, not to actually make permanent changes. This site will need to get upgraded and making custom changes (beyond new modules etc) would not be in their interests.

I'll let you know how I get on.

Sarah