Re: Re: PHP 4.0 Bug #6795 Updated: Problem with the value of $PATH_TRANSLATED

From: Date: Mon, 08 Jan 2001 10:59:30 +0000
Subject: Re: Re: PHP 4.0 Bug #6795 Updated: Problem with the value of $PATH_TRANSLATED
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-43344@lists.php.net to get a copy of this message
What do you mean have I tested it, have you ? You can see the problem by using phpinfo(). If you want a really simple test (looks like you need one) :- Document root is /var/www/html/ /var/www/html/.htaccess (make sure your Apache config file has an AllowOveride to allow this ) -> AddHandler parser .file Action parser /parser.php /var/www/html/parser.php -> <? phpinfo(); print "PATH_TRANSLATED=${PATH_TRANSLATED}"; ?> /var/www/html/test.file -> Contents are un-important Use your browser to go to http://your.server/test.file. Without the patch the first occurence of PATH_TRANSLATED is the one that is part of the Apache enviroment (this one is correct in most Apache circumstances) - /var/www/html/test.file The second occurence is the php version of this variable (the one the code in php re-writes regardless) - /var/www/html/parser.php And the third occurence is the print statement in the script - /var/www/html/parser.php. After the patch all the three values will be /var/www/html/test.file (the Apache generated version). There is a bug in Apache where Apache calls parser.php even if test.file does not exist (I had told the Apache developers about this, never heard an answer, see http://bugs.apache.org/index.cgi/full/5700). I had gone over this in my original report ... And before you ask the problem still exists in the latest php4 snapshot (php4-200101080145). Rgds Drew Wells Jani Taskinen said: > On Thu, 4 Jan 2001 drew@elysium.ltd.uk wrote: > > >Ok, this bug is not fixed, I had at look at the source for this section in > >php-4.0.4 and it still just overwrites the PATH_TRANSLATED variable with > >the script_filename. The patch I gave only set the PATH_TRANSLATED > >variable to the script_filename if there is not an existing > >PATH_TRANSLATED (as supplied by Apache). > > Did you try compiling and really running it?? > > --Jani > > > > > > >Rgds Drew Wells > > > > Bug Database said: > > > >> ID: 6795 > >> Updated by: sniper > >> Reported By: drew@elysium.ltd.uk > >> Old-Status: Feedback > >> Status: Closed > >> Bug Type: Apache related > >> Assigned To: > >> Comments: > >> > >> No feedback, considered fixed. > >> > >> --Jani > >> > >> Previous Comments: > >> --------------------------------------------------------------------------- > >> > >> [2000-12-04 09:01:27] sniper@php.net > >> Could you please check if this problem exists when > >> using the PHP 4.0.4RC3: > >> > >> http://www.php.net/distributions/php-4.0.4RC3.tar.gz > >> > >> --Jani > >> > >> --------------------------------------------------------------------------- > >> > >> [2000-09-17 19:49:16] drew@elysium.ltd.uk > >> There seems to be a problem with the values of $PATH_TRANSLATED under different > >> circumstances :- > >> > >> In your Apache document_root create the following files :- > >> > >> .htaccess > >> AddHandler testhandler .test > >> Action testhandler handler.phtml > >> > >> handler.phtml > >> <? print "PATH_TRANSLATED = $PATH_TRANSLATED"; ?> > >> > >> index.test > >> Content not used > >> > >> You will need AllowOverride All (or similar) in the Directory spec for your Apache > >> document root (to all adding handlers). > >> > >> Here is a list of requests and responses > >> > >> http://localhost/index.test - > >> PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect) > >> http://localhost/handler.phtml - > >> PATH_TRANSLATED = /home/httpd/html/handler.phtml (Correct) > >> http://localhost/index.test/path_info - > >> PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect) > >> http://localhost/handler.phtml/path_info - > >> PATH_TRANSLATED = /home/httpd/html/handler.phtml (Incorrect) > >> > >> The reason I have put incorrect for 3 of the tests is that the value differs from the > >> value of PATH_TRANSLATED that Apache provides. PHP just copies the value of SCRIPT_FILENAME over > >> the top of PATH_TRANSLATED. Please find attached a patch to make to responses the same as > >> Apache's version of PATH_TRANSLATED. > >> > >> http://localhost/index.test - > >> PATH_TRANSLATED = /home/httpd/html/index.test (Correct) > >> http://localhost/handler.phtml - > >> PATH_TRANSLATED = /home/httpd/html/handler.phtml (Correct) > >> http://localhost/index.test/path_info - > >> PATH_TRANSLATED = /home/httpd/html/index.test/path_info (Correct) > >> http://localhost/handler.phtml/path_info - > >> PATH_TRANSLATED = /home/httpd/html/path_info (Incorrect) > >> > >> Not really sure whats going on with the last test - bug in Apache. There is also a > >> pretty big bug in Apache when doing these type of tests from a public_html (~user) type of > >> directory. > >> > >> Rgds Drew Wells > >> > >> --- php-4.0.2/sapi/apache/mod_php4.c.orig Sun Aug 20 15:29:00 2000 > >> +++ php-4.0.2/sapi/apache/mod_php4.c Mon Sep 18 12:16:49 2000 > >> @@ -232,7 +232,7 @@ > >> register int i; > >> array_header *arr = table_elts(((request_rec *) > >> SG(server_context))->subprocess_env); > >> table_entry *elts = (table_entry *) arr->elts; > >> - char *script_filename=NULL; > >> + char *script_filename = NULL, *path_translated = NULL; > >> > >> for (i = 0; i < arr->nelts; i++) { > >> char *val; > >> @@ -241,7 +241,10 @@ > >> val = elts[i].val; > >> if (!strcmp(elts[i].key, "SCRIPT_FILENAME")) { > >> script_filename = val; > >> + } else if (!strcmp(elts[i].key, "PATH_TRANSLATED")) > >> { > >> + path_translated = val; > >> } > >> + > >> } else { > >> val = empty_string; > >> } > >> @@ -249,7 +252,7 @@ > >> } > >> > >> /* insert special variables */ > >> - if (script_filename) { > >> + if (script_filename && !path_translated) { > >> php_register_variable("PATH_TRANSLATED", script_filename, > >> track_vars_array ELS_CC PLS_CC); > >> } > >> php_register_variable("PHP_SELF", ((request_rec *) > >> SG(server_context))->uri, track_vars_array ELS_CC PLS_CC); > >> > >> > >> --------------------------------------------------------------------------- > >> > >> > >> Full Bug description available at: > >> http://bugs.php.net/?id=6795 > >> > >> > > > > > > > >

« previous php.dev (#43344) next »