php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50873 Undocumented incompatible change in ip2long()
Submitted: 2010-01-28 10:56 UTC Modified: 2010-02-17 00:19 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: rthompson at mx dot itmedia dot co dot jp Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.12 OS: Fedora
Private report: No CVE-ID: None
 [2010-01-28 10:56 UTC] rthompson at mx dot itmedia dot co dot jp
Description:
------------
Through at least version 5.2.9, ip2long() returned the input value 
unchanged for valid integer IP address inputs.

Since at least version 5.2.11, ip2long() returns "false" for all 
integer IP address inputs. (5.2.12 and 5.2.11 tested, 5.2.10 
untested).

Our application has been utilizing this function for the past three 
years, originally deployed on 5.1.(6?). Since both string and long IP 
addresses returned valid long results, the function returned valid 
results regardless of the format. This is useful when importing from 
data sources containing inconsistent representations.

The specification of the function's valid input and outputs has been 
changed and made more restrictive, yet there is no changelog entry 
documenting this incompatible change.

Reproduce code:
---------------
---
From manual page: function.ip2long#Changelog
---

echo ip2long("73.150.2.210");
echo ip2long(1234567890);


Expected result:
----------------
Expected return value (through 5.2.9) is the integer "1234567890" for 
both inputs.

Actual result:
--------------
Actual return value (since 5.2.11 or .10) is "false" for the long input, 
correct for the string input.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-28 14:50 UTC] jani@php.net
You're 4 releases too late with this. Invalid input == error == return false.
 [2010-01-29 10:00 UTC] rthompson at mx dot itmedia dot co dot jp
I'm know I'm a few releases late, but since the behavioral change isn't 
documented anywhere it was difficult to understand what was going wrong 
with the application. 

I take it "To be documented" means there's a changelog entry coming?

Is it possible to add some clarification of the validity requirements as 
well?

Thank you!
 [2010-02-17 00:17 UTC] svn@php.net
Automatic comment from SVN on behalf of joey
Revision: http://svn.php.net/viewvc/?view=revision&revision=295189
Log: Add ChangeLog table entry to note when input parsing became more strict. Closes PHP Bug #50873.
 [2010-02-17 00:19 UTC] joey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Dec 02 01:00:01 2025 UTC