ext-eio readlink not (always?) returning
I've noticed that ls does not list (all?) my symlinks in a certain dir when using eio adapter.
It seems to be due to eio_readlink in the cases of these files returning only the pointed file as a result (instead of a full path), as the files are relatively linked
@gizahNL Thanks for reporting! Can you provide a simple test script to reproduce the problem you're seeing?
run this in dir to create links:
#!/bin/bash
WRKDIR=$(pwd)
TESTDIR="$WRKDIR/testlink"
if [[ -d "$TESTDIR" ]]
then
exit 0
fi
TARGET="target_link"
RELATIVE="link_relative"
FULLPATH="link_fullpath"
mkdir "$TESTDIR"
cd "$TESTDIR"
touch "$TARGET"
ln -s "$TARGET" "$RELATIVE"
ln -s "$TESTDIR/$TARGET" "$FULLPATH"
then run from same dir:
<?php
require './vendor/autoload.php';
$loop = \React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$dir = "./testlink/";
$filesystem->dir($dir)->ls()->then(function ($list) {
foreach ($list as $file) {
$filename = $file->getName();
echo($filename."\n");
}
}, function ($error) {
echo($error->getMessage());
});
echo 'Using ', get_class($filesystem->getAdapter()), PHP_EOL;
$loop->run();
output with eio:
Using React\Filesystem\Eio\Adapter target_link link_fullpath
output with childprocess:
Using React\Filesystem\ChildProcess\Adapter link_fullpath link_relative test_target
expected eio output:
Using React\Filesystem\Eio\Adapter link_fullpath link_relative test_target
My guess for the simplest fix would most likely be to intercept the eio_readlink output, and depending if output starts with a forward slash prepend the path of the dir containing the file we are running readlink on so as to always pas a full path
FYI ext-eio tends to have a will of it's own and doesn't always behave as we intend it to.