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.

N/A

CommentFileSizeAuthor
#3 profile-include-issue.2055843.3.patch1.6 KBdmoore
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dmoore’s picture

I 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.

dmoore’s picture

Priority: Normal » Major

OK, 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.

dmoore’s picture

Title: Installation fatal error: Cannot redeclare standard_form_install_configure_form_alter() in case-insensitive filesystems » Installation fatal error: Cannot redeclare standard_form_install_configure_form_alter()
Status: Needs review » Active
FileSize
1.6 KB

After 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.

dmoore’s picture

Issue summary: View changes

Added more details about the problem

webchick’s picture

Title: Installation fatal error: Cannot redeclare standard_form_install_configure_form_alter() » Installation fatal error: Cannot redeclare standard_form_install_configure_form_alter() in case-insensitive filesystems
Status: Active » Needs review

Marking 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.

Title: Installation fatal error: Cannot redeclare standard_form_install_configure_form_alter() » Installation fatal error: Cannot redeclare standard_form_install_configure_form_alter() in case-insensitive filesystems
Status: Active » Needs work

The last submitted patch, profile-include-issue.2055843.3.patch, failed testing.

dmoore’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, profile-include-issue.2055843.3.patch, failed testing.

dmoore’s picture

I 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?

dmoore’s picture

Status: Needs work » Needs review
dmoore’s picture

Issue summary: View changes

Changing to clarify that this issue relates to Macs

dmoore’s picture

Issue summary: View changes

Added an issue summary

dmoore’s picture

OK the patch has passed automated testing. How do we get this committed into core?

dmoore’s picture

Issue summary: View changes

Removed duplicate title

Hydra’s picture

Status: Needs review » Reviewed & tested by the community

@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.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, 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!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Adding a reference to where the patch is defined