- Open on Drupal.org →Environment: PHP 8.1 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass - Status changed to Needs work
over 1 year ago 4:53pm 6 June 2023 - 🇨🇦Canada jodavidson
Going to take a swing at this one at the Mentored Contribution session at DrupalCon2023 Pittsburgh
- 🇨🇦Canada jodavidson
Looking at the crucial method
writeFile($directory, $filename, $contents, $force)
the code as included in the #42 patch is complete.All cases are handled and the method will always return a boolean. The additional tests from #34 (
(file_exists($directory) && is_writable($directory)
) are implied in the@file_put_contents()
call.This should work fine as written.
I'm now looking at how to efficiently test that it is indeed working in the DrupalPod environment.
- 🇨🇦Canada jodavidson
Unfortunately I have not been able to create a situation where this code fires and a .htaccess file is created so testing is still required.
- 🇺🇸United States Amber Himes Matz Portland, OR USA
1.
+++ b/core/lib/Drupal/Component/FileSecurity/FileSecurity.php @@ -157,7 +157,7 @@ protected static function writeFile($directory, $filename, $contents, $force) { + if (@file_put_contents($file_path, $contents ."\n")) {
Coding standards nit. Should be a space after the concatenation dot.
2. And, it needs another reroll.
3. @mstrelan -- Can you give reviewers a clue on how to manually test your patches? Looks like there's some confusion there.
4. I'll add a Drupal 10 test run for the other patch (1915772-34-generated-htaccess-new-line.patch) in #34.
5. Hiding some files. It's confusing because we're dealing with 2 files. (I'm not entirely clear on why that is -- maybe because one is dynamically generated.)
- last update
over 1 year ago Patch Failed to Apply - 🇦🇺Australia mstrelan
#47.3
This can be tested by deleting the web/sites/default/files directory and running
drush site:install minimal
, then run something liketail web/sites/default/files/.htaccess
. If it worked you'll get a line break after</IfModule>
.You can also test the private file system by adding something like this to settings.php
$settings['file_private_path'] = 'sites/default/files/private';
Then ensure the directory exists with this
mkdir web/sites/default/files/private
Then go to the status report page at /admin/reports/status which should trigger the .htaccess file to be generated in the private directory.
But as we discussed on slack, it might be worth investigating if we can replace
\Drupal\Component\FileSecurity\FileSecurity::writeFile
with a simple file copy fromcore/assets/scaffold/files
so we don't need the file contents to live in php code. - Status changed to Postponed
over 1 year ago 5:00am 8 June 2023 - 🇦🇺Australia mstrelan
Postponing on 📌 Update FileSecurity class to copy files from scaffold directory Needs work which should solve this.