Needs work
Project:
Drupal core
Version:
main
Component:
configuration system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
7 Dec 2014 at 18:23 UTC
Updated:
30 Jan 2023 at 21:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nedjoPatch.
Comment #3
nedjoFix typo.
Comment #4
nedjoComment #5
nedjoComment #6
jhodgdonI was asked to comment here because of my sandbox module Configuration Revert
https://www.drupal.org/sandbox/jhodgdon/2391835
However, I do not think that the methods here will be useful as they are for Configuration Revert. The first function getConfigTypes() is only returning the labels for the config types, and Config Revert needs to get the definitions because it needs more information, so this method isn't useful at all. The second function, getConfigByType I can't use either. So I'm not against adding these if another module can use them, but Config Revert can't really use them as they are.
It does look like the getConfigTypes idea is good because it is used even in Core twice. I'm not so sure about getConfigByType though. And I'm also not sure they belong on the class where they were put, because neither of the classes in Core that use these methods had that service injected previously. ??
Regarding the specifics of this patch, there are some small formatting, naming, and documentation issues:
a) This patch could be smaller if the new arguments to constructors and new member variables were added at the end of existing ones instead of at the middle. It makes it a bit hard to read the patch. Would you consider that change? For example, in the Export form:
If you had left configStorage wehre it was, and added the configManager to the end, the patch wouldn't have had all these bogus changes in it.
Then... in the interface:
b) There's an extra line at the end here.
c) Name: "getConfigTypes" doesn't seem like the right name for a method that just returns the names of the config entity types plus "simple configuration".
d) The docs needs to say what the "machine name" is of "simple configuration", because that is not obvious.
e) "avaialble" is misspelled.
f) First line doc should start with "Returns" or "Lists", not "Get".
Now, also in the interface:
g) This needs a one-line summary. Put the second sentence into its own paragraph.
And also in the interface:
h) First line should start with "Returns", "Lists", or "Gets", not "Get".
i) You need to document about what to pass in to list basic configuration that isn't an entity type.
j) I'm again not sure about the method name. "getConfig" says to me that it should return config, but really it's just listing the machine names and labels.
k)
This adds a @param doc but nothing was added to the method???
Comment #7
nedjo@jhodgdon: thanks for the detailed review and tips!
I've made changes to address the issues.
Yeah, I'm not sure either. They didn't seem to fit in any of the services already injected but I'm not sure if ConfigPackagerManager is right either. They might belong more in a set of config utilities, but there I didn't find such. Suggestions or pointers appreciated.
Besides fixes, the one change I've made is to add a boolean argument
$include_simple_configtolistConfigTypes(), on the assumption that there's a use case for fetching only config entity types.Details of fixes:
a) moved service additions to end of existing list
b) removed extra line
c) renamed method to list rather than get
d) documented machine name of simple configuration.
e) fixed "avaialble".
f) fixed verb in first line of documentation
g) moved second line to its own paragraph
h) fixed verb beginning first line of documentation
i) added documentation on simple configuration machine name
j) renamed method to use list rather than get
k) removed unrelated documentation fix
Comment #9
nedjoFix up
ConfigManager::listConfigTypes().Comment #10
dawehnerwhat about name it
entityTypesinstead?Note: You could use ConfigEntityInterface::class instead
I'm wondering whether this constant really belongs into the config manager. It feels to belong more into
\Drupal\Core\Config\ConfigBaseinstead, but yeah, not entirely sure.Should we typehint a bit stricter here and use
ConfigEntityInterfaceinstead?should we use array_filter here maybe? It would be a bit more explicit what is going on.
Note: We use 'bool' not 'boolean'
Comment #12
james.williamsHere's a re-rolled patch (still for 8.1.x, as that's what this issue is for... should it be made against 8.3.x now though?), including the dawehner's suggestions. For his point 3, I reckon the constant should remain in ConfigManagerInterface as that's the 'contract' for the code as an interface and, more relevantly, part of how the config should be managed as opposed to how the config 'exists'. But I can certainly see why it might want to go in ConfigBase instead - I can re-roll with it there if preferred.
Comment #14
james.williamsJust the wrong class suggested in point 4, I think :-) Changed to ConfigEntityTypeInterface, and in more than one place since the same change could be made in listConfigTypes() as well as listConfigByType().
Comment #15
james.williamsComment #16
jhodgdonComment #17
james.williamsHere's a re-rolled patch against 8.3.x - I'm glad someone noticed :-)
Comment #18
jhodgdonI have a few small suggestions on the current patch -- which mostly looks good to me and I think satisfies all the goals of the issue summary:
I'm not sure about the word "Tracks" here. I think most of our variable doc blocks don't start with verbs.
We use [] not array() in Drupal 8 code as a general rule.
I am not sure if we can add functions to public interfaces at this stage of Drupal development. Any other classes that implement the interfaces would immediately be invalid (PHP errors if they don't implement the methods).
So, we might need to put these two methods in a different interface, and make ConfigManager implement that one in addition (classes can implement multiple interfaces).
If we're fixing up this line of code, it should also be converted to use [] instead of array() syntax.
Comment #19
james.williamsThanks - here's a patch+interdiff implementing those suggestions. I went with calling the new interface, 'ConfigListerInterface', which I hope is reasonable.
Comment #20
james.williamsComment #22
james.williamsArgh, missed the actual file for the new interface, sorry. Try again...
Comment #26
nedjoTagging for potential CMI 2.0, see #2957423: Proposal: Configuration Management 2.0 initiative.
Comment #31
hardik_patel_12 commentedRe-rolled against 9.1.x-dev
Comment #33
hardik_patel_12 commentedSolving failure test cases.
Comment #34
hardik_patel_12 commentedComment #36
hardik_patel_12 commentedSolving failure test cases.
Comment #37
jhodgdonThanks for the updates!
This latest patch has some problems:
Two problems here:
a) There was not a new @param added to the doc header in the constructor.
b) The type hint for the new argument is ConfigManagerInterface, but the methods called later in the class, listConfigTypes() and listConfigByType(), are not on that interface but is instead on the new interface added to ConfigManager [see also previous item in this review]. So the type hint is not really correct.
Comment #38
suresh prabhu parkala commentedI have tried to add new methods in configManager as per issue summary and also tried to solve the issues mentioned in #37. The patch is here please review.
Comment #39
hardik_patel_12 commented@Suresh Prabhu Parkala, thank you for the patch but can you kindly provide interdiff also, so it will be helpful for other to keep tracking.
Comment #40
suresh prabhu parkala commentedInterdiff file for patch #36 and #38.
Comment #41
jhodgdonLooking at the interdiff... I don't understand why this change was made in the ConfigManager class:
We don't normally want blank lines after // comments, and even if we did, it doesn't seem to be related to this change?
But... actually I don't see that in the actual patch at all??? So I question whether the interdiff file is accurate?
So I went back to the actual patch in #38, which looks fine actually.
I do have one question though: By changing the key system.simple to system_simple for simple config, we are changing the URL that is used to export simple config, as you can see in this change in the test:
We need to see if this change is allowed for backwards compatibility. I kind of doubt that it is, and I'm not sure why we changed this value in the patch... there doesn't seem to be any discussion about it in this issue that I can see -- it is just in the issue summary and even though I possibly wrote the line in the issue summary about it, I'm not sure what exactly the implications are....
Comment #47
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.