This is not specifically a scheduler problem but it seems appropriate to ask it here.

If a published node has a menu link and is then unpublished, the menu link remains visible until the menu cache is cleared. This occurs whether the unpublish is caused by scheduler or manually editing the node.

I'd prefer my users not to see a menu item to a unpublished node.

Is there a simple way around this when using scheduler?

Comments

jonathan1055’s picture

Hi,
There are drupal-supplied functions to clear the menu cache, so maybe the scheduler process could call them? Not sure if there would be an overhead in processing time if run manally, but when done via a crontab job run it would be fine.

Eric, is this worth investigating?

Jonathan

icosa’s picture

Thanks Jonathan. I haven't quite dug into it enough to figure out what I need to add to the cron job.

I think you're right to ask what sort overhead it would cause.

Note that if you edit a node manually that has a menu link and uncheck "Provide a menu link" then the menu link disappears immediately for anonymous users but the hit doesn't seem as heavy as clearing the page cache. I guess I should try to figure out what extra happens when saving a node after unchecking the menu. I'm kind of surprised that node_save doesn't do it. I guess that's for performance reasons. I'm also surprised that clearing the page cache (which I think cron always does) doesn't do it. I thought the page cache included everything for anonymous users but I guess I need to learn more about caching. Clearing the menu cache or "all caches" is the only way to remove unpublished nodes from the menu.

I'm moving a client from another CMS (DotNetNuke) which has publish from and to dates for a page and I know they're going to find it quite disturbing that menu items remain for expired nodes and an editor type user doesn't even have a good means to force the menu to "correct" itself.

jonathan1055’s picture

I've just tried to replicate this behaviour, but the menu link disappeared on the first screen redraw after being unpublished by cron. Two questions:

  1. Do your links persist for anonymous viewers only, or are they also stuck there for admins too? what about ordinary registered users?
  2. What are your cache settings on admin -> config -> development -> performance?
icosa’s picture

I just discovered where the problem is.

I tried it on a clean Drupal install and it works fine for me too. Sorry, I should have done that first.

I'm using the Superfish menu module. It's clearly related to that since it happens when I install Superfish on the clean install. It must be doing some caching. I'm raise an issue other there.

Thanks

jonathan1055’s picture

No apology needed, glad you are getting to the root of it.

For anyone who comes along later having the same problem, the superfish issue is #1553330: Clear cache entries after access to node changed

jonathan1055’s picture

Status: Active » Closed (works as designed)