In looking through the code, honeypot_create_css makes an assumption that the default file scheme is `public://`. While this is true for the large majority of sites, it isn't a 100% constant and some sites may choose to use other file storage locations for various reasons. There is no guarantee that `public://` is actually shared across all web nodes.

I'd like to propose using variable_get('file_default_scheme', 'public') rather than hard-coding `public` into the module. This provides flexibility moving forward for site owners/devs to use a different file storage mechanism, such as S3, if they so desire.

Additional note: I'm filing this as a feature request even though I originally considered filing it as a bug (specifically the part about assuming `public://`). However, I feel that the use case I'm presenting is a bit edge-case-ish so I moved it to a feature request rather than a bug report. For the large majority of people using this module, this change is likely irrelevant to them.

Comments

rvtraveller created an issue. See original summary.

rvtraveller’s picture

Assigned: Unassigned » rvtraveller

I'm working on a patch for this.

geerlingguy’s picture

Sounds good to me!

rvtraveller’s picture

Assigned: rvtraveller » Unassigned
Status: Active » Needs review
StatusFileSize
new1.82 KB

Patch attached including a test.

geerlingguy’s picture

Status: Needs review » Reviewed & tested by the community
geerlingguy’s picture

There's one more usage assuming public:// inside the install file, that I'll fix after merging the patch from #4.

geerlingguy’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new449 bytes

Extra patch attached.

  • geerlingguy committed 11f660a on 7.x-1.x
    Issue #2696219 by geerlingguy: Fix hardcoded use of public file path in...
geerlingguy’s picture

Status: Needs review » Fixed

Confirmed D8 is good to go, so this is Fixed. Thanks especially to @rvtraveller!

Status: Fixed » Closed (fixed)

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

mbnsorg’s picture

We are having an issue related to this change in 7.x-1.24 release. We use default file scheme private, and now that the honeypot.css file is switched to the private scheme (ownership/permissions required), honeypot fields are visible on the forms because access is denied to the "system/files/honeypot/honeypot.css" file. Is there a recommended solution for this?

We will rollback to 1.23 for now. Would rather not have to install another module like https://www.drupal.org/project/private_files_download_permission just for this file.