You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(it doesn't matter if the relationship is registered on the model or not since the code never checks if it exists)
See error:
Uncaught TypeError: t is null
getIdentifier http://beta16.flarum.localhost/assets/forum-31c35670.js:1
save http://beta16.flarum.localhost/assets/forum-31c35670.js:1
exports http://beta16.flarum.localhost/assets/forum-31c35670.js:822
e http://beta16.flarum.localhost/assets/forum-31c35670.js:1
Expected Behavior
It should be possible to pass an empty value for hasOne relationships, just like it's possible to pass an empty array for hasMany relationships.
If the relationship value isn't an array, it's passed to Model.getIdentifier without checking if it's null.
Either Model.getIdentifier should pass through null values, or Model.getIdentifier should not be called if the value is null.
Additional Context
I'm using this in a yet unreleased extension. As a workaround I am using a local patch that makes Model.getIdentifier return null if the model argument is null.
The text was updated successfully, but these errors were encountered:
Bug Report
Current Behavior
A javascript error is thrown when using
Model.save()
to save anull
value on ahasOne
relationship.Steps to Reproduce
Run:
(it doesn't matter if the relationship is registered on the model or not since the code never checks if it exists)
See error:
Expected Behavior
It should be possible to pass an empty value for
hasOne
relationships, just like it's possible to pass an empty array forhasMany
relationships.Environment
Possible Solution
The problem is here:
https://github.com/flarum/core/blob/a5182a145401f760cf9743fcd2611a85adbdac0c/js/src/common/Model.js#L141
If the relationship value isn't an array, it's passed to
Model.getIdentifier
without checking if it'snull
.Either
Model.getIdentifier
should pass throughnull
values, orModel.getIdentifier
should not be called if the value isnull
.Additional Context
I'm using this in a yet unreleased extension. As a workaround I am using a local patch that makes
Model.getIdentifier
returnnull
if the model argument isnull
.The text was updated successfully, but these errors were encountered: