Skip to content
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

dev/core#2325 import second-handling fix #23754

Merged
merged 1 commit into from
Jun 11, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Jun 10, 2022

Overview

dev/core#2325 import second-handling fix

Before

Seconds dropped when importing dates

After

Seconds retained

Technical Details

This patch only works for if ($dateType === 1) - which has it's own if - I haven't looked at other types

https://lab.civicrm.org/dev/core/-/issues/2325

Comments

@demeritcowboy @monishdeb this improves the earlier fix - and I think can close the issue even thought I kept the scope narrow. The regex is still a bit wonky per @demeritcowboy's comments - but I at least code commented to that effect

@civibot
Copy link

civibot bot commented Jun 10, 2022

(Standard links)

@civibot civibot bot added the master label Jun 10, 2022
@eileenmcnaughton eileenmcnaughton changed the base branch from master to 5.51 June 10, 2022 11:15
@civibot civibot bot added 5.51 and removed master labels Jun 10, 2022
if (empty($date)) {
return $formattedDate;
return FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Policy-wise I don't think you should be able to just change the signature of a longstanding public static function. And in fact null makes more sense to me as a return value here. Why false? Also see line 2144.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm - ok - it is only used by import - but I'm not strongly pro 'false' - it just always seems like php functions generally do that when invalid

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I thought I saw it elsewhere in universe but looks like really just civihr and I'm not sure what its status is. The use in sepa60 wouldn't make a difference. But still line 2144 here then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated back to NULL anyway

@@ -2122,32 +2131,28 @@ public static function formatDate($date, $dateType) {

if (CRM_Utils_Date::convertToDefaultDate($dateParams, $dateType, $dateKey)) {
$dateVal = $dateParams[$dateKey];
$ruleName = 'date';
if ($dateType == 1) {
if ($dateType === 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks it because $dateType is string '1'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh - I got ahead of myself

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - now passing an int but not requiring one

@demeritcowboy
Copy link
Contributor

This looks good. There's an issue with the error output but it seems to happen without the PR - I don't know if it's related to https://lab.civicrm.org/dev/core/-/issues/2566 which was reported fixed (i.e. something like the reason now shows but now the column is missing). Will make a lab ticket, e.g. if I have a date like 2021-02-03 16, it correctly flags it as invalid, but the error output doesn't show the field

"Line Number",Reason,a,b,c,d
1,"Invalid value for field(s) : Activity Date",2,something,13

@demeritcowboy demeritcowboy merged commit f399561 into civicrm:5.51 Jun 11, 2022
@eileenmcnaughton eileenmcnaughton deleted the act_date branch June 11, 2022 20:24
@eileenmcnaughton
Copy link
Contributor Author

thanks - I'll check gitlab for the new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants