- Issue created by @dastan56
- πΊπΈUnited States tr Cascadia
"MySQL server has gone away" in Drupal usually means your database configuration settings need to be changed to handle the number and size of the database requests made while loading a Drupal page. If you search this site for that error, you will find many discussions for this and documentation of what settings to change.
"so the cache is saved for every form even if those forms donot have the honeypot applied"
No, that's not true. This code is in the service, and the cache data is lazy-loaded into memory once per page load, and all subsequent calls to getProtectedForms() on that page use the copy in memory. Read the API documentation on the use of drupal_static() to see how this works. The database cache is just used to persist the list of protected forms across page loads.
But if you delete the cache entry, then the list of protected forms needs to be rebuilt each time
Thank you for your response, but there is one thing you did not address, which is that the error contains this:
ON DUPLICATE KEY UPDATE "cid" =
as you see the error happens, because when it tries to add honeypot_protected_forms to the cache_default table, it gets error that the key already exists, and this is why i delete it so that this duplication error donot happen, thanks again.
- πΊπΈUnited States tr Cascadia
No, the error does not say a duplicate key exists. "ON DUPLICATE KEY UPDATE" is part of the SQL command that tells the database what to do in the case of a duplicate key. Specifically, it tells the database to UPDATE instead of INSERT if there is a duplicate key.
The error is "General error: 2006 MySQL server has gone away". The fact that it happens when trying to update a honeypot table is just coincidental - the number or size of your database queries has exceeded the capacity of your database as configured, and you need to change your database configuration settings to accommodate this.
ok, thanks again, as i said for now using this code has resolved this issue for me:
\Drupal::service('cache.default')->delete('honeypot_protected_forms');
i will keep an eye on it and see if the form freezes again.
- Status changed to Closed: cannot reproduce
9 months ago 12:12am 8 July 2024