2

I have combination of valid input with native WP function throwing PHP notice. In this specific case it is image without extension with image_resize().

This is usually suppressed by WP, but it still has me worried because it runs in feed and such things can explode XML to pieces.

If I can neither change core or input then what should I do? I suppose I could try to explicitly suppress error output around there.

Or should I just ignore the possibility as edge case?

  • Where exactly did you get an error and what does it say? It is a php notice or a wordpress error from the wp_error class? – kaiser May 25 '11 at 10:50
  • @kaiser as described - it's PHP notice, because image_resize() expects image to always have extension when it parses path. – Rarst May 25 '11 at 11:03
2

Simply use the @ operator in front of a function to suppress an error message/notice/whatever. Fun as it is: Even the image_resize() function uses it for chmod. :)

2

You can set up your own error handler, that either ignores the errors or outputs them in comments in the feed. Let it depend on the "surrounding" configuration, so if WP_DEBUG is false, ignore the errors. If it is true, output them in XML comments at the end of the feed, so you don't start a comment when you are in the middle of a tag.

If notices are displayed this is probably because the administrator explicitly enabled them. You would not do this on a production site, so it should be expected that some output (like RSS feeds) can break.

  • Great idea, that I will explore some time, but accepting kaiser's answer as more practical and immediate solution to my specific issue. – Rarst May 28 '11 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.