Skip to content
Snippets Groups Projects
Commit c5472278 authored by Robert Kasza's avatar Robert Kasza
Browse files

Issue #3379796: Performance - Prevent redundant processing back to January 1st...

Issue #3379796: Performance - Prevent redundant processing back to January 1st 1970 on every cron run
parent 1ef4ab07
No related branches found
No related tags found
1 merge request!11Issue #3379796: Performance - Prevent redundant processing back to January 1st...
......@@ -204,17 +204,26 @@ final class TransitionManager {
private function getTransitionable($entity_type_id, DrupalDateTime $now) {
$storage = $this->entityTypeManager->getStorage($entity_type_id);
$now = $now->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$sql_timezone = DateTimeItemInterface::STORAGE_TIMEZONE;
$storage_format = DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
$now = $now->format($storage_format, ['timezone' => $sql_timezone]);
$cron_last = \Drupal::state()->get('system.cron_last');
// Three days before cron last.
$time_ago = $cron_last - 259200;
// Entities are transitionable if their latest revision has any transitions
// scheduled now or in the past.
$IDs = $storage->getQuery()
// scheduled now or going back to a little bit before the last cron run.
// We should not reprocess going back to 1970 beginning of unix time.
// Limit past re-processing for performance and scalability reasons.
// Only go back in time as far as the last successful cron.
$ids = $storage->getQuery()
->latestRevision()
->accessCheck(FALSE)
->condition('scheduled_transition_date.value', $now, '<=')
->condition('scheduled_transition_date.value', $time_ago, '>=')
->execute();
foreach (array_keys($IDs) as $revision_id) {
foreach (array_keys($ids) as $revision_id) {
yield $storage->loadRevision($revision_id);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment