1--TEST-- 2Bug #70417 (PharData::compress() doesn't close temp file) 3--SKIPIF-- 4<?php 5if (!extension_loaded('phar') || !extension_loaded('zlib')) { 6 die("skip ext/phar or ext/zlib not available"); 7} 8exec('lsof -p ' . getmypid(), $out, $status); 9if ($status !== 0) { 10 die("skip lsof(8) not available"); 11} 12if (!str_starts_with($out[0], 'COMMAND')) { 13 die("skip Might be a different lsof"); 14} 15?> 16--FILE-- 17<?php 18function countOpenFiles() { 19 exec('lsof -p ' . escapeshellarg(getmypid()) . ' 2> /dev/null', $out); // Note: valgrind can produce false positives for /usr/bin/lsof 20 return count($out); 21} 22$filename = __DIR__ . '/bug70417.tar'; 23@unlink("$filename.gz"); 24$openFiles1 = countOpenFiles(); 25$arch = new PharData($filename); 26$arch->addFromString('foo', 'bar'); 27$arch->compress(Phar::GZ); 28unset($arch); 29$openFiles2 = countOpenFiles(); 30var_dump($openFiles1 === $openFiles2); 31?> 32--CLEAN-- 33<?php 34$filename = __DIR__ . '/bug70417.tar'; 35@unlink($filename); 36@unlink("$filename.gz"); 37?> 38--EXPECT-- 39bool(true) 40