-
-
Notifications
You must be signed in to change notification settings - Fork 450
Add comprehensive Carbon::parse() exception handling across core modules #5189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 10 commits
aef6154
58e6127
39a8467
52f6295
94e864e
1c287dc
9a2626c
b58e438
2a90eb5
0f4897f
68fd6ac
efeb8d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| */ | ||
|
|
||
| use Carbon\Carbon; | ||
| use Carbon\Exceptions\InvalidFormatException; | ||
|
|
||
| /** | ||
| * Locale model | ||
|
|
@@ -632,7 +633,11 @@ public function storeTimeStamp($store = null) | |
| @date_default_timezone_set($timezone); | ||
| $date = date(Varien_Date::DATETIME_PHP_FORMAT); | ||
| @date_default_timezone_set($currentTimezone); | ||
| return Carbon::parse($date)->getTimestamp(); | ||
| try { | ||
| return Carbon::parse($date)->getTimestamp(); | ||
| } catch (InvalidFormatException) { | ||
| return Carbon::now()->getTimestamp(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -886,8 +891,13 @@ public function isStoreDateInInterval($store, $dateFrom = null, $dateTo = null) | |
| } | ||
|
|
||
| $storeTimeStamp = $this->storeTimeStamp($store); | ||
| $fromTimeStamp = Carbon::parse((string) $dateFrom)->getTimestamp(); | ||
| $toTimeStamp = Carbon::parse((string) $dateTo)->getTimestamp(); | ||
| try { | ||
| $fromTimeStamp = Carbon::parse((string) $dateFrom)->getTimestamp(); | ||
| $toTimeStamp = Carbon::parse((string) $dateTo)->getTimestamp(); | ||
| } catch (InvalidFormatException) { | ||
| return false; | ||
| } | ||
|
Comment on lines
+899
to
+904
|
||
|
|
||
| if ($dateTo) { | ||
| // fix date YYYY-MM-DD 00:00:00 to YYYY-MM-DD 23:59:59 | ||
| $toTimeStamp += 86400; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.