This issue appears to be a bug, but I'll create it initially as a support request until I can get more information to clarify areas I don't know.
config_get_config_directory() references a global $config_directory_name. After grepping for 'config_directory_name', I see how the install process stores the value of that global in settings.php. I don't see how a value for $config_directory_name is inserted into settings.php in the upgrade process.
config_get_config_directory() only uses the $config_directory_name global variable when not in test mode, so if the value of that global is incorrect or missing after a D7 => D8 upgrade, our testing will miss it.
Comment | File | Size | Author |
---|---|---|---|
#47 | drupal8.config-upgrade.47.patch | 9.31 KB | aspilicious |
#47 | interdif_drupal_config.txt | 1.97 KB | aspilicious |
#40 | drupal8.config-upgrade.40.patch | 8.88 KB | sun |
#40 | interdiff.txt | 2.24 KB | sun |
#38 | drupal8.config-upgrade.38.patch | 8.49 KB | sun |
Comments
Comment #1
marcingy CreditAttribution: marcingy commentedLooking at the code and I agree this is an issue. Moving to a task because this is an actionable item.
Comment #2
marcingy CreditAttribution: marcingy commentedInitial patch version to create confi folder on update.
Comment #4
marcingy CreditAttribution: marcingy commentedFailures are related to the lack of config folder being created for simple test.
Comment #5
marcingy CreditAttribution: marcingy commented#2: config_update.patch queued for re-testing.
Comment #7
marcingy CreditAttribution: marcingy commentedThe more I think about this the more I wonder how we are going to test it
* Issue is that we need to file the writable to update
* if we are running simple test we don't want to update settings.php because of sandboxing issues
* The code also needs to ensure that settings is writtable
* We can't rely on variable_get as we should assume it is going away.
We could wrap the update code in
but then of course this code will never be tested.
Comment #8
marcingy CreditAttribution: marcingy commentedWrapping update for simpletest runs.
Comment #9
gddWhat is the issue with sandboxing and writing settings.php? There must be other places that test writing settings.php during the upgrade process, what do those do? I'd like to get this resolved so we can move forward with #1464554: Upgrade path for image style configuration
Comment #10
marcingy CreditAttribution: marcingy commentedIn drupal 7, the rewrite of settings.php is controlled by the $update_rewrite_settings global, which is controlled by update_prepare_d7_bootstrap in the case of simple test
Will be false and as a result update_fix_d7_requirements will not update settings.php unless I am missing something as my understanding is that simpletest uses the exist settings.php for an install and then does this
to prefix tables. It almost seems like in case of CMI that simpletest iteslf would need to enable the ability to write permissions on settings.php and then add a config entry ($conf['simpletest_config'] to leave the master site settings in place.
Comment #11
marcingy CreditAttribution: marcingy commentedAfter reading some other issues I wonder if we could rename settings.php in setUp() and then make a copy of it, set the file to be 777 updated the config variable, set it to read only and then delete at the end of the test and restore the 'master' file when processing is finished. Ideally we should be able to place the config file in simpletest dir and do some sort of overriding but not sure if that will work, as that would give us clean in terms of file deletion for free. I'll try and play around with concept over the next couple of days.
Comment #12
sunNo, simpletest does not touch settings.php. (It's not even able to.)
#1364798: Impossible to generate meaningful diffs of upgrade db dumps will improve the upgrade path testing, but equally won't be able to touch settings.php of the D8 site.
config_get_config_directory() already contains a tweak for test requests, so the config system has a config directory to write to (also during upgrades).
#8 looks acceptable to me, once the other gaps have been filled in.
Comment #13
marcingy CreditAttribution: marcingy commentedChanging status off the back of #1585844: Add config system settings to settings.php on upgrade from D7
Comment #14
catchBumping to critical since this feels like genuine release blocker, unless we do #1052692: New import API for major version upgrades (was migrate module).
Comment #15
alexpott#1576322: page_cache_without_database doesn't return cached pages without the database proposes a way to allow SimpleTest to affect settings.php
I think considering we have a number of test cases that need to do this we should do something about it.
Comment #16
David_Rothstein CreditAttribution: David_Rothstein commentedThe signature key no longer exists due to other issues, so it can be removed.
This should now be
'config_' . drupal_hash_base64(drupal_random_bytes(55))
(per #1464944: Installation of configuration system fails in some cases which was recently committed). If we're using it more than one place now, it might make sense to have a small helper function.Also, I think it should take into account the possibility that someone has added $config_directory_name to settings.php themselves already.
We can't use this since it will overwrite whatever customizations the D7 site had in its settings.php file. (Or at any rate, we can't unless we fix #445012: Prevent drupal_rewrite_settings() from overwriting customizations made to settings.php first.)
Currently, at least, the config system doesn't fall into this category; if you try to do a D6->D7 update you make it to the requirements page just fine (and it warns you that you can't proceed without defining $config_directory_name in settings.php by hand). Although maybe as time goes on that's expected to change?
Comment #17
David_Rothstein CreditAttribution: David_Rothstein commentedThis also makes me wonder if (now that #1464944: Installation of configuration system fails in some cases has been committed) the current issue is actually critical anymore.
There is no longer anything actually broken, I think; the D7->D8 update will not let you proceed until you edit settings.php by hand and make it work correctly.
On the other hand, requiring all sites upgrading from D7 to figure this out (and add a proper config directory name which is sufficiently-obscured to be secure) is not that exciting either, so maybe we should leave it.
Comment #18
David_Rothstein CreditAttribution: David_Rothstein commentedI was on a time warp while writing the above comments; that's supposed to say D7->D8, of course.
Comment #19
aspilicious CreditAttribution: aspilicious commentedI was trying the upgrade path and I needed to add a directory by hand. I just used 'temp' because I hadn't a clue what I should add.
Add the end of the upgrade process I received these warnings:
Still critical IMO
Comment #20
aspilicious CreditAttribution: aspilicious commentedI'm on a windows machine btw
Comment #21
aspilicious CreditAttribution: aspilicious commentedI made a patch, took some time to figure this stuff out... Hopefully this one is better than the previous one. It also includes the fact that settings.php needs to be writable.
Comment #22
aspilicious CreditAttribution: aspilicious commentedThis one is cleaner, cleaned the globals.
Didn't test this one.
Btw there was a bug with the current function
never got called, so I fixed it, don't think we should open a new issue just for that...
Comment #23
aspilicious CreditAttribution: aspilicious commentedHmmm the directory still isn't created...
I hoped the system would do it once I defined the name.
Comment #24
aspilicious CreditAttribution: aspilicious commentedThis one created the damn direcotry and no more warnings when upgrading!
Comment #25
aspilicious CreditAttribution: aspilicious commentedI used the D7 settings.php check less this code
and a database function call. I thought it was something we didn't need someone needs to verify it..
Do I need to check if $config_direcotry_name exists now? And if it doesn't what do we have to do?
What if file_preare_directory fails? Should we do anything with the result.
-3 days to next Drupal core point release.
Comment #26
aspilicious CreditAttribution: aspilicious commentedHere is a different approach that reuses some code from install.core.inc (untested)
Comment #27
aspilicious CreditAttribution: aspilicious commentedComment #29
aspilicious CreditAttribution: aspilicious commentedOk this time I tried the upgrade ;)
Comment #30
aspilicious CreditAttribution: aspilicious commentedI can add a test that verifies the config directory is created.
Comment #32
aspilicious CreditAttribution: aspilicious commented#29: 1500312-fixed-config-upgrade-29.patch queued for re-testing.
Comment #33
aspilicious CreditAttribution: aspilicious commentedTalked with sun and chx on irc and apparantly a test is blocked on #1576322: page_cache_without_database doesn't return cached pages without the database.
They agreed this could go in without a real test for now after some good group manual testing.
So start testing!
1) Install a drupal 7 site,
2) Upgrade with a patched drupal 8
3) Check after upgrade if a config directory is created in sites/default/files
Comment #34
Noe_ CreditAttribution: Noe_ commentedI tested it and there were no errors what so ever.
My setup is a Mac with MAMP.
Comment #35
aspilicious CreditAttribution: aspilicious commentedCan you verify that a folder prefixed with "config_" is created in the sites/default/files directory?
Comment #36
Noe_ CreditAttribution: Noe_ commentedYes it is, and has the same name as $config_directory_name in settings.php
Comment #37
aspilicious CreditAttribution: aspilicious commentedThis has been tested by a few people also in combination with #1464554: Upgrade path for image style configuration
The only problem that we noticed was caused by a non writable files directory but that will be handled in #1674052: update.php shows WSOD if files/ is not writable.
So as far as manual testing goes this is good to go. Can I have a technical review (and a possble rtbc).
Thnx :)
Comment #38
sunI had a longer look at this, and wasn't really happy with the idea that the new helper function rewrites settings.php not only for the config directory, but also for all other settings in the Drupal installer. That mix made the logic really hard to follow. Instead of that, we should rewrite settings.php twice, if needed.
Which brings me to my next point: The code logic tried to rewrite settings.php, even if the $config_directory_name is defined already. Untangling the logic as mentioned above prevents us from doing that.
I relocated the two general helper functions in install.inc to come right after drupal_rewrite_settings(), in order to achieve at least some sane function grouping - thus, the interdiff is a bit larger than the actual changes are.
I also adjusted update_prepare_d8_bootstrap(), since it only attempted to check/create the config directory in case settings.php is writable. I don't think that binding/dependency is true - especially, if your settings.php contains a $config_directory_name already. In that case, update_prepare_d8_bootstrap() does not require a writable settings.php, but still needs to ensure that the config directory exists and is writable.
Lastly, there is one thing I did not adjust, but which irks me a bit -- the new update_prepare_d8_bootstrap() requires settings.php to be writable, which was not the case before. It might be fine to require that. I'm merely thinking of alternative upgrade paths; e.g., using Drush or whatever, in which settings.php might be fully prepared for a D8 bootstrap already and does not actually have to be writable.
Comment #39
sunEssentially, I think we need to make this additional requirement conditional - based on a (potentially increasing) list of settings, which either have to exist in settings.php already, or if they do not, then settings.php needs to be writable.
Thoughts?
Comment #40
sunEssentially, I mean this.
Comment #41
aspilicious CreditAttribution: aspilicious commentedWhy not just
In general I agree with everything said above. And yes we should make the additional requirement conditional.
I just copied the code form the D6 to D7 upgrade. SO in fact we are just doing the same as in previous upgrades, but yes they have a conditional test for this to there. So with the additional test we should be ok :).
THANK YOU for the review and the fixes.
Comment #42
sun@aspilicious: Perhaps it is premature, but I wanted to write it in a way that makes it clear for everyone else that other new/changed settings can/should be added to this condition.
@all: I'm afraid the recent changes are larger and we need to manually test again. :-/ Perhaps it makes sense to wait for another review of the latest patch (to make sure we don't have to test a third time), dunno...
Comment #43
hosef CreditAttribution: hosef commentedI tested both of the patches posted by Sun. Neither of them produced any errors, and both of them created /sites/default/files/config_random_stuff/
Comment #44
ryan.gibson CreditAttribution: ryan.gibson commentedAlright, I tested the patch from #40 and received no errors. I checked and there was a config directory created in /sites/default/files.
Comment #45
ryan.gibson CreditAttribution: ryan.gibson commentedI should add, I followed all of the steps for manual testing from
1) Install a drupal 7 site,
2) Upgrade with a patched drupal 8
3) Check after upgrade if a config directory is created in sites/default/files
And received the results I wrote about in #44.
Comment #46
aspilicious CreditAttribution: aspilicious commentedOk so we just need to fix the first point of me in #41. I can do this tomorow.
Comment #47
aspilicious CreditAttribution: aspilicious commentedIt's an ugly interdiff but should point out the additonal changes are safe. I think this is rtbc...
Comment #48
sunThanks!
Comment #49
damiankloip CreditAttribution: damiankloip commentedSorry, forgot to post on this issue yesterday. I tested this and can confirm it's good.
Comment #50
xjmThanks, office hours testers! :) @damiankloip, @hosef, @ryanissamson
Comment #51
catchThanks for the manual testing. Committed/pushed to 8.x.