XF 2.0 HTTP 500 (gd-png: fatal libpng error: IDAT: CRC) when importing attachments from SMF 2.0

Overscan

Active member
It looks like I spoke too soon. My attachment import died and now can't be resumed - I get an HTTP 500 and the following in the error log:

ErrorException: Fatal Error: imagecreatefrompng(): gd-png: fatal libpng error: IDAT: CRC error - library/XenForo/Image/Gd.php:86
Generated By: overscan, 8 minutes ago
Stack Trace #0 [internal function]: XenForo_Application::handleFatalError()
#1 {main}
Request State array(3) {
["url"] => string(55) "https://v2.[redacted].co.uk/admin.php?import/import"
["_GET"] => array(1) {
["import/import"] => string(0) ""
}
["_POST"] => array(0) {
}
}

Not sure why the importer is using GD in the first place? Maybe building new thumbnails? Anyway, if there is a corrupt PNG I'd really like to skip it and not error out the entire import process....
 
It looks like I'll have to actually find and fix or remove any corrupt images using a script, as it doesn't seem possible to suppress a "fatal" error. This is very irritating indeed. Is there an easy way to figure out what file the import choked on? It comes back to the same error after server restart so it must be keeping session data somewhere.
 
Last edited:
Unfortunately, it can be difficult to identify the specific file that is triggering the problem, as it likely isn't the first one being processed in a request. Generally, this requires modifying the import script to print out the IDs -- the last one printed should be the specific cause of the error.

You'd likely want to do something like this in library/XenForo/Importer/SMF.php, before:
Code:
$success = $model->importPostAttachment(

(As you've noticed, fatal errors are essentially impossible for us to catch/prevent. I don't think there's really any valid reason for this to throw a fatal error.)
 
Thanks Mike, I put a print() in there to show the value of $attachment['id_attach'] then located the offending file and renamed it with a .bad suffix. Import completed fine -- only the one corrupt file. It didn't seem to slow the process down any, so ideally I'd suggest writing current attachment ID to screen in the default importer config.

Now I just need to work on actual forum configuration. I have a minor user rebellion over moving from SMF to XenForo, uniting old people who just don't like change, people who hate social media and think the world will end if I allow Facebook logins, and open source zealots who seem to think paying for software is inherently bad.
 
Back
Top Bottom