View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0031836 | mantisbt | bugtracker | public | 2022-12-19 06:49 | 2024-11-01 11:57 |
Reporter | ricardoalonsos | Assigned To | dregad | ||
Priority | high | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 2.25.5 | ||||
Target Version | 2.25.6 | Fixed in Version | 2.25.6 | ||
Summary | 0031836: Date conversion fails when editing a project version using a non-US date format | ||||
Description | When editing a project version, if the date format is set for a non-US format, the strtotime will fail on date conversion. Attached is the patch to fix the issue | ||||
Steps To Reproduce |
| ||||
Tags | patch | ||||
Attached Files | 0004-if-date-format-is-not-an-US-format-strtotime-will-fa.patch (952 bytes)
From b7c4350fefeb202e58ada34f99561099643eebac Mon Sep 17 00:00:00 2001 From: Ricardo Alonso <ralonso@redhat.com> Date: Mon, 19 Dec 2022 11:38:04 +0000 Subject: [PATCH] if date format is not an US format, strtotime will fail. So first create a datetimeimmutable with the user specified format and perform the string conversion --- core/version_api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_api.php b/core/version_api.php index d2e97e7..4f8060f 100644 --- a/core/version_api.php +++ b/core/version_api.php @@ -111,7 +111,7 @@ class VersionData { if( $p_value == '' ) { $t_value = date_get_null(); } else { - $t_value = strtotime( $p_value ); + $t_value = DateTimeImmutable::createFromFormat( config_get('normal_date_format') , $p_value)->getTimestamp(); if( $t_value === false ) { throw new ClientException( "Invalid date format '$p_value'", -- 2.38.1 | ||||
has duplicate | 0022704 | closed | dregad | Due date not saved when non english date format |
has duplicate | 0023257 | closed | dregad | Due Date saves wrong values |
has duplicate | 0022558 | closed | dregad | Problem with datepicker and custom date format |
related to | 0034928 | assigned | dregad | Date conversion fails using a non-US date format in VersionUpdateCommand.php |
related to | 0033597 | new | Datetime picker breaks when setting normal_date_format |
Thanks, good catch. Your patch should indeed fix the issue from the GUI (will test to confirm), but I believe we'll probably be facing the same problem when creating a new version from the API as well (need to check). Next time if that's possible for you, please submit your contribution as a pull request on GitHub to facilitate the review and merge process. |
|
PR https://github.com/mantisbt/mantisbt/pull/1864 Change includes additional fixes / improvements than just this issue, refer to PR for details. |
|
I take care to generate a pull request next time. |
|
MantisBT: master-2.25 dbafafa9 2022-12-19 06:38 Committer: dregad Details Diff |
Fix project version edit failing with non-US dates If $g_normal_date_format is not an US format, strtotime will fail. So first create a datetimeimmutable with the user specified format and perform the string conversion. Fixes 0031836 Signed-off-by: Damien Regad <dregad@mantisbt.org> |
Affected Issues 0031836 |
|
mod - core/version_api.php | Diff File | ||
MantisBT: master-2.25 a500ed68 2023-02-21 17:41 Committer: community Details Diff |
Improve conversion of date strings to unix timestamps When editing a project version, if the date format is set for a non-US format, the strtotime() call will fail on date conversion. This moves the conversion logic to date_strtotime() API and makes use of the modified API function where relevant, i.e. when date string could be user-provided. Fixes 0031836, PR https://github.com/mantisbt/mantisbt/pull/1864 |
Affected Issues 0031836 |
|
mod - bug_update.php | Diff File | ||
mod - config_defaults_inc.php | Diff File | ||
mod - core/bug_api.php | Diff File | ||
mod - core/commands/VersionAddCommand.php | Diff File | ||
mod - core/date_api.php | Diff File | ||
mod - core/version_api.php | Diff File | ||
mod - docbook/Admin_Guide/en-US/config/duedate.xml | Diff File |