#18646 [Com]: ftp_close not working properly
| From: | msopacua at idg dot nl | Date: | Tue, 30 Jul 2002 16:11:56 +0000 |
| Subject: | #18646 [Com]: ftp_close not working properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-15604@lists.php.net to get a copy of this message | ||
ID: 18646
Comment by: msopacua@idg.nl
Reported By: nohn@php.net
Status: Feedback
Bug Type: FTP related
Operating System: Compaq Tru64
PHP Version: 4CVS-2002-07-30
New Comment:
It's a void function, returning nothing. And nothing == FALSE.
Make the last bit:
if(ftp_close($ftp) === FALSE)
{
$result=0;
}
else
{
$result=1;
}
var_dump($ftp);
var_dump($result);
---OUTPUT---
resource(5) of type (mysql link)
resource(5) of type (Unknown)
resource(6) of type (stream)
resource(6) of type (Unknown)
resource(7) of type (FTP Buffer)
resource(7) of type (Unknown)
int(1)
Than change it to:
if(ftp_close($ftp) === NULL)
Previous Comments:
------------------------------------------------------------------------
[2002-07-30 12:03:27] nohn@php.net
Yes well... But the most important thing is this:
if (ftp_close($ftp)) {
$result = 1;
} else {
$result = 0;
}
result is 0 in this case as described below which means that ftp_close
returns false even on success. So how to check if the connection was
closed?
The unaligned access thing happens since... I don't remember when, but
see bugs 18588, 18288, 18623, 17449 for some examples.
------------------------------------------------------------------------
[2002-07-30 11:44:52] msopacua@idg.nl
Sebas,
is the unaligned access issue, part of this problem, or a larger one?
Because the ftp_close issue, is expected behaviour:
$ cat test.php
<?php
include('pass.php');
$cs = mysql_connect('localhost:/sql/tmp/mysql.sock', $user,
$password);
var_dump($cs);
mysql_close($cs);
var_dump($cs);
$fp = fopen('file.txt', 'w');
var_dump($fp);
fclose($fp);
var_dump($fp);
$ftp = ftp_connect($ftp_server);
var_dump($ftp);
ftp_close($ftp);
var_dump($ftp);
?>
--OUTPUT--
$ !php
php -f test.php
resource(5) of type (mysql link)
resource(5) of type (Unknown)
resource(6) of type (stream)
resource(6) of type (Unknown)
resource(7) of type (FTP Buffer)
resource(7) of type (Unknown)
Kindof disturbing that the type remains resource, but it has never
bothered me IRL :-)
------------------------------------------------------------------------
[2002-07-30 09:59:55] kalowsky@php.net
marking as feedback until Sebastian responds.
------------------------------------------------------------------------
[2002-07-30 09:59:51] nohn@php.net
I hope, this is what you were asking for:
<?php
$ftp_server = "2.14.128.38";
$ftp = ftp_connect("$ftp_server");
echo("FTP: "); var_dump($ftp); echo("\n");
ftp_close($ftp);
var_dump($ftp);
?>
results in this:
Unaligned access pid=19673 <php> va=0x140064c8c pc=0x1201ba050
ra=0x1201ba044 inst=0xb4010000
FTP: resource(4) of type (FTP Buffer)
resource(4) of type (Unknown)
------------------------------------------------------------------------
[2002-07-30 09:48:16] msopacua@idg.nl
Not a bug on the result issue.
void <<< ftp_close.
void returns NULL, which resolves to FALSE.
Could you var_dump($ftp) instead of echoing $result, to see if the
resource was freed?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/18646
--
Edit this bug report at http://bugs.php.net/?id=18646&edit=1