Problem/Motivation
language_save()
and language_delete()
are remnants of the pre ConfigurableLanauge config entity days and should be removed.
#2334763: Tidy up of LanguageInterface - removal of setters and other unnecessary methods is postponed on this.
Proposed resolution
Remove the function and refactor code to use ConfigurableLanguage::save() and ConfigurableLanguage::delete()
language_save()
and language_delete()
where introduced in Drupal 8 so the change record (https://www.drupal.org/node/2336669) is for Drupal 8 to Drupal 8.
Remaining tasks
- (done) review
- (done) change record draft
- Commit.
User interface changes
None
API changes
Removal of language_save()
and language_delete()
.
Minor change in language add/edit form (name => label) to reflect the property naming of ConfigurableLanguage.
Comment | File | Size | Author |
---|---|---|---|
#16 | 2336177.16.patch | 98.65 KB | alexpott |
#16 | 15-16-interdiff.txt | 1.6 KB | alexpott |
#15 | interdiff.2336177.14.15.txt | 1.5 KB | YesCT |
#15 | 2336177.15.patch | 98.55 KB | YesCT |
#14 | 2336177.14.patch | 98.34 KB | alexpott |
Comments
Comment #1
alexpottComment #3
alexpottFix tests and tidy a couple of config language creations in tests up a bit.
Comment #4
alexpottThe only two issues I think we need to decide is:
Comment #5
alexpottRe:logging - actually maybe the form is best - that is where we do it for node types.
Comment #6
Gábor HojtsyReviewing #3. This results in mostly much nicer code, yay :) Especially like the more standard entity form for language. As for where we log, I don't think we have a standard. I don't think we answered questions like "Do we want to log all the changes separately one by one when a config import happens?". We may want to ask that question sometime. Historically we have not been very consistent with our logging unfortunately.
Right, we can remove it here. Do we have tests / core to ensure locked languages cannot be deleted through the UI though? Yes they don't appear on the list/form but they still have a delete URL that should throw a 403 or 404.
Why not use static create on the class here? Like everywhere else.
Forms have an injected logger, no? Your other changes to forms use $this->logger
Comment #7
alexpottThanks @Gábor Hojtsy. Fixed everything from #6.
Comment #8
andypostAwesome clean-up!
Suppose logging needs separate issue to unify (prefer forms because this is a place where visitors interacts by changing data).
Locking of config seems still tricky, the node-types is another example.
Maybe better to provide an actual locking of config with dependencies somehow
is there other way to prevent delete or module uninstall?
Comment #9
alexpottRe #8 well it's certainly not for this issue to address. Using LanguageDeleteForm to delete a locked language because it only allows deleting of languages with LanguageInterface::STATE_CONFIGURABLE - ie. not locked languages.
Comment #10
alexpottAdded #2336689: Test that a locked language can not be deleted through the UI to test deleting of locked languages through UI since this issue does not change anything in that area but we are lacking test coverage.
Comment #11
alexpottComment #12
Gábor HojtsyYeah I tested admin/config/regional/language/delete/und manually too and it throws a 403 perfectly. I certainly don't have any more concerns with #7 and I reviewed the change notice draft as well on IRC and made suggestions for improvements. Looks good to me.
Also reclassifying and retitling as a bug, since the after-effects code in language_save and language_delete now non-standard wrapper functions makes it impossible to use ConfigurableLanguage to create and delete them without needing to take care of the after effects separately. Once we integrate them into the config entity, the after effects happen properly on eg. config import or any other use of the API as well.
Comment #13
alexpottYep I agree that actually this is a bug due to the after effects. Also this should be a major beta target since correct usage of CMI is important for D8's success.
Comment #14
alexpottRerolled due to #2333907: FormatDateTest incorrectly implying a change to local interface language variable will change global assumed interface language langcode
Comment #15
YesCT CreditAttribution: YesCT commentedI saw this was just a re-roll... so read through it hoping to just re-RTBC it. but... since I read through it:
0.
one thing to note is that so many 'name' to 'label' changes are because the object is changing from Language to ConfigurableLanguage and ConfigurableLanguage uses the 'label' property, not 'name'. ok.
this is in here a few times. shouldn't we use a setDefault() ?
Probably a separate issue.
needs a doc block.
nit. fixed.
extra newline.
nit.
fixed.
add the doc line.
fixed.
also added the @return for this new method.
extra space.
nit.
fixed.
just noting that in a bunch of places, this kind of simplification was done. Probably the test did not rely on the name or the direction. So now they are not customized. (create defaults to re-using the langcode as the label if label was not specified).
I was wondering about this set default. why dont we have to unset the old default?
was this broken before? why did you need to set the default to true?
are we going to eventually convert this to pass in the weight to the create method? or have a setWeight()?
I'm not sure about this. why all this setting up of the default language to replace the language_save()? $default_language is set up above. maybe it doesn't need to be now?
Or... hm.
ok. this is just taking out code creating english... which is silly, if the tests are a standard install, they will already have english.
this does not match the same pattern as the other replacements. It is not using the set(weight). and it is not taking out the 'name' and using label, etc. hm. Maybe because this is followed by a save() and not by a drupalPostForm().
ok. $languages was unused anyway.
hm. but this create is changing 'name' to 'label'...
this is good. but I'm not totally sure why it's necessary to change ->id to ->id() in this patch. but ok.
why? are we setting default to protected here? no. I dont understand this change.
why are we ok taking out unsetting the old default to false again?
we are not taking out the setting of name here? we took it out in other places where the label/name did not matter.
Comment #16
alexpott1. I want to review which set methods belong on ConfigurableLanguage interface in #2334763: Tidy up of LanguageInterface - removal of setters and other unnecessary methods. Doing it this way means we can protect the properties and change the methods as we like.
6. Using the createFromLangcode method uses the predefined language information to populate the name/label
7. Because a language's defaultness is not actually saved to the language :) it saved on the container and there can be only one default (this is a massive simplification compared to previous Drupals)
8. Because in the original test the original default language was not reloaded. Now it is - meaning it is no longer the default language so we have to set it back
9. See answer to #1
10. See answer to #8
12. Fixed. In a way that removes as much unnecessary stuff as possible.
14. Yes label is the ConfigurableLanguage property that we want to set.
15. Because $language is now a config entity and this is how we access their IDs. Yes it is public for the ConfigurableLanguage but accessing it publicly is wrong.
16. Because $language is now a config entity and I don't want to access their properties publicly and this way does not and we can sort out the interface in #2334763: Tidy up of LanguageInterface - removal of setters and other unnecessary methods
17. See answer to #7
18. Because we are also setting the default property and this is not using createFromLangcode(). However changed to match how I resolve #12
Also I really don't think we should care too much about about configurable languages are created and their properties set in tests. This usage should not define their public APIs - if a method is only being used in tests it probably should not be there.
Comment #17
Gábor Hojtsy@YesCT: re point 0, yes the ConfigurableLanguage has a label instead of name so the API is a bit different. But @alexpott also fixed the form to reflect the ConfigurableLanguage properties, which is why $edit keys needed to change as appropriate also.
The minor cleanups in #15 are great, the further cleanups in #16 as well. I also agree with @alexpott's reasoning which is why there was so little in the end to correct from #7. So AFAIS back to RTBC.
Comment #18
YesCT CreditAttribution: YesCT commented@alexpott Thanks a lot for the response.
Looks good to me also.
Comment #19
YesCT CreditAttribution: YesCT commentedhm berdir pointed out that this draft change record
https://www.drupal.org/node/2336669
got tweeted
https://twitter.com/drupal8changes/status/510226011301371904
I'm not sure where to report that.
#2292469: [meta] Improve change records doesn't mention the twitter bot.
[EDIT]
@tvn gave me the issue via irc: #2337375: Feed showing draft change records
Comment #20
YesCT CreditAttribution: YesCT commentedre #17
ah, I see here in the LanguageFormBase. :)
Comment #21
Gábor HojtsyYesCT re #19 #2337375: Feed showing draft change records
Comment #22
YesCT CreditAttribution: YesCT commentedComment #23
YesCT CreditAttribution: YesCT commented#2337585: add a Entity::deleteMultiple() to replace procedural entity_delete_multiple() for a question that came up in irc regarding this.
Comment #24
YesCT CreditAttribution: YesCT commented[edit: oops. posted to wrong issue.]
Comment #25
catchCommitted/pushed to 8.0.x, thanks!
Comment #27
Gábor HojtsyYay, thanks a lot! Published the change record.