Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The logging and error settings at admin/config/development/logging need to be converted to use the new configuration system.
Tasks
- Create a default config file named system.logging_and_errors.xml and add it to the system module.
- Convert the admin UI in system.admin.inc to read to/write from the appropriate config.
- Convert any code that currently accesses these variables to use the config system.
- Write an upgrade path from D7 -> D8 to migrate existing data to the new system and drop the appropriate variables.
This would be a good task for someone wanting to get up to speed on how the new config system works. Feel free to ping me on IRC if you need help.
Comment | File | Size | Author |
---|---|---|---|
#91 | drupal8.config-system-logging.91.patch | 1.3 KB | sun |
#88 | config.system-logging.88.patch | 16.24 KB | alexpott |
#88 | 84-88-interdiff.txt | 1.41 KB | alexpott |
#84 | config.system-logging.84.patch | 16 KB | sun |
#84 | interdiff.txt | 490 bytes | sun |
Comments
Comment #1
BerdirWorking on this...
Comment #2
BerdirOk, this turned out to be not so novice after all, but I think I got it covered.
- The logging settings are split between system.module, dblog.module and syslog.module
- So each of them now has a $module.logging config file
- I decided to use logging for two reasons: a) dblog and syslog are really about only logging. b) while the system one is actually only about errors, the settings form is called *logging_settings* and it's consistent with the others.
- syslog.module has a dynamic default value, which is now set in hook_install()
- Update functions for each of them.
Testbot, go for it!
Comment #3
BerdirOh, almost forgot, I also removed an IMHO pointless test assertion that that directly verified the variable directly in the database, *additionally* to the API.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedoh nice. just removing the 'Config novice' tag.
Comment #6
BerdirIt would really help if I'd be able to spell unserialize correctly... D'oh.
Comment #8
catchIs this necessary now?
Comment #9
BerdirHm, I guess the upgrade path tests fail because the basic upgrade path that creates the initial directories and stuff isn't in yet, right?
@catch: That's what I understood from what beejebus explained to me. I guess that's something that could be automated once we have file naming patterns and stuff like that place, similar to the added submit functions. It probably also makes sense to push/decide on the system_settings_form() issue before converting too many settings forms.
Comment #10
Rok Žlender CreditAttribution: Rok Žlender commentedFew things I update in patch from #6
Comment #11
BerdirComment #13
marcingy CreditAttribution: marcingy commentedWe should be deleting after we have saved to ensure that data is not lost in the conversion process in the update hooks.
Comment #14
Mike Wacker CreditAttribution: Mike Wacker commentedComment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedfor bot
Comment #16
Mike Wacker CreditAttribution: Mike Wacker commentedOops, it looks my patch does not include the .xml config files. Those files initially showed up as untracked files when I applied the patch at #10, so I tried using git add to add them in. But it looks like the files don't show up when I ran git diff to produce my patch.
Comment #18
gdd#10: No we should not include the config removals, I'm pretty sure that patch will land and things will take care of themselves.
Comment #19
Mike Wacker CreditAttribution: Mike Wacker commentedI've dug a little bit more into the failing upgrade tests. An example failure is
file_put_contents(sites/default/files/simpletest/config_simpletest694263/system.logging.xml): failed to open stream: No such file or directory
The issue is that the directory 'sites/default/files/simpletest/config_simpletest694263' does not exist when system_update_8006() runs, causing the $config->save() to attempt to create a file in a non-existent directory.
Looking at config_get_config_directory(), I see that a special config directory is used when SimpleTest runs, so it's hard to tell if it's a test issue or a legitimate issue.
Comment #20
BerdirFrom what I understand, as said in #9, the upgrade path tests fail because there is no upgrade path yet at all for the new config system, which first needs to create the directory and so on. Then, the upgrade functions here need to be configured with hook_update_dependencies() to run that one first.
Comment #21
Mike Wacker CreditAttribution: Mike Wacker commentedThe upgrade test issue has been fixed, trying a new patch.
I also don't think the current
hook_update_N()
implementations would work if a variable did not have an entry in the variable table. This can happen whenvariable_set()
is never called for a variable (in which casevariable_get()
falls back to the default value). Here is an example:I wrote a nice helper method to transfer variables to config to solve that problem.
Comment #22
Mike Wacker CreditAttribution: Mike Wacker commentedComment #23
marcingy CreditAttribution: marcingy commentedA helper function already exists update_variables_to_config for updating variables.
Comment #24
Mike Wacker CreditAttribution: Mike Wacker commentedCurrently,
update_variables_to_config()
has no usages outside unit tests, so I merged the two helper methods together rather than stick with the old one. In the upgrade path, I prefer to explicitly state the default values instead of relying on the default values loaded from the default configuration files because:config()
may return an empty configuration object during the D7 > D8 upgrade process instead of the default configuration, and in any case I would not assume the default configuration would be available during the upgrade process unless a unit test proves that to me. The unit tests forupdate_variables_to_config()
would not catch this issue because they are not running in a true upgrade environment.I also dropped the try-catch(all) block because it was suppressing the exception (although it did log it), which could cause the update to incorrectly succeed.
Comment #25
Mike Wacker CreditAttribution: Mike Wacker commentedComment #26
Mike Wacker CreditAttribution: Mike Wacker commentedThis patch has a few more comments for some discussion points in #21 (variables may not have an entry in the variable table) and #24 (
config()
may return an empty configuration object during the D7 > D8 upgrade process).Comment #27
marcingy CreditAttribution: marcingy commentedI would suggest if you want to change the update helper function that you split this out into a seperate issue becaue there are at least 3 patches based on the existing helper function that are ready for final review.
And if we are going to change the behaviour I think it needs wider discussion than being part of this patch.
The upgrade has been discussed elsewhere and basically and it is the responsibility of the upgrading function to load their default config eg config_install_default_config('search'); and discussed here http://drupal.org/node/1497132#comment-5798610. So the default config will always be available maybe some docs need updating?
Comment #28
Mike Wacker CreditAttribution: Mike Wacker commentedThanks for pointing me to that thread, marcingy, when I have some time I'll reactivate it with some input of mine from building this patch.
Comment #29
gddI agree with marcingy, this should be reverted to use the existing update_variables_to_config() and the changes to that function should be broken out into a new patch. The same goes for the test around that functionality.
Once that is done I think this will probably be really close to getting in.
Comment #30
cosmicdreams CreditAttribution: cosmicdreams commentedTagging
Comment #31
marcingy CreditAttribution: marcingy commentedSimplified version of patch.
Comment #33
marcingy CreditAttribution: marcingy commentedthis install locally without issue...
Comment #34
marcingy CreditAttribution: marcingy commented#31: logging.patch queued for re-testing.
Comment #36
marcingy CreditAttribution: marcingy commentedAh 8009 ha been merged will fix tomorrow.
Comment #37
catchThis change concerns me a bit. Currently variable_get() doesn't hit the database (or anything apart from the $conf global), but config() will, so what happens if you get an exception due to something the config system itself relies upon like the database? Also is the config system definitely always available when this code is called?
Comment #38
marcingy CreditAttribution: marcingy commentedJust a re-roll for now will try to look ito catch's question in the next couple of days.
Comment #40
marcingy CreditAttribution: marcingy commentedThis should pass tests.
Comment #41
gdd'syslog_facility' appears to be missing from the default config file.
Other than that I think this is good to go.
12 days to next Drupal core point release.
Comment #42
Berdirsyslog_facility is initialized here.
A static default value is not possible. The only possible thing would be to define an empty placeholder, not sure if that makes sense.
Powered by Dreditor.
Comment #43
gddAh I see. I would like to have an empty placeholder in the default config, just so we can see everything that is defined by looking at the initial file.
Comment #44
marcingy CreditAttribution: marcingy commentedRe-roll with empty value in xml.
Comment #46
marcingy CreditAttribution: marcingy commentedNot sure why this fails applies locally and my code base is current.
Comment #48
marcingy CreditAttribution: marcingy commentedWe need to set facility on update if it isn't in the db. Not sure if this fixes the issues or not because my local install is giving inconsistent results.
Comment #49
marcingy CreditAttribution: marcingy commentedLast patch had extra stuff in it :(
Comment #51
marcingy CreditAttribution: marcingy commented#49: logging-new-49.patch queued for re-testing.
Comment #53
marcingy CreditAttribution: marcingy commentedRe-attaching the patch that passes - if this pass it seems like the issue is outsides cmi and head has issues in some ways.
Comment #54
marcingy CreditAttribution: marcingy commentedComment #56
Tor Arne Thune CreditAttribution: Tor Arne Thune commentedYes, the five upgrade tests randomly fail for other issues as well.
Comment #57
marcingy CreditAttribution: marcingy commentedNote this the patch to review http://drupal.org/node/1493108#comment-6014680 i'll re-upload it latter when I am at my desktop.
Comment #58
marcingy CreditAttribution: marcingy commentedCorrect patch version
Comment #59
kbasarab CreditAttribution: kbasarab commentedRerolls against HEAD. No other changes.
Comment #61
Berdirupdate_variables_to_config() was changed and now requires the second argument, that's why the tests fail. Modules are now required to explicitly pass the variable => config mapping in there.
Comment #62
kbasarab CreditAttribution: kbasarab commentedAhh. Thanks Berdir. Updated functionality for this and ran tests patch effects locally. Had a couple fails but when trying to mimic the config->save options locally from CLI I would get an error cause of file permissions. Gonna see what happens on testbot.
Comment #64
kbasarab CreditAttribution: kbasarab commentedSo it seems as though my variables aren't setting for the tests or maybe my error test handler isn't working correctly. If I try to manually change the error settings on the install via the UI it works and if I manually enable the error test module all is working as well.
I did find an error though in my testing and rerolling that removed the default system.logging.xml and though I'm sure that's not the only problem as I'm still getting the error locally here it is so we have the most recent version to work off of. Any ideas to point me in the right direction?
Comment #66
disasm CreditAttribution: disasm commentedlanguage_negotiation_include() is in language.module. I think in the parent::setup() function above, you need to pass array('language') to enable the language module.
Comment #67
kbasarab CreditAttribution: kbasarab commentedYeah. I think you are right disasm. The one I can't seem to clear is this:
Found error message: Exception: Drupal is awesome in error_test_trigger_exception() (line . Other ErrorHandlerTest.php 98 Drupal\system\Tests\System\ErrorHandlerTest->testExceptionHandler()
Found DatabaseExceptionWrapper in error page. Other ErrorHandlerTest.php 104 Drupal\system\Tests\System\ErrorHandlerTest->testExceptionHandler()
Found SELECT * FROM bananas_are_awesome in error page. Other ErrorHandlerTest.php 105 Drupal\system\Tests\System\ErrorHandlerTest->testException
Found 'in error_test_trigger_pdo_exception() (line ' in error page. Other ErrorHandlerTest.php 107 Drupal\system\Tests\System\ErrorHandlerTest->testExceptionHandler()
Those are the fails that I get running the tests individually rather than all together. When I try to do manual testing of those I'm able to replicate and get the expected text that the test run is looking for.
Those are in this portion of patch:
Comment #68
gddOn top of any other problems
- This file needs to be converted to YAML per #1470824: XML encoder can only handle a small subset of PHP arrays, so switch to YAML
- The names need to match the new naming conventions laid out at http://drupal.org/node/1667896
Comment #69
cosmicdreams CreditAttribution: cosmicdreams commentedworking on this tonight. More to come.
Comment #70
sunAll config system conversions are API changes, so tagging as such.
Comment #71
cosmicdreams CreditAttribution: cosmicdreams commentedI've worked up a new patch for this based on the patch in #64. The issues identified in #67 will likely still be issues with this patch.
Things in this patch:
- converted xml to yml
- added yml files for dblog and syslog
- modified naming of config values to use our new standards
- renamed the system.logging.yml file to system.logging.settings.yml (let's discuss)
Comment #72
sunThanks for working on this! :)
Oh, hm, there shouldn't be a .settings suffix if a module has multiple config objects containing settings. The $module.settings standard only applies to modules that only have one set of settings. Perhaps we need to clarify the howto/tutorial?
I've performed a range of adjustments.
Comment #73
sunBleh. I thought I had fixed all of them in the re-roll...
Comment #74
cosmicdreams CreditAttribution: cosmicdreams commentedThanks sun, I figured there was a detail that would modify the naming rule.
Comment #76
alexpott#73: drupal8.config-system-logging.73.patch queued for re-testing.
Comment #77
aspilicious CreditAttribution: aspilicious commentedThis feels like an API change, I don't think it's a bad one but
1) is it needed here?
2) if we keep it in here (I'm fine with that) we need to make sure we make a change notification for that.
Other than that ==> rtbc it is I think
-26 days to next Drupal core point release.
Comment #78
aspilicious CreditAttribution: aspilicious commentedwhoops
Comment #79
sunI think it makes sense to keep it here, since, frankly, values like 0, 1, 2, 3 do not make any sense in a configuration file.
The good news is that all of core is using the error level constants already, so the actual values of those constants is completely irrelevant for the runtime code. :)
For that reason, I'm also not sure whether the change would require a change notice. All PHP code should be using the constants anyway already, and people will have to rewrite/rebuild their entire configuration for D8 anyway...
That said, the system module update does not translate the old numeric value to the new string identifier yet.
Comment #80
aspilicious CreditAttribution: aspilicious commentedHmmm that means we need to update the variables before converting.
I would like to push #1348162: Add update_variable_*() as fast as possible...
That issue is waiting for months now...
Comment #81
sunOr we simply update the value.
Comment #82
aspilicious CreditAttribution: aspilicious commentedYeah thats fine to...
But I still want the other issue being fixed... :p
I would like to have a test for this upgrade. When thats done this is rtbc.
Comment #84
sunIt looks like we have sufficient tests ;)
2715c60 Fixed upgrade path for error_level for sites that do not have error_level configured.
Comment #85
aspilicious CreditAttribution: aspilicious commentedGood to go now :). Thnx!
Comment #86
alexpottI think we might have an issue in system_update_8014 as we'll be calling code with error_level set to an invalid value.
The call to update_variables_to_config() will set error_level incorrectly and then we map it to the new values and save. It seems odd/inefficient/wrong to set the value twice in the same update. We could do something like this...
Comment #87
alexpottChanging issue status to needs review...
Comment #88
alexpott@aspilicious pointed out on IRC that we need to do other things from update_varaibles_to_config().
Patch attached solves this.
Comment #89
cosmicdreams CreditAttribution: cosmicdreams commentedIf we're OK with update 8014 then the rest of this patch looks good. Recommend RTBC
Comment #90
webchickCool. Asked Greg eyeball this at #mwds, and he said it was good to go!
Committed and pushed to 8.x. Thanks! :D
Comment #91
sunAll variables are stored as serialized PHP.
If the value was '0', then the $error_level condition equals FALSE. You wanted to do a strict type check on !== FALSE here.
Comment #92
alexpottDoh! My bad.
Sun's patch is great. Applied and ran manual tests both with and without error_level in the variables table and everything works as expected.
Comment #93
catchCommitted/pushed the follow-up, thanks!