Bug Bug when uploading svg icon for a product

Status
Not open for further replies.

butteroll

Customer
Error: Call to a member function getType() on null in src/addons/DBTech/eCommerce/Service/Product/IconService.php at line 238
  1. DBTech\eCommerce\Service\Product\IconService->updateIcon() in src/addons/DBTech/eCommerce/Pub/Controller/ProductController.php at line 590
  2. DBTech\eCommerce\Pub\Controller\ProductController->actionEditIcon() in src/XF/Mvc/Dispatcher.php at line 362
  3. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 264
  4. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121
  5. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63
  6. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2826
  7. XF\App->run() in src/XF.php at line 806
  8. XF::runApp() in index.php at line 23
 
This is a problem with your image processor. Are you using GD or ImageMagick?
I have both. I think the script doesn't recognize Imagick, even though it is both existent and enabled, and shows up on the xenforo admin homepage as supported, and thus leaves it to gd which i think doesn't support svgs. But I do have both of the extensions.
 
I am also on GD and I don't experience this problem, the issue is either with the image itself or with your server.

You can get more info if you edit the following XenForo file: src/XF/Image/Manager.php and find this block of code:
PHP:
    public function imageFromFile($file, $driver = null)
    {
        $image = $this->getImageDriver($driver);

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

        return null;
    }

Change the relevant portion to:
PHP:
        catch (\Exception $e)
        {
            \XF::logException($e);
        }

Then try uploading the icon again.
 
I am also on GD and I don't experience this problem, the issue is either with the image itself or with your server.

You can get more info if you edit the following XenForo file: src/XF/Image/Manager.php and find this block of code:
PHP:
    public function imageFromFile($file, $driver = null)
    {
        $image = $this->getImageDriver($driver);

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

        return null;
    }

Change the relevant portion to:
PHP:
        catch (\Exception $e)
        {
            \XF::logException($e);
        }

Then try uploading the icon again.
The error it logged is as such:

  • InvalidArgumentException: File '/tmp/phpOM57zc' is not a valid image
  • src/XF/Image/AbstractDriver.php:323
  • Generated by: Yoel
  • Oct 18, 2024 at 5:08 PM

Stack trace​

#0 src/XF/Image/Manager.php(62): XF\Image\AbstractDriver->imageFromFile('/tmp/phpOM57zc')
#1 src/addons/DBTech/eCommerce/Service/Product/IconService.php(237): XF\Image\Manager->imageFromFile('/tmp/phpOM57zc')
#2 src/addons/DBTech/eCommerce/Pub/Controller/ProductController.php(590): DBTech\eCommerce\Service\Product\IconService->updateIcon()
#3 src/XF/Mvc/Dispatcher.php(362): DBTech\eCommerce\Pub\Controller\ProductController->actionEditIcon(Object(XF\Mvc\ParameterBag))
#4 src/XF/Mvc/Dispatcher.php(264): XF\Mvc\Dispatcher->dispatchClass('DBTech\\eCommerc...', 'EditIcon', Object(XF\Mvc\RouteMatch), Object(DBTech\eCommerce\Pub\Controller\ProductController), NULL)
#5 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(DBTech\eCommerce\Pub\Controller\ProductController), NULL)
#6 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#7 src/XF/App.php(2826): XF\Mvc\Dispatcher->run()
#8 src/XF.php(806): XF\App->run()
#9 index.php(23): XF::runApp('XF\\Pub\\App')
#10 {main}

Request state​

array(4) {
["url"] => string(58) "/dbtech-ecommerce/permission-to-write-articles.2/edit-icon"
["referrer"] => string(67) "https://smartea.co/dbtech-ecommerce/permission-to-write-articles.2/"
["_GET"] => array(0) {
}
["_POST"] => array(5) {
["_xfToken"] => string(8) "********"
["icon_action"] => string(6) "custom"
["_xfResponseType"] => string(4) "json"
["_xfWithData"] => string(1) "1"
["_xfRequestUri"] => string(49) "/dbtech-ecommerce/permission-to-write-articles.2/"
}
}
 
Well there you go then :D GD cannot read your image, it's not a problem with this addon.
 
Well there you go then :D GD cannot read your image, it's not a problem with this addon.
Um, I have both gd and Imagick, and Imagick is selected.
1729268023076.webp
1729268044284.webp

And you responded to me about a day or more after I posted the problem. Really I had my own patch which is this updated src/addons/DBTech/eCommerce/Service/Product/IconService.php file:


And this patch works, so...

No, I think at the very least your addon can slightly troubleshoot poor configurations to avoid these problems.
 
Not acting in bad faith, btw, I do not claim to know the definitive source of issue, could be my own fault, I just wanted to fix it, which I did in my own way. All is good.
 
Um, I have both gd and Imagick, and Imagick is selected.
1729268444877.webp
"and it's on gd"

You literally told me you had GD selected...? I'm sure you can forgive me for thinking you were on GD when you told me you had selected GD when I clarified what I was asking :)

And you responded to me about a day or more after I posted the problem. Really I had my own patch which is this updated src/addons/DBTech/eCommerce/Service/Product/IconService.php file:

And this patch works, so...

No, I think at the very least your addon can slightly troubleshoot poor configurations to avoid these problems.
I'll do a comparison and see if it's something I should add to the core product, thanks.
 
View attachment 10680
"and it's on gd"

You literally told me you had GD selected...? I'm sure you can forgive me for thinking you were on GD when you told me you had selected GD when I clarified what I was asking :)


I'll do a comparison and see if it's something I should add to the core product, thanks.
when I said gd, it was the original state.
I switched to Imagick, and the error remained.

I have my own working patch for now. I would oblige to provide further debugging intel, if needed.
 
Hello @butteroll,

We hope your ticket regarding DragonByte eCommerce has been addressed to your satisfaction. This ticket has now been scheduled to be closed.

If your ticket has not been resolved, you can reply to this thread at any point in the next 7 days in order to reopen the ticket, afterwards this thread will be closed.

Please do not reply to this thread if your ticket has been resolved.

Thank you.


- DragonByte Technologies, Ltd.
 
Status
Not open for further replies.

DragonByte eCommerce

XenForo 2.0.6+ XenForo 2.1.x XenForo 2.2.x XenForo 2.3.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
3,017
Customer rating
4.86 star(s) 7 ratings
Back
Top