Post by peterh » Mon Jan 04, 2021 4:11 am

Hi,
I know this is a subject already debated but I'm experiencing the same problem, found a workaround but can't figure out the root cause, and it happens again.
The other posts report identical behavior and there are diferente results but the root cause is not established, and troubleshooting is difficult.
Sorry that I cannot help excepto to post a new question with my specific problem and tests.

Here's what I have:
Opencart 3.0.3.6
Extensions: Purpletree Multivendor, Portuguese (Portugal), SMS.

I configured The extensions and a lot of options in OC and created categories for products.
No errors on the log.

After a while I started getting the error on OC logs but couldn't associate with a single cause, I believe it was when i started adding images to the categories (the images are .jpg 100x100 72ppi).

So here's what I did:

I restored my setup back to 2 days ago, and decided to restore files only, at least for a first test so i didn't restore the database.
I was back to a state before I uploaded and associated the images to the categories.
So everything was working fine and no entries in the log.

Then I added one image to a category, went to and refreshed the home page, and the error in the log came back:

Code: Select all

PHP Warning:  imagecreatetruecolor(): Invalid image dimensions in /home/asm/public_html/system/library/image.php on line 169
PHP Warning:  imagealphablending() expects parameter 1 to be resource, bool given in /home/asm/public_html/system/library/image.php on line 172
PHP Warning:  imagesavealpha() expects parameter 1 to be resource, bool given in /home/asm/public_html/system/library/image.php on line 173
PHP Warning:  imagecolorallocatealpha() expects parameter 1 to be resource, bool given in /home/asm/public_html/system/library/image.php on line 174
PHP Warning:  imagecolortransparent() expects parameter 1 to be resource, bool given in /home/asm/public_html/system/library/image.php on line 175
PHP Warning:  imagefilledrectangle() expects parameter 1 to be resource, bool given in /home/asm/public_html/system/library/image.php on line 180
PHP Warning:  imagecopyresampled() expects parameter 1 to be resource, bool given in /home/asm/public_html/system/library/image.php on line 182
So I thought, ok problem with the image, if I remove it, error will go away, let me confirm that.
Removed the image from the category.
Cleared the log
Went to and refreshed the home page.
The error persists.

So another thought, maybe it's cached.
So went into extensions, cleared and rebuild, went to dashboard, cleared template and SASS cache, went to channel, deleted all the content in cache directory.
Went to and refreshed the home page.
The error persists.

Everything is working ok, even with the images in the categories and the errors in the log, but these entries have two major impacts:

1 - each time a log is written I/O is wasted, a problem still exists, CPU cycles are wasted and performance is afected specially noticeable in high traffic
2 - if there is another relevant error message, for some other reason, that requires analysis, it'll be almost impossible to detect as the log is cluttered with image error messages, at this point garbage.

So my question is:
where the heck is the image registered or what is OC trying to do that generates this error, and what to do solve this ?

In this original post there was some information missing that i'll add here:
  • Problem related to the theme and empty values - I found some posts and threads with some sugestions name the only suggested by "sw!tch" regarding the problem related to the theme and empty values.
    viewtopic.php?t=208342#p740268, however i could not find in the theme any configuration values empty or non numeric.
  • Using default Opencart theme
  • Link to the site where it happens: https://test.asminhascompras.pt/ - I also have a uat and a production site where this also happens, those have less configurations and extensions.
Thanks
Peteredhair
Last edited by peterh on Tue Jan 05, 2021 4:22 am, edited 3 times in total.

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by sw!tch » Mon Jan 04, 2021 10:40 am

See this thread - viewtopic.php?t=208342#p740268

This is also mentioned on OC GitHub issue reports most likely related to the theme and empty values, so verify the above thread.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by peterh » Tue Jan 05, 2021 2:13 am

Thank you very much your reply.
I did forgot to mention on my original post that i did search the forum previously and in fact found the same thread.
I checked the default theme configuration and didn't find any enpty values or non numeric values.
I'll add this info on the original post to provide better information and context.
Thanks

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by sw!tch » Tue Jan 05, 2021 2:34 am

peterh wrote:
Tue Jan 05, 2021 2:13 am
Thank you very much your reply.
I did forgot to mention on my original post that i did search the forum previously and in fact found the same thread.
I checked the default theme configuration and didn't find any enpty values or non numeric values.
I'll add this info on the original post to provide better information and context.
Thanks
Just to clarify: What theme is being used? My guess is its related to an extension installed not supplying proper width/height values.

Link to your site?

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by peterh » Tue Jan 05, 2021 4:29 am

Damn, those were obvious info i should have added, sorry for that.
I updated the original post to reflect this.

