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

Changes 3: New Version class #6442

Open
wants to merge 3 commits into
base: v5/develop
Choose a base branch
from

Conversation

bastianallgeier
Copy link
Member

@bastianallgeier bastianallgeier commented May 6, 2024

This PR …

Refactoring

  • New Version class which inherits most of the logic from the ContentStorage handler and will eventually replace it.

Outlook

Breaking changes

None

Ready?

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

For review team

  • Add changes & docs to release notes draft in Notion

src/Content/Version.php Show resolved Hide resolved
/**
* Creates a new version for the given language
*/
public function create(array $fields, string $language = 'default'): void
Copy link
Member

Choose a reason for hiding this comment

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

With our current translation architecture (automatic field fallbacks to the default language) we can only lock all language versions together to the same user when editing.

So e.g. when creating a changes version from an existing published version, the changes version must always contain all languages that the published version has.

I don't fully understand how this $version->create() instance method is going to be used. To ensure that the version is complete and consistent, I feel like creation needs to happen atomically, e.g. with a static Version::create(ModelWithContent $model, VersionId $id) method that then takes care to take the content fields from the right source (changes takes content from published, drafts start with empty content, published cannot be created standalone) and to ensure all languages.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right. This was implemented before we talked about returning null for non-existing versions. That would have meant that the version instance could be initalized and the creat method could have been called like that before it exists.

Copy link
Member

Choose a reason for hiding this comment

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

How do we proceed here? I guess we will produce a lot of merge conflicts if we change it here. So maybe let's continue and add it to the todo list?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, sounds good to me. We already have a todo list item in Notion. I think it makes sense to fix it in a separate PR when we get to that point.

}

// delete a single language
$this->model->storage()->delete($this->id, $language);
Copy link
Member

Choose a reason for hiding this comment

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

What is the use case for deleting a single language? Do we already support that in v4?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tbh I mostly just moved over what we had in ContentStorage here. I think you are right and we don't need it so far. This would also clean up the method some more. I'm not super happy about the ambiguous usage depending on what's passed.

Copy link
Member

Choose a reason for hiding this comment

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

I'll check the code and concept history again. If there is no reason, I'll remove it. We can still add it back if we ever need it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you have time to check it already or should I have another look at it?

Base automatically changed from v5/changes/plain-text-handler-refactoring to v5/develop May 25, 2024 14:56
@lukasbestle lukasbestle marked this pull request as ready for review May 25, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants