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
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | reroll_diff_16-18.txt | 1005 bytes | immaculatexavier |
| #18 | 3070747-18.patch | 707 bytes | immaculatexavier |
| #16 | reroll_diff_7-16.txt | 1.38 KB | immaculatexavier |
| #16 | 3070747-16.patch | 789 bytes | immaculatexavier |
| #7 | 3070747-7.patch | 974 bytes | alexpott |
Comments
Comment #2
herved commentedComment #3
herved commentedHere 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.
Comment #4
cilefen commentedComment #6
yoruvo commentedI'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?
Comment #7
alexpottThis 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.
Comment #8
herved commentedThanks @alexpott, it looks good to me.
Comment #13
tobiasbPatch does not apply anymore.
Comment #14
andregp commentedI'm gonna work on a reroll
Comment #15
andregp commentedI could not reproduce the issue, so I believe I won't be able to work on this.
Comment #16
immaculatexavier commentedRerolled patch against 9.4.x with diff
Comment #17
immaculatexavier commentedComment #18
immaculatexavier commentedRereolled patch against #16 with diff
Comment #19
immaculatexavier commentedComment #21
sanduhrsThe patch applies well and works.
Comment #23
catchAgreed 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!
Comment #24
trackleft2The code comment has the word profile twice, which is redundant.
https://git.drupalcode.org/project/drupal/-/commit/04d9a410fab93813cb814...