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.
Currently, modules that require settings for content types (i.e. upload.module
s enabled/disabled status, comment.module
s read-write/read/disabled setting, …) just define variable variables (variable_set('comments_'. $content_type, ...)
). That’s rather messy and pollutes the variable namespace. These settings should be stored elsewhere and be associated to the internal content type (which can change).
Follow-ups
- from #53 (#57 and #66) #1872738: Remove Node Type API for in-code node types after Convert node/content types into configuration
- from #68 Changing the 'type' and 'name' properties for node types definitely has to be a follow-up issue
- Convert other modules storing data in variables - or add a dumping ground property where properties are stored per module (key = module, values = array of properties) which can be removed easily on disabling/uninstall module
Comment | File | Size | Author |
---|---|---|---|
#258 | content-type-111715-258.patch | 146.45 KB | amateescu |
#258 | interdiff.txt | 2.34 KB | amateescu |
#226 | comment_menu_alter_items.png | 24.07 KB | andypost |
#140 | Screen Shot 2013-04-24 at 11.57.11 AM.png | 87.79 KB | gdd |
Comments
Comment #1
kkaefer CreditAttribution: kkaefer commentedThis is my first patch for this issue. It moves all content type related settings away from the
{variable}
table into a serialized array in the{node_type}
table. The patch also includes an update to migrate the old settings to the new place.Comment #2
kbahey CreditAttribution: kbahey commentedKonstantin
While I agree with you that uncluttering the variable name space Is A Good Thing (TM), I am concerned about the following:
- Performance: the variables in the variable table are read once and cached. Now there is more access to the database to get this info, probably from many tables (e.g for pages having lists of many node types).
- Serialized arrays: this is a personal/philosophical point, but rooted in normalization and data storage. A serialized array is just a blob in the database that cannot be used in a WHERE clause, or ORDER BY or any other operations. The blob has to be read in its entirety and processed in PHP, rather than being done in the back end.
So, I recommend a benchmark before and after to see if this has a negative impact before you proceed further with it.
Comment #3
kkaefer CreditAttribution: kkaefer commentedI am aware of the fact that serialized arrays are not really the best solution, however, I don’t see another way to store these settings. In the
{variable}
table, these settings would also be stored as serialized PHP variables, so in that regard, there doesn’t change much. I can’t really think of a good application where we would want content type settings to be queryable. Usually, a site has relatively few content types, so sorting in PHP would also be maintainable.You make a point about querying the database too often with the content type settings moved to the
{node_type}
table. However, as content types are loaded anyway with each page load that deals with nodes, I don’t see how this could impact performance. Nonetheless, we can perform benchmarks, I agree.Comment #4
kkaefer CreditAttribution: kkaefer commented$ ab -c10 -n500 http://head.drupal/ (without patch)
Time taken for tests: 91.360 seconds
Requests per second: 5.47 [#/sec] (mean)
Time per request: 1827.20 [ms] (mean)
Time per request: 182.72 [ms] (mean, across all concurrent requests)
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 697 1808 323.3 1880 3180
Waiting: 696 1808 323.3 1880 3180
Total: 697 1808 323.3 1880 3180
$ ab -c10 -n500 http://head.drupal/ (patch)
Time taken for tests: 92.069 seconds
Requests per second: 5.43 [#/sec] (mean)
Time per request: 1841.38 [ms] (mean)
Time per request: 184.14 [ms] (mean, across all concurrent requests)
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 925 1829 320.4 1908 3354
Waiting: 924 1829 320.4 1908 3353
Total: 925 1829 320.4 1908 3354
Looks like this patch doesn't really have impact. For the unpatched Drupal, I got #/sec values from 5.23 to 5.55, for the patched version about the same range.
Comment #5
chx CreditAttribution: chx commentedIf you want to test this patch then you want to enable comment & upload and then go to admin/content/types and play with the settings for a content type -- does everything work as it should?
Comment #6
eaton CreditAttribution: eaton commentedI, too, am concerned about the serialized arrays. I'd prefer a table that stores dedicated settings, keyed by nodetype and module. That would allow content-type changes to migrate settings over easily, and module uninstallation could easily clear out any node-type settings.
Comment #7
Boris Mann CreditAttribution: Boris Mann commented+1 on Eaton's comments -- let's refactor the variable table instead.
Think also of install profiles: currently, it is easy and simple to do variable_set() to twiddle lots of settings. I don't think this will necessarily have an effect, but wanted to bring it up.
And, if variable_set() goes away (rather than just routing to a different table) the next patch will have to modify the default.profile to capture the change.
Comment #8
sunIf I read the benchmark correctly, this patch does neither boost nor degrade performance. So I'm inclined to reduce this issue to the cause: String concatenations everywhere.
Simplified to this statement, content type-specific variables could be stored as (serialized) arrays, using one variable per module.
Instead of introducing a new variable storage, why not implement two new helper functions?
Comment #9
eaton CreditAttribution: eaton commentedSun, I don't think that boosting performance was the goal of the original issue: the benchmark that showed no speed change was meant to indicate that there was no *penalty* for the new approach.
The benefit of treating content type configuration as a separate set of options is that the main variable namespace isn't polluted, and that it's easier to re-sync content type settings when a type is renamed, among other things.
Comment #10
sun@Eaton: If you look at #8 again, variables are less polluted because each module saves its content type settings in one array for all content types. However, moving all content type variables from one type to another might not be simplified that way.
Comment #11
eaton CreditAttribution: eaton commentedWell, that links up with my hope that we simply use a separate storage system for content-type settings... Rather than the serialized arrays. We don't really gain much if all we add is a wrapper function.
Comment #12
Nick Lewis CreditAttribution: Nick Lewis commentedI feel a bit like this discussion is getting off track -- its pretty clear to me that serialized arrays is an easy and sensible solution to storing these settings.
I don't see a great deal of value in being able to write "SELECT name FROM {node_vars} WHERE value = '0' ORDER by name ASC". And it seems to me that there are too many gotchas when it comes to storing node settings in neat little columns, for example: is this data serialized, a string, numeric? How are we planning on handling the name space between node settings? Are we going to have to have a new series of tables... e.g. (node_type_variables). There are probably enough small, and subjective questions like this that I think we'd fail to get this patch into drupal 6 unless we settle for serialized arrays for now. I'd really like to see this in 6.
The final result of this patch -- being able to declare default settings for nodes in CODE instead of through an interface is priceless. Haven't had time to verify this, but this appears to be an example of how easy it would be to set default node settings:
Far cry from having to fill up a .install file with variable_set($node_type.'_variable_name', TRUE).
So think of it this way:
Does this patch make our code cleaner, and easier to understand? yes.
Does it improve how settings are organized in drupal? yes.
Will it make programming for drupal less time consuming? yes.
Will this make drupal behave better in dev-to-stage-to-production enviroments? F#ck yes.
Will this in the end benefit non programmers? Yes: anything we can do reduce the number of settings someone has to mess with to make their site work is a good thing.
The real question for me is where are the bugs, and oddities in this patch that we need to fix before we include it.
Comment #13
kkaefer CreditAttribution: kkaefer commentedRerolled the patch for HEAD. Please review and point out bugs.
Comment #14
Nick Lewis CreditAttribution: Nick Lewis commentedComment #15
Nick Lewis CreditAttribution: Nick Lewis commentedWhoops... ;-)
Comment #16
webchickDid you even test this? :P
The update path needs to be changed to the correct format post-schema API. There don't appear to be docs for this yet, but see the most recent update for an example.
Comment #17
dropcube CreditAttribution: dropcube commentedMaybe you guys want to take up this again...
Comment #18
sunComment #19
mlncn CreditAttribution: mlncn commentedSubscribing and tagging.
Comment #20
peterx CreditAttribution: peterx commentedAn alternative approach: http://drupal.org/node/1369954
Enhance the variable storage functions so a module can store all the variables for the module as one blob. The content type code could use the same enhancement per content type. The change would benefit many modules.
The OO approach would overcome the silly content type settings variations where some are stored as strings in an array while others are booleans as strings . The could all be booleans in an object. There are several other modules with similar inconsistencies that could be fines the same way.
Comment #21
sunRe-purposing for new configuration system.
Postponing on initial conversion of taxonomy vocabularies in #1552396: Convert vocabularies into configuration, since that revealed a range of shortcomings in the configuration system already that need to be fixed first.
Comment #22
sunDowngrading priority. If anyone's interested, the architectural discussion for dynamic configuration like this happens in #1668820: Concept, base class, and interface for Configurables (e.g., node types, image styles, vocabularies, views, etc)
Comment #23
sunThis is the counter-part to #1779486: Convert Node module variables/settings into configuration now.
I'm on it.
#1564832: Remove _node_extract_type() and node_type_get_name() is a dependency and could use some reviews/love. :)
Comment #24
chx CreditAttribution: chx commentedThe issue referenced in #23 has been committed.
Comment #25
xjmMeta issue for these: #1802750: [Meta] Convert configurable data to ConfigEntity system
Comment #26
andypostSeems this duplicate of #1763974: Convert entity type info into plugins
Comment #27
tim.plunkettNo, this is bundles, not entity types.
Comment #28
swentel CreditAttribution: swentel commentedTaking over from sun for today and tomorrow (sun, feel free to help along of course). First patch moving content types to config entity.
Uploading patch to see what other failures we'll have. Upgrade path will be fail heavily, but want to see if there are others as well.
Comment #30
swentel CreditAttribution: swentel commentedThis should fix all tests. Removed all references to {node_type} as well.
Comment #31
swentel CreditAttribution: swentel commentedRe-assigning to sun again. If any reviews come in before tomorrow I can work on it some more, moving back to field api cmi patch again.
Comment #32
znerol CreditAttribution: znerol commentedDid not do a reality-check on those ideas but probably you should consider:
node_options_ . $type
,node_preview_ . $type
,node_submitted_ . $type
into the config entity, probably alsolanguage_content_type_' . $type
variables in the config entity.Comment #33
moshe weitzman CreditAttribution: moshe weitzman commentedThis looks totally straightforward and good to me.
Do we not need any changes to UI where you create and edit a content type? Also, do we need any typed data changes for the $node->type property? Isn't that a sort of entity reference like uid property?
Comment #34
moshe weitzman CreditAttribution: moshe weitzman commentedIdeally, we would update the Issue Summary as well.
Comment #35
sunUgh. There's (lots of) code for this already in the CMI sandbox; config-node-111715-sun
I'll have to compare the patch (which looks too simple to me based on its size) with the latest state in there and potentially take over any improvements.
Comment #36
sunAlright. I should have provided this earlier to indicate "progress", but the current state of affairs is still so anything-but-complete that this didn't cross my mind.
I merged latest HEAD, and also merged all additional/sensible changes of @swentel from the patch in #30.
As mentioned, this is anything but complete. Unlike other config conversions, the pre-existing node type forms are actually a bit more advanced, which means that they need the advanced form handling that is required for entity forms, which in turn means that this conversion will have to diverge from others and should directly do the conversion to EntityFormController as part of the initial config entity conversion.
The much larger offender is the Node Type API itself though. I have no idea how the patch in #30 was able to pass tests, but this conversion is not able to get around major adjustments in the Node Type API functions.
Comment #38
sun@swentel: Apparently, you did not have write access to the CMI sandbox yet. Now you have. ;)
Comment #39
swentel CreditAttribution: swentel commented@sun - I had no idea there was a sandbox for it, thanks for the write access. I've added my own branch but haven't committed the changes yet based on your work.
The reason mine is was so small (and passes) is because I wasn't as ambitious as your changes (eg, not removing hook_node_info for instance). I am/was merely interested to find out if converting node types was going to end up with the same problems that alex and I found out while converting Field API, see #76 / #77, and it is .. ;)
Anyway, Drupal installs now and most tests will pass, but you'll see I had to remove
entity_load_multiple
andentity_load
innode_type_get_types
andnode_type_load
. Not doing that will not even get you passed the installer. Pure inception hell :)Patch is based on your work, with interdiff attached.
Comment #41
swentel CreditAttribution: swentel commentedI haven't moved those into the config entity, but as separate config file in'node.settings.$type' since the amount of properties can not be determined since every module can alter the content type form and every item in there is automatically saved. We could store all those on separate property (say 'data') on the config entity, but I'm not in favor of that, but that's my opinion of course :)
Anyway, patch attached goes further on my patch from #30. Renamed 'ContentType' to NodeBundle, and machine name from 'contenttype' to 'node_bundle'. The reason I didn't choose node_type is because that name triggers hooks to be called like comment_node_type_load() in ConfigStorageController->attachLoad() ...
The 'node_options_', 'node_preview_', 'node_submitted_' and 'node_type_language_translation_enabled' are converted. Comment and menu variables are also saved in in the config file (but variable_set() is still used as I didn't want to go through all of those conversions yet) which raises an interesting question whether those settings should actually live in node.settings.$type or in a separate object, thus forcing other modules to add additional submit handlers to save their configuration.
Haven't added an upgrade path test yet, however there's already a test to verify that Blog is reassigned to node module, that's a good start, so I think this one will still be green.
Comment #43
swentel CreditAttribution: swentel commentedMeh, one stupid mistake in forum.
Comment #45
sunhook_node_type_*() being called is a desired effect and required behavior.
The entity type name should definitely be 'node_type' with a corresponding NodeType entity class.
Comment #46
swentel CreditAttribution: swentel commentedHaha, comment_node_type_load was a menu loader function, oh dear ... Anyway, back to NodeType. I left out the translation variable out for now, only node_preview, node_submitted and node_options are converted. I'll look a bit further moving the node_type into form_state - it looks like I'm simply going the other way around, but I'm afraid that at some point I'll stop as I have no clue to get around a call to
entity_load
without getting into endless loops.edit - re: my last remakr, in [#1552396#], the workaround is by using config_get_storage_names_with_prefix() in taxonomy_vocabulary_get_names() - that's afaics the only way to avoid the recursion, so I'm going to keep that approach as well. More changes coming up.
Comment #48
yched CreditAttribution: yched commentedMore and more patches are adding workarounds for this. Thus, bumped #1822458: Move dynamic parts (view modes, bundles) out of entity_info() to major.
Could we add a @todo with a link to that URL, for easier later tracking ?
7 days to next Drupal core point release.
Comment #49
swentel CreditAttribution: swentel commentedShould fix the last 3 fails.
Pondering now whether to move node_x to the config entity or not, and thus forcing to write submit handlers for menu, comment and translation - and notifying to everyone in contrib, hey, we don't save your variable anymore.
I'll work on the move to form_state now a bit though.
Comment #52
dagmarRerolled
Comment #53
tim.plunkettWouldn't this also mean that hook_node_info() is gone? Or is that a follow-up?
Comment #54
tstoecklerI think the new standard is to not actually drop the table in D8 in case any contribs reference it in any way. We should just leave it as is for now and add it to #1860986: Drop left-over tables from 8.x
Re #53: I haven't tried this out, but from the looks of it this patch keeps hook_node_info() in tact for now.
Comment #55
Gábor Hojtsy#1552396: Convert vocabularies into configuration just landed, might have patterns to follow, although vocabularies did not have an info hook for example for dynamic vocabularies :) Adding this for D8MI config language tracking too.
Comment #56
Jose Reyero CreditAttribution: Jose Reyero commentedLooks good to me. Just wondering:
- Why do we still need node.type.[type] and node.settings.[name] ?
- Why node.type.blog and node.type.page are not configuration files delivered with the modules?
However, I realize it may be the config system that needs some pattern to resolve these kind of issues, so none of this should block this patch.
Actually I think we should commit this one ASAP so we have time to figure out other issues depending on this one, like how the comment configuration for node types will look like / where should it be.
Comment #57
YesCT CreditAttribution: YesCT commentedHere is a follow up for #53 (based on #54).
Looks like the suggestion in #54 to leave the table in for now needs feedback. Other than that, this is looking ready.
Comment #58
tim.plunkettUpdated for #54, and added the manifest update.
Comment #60
tim.plunkettUrgh, just made the same mistake in the filter issue. Oh well.
Comment #61
tim.plunkett@swentel pointed out I added the manifest for the wrong thing.
Comment #65
tim.plunkettPatch context conflicted with #1874300: Remove $entity_type argument from field.module functions that receive a single $entity and #1814916: Convert menus into entities, no actual changes.
Comment #66
YesCT CreditAttribution: YesCT commentedIn #57 I mentioned a follow up but for got to link to it. Here it is:
#1872738: Remove Node Type API for in-code node types after Convert node/content types into configuration
Comment #67
sunFWIW, attached is an interdiff between #36 and #65.
I'm going to hack a bit on this now, stay tuned.
Comment #68
sunHeh. The upgrade path was completely wrecked here. :) {node_type}.name was the human-readable name previously, not the machine name. {node_type}.type was the ID. ;)
That's super-utterly confusing, because you'd expect a config entity that's using a "name" property instead of "id" for its machine name. Changing the 'type' and 'name' properties for node types definitely has to be a follow-up issue. (Not part of this patch, since just that change is going to be giant little monster.)
I also just noticed this gimmick in
node_type_save()
:From all the things we've discussed previously, I can't remember whether anyone raised this detail about multidimensional modularity. ;)
That's most probably THE killer argument for putting the settings right into node.type.ID config objects. Otherwise, we're running into quite heavy race conditions in the form of what gets saved first, and which module is able to access which data first, etc.
Still working on this.
Comment #69
sunHere we go :)
After trying hard to introduce BC layers to no avail, I realized it's taking too long and figured it needs to be done anyway, so I decided to perform a full stack conversion:
NodeType::getNodeSettings($module)
: Allows to retrieve the module-specific settings for a specific node type.The only part I semi-left-out is
node_type_form()
itself - the NodeTypeFormController simply calls into the existing procedural functions for now. This code can be moved in a follow-up issue.Manual testing worked fine, some tests also passed. Let's see what the testbot has to say. :)
Code lives in the node-config-111715-sun branch of CMI.
Comment #71
sunFixed a couple of oversights.
Comment #72
sunFixed bogus node settings access in template_preprocess_node() and node_permissions_get_configured_types().
Comment #74
sunFixed various variable name hiccups, cache ID mismatches, excessive cache rebuilds, and #type language_configuration processing.
interdiff (not the patch) contains additional debugging code for a really weird Exception triggered in entity_query(), which is invoked via drupal_cron_run() via field_cron() via field_purge_batch()... When a node type is deleted and Comment module is enabled, then the comment bundle's body field is marked for deletion, and the field purge batch entity_query('comment') bails out, because it cannot find a 'node_type' base table. — There is actually no entity query that would query it though. Instead, the field query seems to get heavily confused by the following part of
CommentStorageController::buildQuery()
, and actually mistakes 'node_type' as an entity table to join to instead of a field alias:Comment #76
sunSome remaining test failures are caused by this critical bug, which I just filed:
#1889620: config_install_default_config() overwrites existing configuration
Comment #78
sunMerged HEAD (conflicts).
Comment #80
sunJesus. And once more.
Comment #82
sunComment #84
sunComment #86
yched CreditAttribution: yched commentedSo we're back to talking about node type CMI files being a dumping ground for random data provided by other modules ?
AFAIK, the problems highlighted in #1783346-2: Determine how to identify and deploy related sets of configuration still stand, most notably:
Comment #87
BerdirRe-roll of the last patch. Agree with @yched in #86, we agreed on not doing that in that issue.
Comment #89
moshe weitzman CreditAttribution: moshe weitzman commentedAnyone available to reroll and review?
Comment #90
BerdirRe-rolled.
The patch currently has an endless loop when translation_entity is enabled, that's why it timed out before and I aborted it. So not testing.
The problem is that translation_entity_entity_info_alter() calls entity_get_bundles(), which obviously requests entity info again. That's just wrong :)
I think that either $entity_info['translation'] or the specific stuff that translation_entity works with should move into a separate hook and not be part of entity_info, as mentioned before :)
Edit: I'm not sure why it doesn't already blow up for terms/vocabularies...?
Comment #91
plachOriginally ET did not call
entity_get_bundles()
as bundles were available in the entity info and thus they were safe to get inhook_entity_info_alter()
. This comment is pretty clear:I guess this happened when splitting out bundle info from entity info.
If we are setting a pattern after which all dynamic/bundle-dependent data has to be moved outside entity info, this sounds the proper solution. I don't care too much, maybe stopping putting random stuff into the entity info might even be a good thing :)
Comment #92
BerdirYes, it did happen there, but as I said above, no clue why it works for terms/vocabulary, which work just like Node/NodeType in this issue.
Can you maybe get that issue started? I had a quick look but didn't fully understand how that property exactly plays together with what field.module is doing and so on. I'm happy to work on it and e.g. fixing tests but I think I need something to point me into the right direction. E.g, should the whole key be moved to a separate API/Hook or should we just move the translation_entity specific stuff into a separate, specific hook (which would have the advantage of being able to properly document it within translation_entity.api.php)
I don't even really understand why we need to support multiple things there, given that translation_entity is now in core and is *the* way to handle entity/field translations? Why would you not use it?
Comment #93
plachOk, I'll start some work on this ASAP. It seems #1446382: Need a reliable way to determine if a specific bundle for an entity type is translatable could be the right place where making this happen. Let's move over there and start discussing.
Comment #94
webchickThis feels like at least major; until this is done, we haven't really battle-tested the API.
Comment #95
gddI actually think its critical. Without this and the Field API conversion, we can't do anything even close to realistic user testing of the system.
Comment #96
Gábor HojtsyThis will also make all these config available for translation (once schemas are written for it that is).
Comment #97
YesCT CreditAttribution: YesCT commented#1446382: Need a reliable way to determine if a specific bundle for an entity type is translatable is rtbc (and this issue was waiting on that)
Comment #98
BerdirHere's a re-roll, this seems to have a few failures but it at least doesn't result in an endless loop in the translation UI test anymore. Yay :)
Comment #100
chx CreditAttribution: chx commentedThere's a failed merge marker in book.module but I am not sure how to resolve it.
Comment #101
BerdirI think like this. Also found two others in node.module and a now unecessary yml file for poll.
Comment #103
swentel CreditAttribution: swentel commentedShould fix a bunch of tests (DUBT tests installing node_type table) and a lot of Field UI tests because node_entity_bundle_info() was broken.
Comment #105
swentel CreditAttribution: swentel commentedFixes all tests but EntityTranslationSettingsTest - can't track immediately what is going on there.
NodeType has a 'disabled' property which we can probably swap with 'status'.
Comment #107
swentel CreditAttribution: swentel commentedThis will probably be green. The changes in language.module shouldn't be necessary at all (except node_update hook).
- edit - even that revert doesn't fix it yet - unless I add field_cache_clear(); in the assertSettings() method - but that doesn't feel like the right solution at all.
Comment #109
swentel CreditAttribution: swentel commentedRe-roll after #1924064: node_type_set_defauts has typo in documentaion got in - oh the irony ... still staring on the EntityTranslationSettingsTest()
Comment #110
swentel CreditAttribution: swentel commentedJust checking whether the reroll was fine though
Comment #112
BerdirThat was an interesting one :)
The NodeNG patch changed the instanceof check in node_access() to EntityInterface, which a NodeType is now as well. So we passed that to NodeAccessController (as node is hardcoded there) which then went through all checks, called hook_node_type_access() and as nobody implements that, decided that the user does not have access to create nodes.
This should fix most fails. It's ugly but node_access() will go away anyway.
Comment #114
BerdirDon't ask me why that test passes right now.
Note that all the changes in language.module have been added in this issue, the only remaining changes in ther are now related to the node type update hook.
Comment #114.0
BerdirUpdated issue summary.
Comment #114.1
YesCT CreditAttribution: YesCT commentedadding followup section
Comment #114.2
YesCT CreditAttribution: YesCT commentedadding a follow-up that was mentioned needs to be opened
Comment #116
YesCT CreditAttribution: YesCT commentedthis needs to be re-wrapped to 80 chars.
this might need a comment block. I made one, but a better description might be needed.
I made the type array, but maybe it should be * @var \Drupal\Component\Utility\Settings
how can I tell?
this is \Drupal now.
http://drupal.org/node/1354#classes
"If you use a namespace in documentation, always make sure it is a fully-qualified namespace (beginning with a backslash)."
if this is 'used' we just do the NodeType without the full path.
It's not used so leaving the full path.
check if the @param is typed
it was not. changed it to match this added type.
can we type these since we are changing them? Are they strings?
I made them be strings.
this gets public now.
http://drupal.org/node/325974
I think we type hint array in the function definition too.
hm. I think this gets saved differently. See point 7 in #1948884-14: Create configuration schemas for block and custom_block modules
Ignoring for now.
booleans are saved as '0' '1' I think.
I'm going to check the yml config files that were added and make them match the active saved config that is saved.
Comment #118
YesCT CreditAttribution: YesCT commentedthis has the configs as they are saved.
I took out the enabled from the forum and book ones.
I think the modified should come out too...
We'll need separate issues to fix the status: status format, similar to #1933548: Book allowed_types settings repetitive and in under certain conditions can change unexpectedly and #1928082: Make usage of book.settings:allowed_types consistent, to make it save as -status
I'm not sure how this relates to yched's concerns (#86)
Comment #119
BerdirThis should fix the test fails I think. I noticed that in HEAD, that submit callback is *not* called for the language content form and I honestly still don't quit understand why it's suddenly required, was it called manually and we removed that from the node type settings form? That would IMHO be an out of scope change.
Anyway, here's what I did for now:
- Re-add that snippet for #submit
- Added a check to not add it if it's already there
- Added a check to not add it when language_content_settings_form_submit() is already there because that's essentially a duplicate of that callback except with the different form structure.
Comment #120
Gábor HojtsyI don't want to impose config schema inclusion as the initial land criteria for this, so I opened #1958740: Create configuration schemas for content type config entities. However if people feel like including that here, feel free to. We have some people experienced writing schemas now, so we can find help either way.
Comment #121
tim.plunkettThis definitely looks like it needs to get fixed before commit. Not so sure about all of the other @todos
I'd rather see this as a method on the NodeType entity, but either way it has to include the entity and entity_type in the 'options' key.
What D7 behavior does this replace? I know that if you alter in arbitrary settings, they get saved, but I didn't know they got cleaned up as well. This just doesn't seem like node.module's job to handle.
Comment #124
BerdirRe-roll, conflicted with the changed edit/manage field links weight and the bundle API change.
Comment #126
chx CreditAttribution: chx commentedComment #129
BerdirI think that was just bad timing :) Let's see if this is better.
Comment #130
rbayliss CreditAttribution: rbayliss commentedI don't think this was intended.
Comment #132
BerdirRight, it wasn't. Also removed the installSchema() call in the failing test.
Comment #134
swentel CreditAttribution: swentel commentedFixing last tests.
I think it's time to a) for some in depth reviews, b) start identifying the remaining todo's and c) follow ups no ?
Comment #135
cosmicdreams CreditAttribution: cosmicdreams commentedYou could refactor $entity->entityType() . '_form' into a variable so you don't have to concatenate it multiple times.
I'll try to do a more thorough review later.
Comment #136
jibrantagging
Comment #137
swentel CreditAttribution: swentel commentedSo let's keep it at 'Needs review'
Comment #138
tim.plunkettWhat's all this?
Is this a follow-up or a blocker?
Booooo. Shoulda been NodeType::uri()
Um, sure :)
It's too late now, but these unneeded changes are a bit distracting
This needs options, with entity and entity_type
Comment #139
tim.plunkettI thought I was having some nasty deja vu during that review, and it turns out I gave an almost identical one in #121 but it was never addressed.
Comment #140
gddI just tried manually testing this and got the following in the installer:
Not entirely sure how this is passing tests given that
Comment #141
gddSo I went to a fresh install without the patch and encountered the same problem, so apparently its an environment problem. Ignore #140.
Comment #142
tim.plunkettNope, what @heyrocker saw was exactly the problem
These have been changed, see #1807042: Reorganizie entity storage/list/form/render controller annotation keys
Comment #143
swentel CreditAttribution: swentel commentedLot of changes, so here's a reroll with the interdiff. Re: tim's review of #138
1. This setting would have been committed in the configuration (like it is now in the variable ..) Added additional comment in code.
2. I'd say a follow up.
3. done
4. reverted
5. much simpler now
6. gone with the move of uri() to the class
Let's see what the bot thinks.
Comment #145
swentel CreditAttribution: swentel commentedStupid comma
Comment #147
swentel CreditAttribution: swentel commentedstupid entity
Comment #149
tim.plunkettRerolled. Fixed a couple remaining $form_state['entity'] instances, and moved node_type_form into where it belongs.
Comment #152
tim.plunkettAdded a NodeTypeInterface, now that we're doing that in the rest of core.
Comment #156
tim.plunkettWhile fixing that bug, I decided we might as well finish the job here and go with routes. Bye bye content_types.inc.
Also cleaned up the baseFormID stuff since that was bothering me.
Comment #158
tim.plunkettUgh. Don't make arbitrary changes to almost RTBC issues.
Comment #160
tim.plunkettOkay, restoring node_type_page_title for now. It will have to die later along with the later routing conversions.
Comment #161
swentel CreditAttribution: swentel commentedAnd while we're at it, let's add tests, create and update, haven't done delete yet.
Comment #162
tim.plunkettPatch fuzz conflicted with #1712250: Convert theme settings to configuration system, no changes, identical diffstat
Comment #164
swentel CreditAttribution: swentel commentedFailure due to #1292284: Require 'type' key in .info.yml files for node_test_config module
Comment #165
tim.plunkettAdded that
Comment #166
alexpottPatch looks really good... some very minor nits.
This should just be
$allowed_types[$old_key] = $type->id();
The keys here are numeric. No need to do theunset()
\Drupal::moduleHandler() is probably preferred...
As above... \Drupal::moduleHandler()?
hmmm... I think the functionality in
node_type_cache_reset()
probably belongs in the resetCache() method on the storage controller and we should not be callingnode_type_cache_reset()
from inside the controller.Do we need the !isset() here? don't think so. Also should be using Drupal::config()
Comment #167
tim.plunkettAddressed everything but the first point.
NodeType is config entity, so the keys are non-numeric. (right?)
Also fixed {@inheritdoc}
Comment #168
alexpottThis looks great! Over to catch...
Comment #169
catchOverall this looks great, but I found several things which look like they've been ported from having to maintain both node_type_save() and hook_node_info() to the config system which could likely be dropped. Also it looks like the docs for hook_node_info() aren't removed by the patch as well as at least one helper function. The structure of the YAML file is also a bit confusing as it stands, but that's largely due to metadata from hook_node_info() collection being ported direct to config as well.
Not entirely sure about returning an empty string for this. If an entity type doesn't have a base form ID, should it have this method at all? Not a commit blocker at all but don't know if it's worth a follow-up.
Really? Is this still used anywhere?
The disabled column in the node types table was only added because of hook_node_type() and disabled modules. It shoudn't be necessary for node types as config entity. (Also see below where the code that sets this is removed, I don't see anywhere that sets it now so we could just drop it.
Is custom needed when this is just default config? The book module doesn't require the book node type at all. Again how is this used?
Why would a default node type be modified?
What's status: status?
What's the difference between the status here, and the status in options, and disabled?
this is added, but forum_node_info() isn't removed.
Not sure why this hunk is necessary? Looks unrelated superficially.
mmmm lovely.
Maybe move the invalid types to a helper?
Yes!
Yes!
This is where the disabled property comes from, we don't need that any more.
If hook_node_info() is gone, so should this be.
Doesn't this load the config entity? Also why would we avoid it?
Comment #170
BerdirThe crazy hunk in language.module is necessary because of some changes that we made to the form handling, I don't fully understand how it worked before but it's pretty crazy stuff, see #119 and above, took myself and @swentel quite some time to figure that out.
The node type specific callbacks afaik still exist (hook_form(), hook_submit() and so on), not part of this issue to change that as it's not really related to how the node types are stored.
Comment #171
catchWell the node type specific callbacks are only called for node types created by hook_node_type() - that hook is no longer invoked and the node types were moved to config consistently, so I don't see how they make sense any more.
Comment #173
BerdirThose callbacks don't care how a node type was defined AFAIK, as long as $type->base . '_' . $hook exists as a function it's invoked.
We should absolutely kill that stuff. I see no reason to still support that and it seems that only very very few implementations are left in core (forum_form() being one of them) and I don't see a reason why you can't just use one of the trillion other hooks instead. But it's not related to this patch IMHO.
Comment #174
andypostRemoved remains of hoook_node_info() and some cleanups, still needs more work to address #169
Comment #176
andypostFixed config import after #1890784: Refactor configuration import and sync functions
Comment #177
andypostA bit more clean-up, will try to address disabled/module/status latter
Comment #179
andypostremoved modified property and reverted
node_type_page_title()
back'module' and 'base' could be merged in one property - they needed only for 'node_hook' and form builder
'disabled' could use default 'status' property of config entity
'locked' could be used as 'custom'
'custom' is used to allow delete only... so looks like 'locked'
there's places where disabled property used
Could be refactored in follow-up to use 'status' property of config entity
Comment #182
andypostmerge HEAD
Comment #184
andypostProper merge
Comment #185
andypostMerge after #1892182: #type details: Rename #collapsed to #open
Comment #188
andypostthe last patch included reverted #1892182-22: #type details: Rename #collapsed to #open
Comment #190
andypostre-roll with reverted #185
Comment #191
andypostAnother merge
Comment #191.0
andypostanother follow-up mentioned but not opened yet
Comment #192
aspilicious CreditAttribution: aspilicious commentedThis patch is taking way to long now. Feedback is kicking in to slow. I'm marking this rtbc again, so it get noticed by catch to give a final review.
Comment #193
catchMost of #169 hasn't been dealt with in the latest patch.
Comment #194
Gábor Hojtsy@andypost asked me to reflect on this from @catch in #169:
The patch removes an explicit addition of this submit callback from the form and looks like it wants to add a generic process routine to add it back without specifics in the concrete forms. Are you saying the submit callback should be specifically added in the form in a one-off way like it is before the patch and the generalisation left for another patch?
Comment #195
andypost#179 explains about properties, node_hook() and friends is out of scope of conversion, same for language element
The only questionable -
EntityFormController.php
changes and #194Comment #196
andypostJust a re-roll
Comment #201
andypostWe have no manifests now
Comment #202
catch@andypost I don't think the properties and nook hook are out of scope. Node hook has been for nodes defined by hook_node_info() and the properties like 'disabled' were previously internal to the node type API but now being exposed in default configuration - i.e. the YAML structure is a regression compared to what you used to have to provide for node_type_save().
Comment #204
andypost- Removed 'disabled,locked,custom' in favour of 'node.type.locked' state to allow modules (forum) to lock their types
- Fixed tests
- Changed upgrade path
Comment #205
andypostRemove module property
Fixed
Comment #206
andypostFiled #2018375: Get rid of node_hook and node_invoke and removed 'base' usage, actually only
forum_form()
implements this hookSuppose we should make active related #353494: Remove node_invoke(), comment_invoke(), etc
Also related #1268974: For disabled node types with 'base' != 'node_content', _node_types_build() does not return data about the type.
Comment #210
andypostFix upgrade path and tests
Comment #212
andypostCant reproduce failures locally
Comment #213
catchThis is looking much better. Didn't have an in-depth look through this time, but the node hook patch removed a lot of strange things in the config format.
I'm still having trouble figuring out what
status: status
is though.Comment #214
Berdir"status: status" is the "Published" checkbox, node->status.
Comment #215
andypostMerge HEAD, let's see how much broken (patch does not fix entity forms)
Comment #217
andypostFix forms and cleanup for node_hook()
Comment #218
BerdirLooks like you dropped the @todo but not the thing that should actually be dropped :)
Comment #219
andypost@Berdir yes, because I need to upgrade node-types that prevents deletion while their modules installed.
Currently only core's forum locks it's node type.
probably the condition should check custom + module_exists
Comment #221
andypostFix for #1893772: Move entity-type specific storage logic into entity classes
Comment #222
andypostAnother round of clean-up:
Removed
node_type_page_title()
,node_type_get_label()
,node_type_cache_reset()
node_get_type_label() should use entity_load() for node type.
Comment #223
andypostI think
node_type_get_names()
should care about language but now it always returns plain config values without care about of label language of the type.EDIT interdiff added
diffstat
64 files changed, 1409 insertions(+), 1394 deletions(-)
Comment #224
tim.plunkettYour interdiff is empty.
I'll be pleasantly surprised if this passes test, I'm the one who made changes to node_type_page_title() and I remember needing it
Comment #225
tim.plunkettHow is this supposed to work? hook_menu_alter cannot parse {bundle} correctly.
Comment #226
andypost@tim.plunkett I've got to debug this to find a way to rename this tabs
Comment #228
tim.plunkettYeah, as I said, we needed that. Please revert the changes in #222, and let's just finish this patch.
Comment #229
andypostReverted back
node_type_page_title()
let's see last failuresComment #230
andypostsmall fix
Comment #231
andypostShould be green now, reverts
comment_modules_enabled()
out of scope: Views handlers uses different sanitization/translation -argument does not use
t()
for type nameComment #233
tim.plunkett#231: content-type-111715-231.patch queued for re-testing.
Comment #234
tim.plunkettI still don't get this.
This can be injected now.
Should be marked public.
Comment #235
alexpottThe old key here is numeric... just do
$allowed_types[$old_key] = $type->id();
and move on... see book.settings.yml and the sort will blow away your nice keys anyway :)Everything apart from the change to the if here looks like it might be unrelated change. And there is no discussion in the issue as to why these have to be made.
Let's swap the node_access and entity_load around so you don't have to do the entity_load if you don't have access.
huh? like why is this change necessary - all we are doing is moving node types to CMI...
This doesn't look like it is named correctly...
$type->getNodeSettings('node')
is pretty weird :) ... I suggestgetModuleSettings
If we're converting this to a route we should inject this now...
Missing trim()
Why trim here... the code did not used to do this... if this is valid then we need to trim in the validate as well.
Can we get a followup issue created to address this? And link to it in the code.
Can we add links to the issues that should address this...
As above... lets rename this
getModuleSettings
. Also what are Node settings for a given module... is this not just settings for a specific module?Use String::checkPlain()
Use Xss::filterAdmin
Can be injected by extending EntityControllerInterface
Should inject the url_generator to do this.
This can be injected
Let's get a followup issue created and linked to from here...
Looks like this should go :)
Need to copy config from active to staging before running an import... use
$this->copyConfig($active, $staging);
before you write to the staging. Otherwise you'll lose the field config created in setUp().There is no manifests anymore... and this test needs the same change to copy config from active to staging before writing to staging as the previous test.
Node types are no longer in the database :)
huh?
I think we should just create an issue and not have an @todo... totally unrelated to this change.
Can we really assume that the module is going to be enabled during update. ATM the major upgrade instructions say that you should disable all modules before upgrading. I think this is likely to change but... also in tests above we've assumed the node type is still locked if the book module is disabled.
Can't this be removed and the
entity_page_label
callback used for admin/structure/types/manage/%node_type instead? Or in fact you are using drupal_set_title in the form anyway... shouldn't we just remove the title/title callback on this menu.I think we should be checking the interface here rather than the string... ie.
elseif ($node instanceof NodeTypeInterface) {
Comment #236
alexpottSo hmmm... I think this might need thinking about... (or I may be just over worrying)...
At the moment this will convert all node types... even those not created by node... so this obviously includes core modules like forum but also contrib. Is this the desired behaviour?
Comment #236.0
alexpottUpdated issue summary.
Comment #237
andypostFixed all except rename
getModuleSettings()
should be done in follow-up #2026165: Finish node type settings conversionUpgrade path and should be fixed in follow-up #1872738: Remove Node Type API for in-code node types after Convert node/content types into configuration
New 3 follow-ups are added to summary and @todo comments
Comment #238
andypostLanguage element for menu is landed #1945226: Add language selector on menus
So now we can use this approach here
Comment #239
tim.plunkettAs of #2027183: hook_menu() title callback is ignored on routes you can now use entity_page_label() here
Comment #240
alexpottWe can rename this to
getModuleSettings()
and fix the documentation. These are node type settings and Node is unnecessarily capitalised...Comment #241
alexpottThis @todo is unnecessary... I'm not 100% certain we need this. See #1933548: Book allowed_types settings repetitive and in under certain conditions can change unexpectedly
Comment #242
alexpottRe #241 we should definitely remove the @todo's as I've won't fixed the issue.
Comment #243
amateescu CreditAttribution: amateescu commentedRerolled and implemented the feedback from #239, #240 and #241.
Comment #244
amateescu CreditAttribution: amateescu commentedMissed a few renames.
Also, I reviewed the patch and the only odd thing that I found is that we don't include UUID's in the default config files. Isn't the new policy that we have to provide them now?
Comment #245
aspilicious CreditAttribution: aspilicious commentedYes we should add default uuids :).
Comment #246
andypostSuppose fixed all. Upgrade path comment needs English better then mine :)
Comment #247
amateescu CreditAttribution: amateescu commentedLet's do that then.
Comment #248
amateescu CreditAttribution: amateescu commentedHuge mess here :( Since @andypost's patch from #246 is very close to mine from #244, I just applied the uuid additions and tweaked a comment.
So, disregard #243, #244 and #247, the attached interdiff is for #246.
About @alexpott's question from #236, I think it's fine (and actually nice of us) to upgrade every content type. Otherwise we would have to provide an update helper function and force every core/contrib/custom module to do it on their own..
Comment #249
Gábor HojtsyI reviewed this for compatibility with operations altering, and based on how buildOpeations() is used and the list method is broken up, it seems all right. Nothing wrong found in that sense.
That is we expect to swiftly provide configuration translation user interface support for this in config_translation as soon as this lands :)
Comment #250
BerdirI think that should be getOriginalId()?
Edit: Ok, this is not added here, so rename is out of scope. Still don't understand why it exists and why 50% of the code uses this and the other part ->original->id()?
wondering why text.module is now necessary here?
Can't we just call $info->delete() here?
This now already happens in entity_invoke_bundle_hook(), should not be necessary here anymore?
Technically, the comment changes also wouldn't be necessary as there's only a single cache that we clear, but doesn't matter (the advantage would be that this hunk would not show up in the patch)
Below this uses $type->type. Should we change this too while we're at it? comment was changed but only because it had to be changed anyway. Don't care...
Well, yes, I can see that :)
Something like "Default settings for this content/node type" would be a more useful explanation.
Rly? DRUPAL_OPTIONAL? What a great name for a constant :)
Not relevant here of course, I just had to write this down.
We usually don't use the label() for form default values, as it's still possible to alter this. So I think this should use ->name for now.
Do we have a solution yet for making this not depend on a procedural function? :)
Probably call $this->entity->access('delete') instead of checking isLocked directly?
I think the node_form stuff is gone, so this shouldn't be necessary anymore. And 0 probably simply shouldn't be a valid machine name in general.
That should be covered with the #machine_name validation above?
Again, would be clearer if it would not use ->label() imho, but I don't care really.
We can remove this after #1995048: EntityListController::getOperations() should respect access checks.
Why does this have a D8: prefix?
I think references like this need the namespace...
Hm, interesting. Not specifying this in a callback means we don't have this by default and need to duplicate it everywhere. Might be missing in a few other places?
So we're misusing the resetCache() override just for this I guess? Are there other places that call resetCache() or should we simply inline this?
Should we use the code from language module or something else as example? Otherwise, we will have to remember to update this to config or something else when converting comments...
Entit*I*interface.
Not related to this but this totally needs to be a method on the node storage controller ;)
I think @catch already commented on this, is there a reason for this? This does seem to be almost the same as loading the full node type entity?
Why was this not necessary before? :)
Where is the body field added now?
Comment #251
amateescu CreditAttribution: amateescu commentedNice review! Much better than what I found (missing uuids) :P Just commenting on the points that I didn't touch in this interdiff.
Just for posterity because we discussed this in person, this is needed because the body field is now added in
NodeType::postSave()
Loading the config directly bypasses at least the load hooks, maybe there is a reason for this, but I've no idea tbh :/
Let's see what we broke..
Comment #252
amateescu CreditAttribution: amateescu commentedIt seems that we still need to validate against a node type name being '0' :-<
Comment #254
tim.plunkettThis blocks removal of MENU_LOCAL_ACTION, will handle in #2006624: Implement LocalAction plugins for previously converted routes.
Comment #255
amateescu CreditAttribution: amateescu commentedFixing it now :)
Comment #256
amateescu CreditAttribution: amateescu commentedsigh..
Comment #257
amateescu CreditAttribution: amateescu commentedThere we go.
Comment #258
amateescu CreditAttribution: amateescu commented@Berdir found another small issue, that our default config files are actually in english :)
Comment #259
BerdirOk, so I think the parts that can be addressed from @catch's, mine and other reviews have been. Things like the strangely named settings are still there, but we got rid of the unnecessary and weird stuff in the .yml files.
I did a relatively thorough review I think, so this should be in a fairly good shape. We also manually tested the UI with the validation stuff for 0 and the installer.
@catch, I think it's your turn again :)
Comment #260
alexpottAs this is not my rtbc anymore I think it is acceptable for me to commit...
Committed 46973e7 and pushed to 8.x. Thanks!
Comment #261
Gábor HojtsyYippidiyay!
Comment #262
Gábor HojtsyI added #2029405: Write configuration schema for node types in core and #2029407: Add support for node types in config translation as followups.
Comment #263
longwaveFixing tags
Comment #264
amateescu CreditAttribution: amateescu commentedOpened an issue for a small regression: #2029471: Regression: Content types do not respect all permissions defined by Field UI
Comment #265
andypostAdded https://drupal.org/node/2029519 and updated https://drupal.org/node/1818734
Suppose #2018375: Get rid of node_hook and node_invoke should refer to the same change notice so added about removal at the and of the notice
Comment #266
Gábor HojtsyAnd a WSOD in comment module: #2030913: Comment module WSOD due to old translation_entity module name used.
Comment #267
chx CreditAttribution: chx commentedtidied the change notice a little.
Comment #268
plachRestoring the origianl title.
Comment #270
andypostMaybe better to implement central service to lock entities - #2084567: Implement a EntityLockedInterface and service to allow locking entities
Comment #271
xjmUntagging. Please remove the tag when the change notification task is completed.
Comment #271.0
xjmadded follow-ups
Comment #272
xjmComment #273
klonos...added related issues a children -hid old files ;)