Problem/Motivation
Fatal error when installing Drupal core 8.x-dev on a Mac into a folder that contains a capital letter... e.g. /Users/dan/Sites/drupal8 ...
Fatal error: Cannot redeclare standard_form_install_configure_form_alter() (previously declared in /Users/dan/Sites/drupal8/core/profiles/standard/standard.profile:12) in /Users/dan/sites/drupal8/core/profiles/standard/standard.profile on line 15
Proposed resolution
The resolution is to ensure the install.core.inc process always uses the DRUPAL_ROOT constant when calling include_once or require_once functions to ensure PHP maintains a consistent list of loaded modules. This is because PHP will resolve relative paths to a lowercase version of the full path, but DRUPAL_ROOT resolves to the correct path which may contain capital letters. Either methods are valid, but you cannot mix, as this results in a module being loaded twice.
This simply means updating the 3 lines in install.core.inc from
include_once $profile_file
to include_once DRUPAL_ROOT . '/' . $profile_file
Remaining tasks
Patch has been created (see comment #3), and now awaiting review so it can be committed.
User interface changes
No user interface changes
API changes
The only change is to refine install.core.inc file, and should not impact anything else.
Related Issues
N/A
Comment | File | Size | Author |
---|---|---|---|
#3 | profile-include-issue.2055843.3.patch | 1.6 KB | dmoore |
Comments
Comment #1
dmoore CreditAttribution: dmoore commentedI have just noticed that the error states that standard_form_install_configure_form_alter() has already been declared in /Users/dan/sites/drupal8/core/profiles/standard/standard.profile, and then it tries to redeclare in /Users/dan/Sites/drupal8/core/profiles/standard.profile.
Notice that the /Users/dan/sites directory is using different cases. My directory is actually /Users/dan/Sites/drupal8 - so why is Drupal messing with /Users/dan/sites/drupal8/ ?
I know that Macs ignore case, so /Users/dan/sites is the same as /Users/dan/Sites.
So the problem must be related to how the form alter declarations are called, and why is Drupal using the lowercase version which doesn't technically exist - but the Mac is allowing.
Comment #2
dmoore CreditAttribution: dmoore commentedOK, I have run several tests, and can confirm that Drupal 8.x-dev has a problem when being installed on a Mac OS folder that contains any upper-case letters. e.g. /users/Dan/drupal or /users/dan/Sites/drupal.
When I try to install on a path that is all lower-case then all installs correctly.
When I try to install on a path that contains a capital letter, Drupal seems to include the standard.profile using the correct path (with the capital letter), and then tries to include it again with the incorrect lower-case version of that path - which then causes a redeclaration error.
Because this will not affect all users, but will potentially impact a significant number of Mac users, preventing them from installing Drupal - I feel this should be upgraded to a major priority.
Comment #3
dmoore CreditAttribution: dmoore commentedAfter some investigation it appears that the problem is in the install.core.inc file.
There are several places where the profile modules are included, before they are re-included as part of the profile module load list. These initial includes don't use the DRUPAL_ROOT constant, and therefore they use the default method to resolve the current working directory. This seems to return a lowercase version of the real directory name e.g. /users/dan/sites/drupal8/core/profiles/standard/standard.profile, and then when the profile modules are loaded the DRUPAL_ROOT is used, and so the correct path is loaded aswell: /Users/dan/Sites/drupal8/core/profiles/standard/standard.profile. This means there are effectivelly two versions of the same file in memory, and this causes the redeclaration error.
The fix is to change all references in install.core.inc of
include_once $profile_file
to
include_once DRUPAL_ROOT . '/' . $profile_file
This then ensures that include_once works correctly as the full paths to the profile modules are consistent and avoid loading duplicate versions that are legal on a non case-sensitive file system.
I have uploaded a patch to this comment.
Comment #3.0
dmoore CreditAttribution: dmoore commentedAdded more details about the problem
Comment #4
webchickMarking as needs review, since there's a patch. Nice sleuthing work there!
Clarifying the title a bit, since a lot of people won't be able to reproduce this.
Comment #6
dmoore CreditAttribution: dmoore commented#3: profile-include-issue.2055843.3.patch queued for re-testing.
Comment #8
dmoore CreditAttribution: dmoore commentedI cannot understand why this patch is failing. It seems on both occasions it failed on very different tests. My assumption is that these tests are also undergoing testing themselves, and I am seeing bugs in the test process rather than an issue with my patch?
Comment #9
dmoore CreditAttribution: dmoore commented#3: profile-include-issue.2055843.3.patch queued for re-testing.
Comment #9.0
dmoore CreditAttribution: dmoore commentedChanging to clarify that this issue relates to Macs
Comment #9.1
dmoore CreditAttribution: dmoore commentedAdded an issue summary
Comment #10
dmoore CreditAttribution: dmoore commentedOK the patch has passed automated testing. How do we get this committed into core?
Comment #10.0
dmoore CreditAttribution: dmoore commentedRemoved duplicate title
Comment #11
Hydra CreditAttribution: Hydra commented@dmoore: Somebody needs to review your test manually, to check if the problem really and still exists and if your patch is working and well written. The bot only checks if the automated tests passes.
Well, this patch is fixing this issue for me on my osx, thanks! It does not look like this patch would effect any one not using a osx system in a negative way, so for me this is RTBC.
Comment #12
webchickAwesome, thanks for the fix. Since it's not really possible to write tests for this, I think this is good to go.
Committed and pushed to 8.x. Thanks!
Comment #13.0
(not verified) CreditAttribution: commentedAdding a reference to where the patch is defined