trying to use the value of publish_on in a hook_presave this is not available. it because this value is set to NULL previously. it could be improved with an aditional Event before this publish_on to null.

In scheduler.module :

      // If required, set the created date to match published date.
      if ($entity->getThirdPartySetting('scheduler', 'publish_touch', $config->get('default_publish_touch'))) {
        $node->setCreatedTime($node->publish_on->value);
      }
      $node->publish_on->value = NULL;
      $node->setPublished(TRUE);

Comments

apupiales created an issue. See original summary.

apupiales’s picture

The attached patch is a posible solution

jonathan1055’s picture

Title: Value in $node->publish_on is set to null before other modules can use the value » When publishing immediately $node->publish_on is set to NULL before other modules can react
Category: Bug report » Feature request

Hi apupiales,
From your patch it looks likes your problem is only when the node is being published immediately, that is - when a past date is entered and the config option for dates in the past 'publish immediately' is selected. Is that correct?

Given that we have 'PRE' versions of the events for both of the cron actions, I can see that it might be helpful to also have a 'PRE' event for the immediate action. I had not considered this before, but it makes for a complete set of events.

Thanks for the patch, I will test it. As this is a feature not really a bug I have changed the issue status.

Jonathan

jonathan1055’s picture

Title: When publishing immediately $node->publish_on is set to NULL before other modules can react » Add PRE_PUBLISH_IMMEDIATELY event to allow other modules to react before the node is published
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new7.52 KB

I have modified the API test to cover the new PRE_PUBLISH_IMMEDIATELY event.

  • jonathan1055 committed 499caf7 on 8.x-1.x
    Issue #2843425 by apupiales, jonathan1055: Add PRE_PUBLISH_IMMEDIATELY...
jonathan1055’s picture

Status: Needs review » Fixed

Thanks apupiales. I have credited you on the commit.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.