Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Invalid
-
3.0.14
-
None
-
None
Description
So I recently moved a phpBB forum to a new web-host, and discovered a bug in the `redirect()` function (in `include/functions.php`) due to a change in how the PHP function `file_exists()` behaves between the two servers.
Basically the following line fails:
if (!$disable_cd_check && !file_exists($pathinfo['dirname'] . '/'))
|
This is because when `$pathinfo`'s `dirname` is a single period (`.`), as is the case with most local redirects, `file_exists('./')` is returning `false`, resulting in the function replacing the redirect with a link to the current page; this was especially unfortunate in my case as it resulted in a redirect loop (redirecting back to the page I was being redirected from, fun!).
Anyway, I fixed it by wrapping the offending block of code with a check for `dirname` being a period, which has solved the problem for me, though it feels a bit of a hacky way to do it. The issue exists in phpBB 3.0.14, but the redirect function appears to have been rewritten in phpBB 3.1.x (no use of `file_exists` at all), so I don't think the problem exists there (though I haven't upgraded to 3.1.x yet so I can't say for sure). Perhaps the newer function could be back-ported?
I'm not completely sure why the behaviour of `file_exists` has changed, as it worked on every other server I've used, except that my new server is using HHVM in favour of PHP-FPM for handling scripts, so perhaps it's a quirk with that? It is however really fast, so I'm not planning to switch from HHVM any time soon unless the release version of PHP 7 has indeed finally closed the gap.