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

Fix BlockRepository setting relation of an object and improve amount … #2672

Merged
merged 3 commits into from
Oct 21, 2024

Conversation

Tofandel
Copy link
Contributor

Fixes #2671

And improve saving performance by avoiding uneccessary queries


// Delete all the related items that were emptied
RelatedItem::query()->whereMorphedTo('subject', $model)->whereNotIn('browser_name', $browserNames)->delete();
} else {
$model->clearAllRelated();
Copy link
Contributor Author

@Tofandel Tofandel Oct 15, 2024

Choose a reason for hiding this comment

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

This would previously delete and recreate all related items, which is very write intensive on the database for nothing because saveRelated already does an existence check and deletes the deleted ones

@ifox
Copy link
Member

ifox commented Oct 15, 2024

Thanks @Tofandel, can you make sure to test the 3 following things:

  • changes in a browser in a block render in the Editor previews and full preview
  • changes in a browser outside a block render in the full preview
  • changes in a browser in a child repeater in a block render in the Editor previews and full preview

@antonioribeiro
Copy link
Member

Hey @Tofandel, I didn't test this extensively yet but looks like you fixed it, I was able to reproduce the error here and when switching to your branch I don't have it anymore. Thank you!

@ifox ifox merged commit 9c6416f into area17:3.x Oct 21, 2024
8 checks passed
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.

Call to undefined method stdClass::unsetRelation()
3 participants