Problem/Motivation

500 error at webform after upgrading Honeypot from 2.0.2 to 2.1.0.

Steps to reproduce

  1. Use composer to upgrade Honeypot from 2.0.2 to 2.1.0
  2. Try sending a message from webform with confirmation screen
  3. 500 error occurs when trying to proceed confirmation screen

Note that Honeypot has moved its procedural functions (honeypot_add_form_protection(), etc.) to a service in the new 2.1.0 release. The old procedural functions still exist, but they are deprecated and are simply wrappers for the new service. This is the only change in 2.1.0 that is likely to be the source of this problem.

Comments

sacredfox created an issue. See original summary.

sacredfox’s picture

The following error log is recorded:
LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. (/var/www/drupal_composer/web/core/lib/Drupal/Core/Database/Connection.php の 1993 行目 Drupal\Core\Database\Connection->__sleep() 内)

Unlike issue 3279371, cache rebuild did not work for my case.
Also, when I tried to send a message as a logged-in user of that site, it worked without any problem.

tr’s picture

Project: Honeypot » Webform
Version: 2.1.0 » 6.2.x-dev
Issue summary: View changes

The ServiceNotFoundException from that other issue is unrelated.

What version of Drupal core are you using? What version of Webform? Do you have a full stack trace?

I don't use Webform, so I don't have an easy way to try to reproduce this. It seems that Webform does a lot of things internally when integrating with Honeypot, and I don't know anything about the Webform internals. Searching for this error, it does seem that Webform has seen this problem before, so they may have a better idea of where to look for the source of this problem.

I don't see how the 'honeypot' service would get serialized, and that's the only place that the Honeypot module has a reference to the database connection.

I've added some information to the issue summary and I'm going to move this problem to the Webform queue - maybe someone over there can provide guidance.

sacredfox’s picture

What version of Drupal core are you using? What version of Webform?
I'm using Drupal core 9.3.12 and Webform 6.1.3 from composer.
Do you have a full stack trace?
No. I checked both Apache's error log and Drupal's log, but there was no other info except for that I have quoted in comment #2.

slangston’s picture

Same issue here.
D 9.3.12
P 7.4.29
Maria 10.3.27
Webform 6.1.3

Email is sent, but get that error. Went back to previous honeypot, hard refresh and works fine.

5/11/2022: Ping.
Still getting this error. Any ideas on how to fix it?

LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in Drupal\Core\Database\Connection->__sleep() (line 1993 of core/lib/Drupal/Core/Database/Connection.php).

serialize(Array) (Line: 14)
Drupal\Component\Serialization\PhpSerialize::encode(Array) (Line: 111).....

cmlara’s picture

Project: Webform » Honeypot
Version: 6.2.x-dev » 2.1.x-dev

I don't see how the 'honeypot' service would get serialized, and that's the only place that the Honeypot module has a reference to the database connection.

I haven't thrown this into a lab to 100% confirm however a cursory look at the code indicates this would be the most likely location where the HoneyPot service becomes a part of the form. After that it just requires the form to be serialized for some reason (in my experience forms being serialized is not too uncommon even outside of webform)

        '#element_validate' => [
          [$this, 'validateHoneypot'],
        ],

$this being an initialized honeypot service object. Back in 2.0.x and before this callback is to a global function where there is no class to serialize.

Moving this back to Honeypot project queue as there are two reports that just changing the installed version of Honeypot resolves the issue.

tr’s picture

Project: Honeypot » Webform
Version: 2.1.x-dev » 6.2.x-dev

I moved this to the Webform queue so I could get some advice from the Webform people who have seen this before with other integrations (search the queue), and to raise awareness there that Honeypot is now using a service so Webform's integration with Honeypot will eventually have to be updated.

The fix does probably have to come in Honeypot but it seems the quickest way to get a resolution is to have the Webform people weigh in on this.

cilefen’s picture

Hello,

I am trying to reproduce this. What are the precise steps to reproduce? The issue title says "anonymous user" but the description omits that.

sacredfox’s picture

The issue title says "anonymous user" but the description omits that.
Ah, it was my mistake. I missed mentioning it in the description.
In my environment, the issue occurred only when I was logged out from that drupal site, but did not happen when I was logged in as an admin user.
I guess it was just because Honeypot was not working when I was logged in as an admin.

othermachines’s picture

We are also experiencing this with webform 6.1.3, honeypot 2.1.0 and Drupal 9.2.18. Rolling honeypot module back to 2.0.1 resolved it.

We were alerted to it when our users reported receiving an alert "File upload in progress. Uploaded file may be lost." when attempting to submit a webform with a required "Document file" field. Clicking "OK" on the alert resulted in a form error on the managed file field. When we looked at our PHP logs, we found the LogicException error.

Perhaps there are two separate issues here, but they both went away when I rolled back the honeypot module.

If I can provide any more info, let me know.

Edit: Adding webform version.

cilefen’s picture

It seems like honeypot 2.1.0 should have been honeypot 3.0.0 because 2.1.0 broke backward compatibility.

bart lambert’s picture

Same issue Here.
D9.1.12
honeypot 2.1.0
webform 6.1.3

unknowinly entered as duplicate under honeypot issue

https://www.drupal.org/project/honeypot/issues/3279485

cilefen’s picture

I am still lost as to why this is like a bug for Webform to solve when it is honeypot that broke BC in a minor release.

cmlara’s picture

I am still lost as to why this is like a bug for Webform to solve when it is honeypot that broke BC in a minor release

I believe the maianitner is looking for advice from Webform maintainers on how to allow the service to be serialized by the core Form API.

Honestly I think this issue should be in Honeypot and maybe the maintainer could open a support request issue in webform for advice if they require it.

The initial bug report includes one option using the DependencySerializationTrait to solve the issue.

cilefen’s picture

Title: Webform stopped working for anonymous user after upgrading Honeypot to 2.1.0 » Figure out a way forward to be compatible with Honeypot to 2.1.0, which caused a BC break
Category: Bug report » Task
cmlara’s picture

Linking an issue in Honeypot queue that has one patch attempt already.

tr’s picture

@cilefen, this was most certainly NOT a BC breaking change. The Honeypot API was not changed. Some procedural functions were PROPERLY deprecated in the minor point release, which is explicitly allowed. Core does that all the time.

cilefen’s picture

And yet it broke Webform, and Core, according to the related issue. You can follow all the rules and still break BC.

cilefen’s picture

Status: Active » Closed (duplicate)

It looks as though the fix will be to honeypot.