Instead of (or in addition to) a global procedural function, honeypot should implement a service or trait that can be used inside form controllers.

Issue fork honeypot-2949447

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

aaronbauman created an issue. See original summary.

aaronbauman’s picture

Title: Expose honeypot protection via service or trait » Expose honeypot protection via service
Status: Active » Needs review
StatusFileSize
new9.73 KB

Attached patch service-ifies honeypot_add_form_protection

Status: Needs review » Needs work

The last submitted patch, 2: honeypot-expose_as_service-2949447-2.patch, failed testing. View results

aaronbauman’s picture

Status: Needs work » Needs review
StatusFileSize
new9.28 KB

patch namespace. derp.

markdorison’s picture

Status: Needs review » Needs work

Patch no longer applies cleanly.

markdorison’s picture

Status: Needs work » Needs review
StatusFileSize
new9.33 KB

Re-rolled patch.

markdorison’s picture

StatusFileSize
new9.36 KB

Re-rolled to include change from 090a23353b28b5c30c68dd171d2a03bf12a81d47.

Status: Needs review » Needs work

The last submitted patch, 7: honeypot-expose_as_service-2949447-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

markdorison’s picture

Status: Needs work » Needs review
StatusFileSize
new9.36 KB
markdorison’s picture

Status: Needs review » Reviewed & tested by the community

This is working as expected in my testing.

geerlingguy’s picture

Status: Reviewed & tested by the community » Needs work

This looks good to me in general, but a cursory glance shows a few coding standards issues (comments and spacing, mostly, in the new class). I will try to test a little further then merge soon!

markdorison’s picture

Status: Needs work » Needs review
StatusFileSize
new10.43 KB
new3.85 KB

@geerlingguy Thanks for catching that. Updated patch attached.

Status: Needs review » Needs work

The last submitted patch, 12: honeypot-expose_as_service-2949447-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

markdorison’s picture

Status: Needs work » Needs review
StatusFileSize
new10.42 KB
new474 bytes

Troubleshooting test failures.

manuel garcia’s picture

This looks perfect to me, RTBC++

+++ b/honeypot.module
@@ -119,84 +119,10 @@ function honeypot_get_protected_forms() {
+ * @deprecated Use honeypot service instead

Only thing I can think of is that we should communicate this clearly (ie write a change record, or bold letters on the release notes), just in case someone is using it on their custom code.

mpp’s picture

Status: Needs review » Needs work

We should implement some deprecation items:

- A @deprecated PHPdoc tag;
- A @trigger_error('...', E_USER_DEPRECATED) at runtime
- A unit test proving the deprecation notice will be triggered when the deprecated code is called;

See https://www.drupal.org/core/deprecation

tr’s picture

I think this is a good idea.

This does represent an API change, so it would have to be deprecated in one version then removed in the next. In principle we could deprecate it in 8.x-1.x then remove it in 2.0.x. because this is a major version change.

tr’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

New features should go into 2.0.x first at this point in time. That means it would have to be deprecated in 2.0.x and removed probably in 2.1.x or even 3.0.x.

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new31.11 KB

This properly deprecates ALL the Honeypot API functions and moves them into a service. It also adds tests for the deprecations.

This patch is significantly larger and different from the previous patches, and all of those are >3 years old, so I'm essentially starting from scratch. I still want to clean up the code, but posting here to get feedback from the testbot and from any users who want to try this out.

My intention is to create a 2.1.x branch for API changes like this. That's reflected in the deprecation messages.

tr’s picture

StatusFileSize
new31.11 KB

Status: Needs review » Needs work

The last submitted patch, 20: 2949447-20-service.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new31.58 KB

It is a never-ending source of frustration for me that code copied from Drupal core contains an excessive number of coding standards violations. Here is a new patch with many of those fixed, and hopefully with the test failure fixed as well.

Status: Needs review » Needs work

The last submitted patch, 22: 2949447-22-service.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new31.63 KB

Again.

Status: Needs review » Needs work

The last submitted patch, 24: 2949447-24-service.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new31.81 KB

Again. Debugging this on DrupalCI ...

Status: Needs review » Needs work

The last submitted patch, 26: 2949447-26-service.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new31.86 KB

Status: Needs review » Needs work

The last submitted patch, 28: 2949447-28-service.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tr’s picture

Progress, but everything since #20 is simply debugging the test case on the testbot - nothing is being changed in the actual code.

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new940 bytes
new31.83 KB

Turns out the test actually found a bug in original version of honeypot_get_protected_forms(), which sometimes improperly returns a NULL instead of an array. Here's a new patch which includes a fix for that.

jonathan1055’s picture

As an aside, the deprecation coding standard warnings are incorrect, and are being fixed in #3192093: Deprecation error messages don't allow module:n.n.n versions

jonathan1055’s picture

#3192093: Deprecation error messages don't allow module:n.n.n versions is fixed, so when Core uses the next version of Coder, which will be 8.3.15 these coding standards messages will be gone.

tr’s picture

Thanks jonathan!

tr’s picture

StatusFileSize
new32.91 KB
tr’s picture

StatusFileSize
new32.91 KB

I forgot I also added an interface for the service.

tr’s picture

Version: 2.0.x-dev » 2.1.x-dev
tr’s picture

StatusFileSize
new32.55 KB

Re-rolled against current 2.1.x branch.

tr’s picture

StatusFileSize
new32.48 KB

Correct the arguments to expectDeprecation() in the new test.

  • TR committed a1eae61 on 2.1.x
    Issue #2949447 by TR, markdorison, AaronBauman: Expose honeypot...
tr’s picture

Status: Needs review » Fixed

Committed #39.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.