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 newly committed Configuration system uses xml files to store configuration rather than global variables, impacting the use of variable_set(), variable_get(), and form submission.
The blog post linked above explains how a module would use this new system. The examples module would be a great place a working example of this.
Cheers,
Albert.
Comment | File | Size | Author |
---|---|---|---|
#34 | interdiff_31_34.txt | 2.94 KB | rcodina |
#34 | config-simple-example-module-1615520-34.patch | 6.76 KB | rcodina |
#31 | config-simple-example-module-1615520-31.patch | 5.34 KB | alexandre.todorov |
| |||
#21 | 1615520-21-config-module.patch | 26.48 KB | alberto56 |
#15 | 1615520-15-config-module.patch | 24.71 KB | alberto56 |
Comments
Comment #1
rfayThis will be welcome when there's a patch, especially if the person maintaining the patch is willing to make sure it works all the way through the 8.x cycle.
Comment #2
alberto56 CreditAttribution: alberto56 commentedHi,
thanks for the response.
I'm wondering if you purposefully removed the "Configuration system" tag -- It serves to group issues related to the config management initiaive, across projects. See some examples here.
I believe tagging the issue with "Configuration system" might help people looking for issues related to that initiative, even issues not in core; so you might consider replacing that tag on this issue.
Cheers,
Albert.
Comment #3
rfayI did deliberately remove it, but I was wrong :-) Most of the time when tags like this show up they're because somebody just thought they should make up some tags :-)
Restoring; Thanks for your work on the config system, and hope to get a good demo module in there. It will need tests, and will need ongoing maintenance as 8.x changes.
Comment #4
alberto56 CreditAttribution: alberto56 commentedHi all,
Instead of creating a whole new module for this, I decided to use a module that was already in the examples suite for D7, the reason being that I needed to test the upgrade path as well.
So here is a patch that does the following:
- upgrades block_example to use D8's new configuration management system
- defines passing automated tests
- defines an upgrade path from D7 version of block_example, which I tested manually (no automated tests for this yet).
Here is the block_module in two versions: (1) as a patch against 8.x branch of examples. (2) as a stand-alone zip file you can add to your D8 installation.
Cheers,
Albert.
Comment #6
alberto56 CreditAttribution: alberto56 commentedHmmm, testbot seems to be trying to be breaking, but on my site, the tests _do_ pass.
By the way, I'll be willing provide ongoing maintenance for this as 8.x changes.
Comment #7
rfayThanks for your willingness to do this.
Please do create a new module: configuration_example.module?
Each module is intended to teach exactly one thing. If you need to base it on block_example you can, but its name should tell what you're trying to teach. Please choose the simplest "scaffolding" you can. Block might be OK, but if you can think of something simpler that's great.
The idea is that somebody can look at it and not have to learn *anything* except the config part.
Comment #8
rfay@alberto56, there's an FAQ about why tests pass locally but not on the testbot at http://drupal.org/project/testbot.
Comment #9
alberto56 CreditAttribution: alberto56 commentedThanks @rfay,
Would you agree to a new configuration_example module, but still keeping the block_example module as it is in the patch? A couple of notes:
- first, I need an existing module to test/demonstrate the upgrade path.
- Block example, even though it is not meant to demonstrate config management, will still need to use it, because all modes which previously used variable_get() and variable_set() will need to switch to config management.
- I would not make a lot of sense to add an upgrade hook in a new configuration_example module, so instead I can provide a comment in the configuration_example.install file to the hook presently in block_example in this patch.
Does that make sense to you?
Thanks!
Albert.
Comment #10
rfayI'd really like to have you focus on configuration and not confuse things with links between different example modules. The dbtng_example attempted these things for D7, but did it only with comments. If you don't think it can be done with comments... Do you think it would be reasonable to add a Configuration Example to D7 first, demonstrating all the traditional techniques (db tables, cache, info file, whatever)? Then the D8 version could build on that?
It's OK to use the "block" idea as the core, if you can't get any simpler than that. (Simpletest Examples uses a fork of Nodeapi_example). They key is simplicity.
Just rip out anything not related to what you're trying to teach. Rip out everything that's not essential for teaching or functionality.
Comment #11
alberto56 CreditAttribution: alberto56 commentedGreat idea, that makes a lot of sense, thanks.
Comment #12
alberto56 CreditAttribution: alberto56 commentedComment #13
alberto56 CreditAttribution: alberto56 commented- I have created a config module for D7, see #1630762: Configuration example for D7, so that the upgrade path to D8 may be demonstrated.
- See the enclosed patch for the same module upgraded to D8 using the config system.
- My previous patch, slightly modified, I have submitted in a new issue, because it still works well to demo blocks in D8: #1630760: Update block example module for D8.
Please note that the upgrade path has not been tested yet at all and I'm almost sure it does not work for the more complex configuration (this is in the comments). Let me suggest committing this module as is, and opening a new issue, assigned to me, for the upgrade path.
Comment #14
mrsinguyen CreditAttribution: mrsinguyen commentedWhen i delete the one row config on configuration complex then delete all value in configuration.
Message at http://example.com/dev/drupal-8.x/examples/configuration-complex
Comment #15
alberto56 CreditAttribution: alberto56 commentedHi,
Here is a new patch which integrates all the same improvements as the latest patch (comment #8) of #1630762: Configuration example for D7, so that the upgrade path to D8 may be demonstrated..
Some notes:
(1) @mrsinguyen thanks for pointing out the bug in your comment #14, above. I am confirming that deleting one item was deleting them all, and have added a test to make sure this does not happen. The reason this was happening is that I was using config::delete() instead of config::clear() to unset the data, so it was deleting everything. It now should work.
(2) I have included a working automated test for the upgrade path.
All tests pass.
Cheers,
Albert.
Comment #17
alberto56 CreditAttribution: alberto56 commented#15: 1615520-15-config-module.patch queued for re-testing.
Comment #19
alberto56 CreditAttribution: alberto56 commentedHmmm, the testbot does not like the fact that the patch contains a .gz file: "error: cannot apply binary patch to 'configuration_example/tests/drupal-7.configuration_example.database.php.gz' without full index line". I'm not sure why. Still, in my tests, everything works.
Comment #20
rfayIt's just failing on the git apply. Are you able to do the git apply against this binary manually? I guess I'm surprised that this is required. Applying patches to binary files is not the strong suit of any tool like this.
Comment #21
alberto56 CreditAttribution: alberto56 commentedMy fault, I was not creating the patch correctly. I am now using this technique. Here is the updated patch.
Comment #22
alberto56 CreditAttribution: alberto56 commentedA good chunk of the code is dedicated to implementing and testing an upgrade path from 7.x. Does it make sense to have this here? Or should this be moved to a new module? I have opened an issue about this at #1699440: A dedicated to module to demonstrate hook_update_N() and automatically testing upgrades and updates.
Cheers,
Albert.
Comment #23
alberto56 CreditAttribution: alberto56 commentedAs a follow-up to the above comment, I have updated #1699440: A dedicated to module to demonstrate hook_update_N() and automatically testing upgrades and updates and #1630762: Configuration example for D7, so that the upgrade path to D8 may be demonstrated..
Basically, I would suggest removing all upgrade path code from this patch.
Comment #24
Mile23So is it a hard-wired need to have a .gz file? It might be better to just have the .php file which can then be comprehended by a human in a diff.
Also, I like the idea that you can make a configuration in D7, do an upgrade to D8, and then test the result. In fact, this might be more of a test_data_integrity_example than a configuration_example, which I think is great.
Is there a way to check if the config is saved before telling the user it happened?
Also, is anyone working on a D7 module to spit out config YAML files?
Comment #25
Mile23Marking as postponed for now: #1861598: Examples for Drupal 8 needs relatively stable feature set
Please continue development and discussion as desired.
Comment #26
Mile23Setting this to 'needs review' to see if it still works. :-)
Comment #27
Mile23#21: 1615520-21-config-module.patch queued for re-testing.
Comment #29
Mile23Feel free to assign yourself back if you're still working on it.
Comment #30
Mile23We currently have the config_entity_example. That example demonstrates entities which are more like the taxonomy use-case.
We currently do not have an example for 'simple' config.
I think we should narrow scope here so we have an example which talks about various elements of 'simple' configuration, such as what goes in the config/ directory, what config/install does, how to get at those values, etc. We'll call it simple_config_example
The patch in #21 is old enough that it sets up config entities using hooks, so it might be more work than it's worth to update the whole thing. Though obviously it could be a starting point.
Comment #31
alexandre.todorov CreditAttribution: alexandre.todorov commentedComment #32
Mile23Thanks, @alexandre.todorov this looks really good. Just some extra stuff we need to make it a proper Examples project module:
Explain config_object and talk about the other types a little bit.
Explain what a mapping is.
Explain how this enables translation. Also, let's make a non-translatable config that is somehow excluded here.
These aren't showing in the Tools menu.
Needs another route to a description page explaining what the user is looking at, with links to the admin pages. Use DescriptionTemplateTrait.
Comment #33
ashishdalviMarking this issue for Drupal Mumbai Code Sprint
Comment #34
rcodina CreditAttribution: rcodina at Seidor commentedI replaced old core property with core_version_requirement. I also addressed some of the feedback on #32.
Comment #35
rcodina CreditAttribution: rcodina at Seidor commented