php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31594 virtual(): Unable to include 'xxx' - error finding URI
Submitted: 2005-01-18 10:00 UTC Modified: 2006-01-04 21:59 UTC
From: per at computer dot org Assigned: iliaa (profile)
Status: Not a bug Package: Apache2 related
PHP Version: 5.*, 4.* OS: linux 2.4.26
Private report: No CVE-ID: None
 [2005-01-18 10:00 UTC] per at computer dot org
Description:
------------
I suspect this is related to bug#30446, but thought it best to open a new issue rather than re-open that one.
I had php4-STABLE-200501160930 running for a day or so, when I discovered the following in one of my existing php apps: 

Warning: virtual(): Unable to include 'toc' - error finding URI in /srv/www/vhosts/dansklisten/htdocs/albummet/helebilledet.phtml on line 57

This is from a working, stable application, works fine in php-4.3.8, but not with the latest 4CVS.

I'll try to work out some simple code to reproduce.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-18 10:27 UTC] per at computer dot org
This now appears to be related to setlocale(). 

To reproduce:  

part0.phtml:

<?php
        setlocale(LC_ALL,"da_DK.utf8");
?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>php bug 31594</title>
</head>
<body>
part0+<?php virtual("part1"); ?>
</body>
</html>

part1.phtml:   (contents irrelevant).

part1


Comment out the setlocale() in part0 to make the code work. 

When it's commented out I see:

part0+part1. 

When it's left in I see:

part0+
Warning: virtual(): Unable to include 'part1' - error finding URI in
 [2005-01-18 16:14 UTC] jorton@php.net
Do you get a "no acceptable variant" message logged to the httpd error_log?
Changing the locale can make functions like strcasecmp behave in unexpected ways and hence random stuff can fail.  Why do you need to change the locale?
 [2005-01-18 17:32 UTC] per at computer dot org
I see no 406 codes (no acceptable variant) in the regular log and no such entries in the error_log either.  
I'm changing the locale such that e.g. strftime() will display dates in danish for instance. 
As I said, this application works fine with 4.3.8, so it would appear that something got regressed somewhere.
 [2005-01-22 15:14 UTC] sniper@php.net
How exactly do I have to configure Apache2 to be able to use virtual() without the .php (or like you do, without .phtml) suffix?? 

Apart from that, when I change the parameter to virtual to be correct, your example works just fine with latest CVS checkout regardless of what locale is in use..


 [2005-01-23 10:23 UTC] per at computer dot org
It's content negotiation. You need mod_negotiation and "Options +Multiviews" for the directory. 

I've just tried turning off Multiviews and virtual() then produces "Warning: virtual(): Unable to include 'part1' - request execution failed in " as expected.
 [2005-06-06 17:41 UTC] jorton@php.net
I can reproduce this only with the setlocale call enabled, and see a "no acceptable variant" error in error_log.  Locale settings are process-global and changing them are quite likely to break other Apache modules doing e.g. case-sensitive string comparisons.  So, I think the resolution for this bug should be simply "don't do that".
 [2005-06-06 19:58 UTC] per at computer dot org
Also, I must point out that it worked perfectly well in 4.3.8, so something was quite obviously regressed.
 [2005-09-09 09:07 UTC] per at computer dot org
Ran my testcase using snapshot 200509090630 - still fails:

part0+
Warning: virtual() [function.virtual]: Unable to include 'part1' - error finding URI in /srv/www/vhosts/www/htdocs/phpbug-31594/part0.phtml on line 11
 [2005-10-22 13:10 UTC] per at computer dot org
I should add - I am now getting a line with "no acceptable variant:" for part1 in my apache2 error-log.
 [2006-01-01 21:44 UTC] iliaa@php.net
This is not a PHP bug, the error comes direct from Apache, and indicates that the request URL cannot be resolved.
 [2006-01-02 09:55 UTC] per at computer dot org
Please, glib responses like that does you no service at all. Perhaps you would care to note the following:

1) There is no problem in php 4.3.8, so something was clearly REGRESSED in the following releases.
2) The problem is clearly caused by the PHP function setlocale().
 [2006-01-02 11:25 UTC] sniper@php.net
So in PHP 4.3.9 it started failing? Perhaps this patch would work: http://people.apache.org/~jorton/php_virtual.diff
 [2006-01-02 12:48 UTC] per at computer dot org
Sniper, that did it!  Awesome. 
I applied that patch to 4.3.9, and I'm just now trying out php5.1-200512301130.  I'll be back with an update.
 [2006-01-02 13:24 UTC] per at computer dot org
OK, I can confirm that patch working in 4.3.9, but not in the php5.1 snapshot.  I'll work my way through the 4.3.x versions up to 4.4.x and let you know.
 [2006-01-02 14:16 UTC] per at computer dot org
Well, I didn't get very far - applied the patch to 4.3.10, but here it stopped working.
 [2006-01-02 23:20 UTC] sniper@php.net
As told you by Joe and Ilia: Don't do it.
The only safe and truly working way of setting such environment variables is using apache_setenv().

 [2006-01-03 08:34 UTC] per at computer dot org
I can kind of understand that you guys can't be bothered to do much more, but I have to ask: 

1) why is there such a call as setlocale() if it it doesn't work or is at best unreliable?  Sniper, given your last comment, should I open a doc-bug to have that entered in the documentation? "DO NOT USE"?  It's the only possible conclusion.

2) How do I get e.g. a date formatted using strftime() according to a different locale than apaches? 

And finally - isn't a bit of a fiasco not to be able to fix a solidly reproducable bug?
 [2006-01-03 08:46 UTC] sniper@php.net
I'm not gonna touch this more than this, Ilia, have fun. 
 [2006-01-04 21:59 UTC] iliaa@php.net
setlocale() function changes environment settings, that is its job, nothing more nothing less. In the case of Apache this change affects other operations, that depend on chartset settings. In your case the affect is adverse, to avoid the problem perform the affected operation either after the change or restore the defaults before calling virtual().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 04:01:32 2024 UTC