PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Images » Image_GraphViz » Bug #4972

Undefined variable if $fp not a valid resource

Details

Submitted2005-08-02 16:15 UTC
Fromjpleveille at unimasoft dot com
StatusNo Feedback
PackageImage_GraphViz
PHP Version5.0.4
OSWindows XP Pro SP2
Roadmaps(Not assigned)

Comments

[2005-08-02 16:15 UTC] jpleveille at unimasoft dot com

Description:
------------
I got the following error in Image\GraphViz.php line 192:
fopen(C:\DOCUME~1\apache\LOCALS~1\Temp\gra953.tmp.svg) [function.fopen]: failed to open stream: No such file or directory

Then, it says, for line 200:
Undefined variable: data

I checked the file and found that $data is set only if $fp is a valid file pointer, but here this is not the case. return $data then raises an error because it doesn't exist.

Test script:
---------------
I used the sample exactly has it can be found in documentation here: http://pear.php.net/package/Image_GraphViz/docs/latest/Image_GraphViz/Image_GraphViz.html

Expected result:
----------------
Even if the temp file wasn't created, I expected not to see an error like this (undefined variable).

Actual result:
--------------
The file couldn't be created, but this is due to the fact that GraphViz wasn't (yet) installed on my machine. PEAR_Error should be raised to warn programmer that the extension (which isn't an extension but an executable) is required in order to use package.

[2005-08-03 22:45 UTC] matts at discovery dot org

This bug is also present on Win2003/Apache2/PHP4.4. I'm
encountering it vie phpOpenTracker. My error message looks
like this:

Warning: fopen(C:\WINDOWS\TEMP\gra4C.tmp.png): failed to
open stream: No such file or directory in c:\php\PEAR\Image
\GraphViz.php on line 192

Notice: Undefined variable: data in c:\php\PEAR\Image
\GraphViz.php on line 200

As is the case with jpleveille, I recieve no error of any
kind informing me that the file was not created in the first
place.

I've verified the permissions on that directory and all
appears well.

Any Ideas?

- Matt

[2005-08-04 01:22 UTC] matts at discovery dot org

Ok I think I solved this problem. I had two problems
actually, the first must sound painfully obvious but it
wasn't to me.

I needed to download and install GraphViz - http://
www.graphviz.org/ I assumed the GraphViz libraries were
installed as part of the PEAR package.

Second and probably of more use to the readers is that in
order for Apache (2 at least) to talk to the “dot” program
it must have permission to interact with the desktop.
(Thanks to tr4nc3 at msn dot com on php.net for that tip...)
To allow this do the following:

Start>Run>services.msc
Right click on Apache2, select Properties
Click on the LOG ON tab
Check the box “Allow this service to interact with desktop”
Click OK
Restart Apache

Its worth mentioning that this seems like a security
disaster. By default Apache runs as SYSTEM on windows and so
will every process it creates... This gives PHP carte
blanche to do whatever it feels like to your poor windoze
box :-(. However... you will get to see your pretty graphviz
charts :-).

Hope this helps. Perhaps this should be added to a FAQ
somewhere...