Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004415 [Quercus] minor always 03-01-11 07:01 06-23-12 00:38
Reporter jamesdlow View Status public  
Assigned To nam
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version Product Version 4.0.14
  Product Build
Summary 0004415: php://temp is an unsupported or unknown path
Description I'm trying to use a 3rd party library in my code. It reads from php://temp [^]
I get the following error with the following code, trying to convert a string to a stream.

Warning: php://temp [^] is an unsupported or unknown path for this protocol [fopen]

$body = "Some text";
$stream = fopen('php://temp','r+'); [^]
fputs($stream,$body);
rewind($stream);

Steps To Reproduce
Additional Information Additional information on wrappers can can be seen here:
http://php.net/manual/en/wrappers.php.php [^]
Attached Files  PhpTemp.java [^] (1,441 bytes) 03-01-11 09:42
 PhpTemp2.java [^] (1,502 bytes) 03-01-11 19:41
 PhpProtocolWrapper.java [^] (3,218 bytes) 03-01-11 19:41
 WriteStream.java [^] (29,662 bytes) 03-03-11 23:55
 PhpTemp3.java [^] (1,497 bytes) 03-04-11 11:21
 CircularByteBuffer.java [^] (25,353 bytes) 03-04-11 11:21

- Relationships

- Notes
(0005091)
jamesdlow
03-01-11 09:42

I've been fiddling around trying to make this work. It should possible with some kind of buffered input/output stream. But I actually run out of memory on my computer when I try to compile Quercus.

I've been trying with Pipes (see attached file PhpTemp.java) along with following changes to com.caucho.quercus.lib.file.PhpProtocolWrapper

    if (path.equals("php://output")) [^]
      return new PhpBinaryOutput(env);
    else if (path.equals("php://input")) [^]
      return new PhpBinaryInput(env);
    else if (path.equals("php://stdout")) [^]
      return new PhpStdout();
    else if (path.equals("php://stderr")) [^]
      return new PhpStderr();
    else if (path.equals("php://stdin")) [^]
      return new PhpStdin(env);
    else if (path.equals("php://temp")) [^]
      return new PhpTemp(env);
 
(0005092)
jamesdlow
03-01-11 09:44

I've also read that it might be better to use Oster Miller's CircularBuffer instead of pipes because its not limited to a 1k buffer:

http://ostermiller.org/convert_java_outputstream_inputstream.html [^]
 
(0005096)
jamesdlow
03-01-11 19:43

Ok managed to get it compile without the memory errors, by compiling against the old resin.jar, and just compiling the two classes I changed. I've uploaded them, but had to rename the file PhpTemp2.java, change it back to PhpTemp.java if you download it and compile it. Though I'm not sure if its fully working or the best way to do this.

It seemed to work for the most basic of cases, but I'm still having some trouble getting my library all the time. Trying to track down if that's the same issue, or something else.
 
(0005108)
jamesdlow
03-02-11 19:55

Ok, I've had a bit more of a try with my code and it seems it doesn't work. I'll keep trying, but if someone at Caucho know's how to implement this really easily do let me know.
 
(0005117)
jamesdlow
03-04-11 00:03

Ok PhpTemp2.java seems to work, but I also had to make a change to com.caucho.vfs.WriteStream (see attached file).

in writeStream(InputStream source) I had to change the loop to include source.available() because otherwise read calls on some streams (like the PipedOutputStream I'm using) are blocking until there is date:

    while (source.available() > 0 && (len = source.read(_writeBuffer,
                              _writeLength,
                              length - _writeLength)) >= 0) {
 
(0005119)
jamesdlow
03-04-11 11:25

Hi,

I ended up using the circular buffer mentioned here (see PhpTemp3.java), because 1K with the pipeinput buffer size was too small. Please note that the modification to WriteStream.java is still required to stop read blocking when there is no more data.
http://ostermiller.org/convert_java_outputstream_inputstream.html [^]

I'm not sure if you could make something work with your existing TempInputStream/TempOutputStream classes, but I wasn't confident enough in how these work to try.

Thanks,
James
 
(0005941)
nam
06-23-12 00:38

php/167k
php/167l

Fixed for 4.0.29.
 

- Issue History
Date Modified Username Field Change
03-01-11 07:01 jamesdlow New Issue
03-01-11 08:03 kdecherf Issue Monitored: kdecherf
03-01-11 09:42 jamesdlow File Added: PhpTemp.java
03-01-11 09:42 jamesdlow Note Added: 0005091
03-01-11 09:44 jamesdlow Note Added: 0005092
03-01-11 09:48 jamesdlow Issue Monitored: jamesdlow
03-01-11 19:41 jamesdlow File Added: PhpTemp2.java
03-01-11 19:41 jamesdlow File Added: PhpProtocolWrapper.java
03-01-11 19:43 jamesdlow Note Added: 0005096
03-02-11 19:55 jamesdlow Note Added: 0005108
03-03-11 23:55 jamesdlow File Added: WriteStream.java
03-04-11 00:03 jamesdlow Note Added: 0005117
03-04-11 11:21 jamesdlow File Added: PhpTemp3.java
03-04-11 11:21 jamesdlow File Added: CircularByteBuffer.java
03-04-11 11:25 jamesdlow Note Added: 0005119
06-21-12 13:58 nam Status new => assigned
06-21-12 13:58 nam Assigned To  => nam
06-23-12 00:38 nam Status assigned => closed
06-23-12 00:38 nam Note Added: 0005941
06-23-12 00:38 nam Resolution open => fixed


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
50 total queries executed.
33 unique queries executed.
Powered by Mantis Bugtracker