Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Request #14773 Behaviour of method setPassive()
Submitted: 2008-10-10 15:03 UTC
From: jayr Assigned: jorrit
Status: Closed Package: Net_FTP (version 1.3.7)
PHP Version: Irrelevant OS: Windows / Linux
Roadmaps: 1.4.0a3    
Comments Add Comment Add patch

Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem : 20 - 4 = ?

 [2008-10-10 15:03 UTC] jayr (Jonas Rosenboom)
Description: ------------ The method setPassive() is only working correctly if called after establishing an connection. If it is used together with the pre-connection setting of host, user, password etc it will fail. This can be easily resolved by adding this if ($this->isPassive()) { @ftp_pasv($this->_handle, true); } appropiately. For me it worked smoothly, if it was placed in the login function after checking that the login went smooth. I am sure there may be better places though. Test script: --------------- <?php require_once('Net/FTP.php'); $ftp = new Net_FTP(); // host, port, user, pass, passive set up $ftp->setHostname(''); $ftp->setPort('21'); $ftp->setUsername('user'); $ftp->setPassword('password'); $ftp->setPassive(); // connect to server if ($res = $ftp->connect()) { // login to server if ($ftp->login()) { //upload local file, while using passive mode $ftp->put('', '', true, FTP_BINARY); } // disconnect $ftp->disconnect(); } ?> Expected result: ---------------- Upload of via passive FTP Actual result: -------------- Uploading fails, because @ftp_pasv($this->_handle, true); in the setPassive method can only be called on an established connection.


 [2008-10-15 15:22 UTC] jorrit (Jorrit Schippers)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Please check if it is as you requested
 [2008-10-15 18:50 UTC] basher (Ralf Stadtaus)
Hi, This would work beautifully if it weren't for the ! in this piece of code (method login()): if (!$this->_passv) { $this->setPassive(); } If $this->_passv is false, then set passive? Shouldn't it be the other way around? In fact, the whole thing does work with this code: if ($this->_passv) { $this->setPassive(); } Also. If you call setPassive() directly after establishing a connection, ftp_pasv() is being called before the login and won't work. It'll work, though, when it is automatically called the second time because $_passv has been set true in the first place. I don't know if calling ftp_pasv() twice will be causing any trouble. Best Ralf
 [2008-10-15 20:43 UTC] jorrit (Jorrit Schippers)
You're right, my bad. I've improved the solution.
 [2008-10-15 21:26 UTC] basher (Ralf Stadtaus)
Thank you. It's working like a charm. :-)