Problem/Motivation
The linkit.autocomplete route contains a slug for the {linkit_profile_id}. The controller then loads the LinkIt profile with the given id. However, Drupal supports parameter upcasting to do this automatically, see https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/pa...
Proposed resolution
Upcast the linkit profile in linkit.autocomplete route.
Remaining tasks
- Write a patch
- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3212820-backwards-compatibility_19.patch | 4.03 KB | mark_fullmer |
Comments
Comment #2
idebr commentedAttached patch upcasts the linkit profile in linkit.autocomplete route.
Comment #4
idebr commentedAttached patch should fix the test failures.
Comment #6
idebr commentedAttached patch should fix the remaining test failures.
Comment #7
idebr commentedReroll against latest 6.1.x
Comment #8
idebr commentedAttached patch adds some additional changes to the test files to fix test failures.
Comment #11
mark_fullmerThis change makes sense to me. Thanks for the clear explanation, and the updated test coverage! Merged into both the 6.0.x and 6.1.x branches.
Comment #13
a.dmitriiev commentedThis was actually a breaking change :) all the places in code where
linkit_profile_idwas passed to Url object are now brokenComment #14
mark_fullmerThanks for reporting this. Can you clarify if you're talking about code within the Linkit module itself, or code which extends this module?
Comment #15
a.dmitriiev commentedI meant the third party code in custom modules (maybe also there are contrib modules that use linkit as a dependency, but I don't know any).
Comment #16
a.dmitriiev commentedI think this change deserves at least change record and a big section on the main project page.
Comment #17
mark_fullmerThanks for clarifying. I honestly hadn't anticipated that there would be any 3rd party code that would extend Linkit in this way. Failure of imagination on my part. I agree that a change record would be a minimum thing to call out, but I'm leaning toward a more standard process of deprecating this before removing it altogether (in a new major version release)
Comment #18
samlerner commentedI just ran into this problem in my Drupal 10.1.4 site. Trying to add new menu items tries to load the
linkit_profileslug in the autocomplete path, but it's namedlinkit_profile_idin some custom code we had. This triggered the following error:We can update our code, but it took us some time to figure out what was happening.
Comment #19
mark_fullmerBased on my reading of https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/pa... , we can maintain the legacy route name
linkit_profile_idwhile still using the automatic upcasting that this issue provides. The variable name will be less than ideal, but I'm okay with that to maintain backwards compatibility in custom code.Can someone who has experienced this issue in custom code test the attached patch? This should apply whether you're using 6.0.x or 6.1.x.
Comment #20
samlerner commented@mark_fullmer tested the patch in #19 and it fixed the problem I was having earlier. Thank you!
We'll keep our updated code, but this patch will save some poor souls from WSODs.
Comment #21
trackleft2Patch in Comment#19 worked for us too, thanks @mark_fullmer
Comment #24
mark_fullmerThanks for the input, everyone. Backwards compatibility has been included in follow-up releases 6.0.1 (Drupal 9.5->10.0) and 6.1.1 (Drupal >=10.1).
Comment #26
joegl commentedWe ran into the same issue on 6.0.1:
Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("linkit_profile") to generate a URL for route "linkit.autocomplete". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 181 of core/lib/Drupal/Core/Routing/UrlGenerator.php).Confirming upgrade to 6.0.2 fixed this.
Thanks!