#18646 [Csd]: ftp_close not working properly
| From: | sesser@php.net | Date: | Tue, 30 Jul 2002 20:51:14 +0000 |
| Subject: | #18646 [Csd]: ftp_close not working properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-15623@lists.php.net to get a copy of this message | ||
ID: 18646
Updated by: sesser@php.net
Reported By: nohn@php.net
Status: Closed
Bug Type: Feature/Change Request
Operating System: Compaq Tru64
PHP Version: 4CVS-2002-07-30
New Comment:
fixed in HEAD. ftp_quit/close return now TRUE or FALSE.
Previous Comments:
------------------------------------------------------------------------
[2002-07-30 16:49:52] kalowsky@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a
documentation
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2002-07-30 14:22:31] nohn@php.net
Yes. It would be great to make this a feature like mysql_close that
also returns TRUE if it succeded or FALSE if it failed.
------------------------------------------------------------------------
[2002-07-30 12:44:53] msopacua@idg.nl
Whether it should remain a void function is a feature request.
Maybe it should be changed like below, but that's up to Andrew and
Stefan.
Index: php_ftp.c
===================================================================
RCS file: /repository/php4/ext/ftp/php_ftp.c,v
retrieving revision 1.65
diff -u -r1.65 php_ftp.c
--- php_ftp.c 26 Jul 2002 22:00:25 -0000 1.65
+++ php_ftp.c 30 Jul 2002 16:41:50 -0000
@@ -1021,7 +1021,10 @@
ZEND_FETCH_RESOURCE(ftp, ftpbuf_t*, &z_ftp, -1, le_ftpbuf_name,
le_ftpbuf);
- zend_list_delete(Z_LVAL_P(z_ftp));
+ if(zend_list_delete(Z_LVAL_P(z_ftp)) != SUCCESS)
+ {
+ php_error(E_NOTICE, "Could not close ftp stream");
+ }
}
/* }}} */
------------------------------------------------------------------------
[2002-07-30 12:11:56] msopacua@idg.nl
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)
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
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