Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The fail result is at: https://www.drupal.org/pift-ci-job/339437
It begins:
Aggregator.Drupal\aggregator\Tests\AggregatorRenderingTest
✗
ile_save_htaccess
exception: [Warning] Line 364 of core/includes/file.inc:
file_put_contents(temporary://.htaccess): failed to open stream: "Drupal\Core\StreamWrapper\TemporaryStream::stream_open" call failedfile_put_contents('temporary://.htaccess', '# Deny all requests from Apache 2.4+.
Require all denied
Similar fails for HEAD:
https://www.drupal.org/pift-ci-job/529116
https://www.drupal.org/pift-ci-job/447899
https://www.drupal.org/pift-ci-job/375643
https://www.drupal.org/pift-ci-job/294179
Proposed resolution
The reason this happens is that during drupal install for a test the temporary directory is falling back to the system temporary directory. Therefore multiple processes are trying to write temporary://.htaccess
at the same time.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#24 | 2754217-8.2-24.patch | 8.06 KB | alexpott |
#17 | 2754217-17.patch | 5.89 KB | alexpott |
#17 | 12-17-interdiff.txt | 2.65 KB | alexpott |
#17 | 2754217-17.test-only.patch | 1.49 KB | alexpott |
#12 | 2754217-12.patch | 3.51 KB | alexpott |
Comments
Comment #3
xjmThanks @martin107 for the report!
The fail result is at: https://www.drupal.org/pift-ci-job/339437
This also happened in HEAD recently for a different test: https://www.drupal.org/pift-ci-job/529116 In that case there was also a know failure due to #2806697: Random fail for AlreadyInstalledException.
Comment #4
xjmI also wonder if this might be the same bug as #2806697: Random fail for AlreadyInstalledException, just manifesting differently.
Comment #5
xjmMore instances:
https://www.drupal.org/pift-ci-job/447899
https://www.drupal.org/pift-ci-job/375643
https://www.drupal.org/pift-ci-job/294179
All early in the alphabet like #2806697: Random fail for AlreadyInstalledException seemed to be.
Comment #6
xjmComment #7
xjmComment #8
xjm@catch, @alexpott, @effulgentsia, @Cottser, and I agreed that this is critical as a random test failure under normal circumstances in HEAD.
Comment #9
alexpottSo this occurs because during the installer the temporary directory is not yet set to the test specific one. We need to move the setting of this to be inside the installer. Unfortunately there is no other way.
Here's another occurrence https://www.drupal.org/pift-ci-job/571518.
Comment #10
alexpottComment #12
alexpottoops should have read my own added documentation - the temp directory expected by the test system in not inside the public files directory but it is just up one level.
For example:
Comment #13
alexpottComment #14
MixologicI just found some older evidence that this has been around a long time : https://www.drupal.org/node/2656720#comment-10872502
Comment #15
BerdirThis looks good to me, explanation makes sense. @dawehner agrees.
Comment #16
alexpottIn discussing with @xjm I realised that we can test that we're not writing an .htaccess to the system temp directory and that a .htaccess is present in the test specific directory.
Comment #17
alexpottHere's a patch with tests for both Simpletest and BrowserTestBase. Also on @xjm's suggestion I've improved the comments in \Drupal\Core\Test\FunctionalTestSetupTrait to detail where everything actually occurs.
To test this locally:
\Drupal\FunctionalTests\BrowserTestBaseTest
\Drupal\FunctionalTests\BrowserTestBaseTest
Note that the parent site might create an .htaccess in the system temp folder - this is why the above steps should be done from the CLI and we don't assert that a .htaccess does in exist in that location in the new tests.
As this patch does not apply to 8.2.x we'll need to backport once it lands.
Comment #19
dawehnerMh, I don't really see this as part of the added test code ...
Comment #20
alexpottre #19 -
Comment #21
dawehnerFair
Comment #23
xjmCommitted to 8.3.x, thanks!
Setting PTBP for 8.2.x.
Comment #24
alexpottHere's a patch for 8.2.x - there are a number of differences because of improvements made to the how WebTestBase and BrowserTestBase share code.
Comment #25
catchBackport looks good to me, just a bit more change necessary, moving to RTBC.
Comment #26
catchCommitted/pushed to 8.2.x, thanks!
Comment #30
xjm