Bug #3029
Routing is not working correctly on all platforms
Status: | Resolved | Start date: | 2009-04-03 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | Karsten Dambekalns | % Done: | 100% |
|
Category: | MVC | |||
Target version: | TYPO3 Flow Base Distribution - 1.0 alpha 8 | |||
PHP Version: | Complexity: | |||
Has patch: | Affected Flow version: |
Description
I am getting this error when i request any URL with a path part (http://flow3.local/testing , http://flow3.local/testpackage ,...).
Warning: Unknown: Filename cannot be empty in Unknown on line 0 Fatal error: Unknown: Failed opening required '' (include_path='.:/usr/share/php5:usr/share/php') in Unknown on line 0
Platform:
Gentoo Linux. 2.6.27-gentoo-r7
Apache/2.2.10 (Unix) with mod_fcgid-2.2 NOT mod_fastcgi-2
PHP 5.3beta1 as CGI/FastCGI
cgi.fix_pathinfo=1 in php.ini
Possible Solution/Workaround:
This part is causing the problem. Change .htaccess from:
RewriteRule (.*) index.php/$1
to:
RewriteRule (.*) index.php
...and get the routing information from REQUEST_URI.
Change F3\FLOW3\Utility\Environment#201:
public function getRequestURI() { if (isset($this->SERVER['PATH_INFO'])) { $requestURIString = $this->getRequestProtocol() . '://' . $this->getHTTPHost() . $this->SERVER['PATH_INFO'] . (strlen($this->SERVER['QUERY_STRING']) ? '?' . $this->SERVER['QUERY_STRING'] : ''); } else if ($this->SERVER['REQUEST_URI']) { $requestURIString = $this->getRequestProtocol(). '://' . $this->getHTTPHost() . $this->SERVER['REQUEST_URI']; } else { $requestURIString = $this->getRequestProtocol() . '://' . $this->getHTTPHost() . '/'; } $requestURI = new \F3\FLOW3\Property\DataType\URI($requestURIString); return $requestURI; }
Related issues
Associated revisions
[+BUGFIX] FLOW3 (Utility): Fix for the getRequestURI function which caused problems on some setup using FastCGI. (Patch by Bastian Waidelich) Resolves #3029
[+BUGFIX] FLOW3 (Utility): Reverted the patch from #3029 which resulted in routing problems with URLs like http://localhost/foo/bar/Web. Relates to #3029
[+API] FLOW3 (Utility): Added detectBaseUri() to Environment. Given an URI instance it tries to detect the corresponding base URI.
[+API] FLOW3 (Utility): Added getScriptRequestPath() to Environment, returns the path to the actual script request relative to the document root.
[~API] FLOW3 (Utility): Renamed getScriptRequestPathAndName() to getScriptRequestPathAndFilename() in Environment.
[~TASK] FLOW3 (MVC): Reverted recent change by Robert related to request path handling, relates to #6596
[~TASK] FLOW3 (Utility): Some more changes to getRequestUri() in Environment, relates to #6596, relates to #3029, relates to #3375.
[~TASK] FLOW3 (Resource): Make use of new getScriptRequestPath() method in FileSystemPublishingTarget.
History
#1 Updated by Robert Lemke about 6 years ago
- Target version set to 1.0 alpha 1
#2 Updated by Robert Lemke about 6 years ago
- Category set to MVC
- Assigned To set to Bastian Waidelich
Bastian, can you check this one?
#3 Updated by Bastian Waidelich about 6 years ago
- File FLOW3_3029.patch added
- Status changed from New to Needs Feedback
I can't reproduce this on platform:
OS: Windows 7 RC1 Apache/2.0.63 (Win32) PHP/5.3.0RC2-dev PHP Version 5.3.0RC2-dev
Attached is a patch that applies your suggested change to F3\FLOW3\Utility\Environment. But ATM I need more information to know exactly what the problem is.
Does it still occur with the latest PHP version?
#4 Updated by Robert Lemke about 6 years ago
- Priority changed from Must have to Should have
#5 Updated by Karsten Dambekalns about 6 years ago
Bastian Waidelich wrote:
I can't reproduce this on platform:
Do you run PHP as FastCGI, CGI or Apache module? That probably makes a difference...
#6 Updated by Robert Lemke about 6 years ago
- Target version changed from 1.0 alpha 1 to 283
#7 Updated by Bastian Waidelich about 6 years ago
Karsten Dambekalns wrote:
Do you run PHP as FastCGI, CGI or Apache module? That probably makes a difference...
Apache module..
Can someone else reproduce this?
#8 Updated by Markus Wagner about 6 years ago
I can reproduce this on two machines:
Debian Etch
Apache/2.2.3 with mod_fcgid
PHP 5.3.0 as CGI/FastCGI
cgi.fix_pathinfo=1 in php.ini
Debian Lenny
Apache/2.2.9 with mod_fcgid
PHP 5.3.0RC4 (from php53.dotdeb.org) AS CGI/FastCGI
cgi.fix_pathinfo=1 in php.ini
BTW: $_SERVER['PATH_INFO'] is empty for every request. A FastCGI problem?
#9 Updated by Robert Lemke about 6 years ago
- Priority changed from Should have to Must have
#10 Updated by Robert Lemke about 6 years ago
- Target version changed from 283 to 1.0 alpha 3
#11 Updated by Bastian Waidelich about 6 years ago
- File FLOW3_Distribution_3029.patch added
- File FLOW3_3029_v2.patch added
- Assigned To deleted (
Bastian Waidelich)
I can't reproduce the issue on Windows (with PHP as Apache module). Thus I can't validate the Patch either.. All I can say is: The patch does not break anything in my environment.
Attached is a cleaned-up version of the patch.
@Markus can you please check whether the patch fixes the issue for you?
#12 Updated by Robert Lemke about 6 years ago
- Assigned To set to Bastian Waidelich
- % Done changed from 0 to 30
Bastian Waidelich wrote:
I can't reproduce the issue on Windows (with PHP as Apache module). Thus I can't validate the Patch either.. All I can say is: The patch does not break anything in my environment.
Attached is a cleaned-up version of the patch.@Markus can you please check whether the patch fixes the issue for you?
@Markus: Any chance to try the patch? If so, we could include the fix in alpha3.
#13 Updated by Bastian Waidelich about 6 years ago
I could not get hold of Marcus. Maybe someone else with the same setup could try the patch?
#14 Updated by Robert Lemke almost 6 years ago
- Status changed from Needs Feedback to Resolved
- % Done changed from 30 to 100
Applied in changeset r3017.
#15 Updated by Robert Lemke almost 6 years ago
- Status changed from Resolved to Needs Feedback
- % Done changed from 100 to 70
#16 Updated by Robert Lemke almost 6 years ago
- Target version changed from 1.0 alpha 3 to 283
#17 Updated by Bastian Waidelich almost 6 years ago
- Assigned To deleted (
Bastian Waidelich)
I delete myself as assignee (again) as I can't reproduce this on my machine - sorry
#18 Updated by Karsten Dambekalns over 5 years ago
By Marco Weber:
Im not sure... The error message sound familiar.
Could this be a problem on the gentoo configuration? Sometimes it happens that the path of the script to execute is passed to the php-cgi in wrong format.
In this case you will see an error message like the one in the ticket:
Warning: Unknown: Filename cannot be empty in Unknown on line 0 Fatal error: Unknown: Failed opening required '' (include_path='.:/usr/share/php5:usr/share/php') in Unknown on line 0
The solution: You can then set the PATH_TRANSLATED variable in the FCGI Starter Script. This variable will tell the php-cgi which file to execute.
You can then simply add something like this at the beginning of your starter script:
TRUNC_PATH_TRANSLATED=`/usr/local/bin/translate` if test "$?" = "0" then export PATH_TRANSLATED=$TRUNC_PATH_TRANSLATED fi
( /usr/local/bin/translate
is a tool written by myself... You just need
to analyse the wrong path and then set the corrected one... )
#19 Updated by Thomas Fritz over 5 years ago
Karsten Dambekalns wrote:
By Marco Weber:
Im not sure... The error message sound familiar.
Could this be a problem on the gentoo configuration? Sometimes it happens that the path of the script to execute is passed to the php-cgi in wrong format.
In this case you will see an error message like the one in the ticket:
[...]The solution: You can then set the PATH_TRANSLATED variable in the FCGI Starter Script. This variable will tell the php-cgi which file to execute.
You can then simply add something like this at the beginning of your starter script:
[...](
/usr/local/bin/translate
is a tool written by myself... You just need
to analyse the wrong path and then set the corrected one... )
Could you post the content of your translate tool? This would be great.
But actually i think that this issue requires to change the way FLOW3 handles requests and routing, because php with fcgid has problems with "RewriteRule (.*) index.php/$1"
There are 2 solutions which work in every environment:
One way would be to change the RewriteRule to:
In this case the path would be in the QUERY_STRING Variable.
RewriteRule (.*) index.php?/$1
or to change it to:
This way the path can be analysed from REQUEST_URI Variable.
RewriteRule (.*) index.php
I would prefer the first RewriteRule as QUERY_STRING Variable does not have any problems on any environment. Of course there would be some minor changes to Environment.php too.
I also would append [L,QSA] to the end of the RewriteRule. This would Append the query string to the request. (QSA = Query String Append).
This issue is nothing new at all. You can search for this kind of issue. This is a known issue with this Environment:
http://www.google.at/search?hl=de&q=fcgi+"no+input+file+specified"+mod_rewrite+apache
http://www.mail-archive.com/symfony-users@googlegroups.com/msg20367.html
http://stackoverflow.com/questions/1557258/htaccess-problem-no-input-file-specified
I have also tried all the solutions above:
'FcgidFixPathinfo 1' in vhost configuration
'doc_root=/var/www/xxxx/public' in php.ini
'cgi.fix_pathinfo=1' in php.ini
'RewriteBase /' in .htaccess
Nothing worked.
If i patch Environment.php as i posted, FLOW3 works as expected. I hope this helps and this fix can be integrated soon.
If you need such an environment to test it (Linux, Apache, PHP, mod_rewrite, FCGID), I can give you a virtual machine.
#20 Updated by Thomas Fritz over 5 years ago
I have made some tests:
I tested this url with different RewriteRules.
http://flow3.wda.local/info/path1/path2,asdf,qwertz/lorem.xml?foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz
RewriteRule 1:
RewriteRule info/(.*) info.php [L]
Result:
_SERVER: REQUEST_URI string(110) "/info/path1/path2,asdf,qwertz/lorem.xml?foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz" QUERY_STRING string(70) "foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz" PATH_INFO NULL ORIG_PATH_INFO NULL PATH_TRANSLATED NULL _GET: foo string(3) "bar" foo2 string(7) "baz,xyz" lalala string(42) "/path3/path4_asdf-1235648---xyz,abcdef?xyz"
RewriteRule 2:
RewriteRule info/(.*) info.php [L,QSA]
Result:
_SERVER: REQUEST_URI string(110) "/info/path1/path2,asdf,qwertz/lorem.xml?foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz" QUERY_STRING string(70) "foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz" PATH_INFO NULL ORIG_PATH_INFO NULL PATH_TRANSLATED NULL _GET: foo string(3) "bar" foo2 string(7) "baz,xyz" lalala string(42) "/path3/path4_asdf-1235648---xyz,abcdef?xyz"
RewriteRule 3:
RewriteRule info/(.*) info.php?/$1 [L]
Result:
_SERVER: REQUEST_URI string(110) "/info/path1/path2,asdf,qwertz/lorem.xml?foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz" QUERY_STRING string(34) "/path1/path2,asdf,qwertz/lorem.xml" PATH_INFO NULL ORIG_PATH_INFO NULL PATH_TRANSLATED NULL _GET: /path1/path2,asdf,qwertz/lorem_xml string(0) ""
RewriteRule 4:
RewriteRule info/(.*) info.php?/$1 [L,QSA]
Result:
_SERVER: REQUEST_URI string(110) "/info/path1/path2,asdf,qwertz/lorem.xml?foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz" QUERY_STRING string(105) "/path1/path2,asdf,qwertz/lorem.xml&foo=bar&foo2=baz,xyz&lalala=/path3/path4_asdf-1235648---xyz,abcdef?xyz" PATH_INFO NULL ORIG_PATH_INFO NULL PATH_TRANSLATED NULL _GET: /path1/path2,asdf,qwertz/lorem_xml string(0) "" foo string(3) "bar" foo2 string(7) "baz,xyz" lalala string(42) "/path3/path4_asdf-1235648---xyz,abcdef?xyz"
So i change my mind. I think RewriteRule 1 or 2 is the one you should change to, because Rule 3 and 4 changes 'lorem.xml' to 'lorem_xml'
The Test Code:
<h1>_SERVER:</h1> <pre> <?php echo "<strong>REQUEST_URI </strong>"; var_dump(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null); echo "<strong>QUERY_STRING </strong>"; var_dump(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null); echo "<strong>PATH_INFO </strong>"; var_dump(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : null); echo "<strong>ORIG_PATH_INFO </strong>"; var_dump(isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['PATH_INFO'] : null); echo "<strong>PATH_TRANSLATED </strong>"; var_dump(isset($_SERVER['PATH_TRANSLATED']) ? $_SERVER['PATH_TRANSLATED'] : null); ?> </pre> <br/> <h1>_GET:</h1> <pre> <?php foreach ($_GET as $key => $value) { echo "<strong>" . $key . " </strong>"; var_dump($value); } ?> </pre>
Hope this helps to fix this Issue soon.
#21 Updated by Karsten Dambekalns over 5 years ago
- Status changed from Needs Feedback to Accepted
- Assigned To set to Karsten Dambekalns
- Target version changed from 283 to 1.0 alpha 8
#22 Updated by Karsten Dambekalns over 5 years ago
- Status changed from Accepted to Resolved
- % Done changed from 70 to 100
Applied in changeset r3833.
#23 Updated by Thomas Fritz over 5 years ago
Karsten Dambekalns wrote:
Applied in changeset r3833.
This works for my Environment! Thanks
#24 Updated by Steffen Müller over 5 years ago
confirmed the bug on Debian Squeeze using Apache with mod-fcgid and php-cgi
The patches from r3833 fix the problem on this environment.
Thanks!