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
DrupalKernel::setSitePath()
throws an exception when called repeatedly.
It's understandable that changing the site path after boot is disallowed.
However, the implementation details cause a problem when running Drupal under PHP-PM
(with a booted instance living in memory). This method is called repeatedly.
Proposed resolution
Change the condition:
- If the method is called after boot with a value that is different than the current site path, it throws the exception. This will disallow changing the site path after boot as it does now.
- If the method is called after boot with a value that equals the current site path, it returns quietly.
Context/Background
A patch is forthcoming
Comment | File | Size | Author |
---|---|---|---|
#12 | allow-repeated-calls-to-DrupalKernel-setSitePath-2829346_12.patch | 1.28 KB | ekes |
Comments
Comment #2
kentr CreditAttribution: kentr as a volunteer commentedComment #3
kentr CreditAttribution: kentr as a volunteer commentedComment #4
kentr CreditAttribution: kentr as a volunteer commentedComment #5
kentr CreditAttribution: kentr as a volunteer commentedComment #6
ndobromirov CreditAttribution: ndobromirov at FFW commentedNeeds test.
Comment #7
kentr CreditAttribution: kentr as a volunteer commentedChanging to "unassigned" since I won't be able to work on it for a while.
Comment #9
ekes CreditAttribution: ekes as a volunteer commentedAdded a test.
Comment #10
klausiI know you copied the exception logic from further above, but this is really verbose and not necessary. We can just call setSitePath() again and add a nice comment above from the assertFalse(). If the exception is thrown then the test fails because phpunit catches it.
Comment #11
ekes CreditAttribution: ekes as a volunteer commentedMakes sense.
Comment #12
ekes CreditAttribution: ekes as a volunteer commentedOops. Now the patch and the test.
Comment #13
klausiCool, thanks!
Comment #15
alexpottCommitted 16842fc and pushed to 8.4.x. Thanks!