Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.0RC3

Bug #483 _FILEH_ never opened
Submitted: 2003-12-23 03:33 UTC
From: spammable at howsfamily dot net Assigned:
Status: Duplicate Package: OLE
PHP Version: 4.3.4 OS: Windows XP Pro
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 22 + 38 = ?

 
 [2003-12-23 03:33 UTC] spammable at howsfamily dot net
Description: ------------ I had a problem on my system with another PEAR module creating 0-byte files. It turned out that the problem was that the OLE library, which it depended on, reported an error opening a temporary file. When I looked through the OLE code in Root.php, I found a number of references to $this->_FILEH_, but I never found a place where this was assigned to. I added the line $this->_FILEH_ = fopen($this->_tmp_filename, "r+w"); at line 100 in Root.php, and everything worked. I'm not sure if this is idiosyncratic to my own system, or more widespread. It strikes me as a very obvious bug.

Comments

 [2003-12-23 10:57 UTC] xnoguer at php dot net
What version of OLE are you using? The latest version of OLE has this line on Root.php: $this->_FILEH_ = @fopen($this->_tmp_filename,"w+b");
 [2003-12-23 12:21 UTC] spammable at howsfamily dot net
I'm using OLE 0.5, and you're right, that line does exist. My only interaction OLE is through the a third party module, Spreadsheet_Excel_Writer, so I haven't really gone through the depths of it. But the line you refer to occurs in an "else" clause: //Lines 97-107 if (($filename == '-') or ($filename == '')) ... else { $this->_FILEH_ = @fopen($filename, "wb"); ... } However, the section in the "if" clause still makes reference to _FILEH_: //Line 101-102 if ($this->_FILEH_ == false) return $this->raiseError("Can't create temporary file."); Without _FILEH_ being assigned to, this will always be falsem and thus always raise the error. As I said, I haven't really gone through your code, so it simply may be that the excel module invokes your code incorrectly, but I found that adding a line to open the file in the "if" clause solved my problem. I'm not sure if it translates from my specific problem to the general case.
 [2003-12-24 10:30 UTC] xnoguer at php dot net
The if block is: if (($filename == '-') or ($filename == '')) { $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); $this->_FILEH_ = @fopen($this->_tmp_filename,"w+b"); if ($this->_FILEH_ == false) { return $this->raiseError("Can't create temporary file."); } } so $this->_FILEH_ does get assigned anyway. Only problem is, if you don't have permissions for the default temp dir and haven't set another dir with setTempDir() it will fail. I know that if you are using Spreadsheet_Excel_Writer you don't have a way to set the temp dir to be used by OLE (yet). I'm the maintainer for Spreadsheet_Excel_Writer too, and there is a setTempDir() method in cvs, but I can't make a release now. Please check my answer to bug #482. If that solves your problem I'll close this bug and keep that one open.
 [2003-12-24 10:43 UTC] spammable at howsfamily dot net
Yes, I edited my copy of Spreadsheet_Excel_Writer to set the temporary directory. If the "if" clause you quoted is right, it looks like I must have accidentally modified my copy when I was dicking around with getting it to work. Sorry about that, feel free to close the bug.