Problem/Motivation

As #1356276: Allow profiles to define a base/parent profile is not done yet, we want to come up with a workaround to not only load the current installation profile, but also some additional ones.
Starting with #1356276-129: Allow profiles to define a base/parent profile there have been some attempts to resolve that.

Proposed resolution

Discuss whether adding such a workaround to core is a good idea or whether these patches should be just applied until #1356276: Allow profiles to define a base/parent profile is resolved

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

mpotter’s picture

Status: Active » Needs review
FileSize
5.31 KB

Here is a patch that applies to 8.2.x. The only conflict from the previous issue thread patch was the comments added to ExtensionDiscovery.

Still need to add the tests using the virtual file system. But marking this for Review to see how the other Drupal automated tests work.

naveenvalecha’s picture

fix the patch with some changes.converted teh test to kernel test base
KernelTestBase will not remain in simpletest after 8.2.x #2734663: Update deprecation message for old KernelTestBase in simpletest :( so Moving to unit tests

Status: Needs review » Needs work

The last submitted patch, 3: 2743197-3.patch, failed testing.

abhishek-anand’s picture

Status: Needs work » Needs review
FileSize
6.61 KB
7.15 KB
abhishek-anand’s picture

mpotter’s picture

Starting to try and use this patch for a real distro and running into an issue.

If you try to enable modules in the base_profile in the main profile info.yml file, it seems to fail. When I look at my settings.php file, it isn't writeable so the code in the install.core.inc file wasn't able to take the base_profile from the info.yml and add the profile_directories line to the settings.php.

mpotter’s picture

Tracked part of the problem down to drupal_check_profile() which loops through the dependencies and calls getPath on each one. At this early point of the profile install, nothing has been added to settings.php so the profile_directories haven't been added for the base profile. So if you reference a module within the base profile in the main profile.info.yml it will cause the error:

PHP Fatal error: Call to a member function getPath() on a non-object in /var/www/build/html/core/includes/install.inc on line 942

If I manually add the profile_directories array to settings.php then it gets past this error.

das-peter’s picture

@mpotter just posted a patch which should solve this: #1356276-158: Allow profiles to define a base/parent profile

mpotter’s picture

The patch in #158 of the parent issue #1356276: Allow profiles to define a base/parent profile is great for solving the overall profile inheritance issue. But the purpose of this issue is to split off the code that just sets the profile_directories via $settings into a simple issue that can easily be tested and applied to 8.2.x.

I have re-rolled the patch from #5 that has the new vfStream test (thanks abhishek-anand!!) and have removed the code that writes to the settings.php using the base_profile key. That kind of code needs to stay in the larger parent issue.

I think this is now nice and clean. We have a really straight-forward way to add additional paths to the settings for profile_directories. This code will be needed by the larger parent issue for inheriting profiles. We have a good test for it. Let's try to get this RTBC'd and into 8.2.x so we can focus effort on the larger parent issue.

Edited: To be really clear...all we are doing in this patch is implementing what the existing function setProfileDirectoriesFromSettings() implies that it should be doing.

mpotter’s picture

Title: Provide a workaroud to load additional profiles via settings.php » Load additional profile directories via settings
jhedstrom’s picture

This is looking good. Quite straightforward approach, and the added test illustrates the behavior.

A few tiny issues:

  1. +++ b/core/modules/system/tests/src/Kernel/System/ExtensionDiscoveryProfilesTest.php
    @@ -0,0 +1,115 @@
    +  /**
    +   * Adds example files to the filesystem structure.
    +   *
    +   * @param array $filesystem_structure
    +   *
    +   * @return string[][]
    +   *   Format: $[$type][$name] = $yml_file
    +   *   E.g. $['module']['system'] = 'system.info.yml'
    +   */
    +  protected function populateFilesystemStructure(array &$filesystem_structure, $info_by_file) {
    

    Nit: one of the @params is missing, and they both need short descriptions.

  2. +++ b/core/modules/system/tests/src/Kernel/System/ExtensionDiscoveryProfilesTest.php
    @@ -0,0 +1,115 @@
    +    unset($files_by_type_and_name_expected['module']['otherprofile_nested_module']);
    

    Can you add a code comment here to clarify why this is unset? It isn't immediately obvious I don't think.

  3. +++ b/core/modules/system/tests/src/Kernel/System/ExtensionDiscoveryProfilesTest.php
    @@ -0,0 +1,115 @@
    +  /**
    +   * @param array $filesystem_structure
    +   * @param string[] $pieces
    +   *   Fragments of the file path.
    +   * @param string $content
    +   */
    +  protected function addFileToFilesystemStructure(array &$filesystem_structure, array $pieces, $content) {
    

    Similar to above, this needs @param descriptions, and also a short one-liner description at the top of the docblock.

mpotter’s picture

The new approach I just posted to #1356276: Allow profiles to define a base/parent profile no longer actually uses this method. Will keep this open for a while longer but I think we've got a cleaner method now in the original issue.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Closed (duplicate)

This appears to be a duplicate of https://www.drupal.org/project/drupal/issues/3266057 which is way further along. Closing this one out and moving credit over.