Closed (fixed)
Project:
Link checker
Version:
6.x-2.3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
8 Oct 2009 at 17:29 UTC
Updated:
10 Dec 2009 at 11:58 UTC
Administer › Site configuration › Link checker
Pressing 'Analyze content for links' button brings me to this page:
Scanning for links
An error has occurred.
Please continue to the error page
An error occurred. /batch?id=71&op=do <br /> <b>Fatal error</b>: Cannot redeclare file_read_csv() (previously declared in /usr/share/drupal-6.12/includes/common.inc(1645) : eval()'d code:20) in <b>/usr/share/drupal-6.12/includes/common.inc(1645) : eval()'d code</b> on line <b>27</b><br />
Also, the 'Please continue to the error page' link points back to the "Administer › Site configuration › Link checker" page.
Comments
Comment #1
silurius commentedSame result using the 'Clear link data and analyze content for links' button.
Comment #2
hass commentedI believe you have one or more bad nodes with PHP code. See #538004: PHP based content crashes cron or #586708: Linkchecker may hang cron when "drupal_goto()" is encountered in a node.
Remove the duplicate declaration of
file_read_csv()in your PHP nodes.Comment #3
silurius commentedHuh, thanks. Since I'm positive I didn't add the bad PHP myself, I'll have to comb through everything to find the problem. Any chance the offending node gets logged somewhere?
Also, the 'Please continue to the error page' link points back to the "Administer › Site configuration › Link checker" page. Is this supposed to direct me to an actual error page or was I just confused by the link text?
Comment #4
hass commentedHmmm... if someone have an idea how... I also wished to have this when it happened... The main problem is - this is a PHP error and I have no idea how to catch this and only log if a php error occurred. Cron is in a WSOD situation... :-(
If there is a patch I can add it...
Comment #5
silurius commentedSorry, hass, that kind of patch is probably beyond my present abilities. I would if I could!
Also, I was hoping a database search for the string "file_read" might help, but nothing whatsoever turned up.
Comment #6
hass commentedWho have written your nodes or who have more permissions than you? :-)
Try this to find your active nodes having PHP code:
Comment #7
hass commentedOh, this is much more easier... and only gives your the erroring nodes:
Comment #8
silurius commentedFound it! Thanks for the SQL help.
Here's the PHP code (modified a bit to be more 'exampleish') from the node in question:
This was old even when I first inherited it and I'm not surprised to hear that it may have issues. However, as you can see the file_read_csv function is used only once, and then it is referenced a few lines down in an if statement. Is that what you meant by "duplicate function"?
Comment #9
hass commentedHave you executed the SQL statement in #7? It gives you the node(s) you are searching for.
Comment #10
silurius commentedYes, sorry hass, you must have posted #9 as I was nuking and revising #8. :)
Comment #11
hass commentedThe problem is the function may exist in core or in a second or more nodes... this is why you have the error. You could simply move this function into your themes template.php and you are done. I would suggest - never define functions in nodes - if there is a chance that this function name may be used somewhere else, too. Or rename function to
_node_[nid]_file_read_csv()to make them unique per node.Comment #12
silurius commentedOh, now I understand the duplication reference. This code was scheduled to be integrated into template.php but it hadn't been done yet. You are totally correct about that being best practice.
Guess you can close out the issue now. Thanks for the help.
Comment #13
silurius commentedHass,
Thanks again for your help earlier. It appears that even after temporarily removing the offending node, the fatal error is still triggered by those buttons.
Even worse, I could not even save node changes today, all of a sudden. No error was produced by that, but the scanner popped up automatically, did its thing, and then took me back to the node/edit page each time.
To remedy, first I tried unpublishing the node containing the file_read_csv code, but the problem remained - couldn't edit and the analyze buttons still failed in the same way.
Next I removed all contents from the node and cleared the site cache. No change to the problem.
Next I disabled Link checker, and was now able to save the edited node I wasn't able to save earlier. But when I re-enable Link checker, these issues remain.
Comment #14
hass commentedThe function name is now a different one
get_file_array()...Comment #15
silurius commentedAh, gotcha. Should have noticed that.
Strange that this is only starting to happen this week, when these nodes have existed for six months and Link Checker has been running for two months. I suppose it must not have progressed far enough in its scans until now.
Thanks again.
Comment #16
silurius commentedHass,
I realize this extends somewhat outside the scope of this module, so apologies in advance if this is starting to get annoying.
Template.php is tied up at the moment due to various project-related factors and complications, and it's simpler to rename the two functions for the time being. I renamed the functions to node_45_file_read_csv and node_93_get_file_array respectively. The nodes are working fine individually, but the following appears when I run the scanner from the Broken Links admin page:
Why might this function show up as redeclared? I'm positive it is unique.
Comment #17
hass commentedSupport for php stuff was a new feature in 2.3... this may explain why it worked in past :-)
Comment #18
hass commentedYou make like to install DEV and disable the PHP filter... :-(
Comment #19
silurius commentedYou mean to help debug the "redeclared-but-not-really-redeclared" function, or to prevent people from putting PHP in my nodes? I am interested in working around the issue by renaming functions on a case by case basis. I can't take drastic action with regards to PHP in nodes just yet.
Thanks again.
Comment #20
silurius commentedOh wait, you were referring to linkchecker 6.x-2.x-dev. I thought you meant devel. Not sure what you meant by disabling the PHP filter, though.
Comment #21
hass commentedYes, DEV. It will not solve the issues in general, but remove the errors/fails... you should better fix the bugs :-)
Comment #22
silurius commentedRight, now I'm with you, and I agree 100%. Will give that a shot soon.
Comment #24
hass commented#656144: Try to catch PHP node errors (e.g. duplicate functions)