php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60464 fseek documention incorrect
Submitted: 2011-12-07 22:05 UTC Modified: 2011-12-08 00:10 UTC
From: df1986 at aol dot com Assigned: frozenfire (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: df1986 at aol dot com
New email:
PHP Version: OS:

 

 [2011-12-07 22:05 UTC] df1986 at aol dot com
Description:
------------
---
From manual page: http://www.php.net/function.fseek#refsect1-function.fseek-returnvalues
---
Docs say fseek returns -1 on error, actually returns false.

Test script:
---------------
//Invalid resource
echo json_encode(fseek('', 52));//outputs false
//Dangling resource
$f = fopen('somefile', 'r');//to get a valid resource
fclose($f);//to make it dangle
echo json_encode(fseek($f, 52));//outputs false


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-07 23:33 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=320620
Log: Fixed return value. Closed bug #60464.
 [2011-12-07 23:34 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2011-12-07 23:34 UTC] frozenfire@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

By the way, don't use json_encode for debugging. It's bound to screw you up. Use 
var_dump instead.
 [2011-12-07 23:56 UTC] mfonda@php.net
I think the docs were actually correct here. fseek will return -1 if the seek 
fails, and 0 upon success. It will return false in the case of invalid arguments, 
such as the example below.
 [2011-12-08 00:05 UTC] frozenfire@php.net
Yeah, you're actually right mfonda. Looking back at the sources, that actually 
makes more sense. Normally when I see only two return statements it's a "false on 
failure" situation, but in this case I suppose the RETURN_LONG would provide 
different results based on the internal function it calls.

I'll revert my change.
 [2011-12-08 00:09 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=320623
Log: Reverting previous commit, which was mistaken. Bug #60464.
 [2011-12-08 00:10 UTC] frozenfire@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Aug 09 09:01:24 2020 UTC