Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Dec 2018 at 23:40 UTC
Updated:
6 Jan 2019 at 13:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirTurns out we have a few more calls left than I expected, but I guess this was a good relaxation exercise or something ;)
Comment #4
berdirFixed syntax error in user.api.php.
Comment #6
berdirLets see what's left now. Interestingly, toLink() on ConfigEntityBase() does *not* default to edit-form, unlike link(), url() and toUrl().
Comment #8
berdirI think @Wim and I discussed about that call in the issue when we refactored getEntityUri(), I would have liked to remove it already then as it means we *are* calling a deprecated method.
Question is if this is breaking BC, but then only if someone is relying on a method that was deprecated already before 8.0 so they already had inconsistent behavior. And just like File does, they can override the normalizer then.
The only alternative would be to flag all these tests as @legacy I think but they're not.
Comment #9
alexpottLooking at the code in \Drupal\Core\Entity\Entity::toUrl() shouldn't we be calling that here to give things that implement
uri_callbacka chance?Comment #10
berdirMaybe, uri_callback is also pretty much dead and broken and deprecated :)
Definitely not for new/not having an ID, that's an immediate exception. and if there is no uri_callback, it will also throw an exception, I don't like having to wrap it in try/catch.
Comment #11
alexpottAh I see the following code is in the url method already...
So yeah the whole not having a link template situation is meh and the change in #8 seems good to me.
Comment #12
wim leers👏
Comment #13
alexpottI think this change will break contrib. We need to think a bit harder about config entities ::toLink() method.
Comment #14
alexpotttest needs renaming. And so does
providerTestUrlInfo- or maybe this should be the legacy urlInfo test as with the current change it does not appear to be testing anything and we need a legacy test to for urlInfo().We also don't appear to have any test coverage of the ::link() deprecation.
The existing testUrl and testUrlEmpty are good coverage for the url method.
Comment #15
berdir> I think this change will break contrib. We need to think a bit harder about config entities ::toLink() method.
Yes, it's unfortunate that this is inconsistent, but it has been like this since 8.0, anyone who used the non-deprecated method already had this problem.
I was never a fan of the hack that ConfigEntityBase is doing and I know that for example webform is actively undoing that again.
Changing the default *now* would be a bigger problem IMHO. The thing would I guess be a note on the change record about this behavior change.
Nothing happens automatically to their existing deprecated code, *only* when they convert to toLink().
Comment #16
alexpottAh phew... I thought somehow the behaviour of toLink() was changing. So things seems okay - yes inconsistent but that is already the case and not caused by this patch. It does mean we have to review all the link() -> toLink() conversions very carefully - especially any that are generic.
Comment #17
berdirFixed legacy test coverage of urlInfo() and added something similar for link.
Comment #18
kim.pepperThanks @Berdir. Looks like all feedback has been addressed.
Comment #19
alexpottI think it worth mentioning that the defaults for configuration entities have changed on the deprecation message for
::link(). This seems something that couyld catch people out and documenting this is helpful.Also the ::url() deprecation notice could be helpful and mention the return type change from string to a Url object and to use
toString()if that is needed. The other thing is not handling new entities.I think these notices need to help people avoid errors in their code.
Comment #20
berdir@alexpott I'm not quite sure how to get that information into the fairly limited space we have for deprecation messages.
I expanded https://www.drupal.org/node/2614344 with notes on the changes that callers need to be aware of, is that enough?
I feel like this should not be a huge issue for contrib/custom as these deprecations happened years ago before 8.0 and I would assume most people used the new ones usually. That said, http://grep.xnddx.ru/search finds plenty of cases where they still appear. e.g. 20 pages of urlInfo( and 16 of ->url( vs 60+ of ->toUrl(,
Setting to needs review to get feedback on that.
Comment #21
alexpottI suggest:
Yes the lines are long but the detail is really helpful.
Comment #22
berdirThanks, updated the patch.
Comment #23
alexpottThanks @Berdir - let's get this done. This has been rtbc in #18 and was only sent back for improvements to the deprecation messages.
Comment #24
alexpottCommitted 60505f3 and pushed to 8.7.x. Thanks!