ID:               44987
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ionut dot stan at yahoo dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         SPL related
 Operating System: Windows XP, Ubuntu 8.04
 PHP Version:      5.2.6
 Assigned To:      colder
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

SplFileObject will expand to the full path internally in case
include_path is used.


Previous Comments:
------------------------------------------------------------------------

[2008-05-13 22:52:26] ionut dot stan at yahoo dot com

Description:
------------
If SplFileObject is instantiated with the third parameter (search
include_path) set to true:

$file = new SplFileObject($filename, 'r', true);

and the file is indeed on path and found,
a consequent call to $file->getRealPath() returns false,
as if the file hasn't been found at all, instead of returning the real
path.

Reproduce code:
---------------
/wwwroot
  |
  |-> /directory
  |    |
  |    |-> testfile.txt
  |
  |-> test.php


In test.php:

<?php

set_include_path(dirname(__FILE__) . '/directory');

try {

    $file = new SplFileObject('testfile.txt', 'r', true);
    var_dump($file->getRealPath());
    
} catch (RuntimeException $e) {
    echo 'File does not exist';
}


try {

    $file = new SplFileObject('./directory/test-file.txt', 'r', true);
    var_dump($file->getRealPath());

} catch (RuntimeException $e) {
    echo 'File does not exist';
}


Expected result:
----------------
/wwwroot/directory/testfile.txt
/wwwroot/directory/testfile.txt

Actual result:
--------------
false
/wwwroot/directory/testfile.txt


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44987&edit=1

Reply via email to