From bf58c9d99f8470807d0165844415fa56098f88b0 Mon Sep 17 00:00:00 2001 From: Thomas Colomb Date: Mon, 10 Aug 2015 09:59:50 -0700 Subject: [PATCH] Throw E_STRICT notice when mktime called with no arguments. #4611 Summary: Fix for #4611 Closes https://github.com/facebook/hhvm/pull/5809 Reviewed By: @jwatzman Differential Revision: D2284445 --- hphp/runtime/ext/datetime/ext_datetime.cpp | 5 +++++ hphp/test/slow/ext_datetime/4611.php | 5 +++++ hphp/test/slow/ext_datetime/4611.php.expectf | 1 + 3 files changed, 11 insertions(+) create mode 100644 hphp/test/slow/ext_datetime/4611.php create mode 100644 hphp/test/slow/ext_datetime/4611.php.expectf diff --git a/hphp/runtime/ext/datetime/ext_datetime.cpp b/hphp/runtime/ext/datetime/ext_datetime.cpp index 843591ea842..8b162ba4e33 100644 --- a/hphp/runtime/ext/datetime/ext_datetime.cpp +++ b/hphp/runtime/ext/datetime/ext_datetime.cpp @@ -624,6 +624,11 @@ Variant HHVM_FUNCTION(mktime, month = month < INT_MAX ? month : INT_MAX; day = day < INT_MAX ? day : INT_MAX; year = year < INT_MAX ? year : INT_MAX; + if (hour == INT_MAX && minute == INT_MAX && second == INT_MAX && + month == INT_MAX && day == INT_MAX && year == INT_MAX) { + raise_strict_warning("mktime(): You should be using " + "the time() function instead"); + } bool error; int64_t ts = TimeStamp::Get(error, hour, minute, second, month, day, year, false); diff --git a/hphp/test/slow/ext_datetime/4611.php b/hphp/test/slow/ext_datetime/4611.php new file mode 100644 index 00000000000..6edfd9cb459 --- /dev/null +++ b/hphp/test/slow/ext_datetime/4611.php @@ -0,0 +1,5 @@ +