I am getting 'Due to existing settings, could not track when a redirect is used, so could not remove unused redirects.' in my log on every cron run. I looked at the comment where this message is logged, but am still not sure why I'm seeing this message. This message was added in #2308717: Add watchdog message when unable to delete redirects.

$conf['page_cache_invoke_hooks'] is not set to FALSE in my settings.php. The Redirect settings are:

ON - Automatically create redirects when URL aliases are changed.
ON - Retain query string through redirect.
Default redirect status - 301 Moved Permanently
OFF - Allow redirects to be saved into the page cache.
Delete redirects that have not been accessed for - 1 month

Are my settings unusual in some way? How can I enable removal of unused redirects?

Comments

dncreative’s picture

Did this just start happening for you? I've just noticed it filling the logs on a site today.

dave reid’s picture

Can anyone please screenshot their /admin/config/search/redirect/settings page for me?

agoradesign’s picture

StatusFileSize
new25.48 KB

Here's a screenshot - I'm having the same problem!

dave reid’s picture

Ah, it's due to the 'Do not discard' setting, which is actually the default value. I guess we shouldn't be displaying a watchdog message in that case, since it is pretty common.

dave reid’s picture

Version: 7.x-1.0-rc2 » 7.x-1.x-dev
Category: Support request » Bug report
Status: Active » Needs review
StatusFileSize
new770 bytes

  • Dave Reid committed 03693bd on 7.x-1.x
    Issue #2516740 by Dave Reid: Avoid watchdog message about being unable...
phily’s picture

StatusFileSize
new47.07 KB

Unfortunately for comment #4, I use "Discard after 3 months" setting (see attached screen capture) and the message still appears (patch not applied):

  • clear watchdog
  • run cron
  • message is back in the watchdog

PS: auto redirects is disable for dev purposes.

damienmckenna’s picture

StatusFileSize
new2 KB

I don't think there's any point in logging the message, it's just noise.

This patch removes the message and appends a note to the option on the settings form indicating that the page_cache_invoke_hooks variable defaults to TRUE.

phily’s picture

Sure, there is more relevant things to fix ;-)

agoradesign’s picture

I agree with Damien, that logging this is just noise. A good description on the settings page should be enough!

dave reid’s picture

Considering this was requested by users in the first place, obviously not having a message wasn't enough. Please try out the dev release which should get rid of this message if you have the 'expire redirects' setting disabled (which is the default).

damienmckenna’s picture

StatusFileSize
new1.09 KB

@Dave Reid: Ah, ok, reasonable enough.

This patch just adds an indication on the settings page that the variable is set to TRUE by default.

socialnicheguru’s picture

does 12 remove the watchdog reference?

brad.bulger’s picture

this was odd. i applied the patch, but continued to get errors on cron runs (executed from crontab) until i logged in to the site in a browser and hit Save on the Redirect settings page. without changing anything. now it seems to have stopped.

i am not following this part:

  if (!variable_get('redirect_page_cache', 0) || !variable_get('page_cache_invoke_hooks', TRUE)) {
    // If serving redirects from the page cache is enabled and hooks are not
    // executed during page caching, then we cannot track when a redirect is
    // used. Therefore, we cannot remove unused redirects.

doesn't !variable_get('redirect_page_cache', 0) mean that serving redirects from the page cache is not enabled?

brad.bulger’s picture

the reason for the odd behavior described in 14 is that redirect_purge_inactive was set to '4838400' which is not zero but also not a currently allowed value. so the settings form defaults to zero, and saving it prevents the cron due to the change in the patch.

i still don't follow the logic of that watchdog warning, nor does the message itself convey any meaning to me particularly, but it looks like it's working correctly on its own terms with that fix.

dave reid’s picture

StatusFileSize
new665 bytes

Ah, I think I know how this needs to be fixed. We should be displaying this message only if: saving redirects to the page cache is enabled and the page_cache_invoke_hooks variable is set to FALSE. This does not match the current logic.

Patch attached for review.

dave reid’s picture

StatusFileSize
new1.82 KB

Combined with improved message in the settings form.

dave reid’s picture

Status: Needs review » Fixed

Tested and committed #17 to 7.x-1.x.

  • Dave Reid committed 70dad3f on 7.x-1.x
    Issue #2516740 by Dave Reid, DamienMcKenna: Fixed errant logic for...
damienmckenna’s picture

Woot! :-)

Status: Fixed » Closed (fixed)

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