In use is the Default Opencart theme, i haven't done any changes to the theme.
The link to my test site is: https://test.asminhascompras.pt/
Thank you

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by IP_CAM » Tue Jan 05, 2021 8:45 pm

You have NO products visible in your categories, where some should exist,
according to the Listings, just the message:
There are no products to list in this category.

https:// test. asminhascompras. pt/ desktops/ mac (link made non-functional, to show it here)
https:// test. asminhascompras. pt/ desktops (link made non-functional, to show it here)

Better switch OFF your SEO Setting, and try again.

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by peterh » Thu Jan 07, 2021 9:17 am

Sorry for the delay in the reply.
Default OpenCart installation comes with some categories without products but in fact has SEO disabled.
So first thing I did was to disable SEO friendly Urls.
Tested again and the error messages persist.

But taking into account your suggestion here's what I did:
i once again restore my opencart installation to a point where I didn't have any errors.
So at this point I have an Opencart installation, with the same extensions, categories, categories without products,...., but no errors, and a couple of weeks older, and with less images.

Since tracking this error probably won't be easy I'll check the error log for each change I'll make.
When I find out the reason of the error I'll update here.

I'll take into special attention your and this forum call for attention regarding

Thank you very much for your help.

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by straightlight » Thu Jan 07, 2021 9:40 am

peterh wrote:
Thu Jan 07, 2021 9:17 am
Sorry for the delay in the reply.
Default OpenCart installation comes with some categories without products but in fact has SEO disabled.
So first thing I did was to disable SEO friendly Urls.
Tested again and the error messages persist.

But taking into account your suggestion here's what I did:
i once again restore my opencart installation to a point where I didn't have any errors.
So at this point I have an Opencart installation, with the same extensions, categories, categories without products,...., but no errors, and a couple of weeks older, and with less images.

Since tracking this error probably won't be easy I'll check the error log for each change I'll make.
When I find out the reason of the error I'll update here.

I'll take into special attention your and this forum call for attention regarding

Thank you very much for your help.
If your .htaccess file is enabled on your root opencart folder, ensure the changes inside are opted for your domain. Also ensure your config.php and admin/config.php files are also using the right HTTP_SERVER and HTTPS_SERVER values in those constants. In the mean time, I would suggest, yes, to check your error logs (good) but also your developers kit from the catalog-end side. See if you are also able to login into the OC admin since restoration point.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by IP_CAM » Thu Jan 07, 2021 5:23 pm

I am sure, that this all is the result of your subdomain routing, by use of
https:// test. whatever. com . So change that back to a regular URL
Call, and it will most likely work. Good Luck!
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by peterh » Tue Jan 12, 2021 8:08 am

straightlight,
thanks for your reply and suggestions.
Currently i decided t o activate SEO url's and keep the htaccess.txt, that is delivery with the Opencart installation (renamed to .htaccess).
The i was able to login after going back to the restoration point.
Rechecked the config.php and admin/config.php and both url's are configured with https://test.asminhascompras.pt on both variables, HTTP and HTTPS.
From the catalog side i don't understand the meaning of the "developers kit from the catalog-end side" as I'm using only the Opencart catalog.

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by peterh » Tue Jan 12, 2021 8:21 am

Hi IP_CAM,
the URL is a subdomain I'll check apache config but there is no other "original url" to point to as far as I can verify.
Thanks nevertheless thank you for the tip as that may be a hint or pointer to check while reviewing configurations.

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by straightlight » Tue Jan 12, 2021 8:28 am

From the catalog side i don't understand the meaning of the "developers kit from the catalog-end side" as I'm using only the Opencart catalog.
Hit F12 function on your keyboard in your browser on your catalog-end side of the store. A frame will appear. Then, go to the console tab and notice the error messages written in red near the bottom of the frame when resizing images. If occurring on the admin-end side, follow the same process. Also check your error / server access logs in case of outputted errors when working with new images. Also, which formats are your image files you're working with?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by IP_CAM » Tue Jan 12, 2021 8:54 am

there is no other "original url"
Well, http(s)://(www.) yoursite. com/TEST/ is the ONLY correct/valid MAIN Domain Call.
as soon as you USE anything else, like http(s):// test. yoursite. com, it's a Subdomain
CALL, and that's regardless of, what INTERNAL Server Path to the OC Source exists,
as/if configured in your config Files, like /home/yoursite/www/TEST/....
But as long as you're calling the Shop the wrong way, it just won't work, it's as easy s that.
Good Luck!
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by peterh » Sun Jan 24, 2021 2:51 am

Posting just to let know that although I haven't had the time to figure out and finish the troubleshooting it is not forgotten and will get to the bottom of this and post the solution here.

Meanwhile there is one suggestion I do to all OpenCart users and implementers:

  • Turn on the option to "Display errors" for you Opencart installation in System / Store / Server
