I'm having an issue switching a previously installed site from a standard profile to a custom one. The idea here is I want to be able to move to a dev environment where I can run install hooks. I've added a single install hook in that profile to see if it's working.
Everything *seems* to be working fine if I run "drush sp my_new_profile", except I keep getting the following error while running drush:
[warning] The following profile is missing from the file system: my_new_profile bootstrap.inc:276
[warning] strpos(): Empty needle ExtensionDiscovery.php:295If I run drush updb, I get the error again, then it asks me to install the db update that's in the module it can't find. Very confusing.
I found reference to this error over in #2867180: Begin work on switching installation profiles in Drupal 8, but I tried upgrading to the dev version, no luck.
My profile is symlinked directly in the profiles directory right off the web root.
I've entirely removed the reference to installation profiles from my settings.php
Any ideas what I'm doing wrong?
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | profile_switcher-profile_detection-3022775-12-8.patch | 1.81 KB | nterbogt |
| #10 | 3022775-10--cleanup key_values.patch | 1.03 KB | skaught |
Comments
Comment #2
trevorbradley commentedComment #3
trevorbradley commentedComment #4
trevorbradley commentedOK, digging into this deeper. When I load a page like admin/reports/status, bootstrap.inc loads twice.
The first time is called via SystemManager in drupal_load_updates(), and this loads perfectly fine, because the $extension_list has addedPathNames populated.
The second time through bootstrap.inc is called from ExtensionDiscovery::setProfileDirectoriesFromSettings(). This time around, $extension_list has an empty array for addedPathNames and it fails to pull a directory name for my new profile.
Comment #5
joachim commentedNo idea, I'm afraid. While I was working on the code around November, I endlessly switched my test site back and forth between core and custom profiles and had no such error.
All I can suggest is you keep investigating!
Comment #6
trevorbradley commentedI'll keep at it @joachim. Thanks for the feedback! If I figure it out I'll document it here.
Comment #7
trevorbradley commentedOK, got some time to look at this again.
The issue here appears to be that ExtensionList::getPathnames() is failing to call $this->recalculatePathnames(), because the following elseif statement is evaluating as false:
elseif (!$path_names = $this->state->get($cache_id)) {$this->state has a value for $cache_id = 'system.profile.files', which isn't accurate, so the profile shows up as missing...
If I dig much deeper, I see that State is attempting to call the data from the key_value table, specifically the 'system.profile.files' entry in the database:
select * from key_value where collection = 'state' and name = 'system.profile.files';This throws back a JSON string that does NOT contain my profile. (but does contain "standard", "minimal" , etc)
| state | system.profile.files | a:14:{s:10:"demo_umami";s:44:"core/profiles/demo_umami/demo_umami.info.yml";s:7:"minimal";s:38:"core/profiles/minimal/minimal.info.yml";s:12:"qcew_profile";s:43:"profiles/qcew_profile/qcew_profile.info.yml";s:8:"standard";s:40:"core/profiles/standard/standard.info.yml";s:7:"testing";s:38:"core/profiles/testing/testing.info.yml";s:21:"testing_config_import";s:66:"core/profiles/testing_config_import/testing_config_import.info.yml";s:24:"testing_config_overrides";s:72:"core/profiles/testing_config_overrides/testing_config_overrides.info.yml";s:40:"testing_install_profile_all_dependencies";s:104:"core/profiles/testing_install_profile_all_dependencies/testing_install_profile_all_dependencies.info.yml";s:36:"testing_install_profile_dependencies";s:96:"core/profiles/testing_install_profile_dependencies/testing_install_profile_dependencies.info.yml";s:39:"testing_install_profile_dependencies_bc";s:102:"core/profiles/testing_install_profile_dependencies_bc/testing_install_profile_dependencies_bc.info.yml";s:28:"testing_missing_dependencies";s:80:"core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml";s:20:"testing_multilingual";s:64:"core/profiles/testing_multilingual/testing_multilingual.info.yml";s:33:"testing_multilingual_with_english";s:90:"core/profiles/testing_multilingual_with_english/testing_multilingual_with_english.info.yml";s:20:"testing_requirements";s:64:"core/profiles/testing_requirements/testing_requirements.info.yml";} |I tried a crazy thing in SQL, hoping this cached key_value would get rebuilt if it were missing:
delete from key_value where collection = 'state' and name = 'system.profile.files';Refresh a web page throwing the error, and then run...
select * from key_value where collection = 'state' and name = 'system.profile.files';BAM, the profile is listed in the database row, and the error dissapears completely.
So, in summary, somehow I have stale data in the key_value table entry for system.profile.files, which isn't pulling in my new profile.
Any ideas why this bad data would be there for me, and not for everyone else?
Comment #8
trevorbradley commentedIf anyone else is getting stuck on this, try the following command before running drush sp (profile_name):
drush sqlq "delete from key_value where collection = 'state' and name = 'system.profile.files';"
Just tried it on a fresh reset of my docksal and it worked beautifully.
Comment #9
trevorbradley commentedComment #10
skaughtpatch based on #8.
this works from drush command... except for a final cache-rebuild needs to be run. I can't currently find a way to run that from the command.
Comment #11
joachim commentedThanks for the patch.
Remember to set an issue to 'needs review' when you post one though!
A few points:
There's no need to reference an issue when you're fixing something. If anyone ever needs to know why a line of code is there, they can use git blame and the commit message will lead them here.
What would however be useful is a comment explaining what we're doing.
Isn't the current class a service? If so, this can be injected.
Why do we need to delete from the state and then also flush all caches?
Isn't there an API to use the state?
Comment #12
nterbogt commentedHere is my rewritten patch based on the comments above. I can confirm that the additional cache reset was not required.
Comment #13
nterbogt commentedSorry, needs review again now.
Comment #15
joachim commentedThat looks great.
Thanks everyone!