Hello,

Problem/Motivation

After moving a profile, the path to the profile (stored in the key_value table - collection='state', name='system.profile.files') remains the old one, even after clearing caches.
This causes themes inside the profile to be "lost". Modules paths however appear to be ok.

Reproducing

Here is a bash log to reproduce with the current directory setup:
- profiles
-- my_profile
--- themes
---- my_theme
--- modules
---- my_module

$ drush php-eval "print drupal_get_path('profile', 'my_profile');"
	profiles/my_profile

$ drush php-eval "print drupal_get_path('theme', 'my_theme');"
	profiles/my_profile/themes/my_theme

$ drush php-eval "print drupal_get_path('module', 'my_module');"
	profiles/my_profile/modules/my_module

$ mv profiles/my_profile profiles/contrib/my_profile
$ drush cr
	[success] Cache rebuild complete.

$ drush php-eval "print drupal_get_path('profile', 'my_profile');"
	profiles/my_profile

$ drush php-eval "print drupal_get_path('theme', 'my_theme');"
	[warning] The following theme is missing from the file system: my_theme bootstrap.inc:277

$ drush php-eval "print drupal_get_path('module', 'my_module');"
	profiles/contrib/my_profile/modules/my_module

Expected

After the mv command: profile to be found in profiles/contrib/my_profile and theme in profiles/contrib/my_profile/themes/my_theme

Proposed resolution

Since the profile_handler service suggested in #1356276: Allow profiles to define a base/parent profile is not there yet:
Reset the profile data in drupal_flush_all_caches() as follows:

+ // Rebuild profile, module and theme data.
+ /** @var \Drupal\Core\Extension\ProfileExtensionList $profile_extension_list */
+ $profile_extension_list = \Drupal::service('extension.list.profile');
+ $profile_extension_list->reset();

$module_data = system_rebuild_module_data();

Related issues

- #1356276: Allow profiles to define a base/parent profile: Added a comment to introduce a profile_handler service that could be used in drupal_flush_all_caches()
- and possibly #3022775: The following profile is missing from the file system: they had to reset the system.profile.files state

Comments

herved created an issue. See original summary.

herved’s picture

Issue summary: View changes
herved’s picture

Here are patches for 8.7.x and 8.8.x.

I made several attempts to make kernel tests for that (Vfs and non-Vfs) but the test environment doesn't seem to read the changes to the filesystem after moving the testing profile.
All help/guidance on that is welcome.

cilefen’s picture

Status: Active » Needs review

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.

yoruvo’s picture

Status: Needs review » Reviewed & tested by the community

I've had an installation which was affected by the error described in #3022775, but without using the contrib module that issue belonged to.

This patch has resolved the issue for me completely on Drupal 8.8.3.

Perhaps it needs a reroll against 8.9?

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new974 bytes

This seems worth doing. But let's take the opportunity to tidy things up and refresh all the extension lists. This is something that is extremely hard to test and as we're only calling reset here I think proceeding without tests is okay.

herved’s picture

Thanks @alexpott, it looks good to me.

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.

tobiasb’s picture

Status: Needs review » Needs work

Patch does not apply anymore.

andregp’s picture

Issue tags: +Needs reroll

I'm gonna work on a reroll

andregp’s picture

I could not reproduce the issue, so I believe I won't be able to work on this.

immaculatexavier’s picture

StatusFileSize
new789 bytes
new1.38 KB

Rerolled patch against 9.4.x with diff

immaculatexavier’s picture

Status: Needs work » Needs review
immaculatexavier’s picture

StatusFileSize
new707 bytes
new1005 bytes

Rereolled patch against #16 with diff

immaculatexavier’s picture

Issue tags: +Needs tests

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.

sanduhrs’s picture

Status: Needs review » Reviewed & tested by the community

The patch applies well and works.

  • catch committed 1b8c1e9 on 10.0.x
    Issue #3070747 by immaculatexavier, herved, alexpott, yoruvo: Profile...
  • catch committed e9a1ea2 on 10.1.x
    Issue #3070747 by immaculatexavier, herved, alexpott, yoruvo: Profile...
  • catch committed 04d9a41 on 9.4.x
    Issue #3070747 by immaculatexavier, herved, alexpott, yoruvo: Profile...
  • catch committed bb3c0cb on 9.5.x
    Issue #3070747 by immaculatexavier, herved, alexpott, yoruvo: Profile...
catch’s picture

Version: 9.5.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs reroll, -Needs tests

Agreed with @alexpott that test coverage doesn't seem very viable here.

Committed/pushed to 10.1.x, cherry-picked to 10.0.x, 9.5.x and 9.4.x, thanks!

trackleft2’s picture

The code comment has the word profile twice, which is redundant.
https://git.drupalcode.org/project/drupal/-/commit/04d9a410fab93813cb814...

Status: Fixed » Closed (fixed)

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