php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60940 SplFileInfo::getLinkTarget fails
Submitted: 2012-01-31 21:38 UTC Modified: 2012-03-03 19:30 UTC
From: aheadley at nexcess dot net Assigned: iliaa (profile)
Status: Closed Package: SPL related
PHP Version: 5.3SVN-2012-01-31 (snap) OS: Fedora 16
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: aheadley at nexcess dot net
New email:
PHP Version: OS:

 

 [2012-01-31 21:38 UTC] aheadley at nexcess dot net
Description:
------------
SplFileInfo::getLinkTarget (http://www.php.net/manual/en/splfileinfo.getlinktarget.php) does not seem to work at all. It fails with a "Unable to read link <symlink name>, error: Invalid argument" message. Reproduced on 5.3.8 and 5.3.10-dev snapshot (201201312030) but works on 5.2.17.

This similar but not quite the same as #51804 (https://bugs.php.net/bug.php?id=51804)

Test script:
---------------
touch('testfile');
symlink('testfile', 'testlink');
$f = new SplFileInfo( 'testlink' );
printf( 'readlink: %s'.PHP_EOL, readlink( $f->getPathname() ) );
printf( 'SplFileInfo::getLinkTarget: %s'.PHP_EOL, $f->getLinkTarget() );

Expected result:
----------------
readlink: testfile
SplFileInfo::getLinkTarget: testfile

Actual result:
--------------
readlink: testfile

Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to read link testlink, error: Invalid argument' in /home/aheadley/Desktop/testing/test.php:6
Stack trace:
#0 /home/aheadley/Desktop/testing/test.php(6): SplFileInfo->getLinkTarget()
#1 {main}
  thrown in /home/aheadley/Desktop/testing/test.php on line 6

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-31 21:57 UTC] aheadley at nexcess dot net
It also appears to be working in 5.4.0RC6.
 [2012-02-04 17:58 UTC] php-dev at zerocue dot com
Confirmed works in 5.4RC7 and trunk as well.
 [2012-03-03 19:30 UTC] iliaa@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 [2012-03-03 19:30 UTC] iliaa@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: iliaa
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 23:01:27 2025 UTC