Doc #69685 [NEW]: gmmktime() does not return boolean false on error
| From: | alexander dot schuch+php at dezem dot de | Date: | Thu, 21 May 2015 19:16:22 +0000 |
| Subject: | Doc #69685 [NEW]: gmmktime() does not return boolean false on error | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-12350@lists.php.net to get a copy of this message | ||
From: alexander dot schuch+php at dezem dot de
Operating system:
PHP version: 5.4.41
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:gmmktime() does not return boolean false on error
Description:
------------
---
From manual page: http://www.php.net/function.gmmktime
---
The documentation of mktime() says for the return value "mktime()
returns the Unix timestamp of the arguments given. If the arguments are
invalid, the function returns FALSE (before PHP 5.1 it returned -1)."
However, gmmktime() only ever returns an integer as of documentation.
I checked the PHP source code.
https://github.com/php/php-src/blob/c2ef8a9acc7977d07a9a92b07352cdefa7c4b9a5/ext/date/php_date.c#L1572
mktime() and gmmktime() both use the same internal function
php_mktime().
https://github.com/php/php-src/blob/c2ef8a9acc7977d07a9a92b07352cdefa7c4b9a5/ext/date/php_date.c#L1491
This one in all cases returns false on invalid parameters.
The only way for gmmktime()/php_mktime() to fail is in
timelib_date_to_int():
https://github.com/php/php-src/blob/f179852f838c1d88cb39097b9557b7d2ba8e5755/ext/date/lib/timelib.c#L186
However, I do not properly understand the difference between
timelib_long and timelib_sll:
https://github.com/php/php-src/blob/f179852f838c1d88cb39097b9557b7d2ba8e5755/ext/date/lib/timelib_structs.h#L144
So, when actually can gmmktime() fail in case the arguments are correct
or, does it return any errors?
Test script:
---------------
http://3v4l.org/2esJM
<?php
var_dump(PHP_INT_MAX);
var_dump(gmmktime(0,0,0,1,1,PHP_INT_MAX));
?>
Expected result:
----------------
I wish:
- The function should return an error in case of integer overflows or
underflows (proleptic Gregorian calender is assumed).
Issues, depending on classification of documentation bug or
implementation bug:
- mktime() and gmmktime() should return the same "kind of data". So only
integer, or integer or false.
- Documentation of return value of mktime() and gmmktime() should be the
same.
- Documentation should mention that errors are/are not detected, so
either the returned timestamp is "random" (single or multiple overflows)
or an error is indicated.
Actual result:
--------------
Output for 5.2.6 - 5.6.9, php7@20140507 - 20150501
int(9223372036854775807)
int(-62198793216)
Output for 5.1.3 - 5.2.5
int(9223372036854775807)
bool(false)
Output for 5.1.0 - 5.1.2
int(9223372036854775807)
Process exited with code 137.
Output for 4.4.0 - 4.4.9, 5.0.5
int(9223372036854775807)
int(-62198755200)
--
Edit bug report at https://bugs.php.net/bug.php?id=69685&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69685&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69685&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69685&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69685&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69685&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69685&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69685&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69685&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69685&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69685&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69685&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69685&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69685&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69685&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69685&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69685&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69685&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69685&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69685&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69685&r=mysqlcfg