diff --git a/ext/standard/file.c b/ext/standard/file.c index 933747ef8cf9..992b60db5d41 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1374,7 +1374,11 @@ PHP_FUNCTION(ftruncate) RETURN_FALSE; } - RETURN_BOOL(0 == php_stream_truncate_set_size(stream, size)); + if (php_stream_truncate_set_size(stream, size) == 0) { + php_clear_stat_cache(0, NULL, 0); + RETURN_TRUE; + } + RETURN_FALSE; } /* }}} */ PHPAPI void php_fstat(php_stream *stream, zval *return_value) diff --git a/ext/standard/tests/file/ftruncate_stat_cache.phpt b/ext/standard/tests/file/ftruncate_stat_cache.phpt new file mode 100644 index 000000000000..d3a0227c43e2 --- /dev/null +++ b/ext/standard/tests/file/ftruncate_stat_cache.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-25232 ftruncate() clears the stat cache +--CREDITS-- +tolry (tobias.olry@gmail.com) +--FILE-- + +--EXPECT-- +int(8) +bool(true) +int(3)