salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.54k stars 2.1k forks source link

My Activity Stream Date Is Backdating #8004

Open MyBlissIT opened 5 years ago

MyBlissIT commented 5 years ago

image

Hi, I have this issue of My Activity Stream backdating dates, like on this screenshot. I am on Version 7.11.8

Dillon-Brown commented 5 years ago

I haven't actually been able to replicate this locally but I'm guessing the issue is with the week calculation not being correctly converted to an int. I've fixed this and a few other bugs I found in #8005. Let me know if you have any further issues, thanks!

holdusback commented 5 years ago

@Dillon-Brown It seem to happen only for admin, I've tested as a normal user and it dont happen, its confirmed by PGR in the other topic : https://github.com/salesagility/SuiteCRM/issues/5918

MyBlissIT commented 5 years ago

It happens with normal users as well on my installation

MyBlissIT commented 5 years ago

I haven't actually been able to replicate this locally but I'm guessing the issue is with the week calculation not being correctly converted to an int. I've fixed this and a few other bugs I found in #8005. Let me know if you have any further issues, thanks!

Hi Dillion, I was unable to locate the actual fix from that thread

pbartett commented 4 years ago

Im having the issue where the activity stream says 0 seconds. We are running 7.11.10.

This only started happening when I changed the date formatting from US mm/dd/yyyy to uk dd/mm/yyyy

pgorod commented 4 years ago

@pbartett where exactly did you change that date format? In PHP timezone? In database properties? In SuiteCRM user profile?

pbartett commented 4 years ago

I changed it in user profile. If it change it back to mm/dd/yyyy it displays correctly

bradstcroix commented 4 years ago

I am also having the exact same issue as @pbartett on version 7.11.13

If I set my profile to mm/dd/yyyy everything is fine, but if I set it to dd/mm/yyyy all activity is stuck at "0 seconds ago"

Can any devs please advise on how I can manually patch this to fix it?

Thanks

chris001 commented 4 years ago

Without looking at the code, sounds like a bug in the date class, and/or the elapsed time class.

Mister-A commented 4 years ago

This problem of incorrect past date display in My Activity Stream remains and is triggered by certain date formats in a User's Profile > Advanced > Date Format setting

I'm testing v7.11.15

The following options trigger issues: 2010.12.23 causes all dates to be "0 Seconds ago" 2010 12 23

12.23.2010 and 23/12/2010 causes wildly varied "ago times" from negative to thousands of weeks ago (for things that actually occurred within the last 7 days) 12 23 2010 and dd slash mm slash yyyy

All other options seem to show reasonable times.

I have yet to test if it's affected by the data display preferences of the user who's action is being displayed and will endevour to and report back.

holdusback commented 4 years ago

I use format 23-12-2010 to solve the issue. But what Mister-A is telling is true !

Mister-A commented 4 years ago

So the problem is that user localised time strings are used for comparison and SugarFeed->getTimeLapse attempts to convert to UNIX time values using php strtotime - however some of the date formats provided by SuiteCRM are not supported by strtotime and so it returns false instead of valid time int as it can't workout what format the timedata is.

It looks like someone has already addressed this in the hotfix-7.10.x branch so I won't create a PR for my simpler fix, instead I'll document it here on the assumption the more involved version in the hotfix will make it through to release in due course.

Since we're making a comparison here, rather than displaying an absolute time then a solution is for SugarFeed to always use DB time for comparisons, not converting to user time.

I've achieved this with two changes in modules\SugarFeed\SugarFeed.php at what was line 490: $currentTime = $timedate->now(); change to $currentTime = $timedate->nowDB();

in the constructor __construct() adding global $disable_date_format; $disable_date_format = true; before parent::__construct();

I am not seeing any unexpected knock-on effects of setting disable_date_format in this module, all other modules still correctly use user time for date display.

My fork with this fix can be found here: https://github.com/Mister-A/SuiteCRM/commit/2f647fd5d4de32fdc8f4ed2d82ee15cdfab17c35

NOTE: I am fairly new to SuiteCRM, I do not have a broad enough understanding of the project to be certain my fix doesn't have wider ramifications, use with caution, or fork the official hotfix-7.10.x branch for the "official" fix.

nelem commented 4 years ago

This is a manifestation of a larger issue of date formats for the admin user. I'm in the UK, so I used to routinely change the admin date format to dd/mm/yyyy. The first visible issue is the Activity Stream dates being wrong. A much deeper issue is that WorkFlows run as admin and many date calculations can fail if the date format is not yyyy-mm-dd.

The workaround is to keep the admin date format as yyyy-mm-dd.

MyBlissIT commented 4 years ago

Thank you for this, I will manually change all user date formats to fix this issue.

On Wed, 22 Jul 2020, 13:51 nelem, notifications@github.com wrote:

This is a manifestation of a larger issue of date formats for the admin user. I'm in the UK, so I used to routinely change the admin date format to dd/mm/yyyy. The first visible issue is the Activity Stream dates being wrong. A much deeper issue is that WorkFlows run as admin and many date calculations can fail if the date format is not yyyy-mm-dd.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/salesagility/SuiteCRM/issues/8004#issuecomment-662409026, or unsubscribe https://github.com/notifications/unsubscribe-auth/AII4LJN7E7DFMTELYUVW453R43HDJANCNFSM4I6XV7IQ .

kale1d0code commented 1 year ago

@Mister-A's proposed changes fixes the problem.

someone should make a pull request. its crazy this hasn't been looked at for over almost 3 years

chris001 commented 1 year ago

@Mister-A's proposed changes fixes the problem.

someone should make a pull request. its crazy this hasn't been looked at for over almost 3 years

Hi @kale1d0code

I read the code of the @Dillon-Brown fix in #8005 , it's clean, it removes duplicate functions of the same name with the same bugs, it unites the date comparison calculation code into one place, updates the automated tests, etc. If you can, could you give it a try and apply the changes in Pull Request 8005 and see if it works with the Activity Stream Dates the same as the @Mister-A patch?

kale1d0code commented 1 year ago

Yeah I can give that a go it may take sometime to setup and I'll be on and off with other commitments

I've looked into this.

I created a fork of Mister-A's repo of SuiteCRM however I'm having a hard time figuring out how to change it to this repo