Home » File System » File » Bug #3926
File_CVS gives no way to CLOSE a file handle
Details
| Request #3926 | File_CVS gives no way to CLOSE a file handle |
|---|---|
| Submitted | 2005-03-23 04:53 UTC |
| From | tommythekid at mac dot com |
| Status | Bogus |
| Package | File |
| PHP Version | 5.0.3 |
| OS | solaris sparc |
| Roadmaps | (Not assigned) |
Comments
[2005-03-23 04:53 UTC] tommythekid at mac dot com
Description:
------------
I cannot use File_CSV::write($filename, $data, $conf) because it seems to manage its own filehandles .. which I am sure is nice, but it makes it hard to close said file handle to then send the file to a user with HTTP_Download.
Tommy
Reproduce code:
---------------
function generateCSVFile($txn_id) {
global $debug;
$conf = array (
'fields' => 31,
'sep' => ",",
'quote' => '"',
'header' => TRUE
);
$TempFileName = File::getTempFile();
$data = getQuotesForTransaction($txn_id);
foreach ($data as $value) {
File_CSV::write($TempFileName, $value, $conf);
}
return $TempFileName;
}
.. then try to send $TempFileName to someone.. it comes up as zero length cause its still "open" (and not written to disk) till the script exits.
Expected result:
----------------
It should behave like all other PEAR things.. make an object set the params then it should have a destructor like $csvfile->close();
(aka a function close():) :)
Tommy
Actual result:
--------------
since the file is not "written" to disk, when I try to send it to the user via HTTP_Download, the user gets a blank file.
A possible workaround would maybe be:
$pointer = File_CSV::getPointer($filename, $conf, FILE_MODE_WRITE);
flcose($pointer);
[2005-03-23 04:56 UTC] tommythekid at mac dot com
uh.. fclose($pointer);
.. and that may be all thats needed for the close($filename) function anyhow :)
:)
[2005-08-24 04:05 UTC] tommythekid at mac dot com
FWIW, I am sorry, the problem turned out to actually be a PHP/NSAPI problem.
http://bugs.php.net/bug.php?id=32424
~tommy