Skip to content
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

Craft 5.3 #45

Closed
JeroenJRP opened this issue Nov 12, 2024 · 5 comments
Closed

Craft 5.3 #45

JeroenJRP opened this issue Nov 12, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@JeroenJRP
Copy link

The changes in Craft 5.3 that made relation fields multi-instance (craftcms/cms#15400) break the functionality of this plugin.

The immediate problem is that the is_array($value) check in normalizeValue always returns true now, skipping the plugin logic. But there are probably other implications.

@boboldehampsink
Copy link
Member

Thanks, will have to look into this. For now, I have released 3.0.1 which has a constraint on Craft CMS < 5.3.

@boboldehampsink boboldehampsink added the enhancement New feature or request label Nov 12, 2024
@Marcuzz
Copy link

Marcuzz commented Nov 28, 2024

The issue occurs because the default value of a BaseRelationField has changed: https://github.com/craftcms/cms/pull/15400/files#diff-dd150284a0df94daa2918aaacda81e6ad9b20bac8d429414043f37120a5769ddR100-R103

Since the default value for a BaseRelationField is no longer null we now run into two problems:

  1. We never enter the following clause, as mentioned by OP: https://github.com/robuust/craft-reverserelations/blob/develop/src/fields/ReverseEntries.php#L54 – the side effect of this is that we never render the reverse relation list in the UI.
  2. Because the default value is now an array, we always enter the following condition in BaseRelationField when viewing a regular entries field: https://github.com/craftcms/cms/blob/5.x/src/fields/BaseRelationField.php#L670 – previously the entire logic for grabbing the list of relations hinged on entering this clause: https://github.com/craftcms/cms/blob/5.x/src/fields/BaseRelationField.php#L679. It seems like this is now legacy code, and the code for saving a relation has to be updated because relation fields are now "multi instance".

Edit: You can fix the ReverseEntries field itself by overriding dbType: https://github.com/Marcuzz/craft-reverserelations/blob/develop/src/fields/ReverseEntries.php#L40-L43

This works if you have a read only field from the ReverseEntries field side, but editing from that side still requires a fix in the code that saves relations.

@Marcuzz
Copy link

Marcuzz commented Nov 28, 2024

An update to my previous comment ☝️

These changes fixes all the aforementioned issues, and makes it compatible with 5.3: develop...Marcuzz:craft-reverserelations:develop

Let me know if you would like me to submit a PR 😄

@boboldehampsink
Copy link
Member

Thanks, will look into it the coming days. No PR needed.

@boboldehampsink
Copy link
Member

3.0.2 is out now with this fix, thanks a lot @Marcuzz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants