Problem/Motivation

config form errors if public://eu_cookie_compliance is not writable. This is acceptable, and some sysadmins may want to make scripts within public:// unwritable by the web server for security. However, the config form should not trigger a 503 in this case.

From the Apache error log: Got error 'PHP message: Uncaught PHP Exception Drupal\\Core\\File\\Exception\\DirectoryNotReadyException: "The specified file 'temporary://fileExVXzK' could not be copied because the destination directory 'public://eu_cookie_compliance' is not properly configured. This may be caused by a problem with file or directory permissions." at .../site/web/core/lib/Drupal/Core/File/FileSystem.php line 476', referer: https://example.com/admin/config/system/eu-cookie-compliance/settings

Steps to reproduce

With the new beta version which creates a script in public://, if we run drush updb with the "wrong" user, e.g. root, public://eu_cookie_compliance and the script in it become unwritable.

Proposed resolution

Test whether the directory and file are writable. If they are not, bail out with an on-page message so that the server does not return a 503.

Remaining tasks

User interface changes

API changes

Data model changes

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

John_B created an issue. See original summary.

svenryen made their first commit to this issue’s fork.

svenryen’s picture

Status: Active » Fixed

@John_B, can you take a look at this MR branch and see if it improves the behavior on your end. I now check if the directory is writeable before trying to save the file, and a message is shown if the directory is not writeable.

Also, I improved handling of the inclusion of the file so we don't get a 404 if the file is not readable.

  • svenryen committed 1187644 on 8.x-1.x
    Issue #3278062 by svenryen, John_B: config form errors if public://...
svenryen’s picture

Status: Active » Fixed
john_b’s picture

Status: Fixed » Needs work

This works, once the typo is fixed.

The typo is a stray character at the start of _eu_cookie_compliance_explode_multiple_lines() in src/EventSubscriber/EuCookieComplianceConfigEventsSubscriber.php line 81:

Separately, the dev version does not work because the directory name eu-cookie-compliance (rather than eu_cookie_compliance) triggers a "class does not exist" error.

  • svenryen committed 89d5a18 on 8.x-1.x
    Issue #3278062 by svenryen, John_B: config form errors if public://...
svenryen’s picture

Status: Needs work » Postponed (maintainer needs more info)

I fixed the stray character.

Separately, the dev version does not work because the directory name eu-cookie-compliance (rather than eu_cookie_compliance) triggers a "class does not exist" error.

Could you care to explain this, preferably with a screenshot, link to the code reference in gitlab or code snippet? We haven't changed any directory name.

john_b’s picture

It is only an issue with a copy of the module obtained with git. The public git repo is obtainable with:

git clone https://git.drupalcode.org/project/eu-cookie-compliance.git

users must change the directory containing the cloned repo to eu_cookie_compliance before it works on D9. Modules with hyphens in the directory name work D7 but apparently not D8/9.

I have tested installing dev version with composer and with wget *.tar.gz and there is no issue there.

svenryen’s picture

Status: Postponed (maintainer needs more info) » Fixed

I don't think that's our bug - we have no control of whether the directory has - or _.
I believe it's git that creates the directory when you do a git clone.

If you have a preference for dashes or underscores you could just write:

git clone https://git.drupalcode.org/project/eu-cookie-compliance.git eu_cookie_compliance

And then the directory will have underscores.

Status: Fixed » Closed (fixed)

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