Req #49396 [Opn->Sus]: Need access to system errno
| From: | cmb@php.net | Date: | Wed, 06 Jan 2021 15:17:04 +0000 |
| Subject: | Req #49396 [Opn->Sus]: Need access to system errno | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231409@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=49396&edit=1
ID: 49396
Updated by: cmb@php.net
Reported by: phpbugs at jan-o-sch dot net
Summary: Need access to system errno
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: *General Issues
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
As of PHP 7.4.0, you could use the FFI extension to access errno.
However, I would not recommend doing so. The proper way forward
might indeed be some PHP internal improvements, but these would
need to be discussed on the internals mailing list, and might
require the RFC process[1]. So if you're still interested in
this, please start that process. For the time being, I'm
suspending this ticket.
[1] <https://wiki.php.net/rfc/howto>
Previous Comments:
------------------------------------------------------------------------
[2013-07-23 14:42:51] Laurent dot Lyaudet at gmail dot com
While touch is a user level function as are the ftp functions, I still think a better error handling
is needed.
------------------------------------------------------------------------
[2013-07-23 14:14:31] Laurent dot Lyaudet at gmail dot com
Hi,
I want to add up to this feature/change request.
In particular for ftp functions.
Here is my report and a test script.
I did a few tests with ftp functions:
it would be better for ftp_nlist to return error codes.
Right now the situation is the following :
- with an invalid resource (ftp_nlist(0,'.') for example), it will return NULL
- if you're not loggued in, it will return false
- if you're loggued in, it will return an array
- if you kill the connexion on the server, it will return false
BUT you will not be able to log in again with the same resource.
You have to close the connexion and create a new one with connect.
Moreover, you somehow have two kinds of invalid resources:
- arbitrary doubles,
- killed connexions.
Best regards,
Laurent Lyaudet
vm3:~# php
<?php
$con = ftp_connect(@myIP@);
ftp_login($con, @myLogin@, @myPassword@);
sleep(11); //kill the ftp process on the server
$test = ftp_login($con, @myLogin@, @myPassword@);
$res = ftp_nlist($con,'./test');
var_dump($res);
var_dump($test);
?>
------------------------------------------------------------------------
[2009-08-28 07:56:19] phpbugs at jan-o-sch dot net
Description:
------------
All system level php functions only return boolean values, which makes generic error handling easy.
However, for a more sophisticated error handling, access to errno is required.
For example: I try to touch() a file and touch() returns false. The only hint I can get is using an
error handler or calling error_get_last(), none of which provides me with an errno value. Yes, I do
want to react differently to EPERM and EDQUOT. No, I do not want to parse "touch(): Unable to
create file /fail because Permission denied".
Alternatively, having posix_* versions of all system functions would allow one to use
posix_get_last_error().
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=49396&edit=1