Client Login
Blink-Reaction
  • Home
  • Web Services
  • Portfolio
  • About
  • Blog
  • Quote Request
  • Contact

Our Blog

Today's internet offers unprecedented power. Blink keeps you updated.

Home Our Blog Be aware: nodes with PHP code and Drupal search index

Be aware: nodes with PHP code and Drupal search index

We finally decided to go to Apache Solr as our search solution. Basic installation and configuration went well out of the box (both solr engine and the Drupal module). The only thing left was waiting on the index to fill.

Indexing is done on a cron run. Solr relies on Drupal's code Search engine, for hook_update_index invocation. So cron was set to be launched every 5 minutes instead of 1h to speed things up (650k+ nodes to index...).

However something broke... Drupal logs started showing "Cron run exceeded the time limit and was aborted."

Launching cron.php from a web browser was giving 403 Access Denied Drupal message. However running cron manually (admin/reports/status/run-cron) worked correctly.
After Googling a bit found a wonderful debug solution (http://drupal.org/node/123269) - adding an extra line to module.inc:

...
foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;

if ($hook == 'cron') watchdog('cron', "hit $module cron"); // add this line
...

At next run "hit search cron" in the log targeted the culprit.

Search module invokes hook_update_index during a cron run. Further investigation showed that failure was happening during node_update_index invocation.
Searching in DB for PHP enabled nodes (there were not that much) gave the final answer:

<?php

if (!user_access('create article content')) {
drupal_access_denied();
exit();
}

?>
...

During nodes indexing PHP code inside nodes is evaluated! This is reasonable, since you want to get a clean output and not to index the code :D.
In this case however it led to anonymous cron calls getting Access Denied and breaking cron run.

Be careful with what you store in your nodes. PHP code does not belong to DB and should be used in node either for simple things (like ('Login', 'user/login');) or rarely and with care.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.

Categories

  • Drupal
  • Graphic and Flash Design
  • Internet Marketing Tips
  • Technology Tools
  • Usability

Archives

  • January 2010
  • August 2009
  • December 2009
  • February 2010
  • March 2010
  • April 2010
  • August 2010

Let's be direct

Customers go to the web for information - they want it fast, simply stated and easy to understand. Conveniently, this is our specialty.

Click here to Contact Us.

Not a Tech Guru?

No problem - most of our clients aren't either. All we need to understand are your company's internet marketing goals. We'll take it from there.

Click here to learn more about our Blink team
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.


Address:
348 Hwy 9 North
Suite F
Manalapan
New Jersey, 07726

Phone:
732-792-6566


© 2009 Blink Reaction. All rights reserved.
Blink-Reaction