- Issue created by @acbramley
- First commit to issue fork.
- πΊπΈUnited States kappaluppa
Submitted as a new contributor mentored by @ultimike (thank you!) at DrupalCon Atlanta 2025 Mentored Contrib Day.
Added logging service via dependency injection in LinkFormater and LinkWidget.
Error can occur via bad migration data. It is not completely testable via admin UI.
Test by manually updating the link field uri via SQL:
- test LinkFormatter by using "testme" as uri value
- test LinkWidget by using "https://" by user without "link to any page" permissionWe spent all morning trying to figure this darn thing out, well, mostly Mike did. And many heads came together to solve a mystery that I won't go into here - let's just say that order of operations matter! We had lunch, got coffee and went potty. But, finally... victorious! See you at the next DrupalCon!! #drupalrules
- πΊπΈUnited States ultimike Florida, USA
Following up on @kappaluppa's comment...
This was a bit of a tricky issue to reproduce as the form validation doesn't allow us to add an invalid link from an add/edit page that triggers the exception that needs to be logged. To get around this, we created a node with a link field with a valid URL, and then modified the uri value directly using SQL (see values in previous comment.)
Invalid values like this can be created via data migrations with malformed urls (as migrated link uri values are not always validated.)
Tests are still needed for this issue.
-mike
Can the work done to this point in the issue fork be turned into an MR (draft, if preferred), to make it the base of any effort going forward?
The tests added for π Link-widget throws exception when rebuilding a form with an invalid uri Fixed and π Uncaught exception in link formatter if a link field has malformed data Fixed might be good starting points for testing the logging added here, though perhaps π Uncaught exception in link formatter if a link field has malformed data Fixed .
Drupal\Tests\language\Kernel\LanguageNegotiatorPluginTest
might also provide an example of how to use the BufferingLogger class to assert expected messages were logged.