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
Issue fork eu_cookie_compliance-3278062
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
Comment #4
svenryen commented@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.
Comment #6
svenryen commentedComment #7
john_b commentedThis 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.
Comment #9
svenryen commentedI fixed the stray character.
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.
Comment #10
john_b commentedIt 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.
Comment #11
svenryen commentedI don't think that's our bug - we have no control of whether the directory has - or _.
I believe it's
gitthat 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_complianceAnd then the directory will have underscores.