If you don't have any errors on your Opencart installation and you are making changes to the configuration or installing some extension that is the origin of the errors, then you will notice it immediately the errors on you store catalog page.

  • This will allow you to detect that the most recent changes were the cause for your errors.
Also check frequently you error log in System / Maintenance / log menu.

Thanks all for your help.

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by straightlight » Sun Jan 24, 2021 3:11 am

You can also check your error_log file on your root FTP of the OC folder or in the root OC admin folder which can be very handy.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Poole907 » Wed Feb 03, 2021 8:29 pm

Code: Select all

function resize($newWidth, $targetFile, $originalFile) {

    $info = getimagesize($originalFile);
    $mime = $info['mime'];

    switch ($mime) {
            case 'image/jpeg':
                    $image_create_func = 'imagecreatefromjpeg';
                    $image_save_func = 'imagejpeg';
                    $new_image_ext = 'jpg';
                    break;

            case 'image/png':
                    $image_create_func = 'imagecreatefrompng';
                    $image_save_func = 'imagepng';
                    $new_image_ext = 'png';
                    break;

            case 'image/gif':
                    $image_create_func = 'imagecreatefromgif';
                    $image_save_func = 'imagegif';
                    $new_image_ext = 'gif';
                    break;

            default: 
                    throw new Exception('Unknown image type.');
    }

    $img = $image_create_func($originalFile);
    list($width, $height) = getimagesize($originalFile);

    $newHeight = ($height / $width) * $newWidth;
    $tmp = imagecreatetruecolor($newWidth, $newHeight);
    imagecopyresampled($tmp, $img, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);

    if (file_exists($targetFile)) {
            unlink($targetFile);
    }
    $image_save_func($tmp, "$targetFile.$new_image_ext");
}
It is the content of the function so you just needed to wrap it with the same function tag. But I've done it for you above.

crediblebh


Newbie

Posts

Joined
Wed Feb 03, 2021 8:20 pm

Post by peterh » Sun Feb 21, 2021 10:31 pm

Now I have to admit my ignorance.
Where should I try this code update ? (guide me to the file and I'll try to figure out the rest)

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by peterh » Sun Apr 11, 2021 2:10 am

Well after some time without finding any solution i came to the conclusion that the problem can be related to multiple factors, from translation files, to modules, to opencast configurations,.....

Since i was committed to solve the problem mainly to give back a solution or suggest some improvement to Opencart Community, i spent quite a few hours trying to find out the origin and ultimately failed :-(
My only option was to do a fresh install and configuration which is a lot of work but compensates. i now have a development env, a user testing env and a production store.
I'm using Softaculus installation which make it easy to upgrade so I've already upgraded to 3.0.7.

My best peace of information and suggestion was the one i posted above:

On System Store Settings activate the display errors option, and performs and test changes one at a time.
This way you'll notice the error after you make the change and you'll know what caused it.

Thank you all for your feedback and help.

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am

Post by straightlight » Sun Apr 11, 2021 4:03 am

peterh wrote:
Sun Apr 11, 2021 2:10 am
Well after some time without finding any solution i came to the conclusion that the problem can be related to multiple factors, from translation files, to modules, to opencast configurations,.....

Since i was committed to solve the problem mainly to give back a solution or suggest some improvement to Opencart Community, i spent quite a few hours trying to find out the origin and ultimately failed :-(
My only option was to do a fresh install and configuration which is a lot of work but compensates. i now have a development env, a user testing env and a production store.
I'm using Softaculus installation which make it easy to upgrade so I've already upgraded to 3.0.7.

My best peace of information and suggestion was the one i posted above:

On System Store Settings activate the display errors option, and performs and test changes one at a time.
This way you'll notice the error after you make the change and you'll know what caused it.


Thank you all for your feedback and help.
What did caused the error?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by peterh » Sat Apr 24, 2021 7:44 pm

Like I said in my previous post:

"i spent quite a few hours trying to find out the origin and ultimately failed :-("

So although some I have some suspicions I could not find the root cause, it might have not been just one:
Suspitions rely on translations/languages files (some variables or special characters or encoding)
Misconfigured modules,...
The problem is that the return errors can't provide better information for troubleshooting .
Im'm using https://ptisp.pt provider that uses softaculus and it works great and worked great while upgrading Opencart also.

I'm repeating myself but as posted on my previous reply best action is from the beginning of your setup right from the start when you install OpenCart the first action should be to go into:
System Store Settings activate the display errors option.
This way if a change promotes and error it'll be much easier to detect it and associate it with the change you just made.
Believe this is a very good recommendation.

New member

Posts

Joined
Mon Jan 04, 2021 3:30 am
Who is online

Users browsing this forum: No registered users and 107 guests