See: http://drupal.org/node/76437
For example, make a node with a php filtered body as:
<?php
function hello_world() {
return 'Hello world!';
}
?>
<div><?php print hello_world(); ?></div>
When submitting this node or viewing it, you get the error:
Fatal error: Cannot redeclare hello_world() (previously declared in /var/www/drupal/47/drupal/includes/common.inc(1175) : eval()'d code:3) in /var/www/drupal/47/drupal/includes/common.inc(1175) : eval()'d code on line 2
This possibly has to do with the fact that nodewords calls node_prepare($node, TRUE) to get the teaser of a node if "use teaser if description is empty" is set. Somewhere this is already evaluated, giving the "can't redeclare hello_world() function" error.
Not sure if we can avoid it. Maybe it is even a core bug. But I should look into it.
Comments
Comment #1
Robrecht Jacques commentedFixed in 4.7.
Well, not fixed, it's a quick hack: we don't output (or generate) a DESCRIPTION meta tag for nodes that have a non-cachable input format (which is probably a PHP enabled input format). This will eliminate the error, but also eliminate the output obviously.
If someone has better ideas?
Probably this needs to be fixed in core somewhere. Core doesn't have the problem because it doesn't display trimmed down versions for PHP posts. If it would, it would see the same problem as we do.
Comment #2
Robrecht Jacques commentedSetting it as "fixed".
If you think this is not the case, please reopen it.
Comment #3
joeguru commentedThis is popping up all over the place in various php modules including cron.php. No included php seems to run after an upgrade from 4.6 to 4.7. I'm not sure if it is a module conflict or not. Just trying to get my site back up.
Comment #4
joeguru commentedWell, this is a crufty hack but it's a work-around. Wrap your functions thusly:
if (!function_exists('hello_world') {
function hello_world....
}
Also, all the scripts that are affected seem to be flexinodes.
Comment #5
avpadernoIf Drupal core code doesn't have any problems with PHP filtered content, or it doesn't create a teaser for such content, I would investigate on what it does in these cases. If the method works for the Drupal core code, then it should work for this project code too.
Comment #6
avpadernoI am setting this report as fixed because the module doesn't create the description meta tag content from the teaser when the filter doesn't allow its content to be cached (in other words, when the filter creates dynamic content).