@@ -3714,14 +3714,32 @@ private static function writeTgzFile(
37143714 decoct ($ stat ['mtime ' ]), // Last modification time
37153715 );
37163716
3717+ static $ uid_cache = [];
3718+ static $ gid_cache = [];
3719+
3720+ $ uid = $ stat ['uid ' ];
3721+ $ gid = $ stat ['gid ' ];
3722+
3723+ if (!isset ($ uid_cache [$ uid ])) {
3724+ $ uid_cache [$ uid ] = function_exists ('posix_getpwuid ' )
3725+ ? (posix_getpwuid ($ uid )['name ' ] ?? '' )
3726+ : '' ;
3727+ }
3728+
3729+ if (!isset ($ gid_cache [$ gid ])) {
3730+ $ gid_cache [$ gid ] = function_exists ('posix_getgrgid ' )
3731+ ? (posix_getgrgid ($ gid )['name ' ] ?? '' )
3732+ : '' ;
3733+ }
3734+
37173735 $ data_last = pack (
37183736 'a1a100a6a2a32a32a8a8a155a12 ' ,
37193737 $ is_dir ? '5 ' : '0 ' , // File type ('0' = file, '5' = directory)
37203738 '' , // Link name
37213739 'ustar ' , // UStar indicator
37223740 '00 ' , // Version
3723- \function_exists ( ' posix_getpwuid ' ) ? posix_getpwuid ( $ stat [ ' uid ' ])[ ' name ' ] : '' , // Owner name
3724- \function_exists ( ' posix_getgrgid ' ) ? posix_getgrgid ( $ stat [ ' gid ' ])[ ' name ' ] : '' , // Group name
3741+ $ uid_cache [ $ uid], // Owner name
3742+ $ gid_cache [ $ gid], // Group name
37253743 '' , // Device major number
37263744 '' , // Device minor number
37273745 '' , // Root directory for paths
0 commit comments