Error 50 when accesing customer carts?

  • Posts: 517
  • Thank you received: 8
  • Hikashop Business
1 year 1 week ago #356575

-- HikaShop version -- : 5
-- Joomla version -- : 4.4
-- PHP version -- : 8.1
-- Browser(s) name and version -- : Fifefox
-- Error-message(debug-mod must be tuned on) -- : Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vhosts/mohairbearmakingsupplies.co.uk/public_html/administrator/components/com_hikashop/classes/cart.php on line 3088

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 159744 bytes) in /var/www/vhosts/mohairbearmakingsupplies.co.uk/public_html/libraries/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php on line 271

Hi, I am getting a 500 error when trying access carts in the backend. Everything else is ok?


Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /var/www/vhosts/xxxxxx.co.uk/public_html/administrator/components/com_hikashop/classes/cart.php on line 3088

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 159744 bytes) in /var/www/vhosts/xxxxxxxx.co.uk/public_html/libraries/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php on line 271

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 1 week ago #356582

Hi,

Loading a cart in memory is a heavy process. On the carts listing of the backend, HikaShop has to load each cart of the listing. By default, it's only 20 carts but if you increased the "Default List Limit" setting of the Joomla configuration to have more elements per page, it will load as many carts. If you set the default list limit to 200 for example, it means HikaShop will load 200 carts in memory. That's way too much for a normal server.
Increasing the memory_limit setting of your php.ini to 512M instead of 256M might be enough. Otherwise, I would recommend reducing the value in that setting of the Joomla configuration, or not using the carts listing in the backend.

Please Log in or Create an account to join the conversation.

  • Posts: 517
  • Thank you received: 8
  • Hikashop Business
1 year 1 week ago #356594

Hi, Something is not correct here?

Something is adding individual items to individual carts and increasing all the time?

I now cannot even get into carts with a 25 list limit and 1024 in php?

Attachments:
Last edit: 1 year 1 week ago by mohairbears.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 1 week ago #356597

Hi,

Having 1 million and a half carts is clearly a problem.
I think you'll have to do several things:
1. Delete most of the carts. To do that, you'll have to do it through your PHPMyAdmin. Otherwise, it will be impossible due to the shear amount. You have to run MySQL queries like:

DELETE FROM #__hikashop_cart WHERE cart_modified < UNIX_TIMESTAMP()-2629746;
This will delete the carts older than 1 month
DELETE FROM #__hikashop_cart_product WHERE cart_product_modified < UNIX_TIMESTAMP()-2629746;
This will delete the links between carts and products older than 1 month
Also, make sure you replace #__ by the table prefix of your tables (it seems to be mb16ms_ on your website).

2. You might want to reduce the "Cart retaining period" setting of the HikaShop configuration so that carts don't stay too long. By default, it's 1 month. But you can potentially reduce it to 1 week.
However, you need to reduce the "Frequency of the check for the carts" to as low as possible. For example, 1 second. That way, the system will clear carts much more often so that it can clear bunches of carts way more often.

3. So many carts created in such a small time frame indicates that bots are involved:
www.hikashop.com/forum/product-category-...-adding-to-cart.html
So you should look in your web server access log to identify how you can restrict access to them to the cart via the robots.txt or the htaccess or both.

The first two points should already be enough. The third point is more complex to implement but would be nice to do.

Please Log in or Create an account to join the conversation.

  • Posts: 517
  • Thank you received: 8
  • Hikashop Business
1 year 1 week ago #356616

Hi, Done all the above but:

There was still over 100,00 carts there so I have emptied the tables.

The bots are still adding carts even with the site taken off line? how?

Is there a way to stop this by only allowing carts to be created by registered users?

see robots file attached?

Attachments:
Last edit: 1 year 1 week ago by mohairbears.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 1 week ago #356617

Hi,

First, you need to look into the web server access log to get more information on how the bots are creating carts.
Only then can you tweak the robots.txt and the htaccess. And the robots.txt probably won't help. I suppose you'll have to tweak the htaccess.

Please Log in or Create an account to join the conversation.

  • Posts: 517
  • Thank you received: 8
  • Hikashop Business
1 year 1 week ago #356634

Hi, Sorry no idea what code to use to do that?

Can recaptcha be used when creating a cart?
Can carts be disabled?

Come in this morning to find another 3,700 carts had been created?

Can you point me in the right direction of some code to use please? Google is contradictive

Rgds

Last edit: 1 year 1 week ago by mohairbears.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 1 week ago #356638

Hi,

Sorry no idea what code to use to do that?

The exact code will depend on what you have in the access log of your web server, so I can't give you a precise code to use.

Can recaptcha be used when creating a cart?

No

Can carts be disabled?

If you disable carts, then payments won't be possible, that's not a solution.

Come in this morning to find another 3,700 carts had been created?

That's not necessarily a problem. If you configured the settings in the HikaShop configuration as I told you to in www.hikashop.com/forum/orders-management...er-carts.html#356597 it means that HikaShop will start deleting carts once they are 1 week old and you should not get more than a hundred thousands carts, which is manageable.

Can you point me in the right direction of some code to use please?

Again, the exact code will depend on what you have in the access log of your web server, so I can't give you a precise code to use.
Here are some indications on other forum threads:
www.hikashop.com/forum/install-update/88...rts-due-to-bots.html
www.hikashop.com/forum/3-bug-report/9048...-website.html#343812
And some documentation on blocking things with htaccess:
world.siteground.com/kb/htaccess-block-user-agent/
htaccessbook.com/block-ip-address/
Note that since this is something needed to be setup on the server side, you might want to ask for help with your hosting support.

Please Log in or Create an account to join the conversation.

  • Posts: 517
  • Thank you received: 8
  • Hikashop Business
1 year 1 week ago #356640

Hi, Ok got that. think I have got the biggest one which was from a Microsoft server, blocked with Admin Tools.

Only other query with these answers is the auto delete of carts? this looks NOT to have been happening, I had carts from 2022 before I deleted the whole database of carts?

It is now set to 1 week retaining and 1 minute, these are the lowest settings available.

Rgds

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 1 week ago #356644

Hi,

These settings are fine. Together with the blocking of bots in the htaccess or AdminTools, you should be fine now.

The following user(s) said Thank You: mohairbears

Please Log in or Create an account to join the conversation.

Time to create page: 0.087 seconds
Powered by Kunena Forum