fix: getCurrentEntryId() should return null instead of false#5416
fix: getCurrentEntryId() should return null instead of false#5416MikeyBeLike wants to merge 1 commit intoLaravel-Backpack:mainfrom
Conversation
|
hi @MikeyBeLike Since this change could break some compatibility, we will add it to our to-do list for v7. However, we see it as feasible to apply this modification for that version. Thank you for your contribution. Cheers. |
would it make more sense to update the files that are using nullish coalescing (??) instead? as the current implementation is broken anyway: e.g instead of do this: |
|
Hey @MikeyBeLike it would still a BC, because previously if the entry was not found with If now we return the Thanks for your patience 🙏 |
WHY
BEFORE - What was wrong? What was happening before this PR?
getCurrentEntryId()returns false, but ideally it should be returning null if unable to retrieve a value.There are also several places in the codebase that use this line to get the crud ID:
A few files:
src/app/Http/Controllers/Operations/DeleteOperation.phpsrc/app/Http/Controllers/Operations/ListOperation.phpsrc/app/Http/Controllers/Operations/ShowOperation.phpsrc/app/Http/Controllers/Operations/UpdateOperation.phpThis will never allow you to fallback to
$idusing null coalescing since it returns false and doesn't return null.AFTER - What is happening after this PR?
change the return type from false to null, so that we can make use of fallbacks via null coalescing
HOW
How did you achieve that, in technical terms?
update the return type from false -> null
Is it a breaking change?
potentially if people are strictly checking for
FALSEbut if looselynullis falsy so should be fineHow can we test the before & after?
??
If the PR has changes in multiple repos please provide the command to checkout all branches, eg.: