php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49396 Need access to system errno
Submitted: 2009-08-28 07:56 UTC Modified: 2010-12-29 13:16 UTC
Votes:13
Avg. Score:4.8 ± 0.6
Reproduced:11 of 11 (100.0%)
Same Version:7 (63.6%)
Same OS:9 (81.8%)
From: phpbugs at jan-o-sch dot net Assigned:
Status: Open Package: *General Issues
PHP Version: * OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-08-28 07:56 UTC] 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().


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 13:16 UTC] jani@php.net
-Package: Feature/Change Request +Package: *General Issues -Operating System: Linux / Solaris +Operating System: * -PHP Version: 5.2.10 +PHP Version: *
 [2013-07-23 14:14 UTC] 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);
?>
 [2013-07-23 14:42 UTC] 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.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 13:01:23 2019 UTC