- Issue created by @lawxen
- π¬π§United Kingdom jonathan1055
Hi lawxen,
I just want to check, are you saying that Scheduler could update "changed" to the actual time that the cron job is run, instead of the scheduled publish_on time? That could be a valid thing to do, but it would have to be an option per entity type, and the default would be to use the publish_on time to maintain the existing behavior.You say "But in most cases", do you have any way to quantify that? Do you think this option will be widely used? I can add it, but only if users want it.
- π¨π³China lawxen
Hi jonathan1055.
are you saying that Scheduler could update "changed" to the actual time that the cron job is run
Yes
but it would have to be an option per entity type, and the default would be to use the publish_on time to maintain the existing behavior.
Agreed, we can make this function https://git.drupalcode.org/project/scheduler/-/blob/2.x/scheduler.module...
// Set the 'changed' timestamp to match what would have been done had this // content been published via cron. if ($entity instanceof EntityChangedInterface) { $entity->setChangedTime($entity->publish_on->value); }
as an config condition
"But in most cases"
Sorry, we didn't make much survey, It that our several customers want to see the real change time of any scheduled entity.
The schedular module will clean the publish_on time on cron job, then schedular save the publish_on to the changed field. Our resolution is to build a new field to store the publish_on time. For our use cases, both publish_on time and real changed time is important information. - π¬π§United Kingdom jonathan1055
OK that sounds like a reasonable option to provide. I can see that some sites might want the actual time that the entity was published or unpublished, especially if the cron job is not very frequent.
The actual line you linked to is in
hook_entity_presave()
when the entity is being published immediately on save, due to the publish_on date being in the past and the 'immediate' option is set. But I think you also want this new feature when the entity is published / unpublished via cron? It would be confusing to have one and not the other. - πΊπΈUnited States pcate
I ran into a similar issue adding this option would help fix.
We have a content type that has publish immediately on save if the date is in the past, with the change the created date option disabled. Because the changed date is set to the scheduled published date, but the created date isn't changed, the changed date is actually before the created date.
For instance:
Scheduled for publish on 10/20/24.
Run scheduled on 10/22/24.
Changed date is 10/20/24 (timestamp equivalent)
Created date is 10/22/24 (timestamp equivalent)