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

Don’t pass kirby as property to models #6072

Merged
merged 6 commits into from
Dec 30, 2023

Conversation

bastianallgeier
Copy link
Member

@bastianallgeier bastianallgeier commented Dec 15, 2023

This PR …

With the refactoring of property setters in models in v4, Kirby got passed as an instance to propertyData['kirby'] This broke serializing and could have other side effects. I wonder if some whoops issues are related to it as well.

I've tracked down all the parts where we pass Kirby to a model. This should have no side-effects in theory. The models use static::$kirby as property and don't fetch the Kirby instance from the propertyData array anyway. But it remains a bit risk.

Fixes

Breaking changes

  • Hopefully none

Ready?

  • Unit tests for fixed bug/feature
  • In-code documentation (wherever needed)
  • Tests and checks all pass

For review team

lukasbestle
lukasbestle previously approved these changes Dec 15, 2023
Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing the app object as property indeed seems superfluous as it isn't used anywhere at the moment. I can't find any reason why this would break anything.

The question is what our future plans with object coupling are. I think in general it would be desirable to avoid using global objects wherever possible, e.g. when using Kirby on the CLI with multiple independent app objects. But that's definitely a question for the future, we can still add the app objects as props back in later.

What we could also consider in the future is to implement custom serialization logic with the Serializable interface. It really doesn't make much sense to serialize all property data with every object.

@lukasbestle lukasbestle added the type: bug 🐛 Is a bug; fixes a bug label Dec 15, 2023
@lukasbestle lukasbestle linked an issue Dec 15, 2023 that may be closed by this pull request
@lukasbestle lukasbestle added type: regression 🚨 Is a regression between versions and removed type: bug 🐛 Is a bug; fixes a bug labels Dec 15, 2023
@afbora afbora added the needs: two-person review 🧑‍🤝‍🧑 PR must only be merged with two approvals label Dec 15, 2023
@afbora
Copy link
Member

afbora commented Dec 15, 2023

Not sure but I think also you need to check out following lines: (check serialize($kirby->user()) to test it)

@bastianallgeier
Copy link
Member Author

@afbora I found two more places where we pass kirby to the user models.

@afbora
Copy link
Member

afbora commented Dec 18, 2023

@bastianallgeier Sorry, I just pointing what I found similar ones. Is this possible one?
https://github.com/getkirby/kirby/blob/fix/6061-serializable-objects/src/Cms/App.php#L1470

@bastianallgeier
Copy link
Member Author

@afbora yep, we don't even use it in the role class

Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes all look safe to me as I can't find any place in our code that tries to access those kirby props. Also can't find more places where we pass but don't use the kirby prop. A few classes (Cms\Api and Cms\Auth\Status) actually rely on it, but those are commonly not serialized.

@distantnative distantnative merged commit a130e4a into develop-minor Dec 30, 2023
12 checks passed
@distantnative distantnative deleted the fix/6061-serializable-objects branch December 30, 2023 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: two-person review 🧑‍🤝‍🧑 PR must only be merged with two approvals type: regression 🚨 Is a regression between versions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[K4] Session: need to serialize data. Regression?
4 participants