Fixed vB5: Error importing avatars, won't skip over bad one

Viper007Bond

New member
vBulletin used to be dumb and stored all avatars with a GIF extension regardless of actual filetype. For example: https://forums.finalgear.com/core/customavatars/avatar3_6.gif

I assume this is why the XF importer and libpng are throwing tons of errors (see below).

Okay, fine, but now it's blocking my import from finishing:

Code:
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
 - Step  4 of 26: Avatars                   00:05:48 [1,983] 23.92%libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
 - Step  4 of 26: Avatars                   00:05:57 [2,038] 24.48%

  [RuntimeException]
  Failed to save image to temporary file; image may be corrupt or check internal_data/data permissions


xf:import

root@1e66089be334:/var/www/html/public# php cmd.php xf:import
Starting import from vBulletin 5.x (Beta)...
- Importing...

  [RuntimeException]
  Failed to save image to temporary file; image may be corrupt or check internal_data/data permissions


xf:import

XenForo 2.0.4 and Importers 1.0.1a.
 
I think there are two issues here:

One is the libpng warnings - which are part of a known bug in PHP/libpng whereby it's impossible to shut up the warnings from libpng even when a perfectly acceptable result can be extracted - I don't think we can do anything about those.

But the exceptions seem to be falling over on a genuinely broken image, so we need to detect that, catch it and skip it.
 
Could you run your import with --verbose tagged onto it so we can get the full error trace please?

php cmd.php xf:import --verbose
 
Here you go! :)

Code:
Exception trace:
 () at /var/www/html/public/src/XF/Service/User/Avatar.php:256
 XF\Service\User\Avatar->updateAvatar() at /var/www/html/public/src/XF/Import/DataHelper/Avatar.php:37
 XF\Import\DataHelper\Avatar->setAvatarFromFile() at /var/www/html/public/src/addons/XFI/Import/Importer/vBulletin.php:1419
 XFI\Import\Importer\vBulletin->stepAvatars() at /var/www/html/public/src/XF/Import/Runner.php:160
 XF\Import\Runner->runStep() at /var/www/html/public/src/XF/Import/Runner.php:74
 XF\Import\Runner->run() at /var/www/html/public/src/XF/Cli/Command/Import.php:66
 XF\Cli\Command\Import->execute() at /var/www/html/public/src/vendor/symfony/console/Command/Command.php:242
 Symfony\Component\Console\Command\Command->run() at /var/www/html/public/src/vendor/symfony/console/Application.php:843
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/public/src/vendor/symfony/console/Application.php:193
 Symfony\Component\Console\Application->doRun() at /var/www/html/public/src/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at /var/www/html/public/src/XF/Cli/Runner.php:63
 XF\Cli\Runner->run() at /var/www/html/public/cmd.php:15
 
If you need me to test or debug anything, I write PHP code for a living so I'm perfectly comfortable modifying code as needed to verify your fix works. I'm just not familiar with the XF codebase otherwise I would have attempted to debug it myself. :)
 
@Kier FYI https://xenforo.com/community/threads/vb4-user-import-fails-failed-to-save-image.146639/ basically failure to convert an avatar should be non-fatal, configurable fatal or not, or maybe more fine-grained behaviour (i.e., fatal is the imagecreatefromXXX functions are missing, indicating a broken install, but non-fatal in case one specific image fails to load for whatever random reason). In general assuming the input is sane might be a little naive .
 
Back
Top Bottom