警告:ftp_get():删除操作成功 [英] Warning: ftp_get(): Delete operation successful

查看:139
本文介绍了警告:ftp_get():删除操作成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码可以从我们的开发服务器上传输备份,并且它随机地看起来表现得很奇怪,并给出以下错误/输出:

I've got a bit of code that transfers backups from our development servers, and it randomly seems to behave very strangely and giving the following errors/output:

Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-22-04-blahjob_dev18.tgz
PHP Warning:  ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106

Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-22-37-blahjob_dev19.tgz
PHP Warning:  ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106

Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-23-05-blahjob_dev5.tgz
PHP Warning:  ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106

Warning: ftp_get(): Delete operation successful. in /root/cron/get_dev_archives.php on line 106
ERR blahjob: Failed to get file: 2013-09-25_18-23-37-blahjob_dev33.tgz

我没有丝毫的想法知道删除与 ftp_get()有什么关系,或者它为什么返回 false 并抛出关于另一个操作成功的警告。 Google也一直无法找到任何类似的问题。

I haven't the slightest idea what delete has to do with ftp_get(), or why it's returning false and throwing a warning about another operation's success. Google has also been unhelpful in finding any similar issues.

有问题的代码:

Code in question:

// ftp connection established, file list acquired, yadda yadda
foreach( $targets as $target ) {
    $localfile = $backup_dir . $target;
    if( file_exists($localfile) ) {
        do_log($task['name'], "Local file ".$target." already exists, skipping.", 1);
        continue;
    }
    if( ! ftp_get($conn, $localfile, $target, FTP_BINARY) ) { // line 106
        do_log($task['name'], "Failed to get file: ".$target, 2);
    } else {
        do_log($task['name'], "Got file: ".$target);
        ftp_delete($conn, $target);
    }
}


推荐答案

我的意见是你在招惹奇怪的PHP错误。

In my opinion you are incurring in a strange PHP bug.

删除操作成功。不是PHP错误信息,它是成功删除(DELE)命令的FTP服务器响应消息。

The Delete operation successful. is not a PHP error message, it's the FTP server response message for a successful delete (DELE) command.

分析完PHP源代码后,我可以找到这个问题的唯一解释是 ftp_get 函数在没有从FTP服务器收到错误消息的情况下失败,因此它显示上一次执行的命令的FTP服务器响应,在此特定情况下,它是删除命令。

After an analysis of the PHP source code, the only explanation I can find for this problem is that the ftp_get function is failing without getting an error message from the FTP server, therefore it's displaying the FTP server response of the previous executed command which, in this specific case, is a delete command.

PHP FTP函数将FTP服务器响应文本存储在 inbuf字段 ftpbuf 结构:

The PHP FTP functions store the FTP server response text in the inbuf field of the ftpbuf structure:

typedef struct ftpbuf {
    ...
    char        inbuf[FTP_BUFSIZE]; /* last response text */
    ...
}

此栏位然后在 ftp_get函数中使用显示警告消息:

Such field is then used in the ftp_get function to display the warning message:

if (!ftp_get(ftp, outstream, remote, xtype, resumepos TSRMLS_CC)) {
    php_stream_close(outstream);
    VCWD_UNLINK(local);
    php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf);
    RETURN_FALSE;
}

ftp-> inbuf 字段由 ftp_getresp fnc < a>,但可能出于某种不明的原因,低级 ftp_get函数失败时未调用 ftp_getresp 函数,因此显示误导性错误消息。

也许FTP服务器错误日志可以提供关于真正问题的一些线索,但如果没有进一步的信息,很难说为什么您遇到了这个问题,甚至提出了一种解决方法。

The ftp->inbuf field is written by the ftp_getresp fnc, but it may be that, for some obscure reason, the low level ftp_get function is failing without calling the ftp_getresp function, therefore showing a misleading error message.
Maybe the FTP server error logs could give some clues about what the real problem is, but without further informations is really difficult to say why you're experiencing this problem and even to propose a workaround.

我唯一的建议是针对不同的FTP服务器测试您的代码(如果可能),然后最终将您的PHP升级到更新的版本。

My only suggestion is to test your code (if possible) against a different FTP server, then eventually upgrade your PHP to a newer version.

这篇关于警告:ftp_get():删除操作成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