php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46443 closedir and readdir DO work for file resource
Submitted: 2008-10-31 22:38 UTC Modified: 2008-11-01 04:11 UTC
From: hostmaster at uuism dot net Assigned:
Status: Not a bug Package: Directory function related
PHP Version: 5.2.6 OS: Fedora Core 4
Private report: No CVE-ID: None
 [2008-10-31 22:38 UTC] hostmaster at uuism dot net
Description:
------------
When I run ext/standard/tests/dir/closedir_variation3.phpt with PHP 5.2.6, the closedir() function works with a file resource.  This test script expects it not to work, so the test fails.

I'm see this kind of test failure in a number of cases.

Is there some kind of configuration option for allowing php with sloppy syntax?

Thanks.

Jim

PS.  This may the same issue as Bug #44246: closedir() accepts a file resource opened by fopen()

Reproduce code:
---------------
<?php
/* Prototype  : void closedir([resource $dir_handle])
 * Description: Close directory connection identified by the dir_handle
 * Source code: ext/standard/dir.c
 * Alias to functions: close
 */

/*
 * Create a file pointer using fopen() then try to close it using closedir()
 */

echo "*** Testing closedir() : usage variations ***\n";

echo "\n-- Open a file using fopen() --\n";
var_dump($fp = fopen(__FILE__, 'r'));

echo "\n-- Try to close the file pointer using closedir() --\n";
var_dump(closedir($fp));

echo "\n-- Check file pointer: --\n";
var_dump($fp);

if(is_resource($fp)) {
        fclose($fp);
}
?>


Expected result:
----------------
*** Testing closedir() : usage variations ***

-- Open a file using fopen() --
resource(%d) of type (stream)

-- Try to close the file pointer using closedir() --

Warning: closedir(): %d is not a valid Directory resource in %s on line %d
bool(false)

-- Check file pointer: --
resource(%d) of type (stream)


Actual result:
--------------
*** Testing closedir() : usage variations ***

-- Open a file using fopen() --
resource(5) of type (stream)

-- Try to close the file pointer using closedir() --
NULL

-- Check file pointer: --
resource(5) of type (Unknown)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-31 22:45 UTC] felipe@php.net
See Bug #46440. Thanks.
 [2008-10-31 22:51 UTC] hostmaster at uuism dot net
I'm having the same kind of results with ext/standard/tests/dir/readdir_variation7.phpt.
 [2008-10-31 22:52 UTC] hostmaster at uuism dot net
updated Summary
 [2008-11-01 04:11 UTC] hostmaster at uuism dot net
All the ext/standard/tests/dir/ tests pass with php5.2-200810312330.

Thanks.

Jim
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC