Merge branch 'PHP-7.2' into PHP-7.3

* PHP-7.2:
  Fix #68825: Exception in DirectoryIterator::getLinkTarget()
This commit is contained in:
Christoph M. Becker 2018-08-22 15:39:34 +02:00
commit 3278b3347c
3 changed files with 29 additions and 0 deletions

1
NEWS
View File

@ -25,6 +25,7 @@ PHP NEWS
file). (Laruence)
- SPL:
. Fixed bug #68825 (Exception in DirectoryIterator::getLinkTarget()). (cmb)
. Fixed bug #68175 (RegexIterator pregFlags are NULL instead of 0). (Tim
Siebels)

View File

@ -1243,6 +1243,9 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);
if (intern->file_name == NULL) {
spl_filesystem_object_get_file_name(intern);
}
#if defined(PHP_WIN32) || HAVE_SYMLINK
if (intern->file_name == NULL) {
php_error_docref(NULL, E_WARNING, "Empty filename");

View File

@ -0,0 +1,25 @@
--TEST--
Bug #68825 (Exception in DirectoryIterator::getLinkTarget())
--FILE--
<?php
$dir = __DIR__ . '/bug68825';
mkdir($dir);
symlink(__FILE__, "$dir/foo");
$di = new \DirectoryIterator($dir);
foreach ($di as $entry) {
if ('foo' === $entry->getFilename()) {
var_dump($entry->getLinkTarget());
}
}
?>
===DONE===
--EXPECTF--
string(%d) "%s%eext%espl%etests%ebug68825.php"
===DONE===
--CLEAN--
<?php
$dir = __DIR__ . '/bug68825';
unlink("$dir/foo");
rmdir($dir);
?>