KnpLabs / Gaufrette

PHP library that provides a filesystem abstraction layer − will be a feast for your files!

Home Page:http://knplabs.github.io/Gaufrette

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FTP: isConnected does not recognize timed out FTP connection

moritzwachter opened this issue · comments

I had the issue while using the Ftp-Adapter with Sonata's Notification Queue.

Basically the Notification listener is running for some hours before a new Event is triggered and the service which uses the KnpGaufretteBundle is executed. As the service is a singleton there is no new initialisation of the Ftp connection.
So in the meantime the Ftp connection timed out but isConnected still returns true.

My workaround was to change the function as follows:
Before:

private function isConnected()
{
    return is_resource($this->connection);
}

After:

private function isConnected()
{
    return is_array(ftp_nlist($this->connection, '.'));
}

Do you think this 'workaround' makes sense to be adapted to the official FtpAdapter? I am happy to provide a PR if needed.