Skip to content

Commit e1aeecd

Browse files
committed
Add test case for SplFileObject::fstat() when fstat() is disabled
1 parent 5344791 commit e1aeecd

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ext/spl/spl_directory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2706,6 +2706,7 @@ PHP_METHOD(SplFileObject, fread)
27062706
}
27072707

27082708
/* {{{ Stat() on a filehandle */
2709+
// TODO Don't call fstat? As it may be undefined if it is disabled via disable_functions
27092710
PHP_METHOD(SplFileObject, fstat)
27102711
{
27112712
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
@@ -2717,7 +2718,7 @@ PHP_METHOD(SplFileObject, fstat)
27172718

27182719
func_ptr = (zend_function *)zend_hash_str_find_ptr(EG(function_table), "fstat", sizeof("fstat") - 1);
27192720
if (func_ptr == NULL) {
2720-
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Internal error, function fstat() not found. Please report");
2721+
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "fstat() is not defined");
27212722
RETURN_THROWS();
27222723
}
27232724

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
SplFileObject::fstat when fstat() has been disabled.
3+
--INI--
4+
disable_functions="fstat"
5+
--FILE--
6+
<?php
7+
$obj = New SplFileObject(__DIR__.'/SplFileObject_testinput.csv');
8+
try {
9+
var_dump($obj->fstat());
10+
} catch (\RuntimeException $e) {
11+
echo $e->getMessage() . \PHP_EOL;
12+
}
13+
?>
14+
--EXPECT--
15+
fstat() is not defined

0 commit comments

Comments
 (0)