New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #12454 by having Coalesce handle null values #12456
Conversation
Hi there @arknu, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Thanks @arknu 💪 |
Thanks for spotting and solving this @arknu 👍 I maybe have a question or two for you and @bergmania as well before merging. I am wondering if the switch of parameter to Also, if I may suggest, I would put it all in the FirstOrDefault clause:
This way, we check the param arguments one by one and stop at the first one that fits, and therefore we avoid building first a list with all of them transformed ToString and then going through that full list to find the first non-null. What do you think? 😁 Cheers! |
I guess in a |
@bergmania @mikecp With nullable reference types enabled (which it is by default in v10) the @mikecp Regarding your second suggestion, yes that would work as well. I was mainly looking to make the smallest change possible, since v10 is close to release. And also trying to match all the other helper methods. I think that if it should be changed, that should be a separate PR for all the helper methods at once. |
Hey @arknu, @bergmania , Thanks for your quick feedback about the nullable reference types (was indeed forgotten), and it's indeed good to remain consistent with the other helper methods 👍 So let's merge this now 🎉 |
I do think, however, that normally we now target v10.1.0 for the community contributions, but I let @bergmania and/or @nul800sebastiaan decide if this one is a candidate for the initial v10.0.0 release 😁 |
@mikecp @bergmania I think this needs to be in 10.0. For me it broke several sites when I upgrade, since we use coalesce quite heavily. |
I'll cherry pick for 10.0 |
commit 9ff06ee Author: Ronald Barendse <ronald@barend.se> Date: Wed May 25 11:16:39 2022 +0200 v10: Instantly reload ConnectionStrings after saving configuration (#12475) * Do not replace DataDirectory placeholder when setting connection string * Ensure ConnectionStrings options are updated when configuration is reloaded * Use CurrentValue to get default Umbraco connection string commit fcee6dc Author: Paul Johnson <pmj@umbraco.com> Date: Wed May 25 10:08:43 2022 +0100 Fix legacy scope provider no longer implementing ICoreScopeProvider (#12480) commit 88f3628 Author: Paul Johnson <pmj@umbraco.com> Date: Wed May 25 09:49:33 2022 +0100 Fix options monitor setup for connectionstrings (#12472) commit 4eeb03e Author: Johan Runsten <jrunestone@users.noreply.github.com> Date: Wed May 25 10:13:25 2022 +0200 Fixed null check typo in CacheInstructionService. Fixes #12473. (#12474) * Fixed null check typo. Fixes #12473. * Removed unneccessary null forgiving operator Co-authored-by: Johan Runsten <johan.runsten@toxic.se> commit d810d66 Author: Asbjørn Riis-Knudsen <ar@jf-data.com> Date: Tue May 24 17:41:10 2022 +0200 Fix #12454 by having Coalesce handle null values (#12456) * Fix #12454 by having Coalesce handle null values * Allow null values in Html.Coalesce #12454 commit 963d4c5 Author: Paul Johnson <pmj@umbraco.com> Date: Tue May 24 13:55:39 2022 +0100 Ensure unique buildnumber for devops UI
Prerequisites
This fixes #12454
Description
This makes the Coalesce method able to handle null values again. This seems to have accidentally been removed in v10. Since the whole point of the Coleasce method is to choose the first non-null value from a list, this is a problem.
This PR uses the null coalescing operator to handle null values.
To test, call Html.Coleasce in a view, with one of the values being null. Without this PR, it will crash. With this PR, it should work like v9 and return the non-null value.