diff --git a/hphp/runtime/ext/fb/ext_fb.cpp b/hphp/runtime/ext/fb/ext_fb.cpp index c61cf227959a8b..f19627ff4e4d4c 100644 --- a/hphp/runtime/ext/fb/ext_fb.cpp +++ b/hphp/runtime/ext/fb/ext_fb.cpp @@ -1158,6 +1158,13 @@ static Variant do_lazy_stat(Function dostat, const String& filename) { return stat_impl(&sb); } +Variant HHVM_FUNCTION(fb_lazy_stat, const String& filename) { + if (!FileUtil::checkPathAndWarn(filename, __FUNCTION__ + 2, 1)) { + return false; + } + return do_lazy_stat(StatCache::stat, filename); +} + Variant HHVM_FUNCTION(fb_lazy_lstat, const String& filename) { if (!FileUtil::checkPathAndWarn(filename, __FUNCTION__ + 2, 1)) { return false; @@ -1173,6 +1180,14 @@ Variant HHVM_FUNCTION(fb_lazy_realpath, const String& filename) { return StatCache::realpath(filename.c_str()); } +Variant HHVM_FUNCTION(fb_lazy_readlink, const String& filename) { + if (!FileUtil::checkPathAndWarn(filename, __FUNCTION__ + 2, 1)) { + return false; + } + + return StatCache::readlink(filename.c_str()); +} + /////////////////////////////////////////////////////////////////////////////// EXTERNALLY_VISIBLE @@ -1210,8 +1225,10 @@ struct FBExtension : Extension { HHVM_FE(fb_output_compression); HHVM_FE(fb_set_exit_callback); HHVM_FE(fb_get_last_flush_size); + HHVM_FE(fb_lazy_stat); HHVM_FE(fb_lazy_lstat); HHVM_FE(fb_lazy_realpath); + HHVM_FE(fb_lazy_readlink); HHVM_FE(fb_call_user_func_safe); HHVM_FE(fb_call_user_func_safe_return); HHVM_FE(fb_call_user_func_array_safe); diff --git a/hphp/runtime/ext/fb/ext_fb.h b/hphp/runtime/ext/fb/ext_fb.h index 84fb965d710030..61677a44600643 100644 --- a/hphp/runtime/ext/fb/ext_fb.h +++ b/hphp/runtime/ext/fb/ext_fb.h @@ -49,8 +49,10 @@ Variant HHVM_FUNCTION(fb_disable_code_coverage); bool HHVM_FUNCTION(fb_output_compression, bool new_value); void HHVM_FUNCTION(fb_set_exit_callback, const Variant& function); int64_t HHVM_FUNCTION(fb_get_last_flush_size); +Variant HHVM_FUNCTION(fb_lazy_stat, const String& filename); Variant HHVM_FUNCTION(fb_lazy_lstat, const String& filename); Variant HHVM_FUNCTION(fb_lazy_realpath, const String& filename); +Variant HHVM_FUNCTION(fb_lazy_readlink, const String& filename); Array HHVM_FUNCTION(fb_call_user_func_safe, const Variant& function, diff --git a/hphp/runtime/ext/fb/ext_fb.php b/hphp/runtime/ext/fb/ext_fb.php index 1c3d0c84ee3ab5..b3da7c11e772db 100644 --- a/hphp/runtime/ext/fb/ext_fb.php +++ b/hphp/runtime/ext/fb/ext_fb.php @@ -179,6 +179,15 @@ function fb_set_exit_callback(mixed $function): void; <<__HipHopSpecific, __Native>> function fb_get_last_flush_size(): int; +/* Gathers the statistics of the file named by filename, like stat(), except + * uses cached information from an internal inotify-based mechanism that may + * not be updated during the duration of a request. + * @param string $filename - Path to a file or a symbolic link. + * @return mixed - Same format as the normal php stat() function. + */ +<<__Native>> +function fb_lazy_stat(string $filename): mixed; + /* Gathers the statistics of the file named by filename, like lstat(), except * uses cached information from an internal inotify-based mechanism that may * not be updated during the duration of a request. @@ -198,6 +207,15 @@ function fb_lazy_lstat(string $filename): mixed; <<__Native>> function fb_lazy_realpath(string $filename): mixed; +/* Returns the contents of the symbolic link path, like realpath(), + * except uses cached information from an internal inotify-based mechanism + * that may not be updated during the duration of a request. + * @param string $filename - The symbolic link path. + * @return string - Returns the contents of the symbolic link path. + */ +<<__Native>> +function fb_lazy_readlink(string $filename): mixed; + /* This function invokes $function with the arguments specified in its * parameter list. It returns an array of two elements, the first being a * boolean specifying whether or not the function was invoked, the latter diff --git a/hphp/test/slow/ext_fb/fb_lazy.php b/hphp/test/slow/ext_fb/fb_lazy.php new file mode 100644 index 00000000000000..9e5cd4a527d3cf --- /dev/null +++ b/hphp/test/slow/ext_fb/fb_lazy.php @@ -0,0 +1,13 @@ +