I'm experiencing an intermittent error that I'd like some help debugging. I've seen this error both during cron runs and also when loading a lot of nodes, for example when using www.example.com/admin/content. I've also seen it when loading normal page-type pages. When this bug occurs as a result of a page load, I observe that the page fails to load and the following PHP error is printed on the page:
[16-Nov-2011 15:38:06] PHP Fatal error: Maximum execution time of 240 seconds exceeded in <snip>/sites/all/modules/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php on line 493
When it occurs during a cron run, I only see this error in my PHP errors log. I have tried clearing my HTML Purifier cache, but this does not seem to help.
I added dpm($old) immediately above line 493 in MakeWellFormed.php and observed that this function is called many hundreds of times while loading admin/content, all with empty $old. Is this the expected behavior? Any ideas about why this is happening on my site or directions I can look to figure it out?
Thank you.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | drupal_debug.txt | 328.75 KB | sdrycroft |
| #2 | signature.png | 52.26 KB | addicted_to_drupal |
Comments
Comment #1
ultimikeI have been seeing the same behavior...
-mike
Comment #2
addicted_to_drupal commentedI had the same problem, i went on the net and after a lot pages i found this one
the soluce
And it works. You have to go one location of drupal/sites/default folder then found the file defaulf.setting and add new line on it
ini_set('max_execution_time', 0);
You can also use others one like
ini_set('session.cookie_lifetime', 2000000);
it's as you wish
I hope it help's you
Comment #3
ezyang commentedHTML Purifier is something of a time-and-space hog. Unfortunately, there's not much I can do to help you here unless you can identify the specific content which is causing problems.
Comment #4
sdrycroft commentedI too am experiencing this same error. addicted_to_drupal's suggestion is NOT a good one, and should not be used on a production site.
Comment #5
heddnCan you provide details please? Specific html content and some context?
Comment #6
sdrycroft commentedAttached is the problematic HTML.
Comment #7
sonicthoughts commentedsame issue. CPU pinned to 100% and failed after 60 seconds on a big machine. note that the page was also 2000 lines of html, but this is a problem....
Comment #8
robmalon commentedSame thing here. I've noticed this particularly on admin/content when the newest nodes in that list have more than usual html markup cumulatively. Likewise, on individual node view/edits that have a ton of markup via tables (similar to sdrycroft's). Raising the timeout limit or removing it solves the problem in some cases after 10 minutes, but that's not something I'm willing to do on production. Unfortunately that makes this module a deal-breaker for me. I can see my users submitting content, going nuts with the markup, and crashing my server :-\
I DO however have some lengthy configurations. The one that stands out is HTML.Allowed which is (note I forced 2 line breaks to fit it on the page nicely):
p[align|style|class],strong,a[href|title|rel],em,table[class|width|cellpadding],td,tr,h2,h3,h4,h5,h6,
hr,br,u,ul,ol,li,img[src|width|height|alt|class],span[class],strike,sup,sub,div[class],code,del,blockquote,
q,cite,dt,dl,dd,b,th,tbody,thead,tfoot,colgroup,caption
Maybe if I slim this down things will go smoother.
Comment #9
sdrycroft commentedI agree with heddn's comment on #1831196-3: 7.x-2.x Roadmap - this really needs fixing at the library level. It would be nice if this module were able to monitor the progress of the library, and kill it if it's taking too long (I realise this would be far from easy to implement).
Comment #10
jay.dansand commentedWe
solvedworked around this issue by imposing a 10-second execution limit, checked via AJAX on form submission. Our theory was that if HTML is too complex to be parsed within that time, it should be refactored by the author. For example, instead of submitting an entire book as a single body field, it could be broken up by chapter into smaller, digestible chunks. Or, if it can't be reasonably refactored, one of the webmasters should be contacted and we can review the code and post it as Full HTML (which doesn't invoke HTMLPurifier), or maybe some other type of compromise can be made.The method is, basically, when a filtered HTML field is submitted:
Yes, JavaScript is required for this approach to work, but we're mostly using CKEDITOR anyway so that's not an added requirement. I can share the module if there's any interest in this sort of solution.
Comment #11
heddnPlease provide the working solution. I'd like to see if we can incorporate it into this module.
Comment #12
heddn@jay.dansand please re-open and kindly provide more details. Otherwise there's no means to resolve this without more info.
Comment #13
sdrycroft commentedThe HTML I provided in comment #1344664-6: PHP Fatal error: Maximum execution time of 30 seconds exceeded in MakeWellFormed.php will allow you to reproduce the original error. I'm happy that this should be fixed at the library level, but that doesn't mean that this issue should be closed. If anything, this issue should be marked as "postponed" with a link to a bug report on the library's issue reporting system.
Comment #14
heddnThat makes sense. I was looking at #10 for a potential solution but if you want to open an issue upstream @ http://htmlpurifier.org, go ahead and move this to postponed.
Comment #15
jay.dansand commentedSorry for the late follow-up! I work in higher-ed so my developing time is dictated by the demands and vagaries of the school year. Our solution's co-developer (a bright student at my university) currently has the job of cleaning up the code to be worthy of a Drupal.org submission, at which point it'll be released.
I think the high-level description in #10 is probably enough to build the work-around from scratch, but admittedly that's a fair bit of redundant (wasted) effort: it'd be way better if we could get our version cleaned up and into the community. We're working on it and we'll post again as soon as the code is available.
Comment #16
isolate commentedWe had a similar problem. This patch in htmlpurifier fixed it for us: http://repo.or.cz/w/htmlpurifier.git/commit/54477c172b31ff69f6d9bc0c6652...
Comment #17
heddnLooks like a fix was provided upstream. Marking as fixed.
Although I'd be interested in looking at the solution that @jay.dansand has as well.
Comment #18
jay.dansand commentedI don't think it's cleaned up enough for a Drupal.org project submission, but it works. Here's the sandbox: https://drupal.org/sandbox/tuanc/2033663