php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #66014 tmpfile() file deleted prematurely
Submitted: 2013-10-31 23:46 UTC Modified: 2013-11-01 00:48 UTC
From: divinity76 at gmail dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.5.5 OS: irrelevant?Win7 x64 and Debian7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: divinity76 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-10-31 23:46 UTC] divinity76 at gmail dot com
Description:
------------
(according to docs) "~The file is automatically removed when closed (using fclose()), or when the script ends."

but seems it is also automatically removed when the last reference to the resource handle is removed/overwritten/whatever-its-called

either the implementation or the docs seems to be wrong here 

Test script:
---------------
<?php

$h=tmpfile();
if($h===false){throw new Exception('tmpfile() failed!');};
    //$hh=$h;
    $h=stream_get_meta_data($h);//pretty sure its deleted here..
$h=$h['uri'];
var_dump(fopen($h,'r'));

Expected result:
----------------
resource(X) of type (stream)

Actual result:
--------------
Warning: fopen(/tmp/phpS6THmC): failed to open stream: No such file or directory in /in//in/IkpAW on line 8
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-01 00:07 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Type: Bug +Type: Documentation Problem -Package: *General Issues +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2013-11-01 00:07 UTC] aharvey@php.net
Documentation issue; I'll fix it up shortly.
 [2013-11-01 00:48 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=332039
Log: Note that the file returned by tmpfile() may be closed once out of scope.

Fixes doc bug #66014 (tmpfile() file deleted prematurely).
 [2013-11-01 00:48 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2013-11-01 00:48 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 03:00:02 2026 UTC