php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68462 ftp-put: debugging fail after "PORT command successful"
Submitted: 2014-11-20 13:26 UTC Modified: 2021-09-12 04:22 UTC
Votes:5
Avg. Score:4.2 ± 1.0
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: stratflow at hotmail dot com Assigned: cmb (profile)
Status: No Feedback Package: FTP related
PHP Version: 5.4.35 OS: FreeBSD 9.2-RELEASE-p10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stratflow at hotmail dot com
New email:
PHP Version: OS:

 

 [2014-11-20 13:26 UTC] stratflow at hotmail dot com
Description:
------------
ftp_put() in some cases returns FALSE after transfer of a file.
The last logged error in $php_errormsg is 
  "ftp_put() [function.ftp-put.php]: PORT command successful"

It is unclear if this is a problem within PHP:FTP, a clientside filesystem problem or a serverside problem.

The same script runs 100 transfers every 15 mins from one server off to different platforms of different flavours. We have recently encountered a HUGE increase of these errors which would indicate a problem in the source system.

As far as we can see, there is no (documented?) way to debug this problems and look into the server responses. There was one proposal how to solve something like this in
  https://bugs.php.net/bug.php?id=44059
but that never made it into the tree.






Test script:
---------------

$ftp         = ftp_connect($ftphost,21,15);
$ftp_login   = ftp_login($ftp, $ftpuser, $ftppass);
$ftp_pasv    = ftp_pasv($ftp, true);

$ftp_up      = ftp_put($ftp, $trgfile, $srcfile, FTP_BINARY); 

# now check upload status:
if (!$ftp_up) { 
  print "upload check failed [" . $php_errormsg . "]<";
} else {
  print "upload successful";
}




Expected result:
----------------
Access to some sort of log of last server messages.



Note: 
The last erromessage in php_errormsg is might be misleading.

Note 2:
Unless you're transferring to a server to which you have ftp-logfile access, it's impossible to debug this from the serverside.



Actual result:
--------------
ftp_put() returns FALSE for undebuggable reason.

Misleading or unclear messages in $php_errormsg

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-20 13:41 UTC] stratflow at hotmail dot com
In addition, the following, ambiguious warnings might get issued:

Warning: ftp_put() [function.ftp-put.php]: php_connect_nonb() failed: Operation now in progress (36) in xxxxx.php on line xxx

Warning: ftp_put() [function.ftp-put.php]: Type set to I in xxxxx.php on line xxx
 [2014-11-20 14:45 UTC] stratflow at hotmail dot com
Further digging lead to a patch that was never accepted and might address a component of this issue:

https://bugs.php.net/bug.php?id=55651
[http://www.elitehosts.com/blog/php-ftp-passive-ftp-server-behind-nat-nightmare/]
 [2014-11-20 16:46 UTC] stratflow at hotmail dot com
Even further digging lead to E_WARNINGs:

call to ftp_put() in troubleful cases trigger this sequence of warnings:

------------------------------------------------
[#2] E_WARNING
ftp_put() [function.ftp-put.php]: php_connect_nonb() failed: Operation now in progress (36)

[#2] E_WARNING
ftp_put() [function.ftp-put.php]: Entering Passive Mode (92,42,188,103,192,0).
------------------------------------------------

looking at $php_errormsg after ftp_put(), only the last message (Entering Passive Mode) is recorded. This is misleading. In fact, php_connect_nonb() had already failed and should trigger a proper response!
 [2021-09-01 13:50 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-09-01 13:50 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?  Especially, this *might* be a duplicate of bug
#79100, which has been fixed in the meantime.

[1] <https://www.php.net/supported-versions.php>
 [2021-09-12 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:29 2024 UTC