XF 2.0 vb4 user import fails "failed to save image..."

mazdas247

Member
My vb4 user import fails at user #129918 with this nice stack trace.
  • I have checked my permissions, they are ok (777).
  • I have checked the relevant user in VB (assuming the last user in the log table is the failing one?) and I see nothing wrong
  • The error log has nothing of consequence.
  • I ran this in command line --verbose, and see nothing else that is helpful. I will now resort to printf debugging unless I hear some better suggestion.


1525097074415.webp
 
Last edited:
Here is the place in the code where it craps out in Avatar::updateAvatar()

PHP:
if (count($outputFiles) != count($this->sizeMap))
{
        throw new \RuntimeException("Failed to save image to temporary file; image may be corrupt or check internal_data/data permissions");
}

Here is the value of the outputFiles:
Code:
array(1) {

  'o' =>
  string(49) "/var/www/localhost/xf-internal_data/temp/xfpjBmkH"
}

and sizeMap:
Code:
array(5) {
  'o' =>
  int(384)
  'h' =>
  int(384)
  'l' =>
  int(192)
  'm' =>
  int(96)
  's' =>
  int(48)
}
 
And the culprit is below. That said, the way php GD is used is not great, because it silently hides this because:

1) the imagefrompng and other call in Gd.php are called with @, which appears to suppress the exception
2) Even if you remove the @, it seems that the code in Image/Manager.php is designed to be really "safe":

Code:
try^M
{^M
        if ($image->imageFromFile($file))^M
        {^M
                return $image;^M
        }^M
}^M
catch (\Exception $e) { }^M

Silently absorbing fatal errors is bad bad bad practice; why not print it to the error log?

But all this is besides the point. From what I've read, this error is due to some PNG being "different". I couldn't care less if some of my users out of 130k are left without avatar, so why does this error need to be fatal? How can I skip broken avatar, and might I suggest you make this an option in the importer?

Code:
ErrorException: [E_WARNING] imagecreatefrompng(): gd-png:  fatal libpng error: IDAT: invalid distance too far back in /var/www/localhost/htdocs/src/XF/Image/Gd.php:42
Stack trace:
#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] ima...', '/var/www/localh...', 42, Array)
#1 /var/www/localhost/htdocs/src/XF/Image/Gd.php(42): imagecreatefrompng('/var/www/localh...')
#2 /var/www/localhost/htdocs/src/XF/Image/AbstractDriver.php(289): XF\Image\Gd->_imageFromFile('/var/www/localh...', 3)
#3 /var/www/localhost/htdocs/src/XF/Image/Manager.php(60): XF\Image\AbstractDriver->imageFromFile('/var/www/localh...')
#4 /var/www/localhost/htdocs/src/XF/Service/User/Avatar.php(249): XF\Image\Manager->imageFromFile('/var/www/localh...')
#5 /var/www/localhost/htdocs/src/XF/Import/DataHelper/Avatar.php(37): XF\Service\User\Avatar->updateAvatar()
#6 /var/www/localhost/htdocs/src/XF/Import/Importer/vBulletin.php(1397): XF\Import\DataHelper\Avatar->setAvatarFromFile('/var/www/localh...', Object(XFRM\XF\Entity\User))
#7 /var/www/localhost/htdocs/src/XF/Import/Runner.php(160): XF\Import\Importer\vBulletin->stepAvatars(Object(XF\Import\StepState), Array, 8)
#8 /var/www/localhost/htdocs/src/XF/Import/Runner.php(74): XF\Import\Runner->runStep('avatars', Object(XF\Import\StepState), 8)
#9 /var/www/localhost/htdocs/src/XF/Cli/Command/Import.php(66): XF\Import\Runner->run()
#10 /var/www/localhost/htdocs/src/vendor/symfony/console/Command/Command.php(242): XF\Cli\Command\Import->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/localhost/htdocs/src/vendor/symfony/console/Application.php(843): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/localhost/htdocs/src/vendor/symfony/console/Application.php(194): Symfony\Component\Console\Application->doRunCommand(Object(XF\Cli\Command\Import), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/localhost/htdocs/src/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/localhost/htdocs/src/XF/Cli/Runner.php(63): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/localhost/htdocs/cmd.php(15): XF\Cli\Runner->run()
#16 {main}
 
Top Bottom