PharData-Klasse schlägt fehl, wenn der Inhalt von tar relative Pfade hat
Ich habe Probleme mit der Verwendung von Phar, um auf gezippte Tar-Dateien zuzugreifen.
Hier ist mein Testcode:
<?php
function r($a) {
print " has " . count($a) . " files:\n";
foreach (new RecursiveIteratorIterator($a) as $path => $fileinfo) {
print " " . $path . "\n";
}
}
print "\n1.tgz";
r(new PharData('1.tgz'));
print "\n2.tgz";
r(new PharData('2.tgz'));
print "\norig dir:";
chdir('orig-dir');
r(new RecursiveDirectoryIterator('./'));
Hier ist das Fixture:
mkdir -p orig-dir/subdir; touch orig-dir/{a,b,subdir/c}; cd orig-dir
tar czf ../1.tgz *
tar czf ../2.tgz ./
cd ../
# put the test code file here and run with php test-code.php
Hier ist die Ausgabe:
1.tgz has 4 files:
phar:///tmp/t/1.tgz/a
phar:///tmp/t/1.tgz/b
phar:///tmp/t/1.tgz/subdir/c
2.tgz has 5 files:
orig dir: has 1 files:
./b
./.
./subdir/.
./subdir/c
./subdir/..
./..
./a
Q. Warum hat PHAR solche Schwierigkeiten mit der 2. TAR-Datei? (Ich bin auf PHP 5.6)