Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#523 Problem with Request-->redirect

PHP_error
open
Reini Urban
5
2012-10-11
2006-01-31
Thierry Nabeth
No

Hello,

As I moved from a Windows 2000 to a Windows 2003
server, I got some problem with the redirect function.

I am running PhpWiki under IIS6.
(things are working relatively well if we except
this problem, and a logout problem that I mentionned
previously).

I use the latest version of PHP 5. (5.12 I believe).

Here is the problem I have:

I have
DISABLE_HTTP_REDIRECT set to true.

(when I set DISABLE_HTTP_REDIRECT to false the system
works).

When I update a page, and after I click on the Save
button, the system never returns.
When I stop the browser and look at the page, I can
see that my page has been correctly updated.

I spent sometime trying to figure out what was the
problem (Initially I though about a bug with IIS6 and
the http redirect, but other tests have shown me that
http redirect work).

The problem seems to originate in Request.php

function redirect($url, $noreturn = true) {
$bogus = defined('DISABLE_HTTP_REDIRECT') &&
DISABLE_HTTP_REDIRECT;

if (!$bogus) {
header("Location: $url");
....
}

if ($noreturn) {
$this->discardOutput(); // This might print the
gzip headers. Not good.
$this->buffer_output(false);

 include_once('lib/Template.php');
 $tmpl = new Template('redirect', $this, array

('REDIRECT_URL' => $url));
$tmpl->printXML(); ===> #### BLOCKED ####

 $this->finish();  ==> not executed ????

}
...

}

As a workaround, I have commented the $tmpl->printXML
();.

I do not know what this redirect template is about.
(could be good to have a few more comments in the
code)

Thierry.

Discussion

  • Thierry Nabeth
    Thierry Nabeth
    2006-01-31

    Logged In: YES
    user_id=111379

    Note:

    I have seen that there was some fix of the file
    Request.php file.

    I have installed this new version, but it does not solve
    the problem.

     
  • Thierry Nabeth
    Thierry Nabeth
    2006-02-01

    Logged In: YES
    user_id=111379

    Hello,

    Having investigated a little bit and understood a little
    bit more the template thing, I have notice that the
    problem may originate, in some http servers (such as IIS6)
    that we are sending twice header information related to
    redirection.

    In the function redirect(), we have a call to the function

    header("Location: $url");

    and later using the template call, we are sending another
    redirect page.
    I assume that some servers get confused.

    In my code I will therefore keep commented the call to the
    redirect template, althought I would have been interested
    to know if there is any use of this file (since the
    server --or is it the client?-- is supposed to have
    already redirected the request when using the header
    ("Location: $url")).

    Thierry

     
  • Thierry Nabeth
    Thierry Nabeth
    2006-02-01

    Logged In: YES
    user_id=111379

    Testing again:

    Commenting the sending of header information (what is
    inside the block if (!$bogus) {...} ) also seems to solve
    the problem (for IIS6).

    Question:

    It is still not clear to me what would be the best way
    (most standard according to the http specifications?,
    performence?, felxibility) to redirect the page.

    Thierry

     
  • Reini Urban
    Reini Urban
    2006-02-22

    Logged In: YES
    user_id=13755

    Thanks. I'll disable the 2nd redirect for IIS