Moodle

Redirect - header already printed notice

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 1.6
  • Fix Version/s: 1.6.2
  • Component/s: General
  • Labels:
    None
  • Environment:
    All
  • Affected Branches:
    MOODLE_16_STABLE
  • Fixed Branches:
    MOODLE_16_STABLE

Description

In lesson, I print the header, do some processing, and then redirect. In doing this, I get a notice that the header has been printed twice. Is this a bug with lesson (as in I shouldn't print the header) or with redirect (printing the header when one has already been printed)?

Activity

Hide
Martin Dougiamas added a comment -

From Petr Skoda (skodak at centrum.cz) Monday, 15 May 2006, 03:24 PM:

redirect should be used alone - no page output before,

working on a solution to allow redirect also after other output.

It should print continue + footer + die and try to redirect if possible.

From Petr Skoda (skodak at centrum.cz) Thursday, 18 May 2006, 02:08 AM:

fixed in CVS, you can now use error() and redirect() after print_header() :-D

Show
Martin Dougiamas added a comment - From Petr Skoda (skodak at centrum.cz) Monday, 15 May 2006, 03:24 PM: redirect should be used alone - no page output before, working on a solution to allow redirect also after other output. It should print continue + footer + die and try to redirect if possible. From Petr Skoda (skodak at centrum.cz) Thursday, 18 May 2006, 02:08 AM: fixed in CVS, you can now use error() and redirect() after print_header() :-D
Hide
Michael Blake added a comment -

assign to a valid user

Show
Michael Blake added a comment - assign to a valid user
Hide
Mark Nielsen added a comment -

Hi Petr,

Looks like this is still causing problems inside Lesson. The redirect adds a delay when there is no message and when the header has already been printed. An easy way to reproduce the problem is by creating a branch table in a Lesson and then preview the branch table and click on one of the buttons. You will see a "(continue)" printed with a 3 second delay instead of jumping directly to the next page. I do not blame the redirect code, because the Lesson code is currently terrible and is not using the redirect properly. But, this problem exists in Moodle 1.6 and I cannot fix it in Lesson without major changes. Let me know if you can fix this.

Moodle Discussion:

http://moodle.org/mod/forum/discuss.php?d=52338

Cheers,
Mark

Show
Mark Nielsen added a comment - Hi Petr, Looks like this is still causing problems inside Lesson. The redirect adds a delay when there is no message and when the header has already been printed. An easy way to reproduce the problem is by creating a branch table in a Lesson and then preview the branch table and click on one of the buttons. You will see a "(continue)" printed with a 3 second delay instead of jumping directly to the next page. I do not blame the redirect code, because the Lesson code is currently terrible and is not using the redirect properly. But, this problem exists in Moodle 1.6 and I cannot fix it in Lesson without major changes. Let me know if you can fix this. Moodle Discussion: http://moodle.org/mod/forum/discuss.php?d=52338 Cheers, Mark
Hide
Petr Škoda (skodak) added a comment -

Try this patch, it allows redirect delay 0, usage:

redirect('yoururl', '', 0)

There is IMO nothing else that can be done in redirect(), because the continue link must be printed for non-javascript compatibility. In any case you should fix the code in 1.7 to not print header before redirect().

I guess we should dicsuss the patch with Martin before commiting into STABLE.

Show
Petr Škoda (skodak) added a comment - Try this patch, it allows redirect delay 0, usage: redirect('yoururl', '', 0) There is IMO nothing else that can be done in redirect(), because the continue link must be printed for non-javascript compatibility. In any case you should fix the code in 1.7 to not print header before redirect(). I guess we should dicsuss the patch with Martin before commiting into STABLE.
Hide
Mark Nielsen added a comment -

> continue link must be printed for non-javascript compatibility

Ah, of course!

The patch works wonderfully.

Thanks for your help in this Petr. Last night I already started to reorganize continue.php. I'm attempting to think of some stepping stones toward Lesson and question bank integration and I thought separating out the logic and presentation in Lesson was a good start. By doing this to continue.php it will then use redirect properly.

Cheers,
Mark

Show
Mark Nielsen added a comment - > continue link must be printed for non-javascript compatibility Ah, of course! The patch works wonderfully. Thanks for your help in this Petr. Last night I already started to reorganize continue.php. I'm attempting to think of some stepping stones toward Lesson and question bank integration and I thought separating out the logic and presentation in Lesson was a good start. By doing this to continue.php it will then use redirect properly. Cheers, Mark
Hide
Petr Škoda (skodak) added a comment -

I have commited the patch into STABLE, closing now...

Show
Petr Škoda (skodak) added a comment - I have commited the patch into STABLE, closing now...
Hide
Joseph Rézeau added a comment -

Petr ?koda [31/Aug/06 03:57 PM]
Try this patch, it allows redirect delay 0, usage:

redirect('yoururl', '', 0)

There is IMO nothing else that can be done in redirect(), because the continue link must be printed for non-javascript compatibility. In any case you should fix the code in 1.7 to not print header before redirect().

To Mark:
Please read Petr's message again: for the 3 seconds [irritating] delay to be suppressed, you still have to modify \mod\lesson\action\continue.php line 596 as per my message in MDL-6503

redirect("view.php?id=$cm->id&action=navigation&pageid=$newpageid","","0");

i.e. add empty message and 0 seconds delay when calling redirect()

To Petr
I do NOT understand why we still bother about non-javascript compatibility in Moodle!? If Javascript is not enabled in a navigator, then it is quite impossible to use most of Moodle's functions anyway, so why why why?

Joseph

Show
Joseph Rézeau added a comment - Petr ?koda [31/Aug/06 03:57 PM] Try this patch, it allows redirect delay 0, usage: redirect('yoururl', '', 0) There is IMO nothing else that can be done in redirect(), because the continue link must be printed for non-javascript compatibility. In any case you should fix the code in 1.7 to not print header before redirect(). To Mark: Please read Petr's message again: for the 3 seconds [irritating] delay to be suppressed, you still have to modify \mod\lesson\action\continue.php line 596 as per my message in MDL-6503 redirect("view.php?id=$cm->id&action=navigation&pageid=$newpageid","","0"); i.e. add empty message and 0 seconds delay when calling redirect() To Petr I do NOT understand why we still bother about non-javascript compatibility in Moodle!? If Javascript is not enabled in a navigator, then it is quite impossible to use most of Moodle's functions anyway, so why why why? Joseph
Hide
Joseph Rézeau added a comment -

What I meant in my previous message is:

If redirect('yoururl', '', 0) is called with an empty message AND a zero delay, then it is clear that we do NOT need/want either a delay nor a Continue link to be printed... then, why not modify weblib to skip the print Continue link when both these conditions are met?

Joseph

Show
Joseph Rézeau added a comment - What I meant in my previous message is: If redirect('yoururl', '', 0) is called with an empty message AND a zero delay, then it is clear that we do NOT need/want either a delay nor a Continue link to be printed... then, why not modify weblib to skip the print Continue link when both these conditions are met? Joseph
Hide
Petr Škoda (skodak) added a comment -

Hi Joseph,

non-javasciprt compatibility is IMO a must, I know there are several places in Moodle where javascript is required, but it is IMHO wrong. For security reasons it would be ideal if administrators turned off the active content and javascript completely in their browsers

I have changed redirect() in HEAD some time ago - it is using proper http header redirect when no message given and header not already printed. In any case I mostly find it annoying when I have to wait for the redirect - I would personnaly prefer redirect to page that just displays success notice somewhere in the text - example: one page has save button, it sends data to itself, the redirects to another page with parameter ?=saved=1 and the other page displays "changes saved" somewhere to notify me it was ok, please note that it is much faster, you can press F5 on the last page, it works in all browsers and you have more time to read the message.

skodak

Show
Petr Škoda (skodak) added a comment - Hi Joseph, non-javasciprt compatibility is IMO a must, I know there are several places in Moodle where javascript is required, but it is IMHO wrong. For security reasons it would be ideal if administrators turned off the active content and javascript completely in their browsers I have changed redirect() in HEAD some time ago - it is using proper http header redirect when no message given and header not already printed. In any case I mostly find it annoying when I have to wait for the redirect - I would personnaly prefer redirect to page that just displays success notice somewhere in the text - example: one page has save button, it sends data to itself, the redirects to another page with parameter ?=saved=1 and the other page displays "changes saved" somewhere to notify me it was ok, please note that it is much faster, you can press F5 on the last page, it works in all browsers and you have more time to read the message. skodak
Hide
Mark Nielsen added a comment -

@Petr

> the redirects to another page with parameter ?=saved=1 and the
> other page displays "changes saved" somewhere to notify me
> it was ok, please note that it is much faster

You should check out my suggested message API: MDL-6470. It would handle this nicely without the &saved=1.

@Joseph

Sorry Joseph! I forgot Thanks for keeping me on top of things

I just committed the change to MOODLE_16_STABLE but I don't think it will be in Moodle 1.6.2

Cheers,
Mark

Show
Mark Nielsen added a comment - @Petr > the redirects to another page with parameter ?=saved=1 and the > other page displays "changes saved" somewhere to notify me > it was ok, please note that it is much faster You should check out my suggested message API: MDL-6470. It would handle this nicely without the &saved=1. @Joseph Sorry Joseph! I forgot Thanks for keeping me on top of things I just committed the change to MOODLE_16_STABLE but I don't think it will be in Moodle 1.6.2 Cheers, Mark

Dates

  • Created:
    Updated:
    Resolved: