php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46440 Different Results with rewinddir_variation3.phpt
Submitted: 2008-10-31 22:07 UTC Modified: 2008-11-01 04:10 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
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: hostmaster at uuism dot net
New email:
PHP Version: OS:

 

 [2008-10-31 22:07 UTC] hostmaster at uuism dot net
Description:
------------
When I run test ext/standard/tests/dir/rewinddir_variation3 with PHP 5.2.6, the test fails because the Warning is not returned:

When rewinddir() is executed with a file resource, PHP does not return an Warning message.

The test expects that PHP will return "Warning: rewinddir(): %d is not a valid Directory resource in %s on line %d"

Otherwise, the test results are fine.

Jim


Reproduce code:
---------------
<?php
/* Prototype  : void rewinddir([resource $dir_handle])
 * Description: Rewind dir_handle back to the start
 * Source code: ext/standard/dir.c
 * Alias to functions: rewind
 */

/*
 * Pass a file pointer to rewinddir() to test behaviour
 */

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

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

$result1 = fread($fp, 5);
var_dump(rewinddir($fp));
$result2 = fread($fp, 5);

echo "\n-- Check if rewinddir() has repositioned the file pointer --\n";
if ($result1 === $result2) {
        echo "rewinddir() works on file pointers\n";
} else {
        echo "rewinddir() does not work on file pointers\n";
}
?>


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

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

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

-- Check if rewinddir() has repositioned the file pointer --
rewinddir() does not work on file pointers


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

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

-- Check if rewinddir() has repositioned the file pointer --
rewinddir() works on file pointers


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-31 22:12 UTC] hostmaster at uuism dot net
I didn't notice that the rest of the expected results were different also. 

It appears that rewinddir() DOES work for file resources.

Jim
 [2008-10-31 22:13 UTC] hostmaster at uuism dot net
Updated Summary
 [2008-10-31 22:32 UTC] felipe@php.net
Hello, that test isn't to 5.2.6. The bug was fixed in 5.2.7-RC1.

Thanks.
 [2008-11-01 02:02 UTC] hostmaster at uuism dot net
Can I test the solution with php5.2-200810312330 that I downloaded from php-5.2-latest.gz?

I don't know what you mean by "that test isn't to 5.2.6."

Test rewinddir_variation3.phpt was part of the released package for php-5.2.6, as were closedir_variation3.phpt and readdir_variation7.phpt.

They all failed for similar reasons:  directory functions work for file resources.

Thanks.

Jim
 [2008-11-01 04:10 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: Sat Dec 21 16:01:28 2024 UTC