It seems that this module redirects when running cron.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

damienmckenna’s picture

Category: bug » support
Status: Active » Needs work

If you mean that it gets triggered by the search indexing, you need to ensure that the content type being used has a customized display for the "Full content" display mode. In other words, don't use the Redirect display widget if all you're using is the Default display mode as it'll completely bork things up :)

That said, perhaps a little more explanation in the README.txt file, and possibly a comment in the widget form, would help?

damienmckenna’s picture

Component: Code » Documentation
Status: Needs work » Active

This needs documentation.

zambrey’s picture

I've done as requested in #1 but still getting redirected.
As you said it is because of SearchAPI indexing process.
There is alternation method which enables you to index whole node so it seems that it just loads full node view.
After turning it off redirection stopped.
I wonder if anything can be done here.

damienmckenna’s picture

I've just started using SearchAPI too, so I'll see what I can work out.

damienmckenna’s picture

I've added a new issue for verifying the SearchAPI compatibility: #1609248: Ensure compatibility with SearchAPI

damienmckenna’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new1.05 KB

This adds some checks at the start of field_redirection_field_formatter_view() that will make execution bail when ran via Drush, via the cron.php file or when in maintenance mode.

damienmckenna’s picture

Component: Documentation » Code
StatusFileSize
new1.19 KB

Added a check for the admin/reports/status/run-cron page, fixed the check for maintenance mode.

damienmckenna’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

lsolesen’s picture

Version: 7.x-2.x-dev » 7.x-2.5
Status: Closed (fixed) » Active

Still a problem when run from: admin/config/system/cron

But if I run cron.php and try again from admin/config/system/cron, cron runs correctly.

damienmckenna’s picture

FYI #1979300: Display a warning when editing unsuitable view modes should help people avoid configuring Field Redirection for the wrong view modes.

damienmckenna’s picture

Status: Active » Postponed

Leaving this as postponed as I'm not sure how much work can or should be done to work around the problem.

  • DamienMcKenna committed 42b8891 on 8.x-2.x
    Issue #1361806 by DamienMcKenna: Avoid redirects during cron.
    
anybody’s picture

Issue summary: View changes

This sadly still seems to breaks cron runs on search index in certain cases. This happens if a page is indexed which uses field_redirection for a link field. It doesn't limit to view mode "Default" like described above as for example you might use the redirection on other view_modes too which are displayed / indexed.

In our case it's view mode "Full" of a taxonomy term, I'm not yet sure why it's being indexed by search API, but it kills cron via redirect.

I'll further investigate this and try to find out why none of the conditions that were added in the commit work. Does someone know if core exposes information if the current call is a cron run? Perhaps it would make sense if core would set a parameter at the beginning of a cron run for such cases?
On the other hand it's not really a cron problem, but more a "This is a search crawl" problem and cron is just running it? Any ideas?

anybody’s picture

Version: 7.x-2.5 » 8.x-2.x-dev

Switching this to 8.x as it seems it doesn't work in all cases... Didn't yet figure out why none of the if's work here...

But I think I have a safer idea, at least for Search API:
This module could provide a search api preprocessor to "Exclude all entities with field redirection". If checked, all entities with an active redirect are skipped.

Just like checking the "Skip" checkbox at https://www.drupal.org/project/search_api_exclude_entity.

Wanted to leave that idea, but let's first see why redirects still happen on cron run with search_api indexing and break cron.

anybody’s picture

Status: Postponed » Active

Haha, I found the reason! :)

    if (mb_strpos($current_path, '/cron') === 0) {
      return TRUE;
    }

doesn't work for multilang projects! ;)

$current_path is /de/cron there...

Solution: use

$current_url->getInternalPath();

instead of

$current_url->toString();

Didn't check if Drupal 7 has the same problem.

anybody’s picture

MR !2 is the right one!

One more point I'd like to suggest: When using Search API you can start indexing via UI as batch job, e.g. on admin/config/search/search-api/index/content_index

The $current_url is then starting with /batch so I'd suggest to handle it just like /cron and add that condition?

anybody’s picture

Status: Active » Needs review

@DamienMcKenna could you have a look at MR2 and #20 please? :)

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Let's do any additional changes in separate issues.

anybody’s picture

Thanks, Damien! :) Looking forward to the next stable release with this fix.

Status: Fixed » Closed (fixed)

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

anybody’s picture

@DamienMcKenna, this didn't make it into a stable release yet. Is one planned? (BTW note that there's a test failure in dev)

damienmckenna’s picture