Commit c76da6c0 authored by Dieter Holvoet's avatar Dieter Holvoet Committed by Jonathan Smith
Browse files

Issue #3282068 by DieterHolvoet: Add support for entities without changed date

parent 1c41c324
Loading
Loading
Loading
Loading
+4 −0
Changes for scheduler.module: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\Action\Plugin\Action\UnpublishAction;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
@@ -884,7 +885,10 @@ function scheduler_entity_presave(EntityInterface $entity) {

      // 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);
      }

      // If required, set the created date to match published date.
      if ($scheduler_manager->getThirdPartySetting($entity, 'publish_touch', $config->get('default_publish_touch')) ||
        ($scheduler_manager->getThirdPartySetting($entity, 'publish_past_date_created', $config->get('default_publish_past_date_created')) && $entity->getCreatedTime() > $entity->publish_on->value)) {
+6 −0
Changes for src/SchedulerManager.php: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Drupal\Core\Cache\Cache;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
@@ -310,7 +311,10 @@ class SchedulerManager {
          $this->dispatchSchedulerEvent($entity, 'PRE_PUBLISH');

          // Update 'changed' timestamp.
          if ($entity instanceof EntityChangedInterface) {
            $entity->setChangedTime($publish_on);
          }

          $msg_extra = '';

          // If required, set the created date to match published date.
@@ -528,7 +532,9 @@ class SchedulerManager {
          $this->dispatchSchedulerEvent($entity, 'PRE_UNPUBLISH');

          // Update 'changed' timestamp.
          if ($entity instanceof EntityChangedInterface) {
            $entity->setChangedTime($unpublish_on);
          }

          $create_unpublishing_revision = $this->getThirdPartySetting($entity, 'unpublish_revision', $this->setting('default_unpublish_revision'));
          if ($create_unpublishing_revision && $entity->getEntityType()->isRevisionable()) {