Bug #72343 [NEW]: SplFileInfo from DirectoryIterator opens new FTP connections
| From: | sander at prezent dot nl | Date: | Mon, 06 Jun 2016 11:47:44 +0000 |
| Subject: | Bug #72343 [NEW]: SplFileInfo from DirectoryIterator opens new FTP connections | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-201475@lists.php.net to get a copy of this message | ||
From: sander at prezent dot nl
Operating system: Linux
PHP version: 7.0.7
Package: FTP related
Bug Type: Bug
Bug description:SplFileInfo from DirectoryIterator opens new FTP connections
Description:
------------
Iterating over an FTP directory using \DirectoryIterator and then using
the \SplFileInfo is extremely slow. Methods called un the \SplFileInfo
object, such as
isDir() and isFile() cause PHP to open a new FTP
connection under the hood for every file to retrieve file information.
This issue becomes more apparent when an FTP server is slow during
authentication.
Test script:
---------------
<?php
// Some public FTP servers to use
$ftp = 'ftp://speedtest.tele2.net/'; //
Fast server
//$ftp = 'ftp://ftp.hq.nasa.gov/'; // Not
so fast server
echo "Testing on $ftp\n";
$it = new NoRewindIterator(new DirectoryIterator($ftp));
foreach ($it as $file) {
var_dump($file->isFile()); // This causes new connections and the
slowdown
}
Expected result:
----------------
No constant stream of new FTP connections and better performance. The
FTP extension should reuse the connection that was established with the
\DirectoryIterator.
Also, since \DirectoryIterator already gets an FTP file listing, it
probably already knows what it should respond to isFile()/isDir() and
other \SplFileInfo method calls. Can that information not simply be
reused?
--
Edit bug report at https://bugs.php.net/bug.php?id=72343&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72343&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72343&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72343&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72343&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72343&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72343&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72343&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72343&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72343&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72343&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72343&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72343&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72343&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72343&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72343&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72343&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72343&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72343&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72343&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72343&r=mysqlcfg