💾 Archived View for chirale.org › 2009-07-10_356.gmi captured on 2024-08-24 at 23:54:17. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

Cron cannot run on Drupal: the drupal_goto() case

Sometimes you want to redirect a page to another on drupal. You can do this using a simple function called drupal_goto().

drupal_goto()

On few sites I’ve enabled the PHP filter module and then created a new page with PHP code input format with drupal_goto(‘node/2’) to redirect the current page to a specified node. Bad idea.

I’ve noticed that, after this change, cron.php operations failed, if you have Search module enabled. On cron new contents are indexed by the Search module: when it got my PHP page, it tries to index it but suddenly is redirected to another. You can also found an error like “Maximum function nesting level of ‘100’ reached” on php error log, symptom of an indexing blocked by pages with drupal_goto inside.

Solution:

Comment all drupal_goto() instruction in your site within pages. Use an alternative method to redirect from a node to another. Run cron from Status Report page: you can adjust indexed content per cron on Search configuration page (admin/settings/search on x)

You can add a new block with PHP code inside or (better) create a new module for this simple block (with a simple PHP switch statement as content), displaying it only on specified pages (on the bottom of block configuration). But if you create a PHP block via UI, and you put that block on every page, your site could be loop, so creating a module is the cleanest and secure way (if something go wrong, you can delete your module from the codebase and correct it). You can also find some contrib modules for redirect on drupalmodules.com.

drupalmodules.com

See also:

Fatal error: Maximum function nesting level of ‘100’ reached, aborting!

https://web.archive.org/web/20090710000000*/http://api.drupal.org/api/function/drupal_goto/6

https://web.archive.org/web/20090710000000*/http://drupalmodules.com

https://web.archive.org/web/20090710000000*/http://drupal.org/node/471698

https://web.archive.org/web/20090710000000*/http://api.drupal.org/api/function/drupal_goto/6