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

Feature/delta updates #277

Closed

Conversation

brandonkelly
Copy link
Contributor

Hey Spicy!

Craft 3.4 is adding support for delta element updates, meaning that entry, category, and user forms will only submit custom field values that actually changed, giving the back end a chance to optimize the element save process by avoiding saving things that haven’t changed.

Matrix already supports it, and we hope that Neo and Super Table will add support soon as part of a feature branch so people can start testing ahead of the 3.4.0 release.

I started working on adding Neo support for you, but hit a roadblock because the field is built by JavaScript, and I couldn’t find the JS source files in the repo. I’m hoping that you can take over from here.

Here’s what’s needed to add full delta update support to Neo:

  • Skip post-element save processing in Field::afterElementPropagate() if the field isn’t dirty
  • Check for alternate POST syntax in Field::_createBlocksFromSerializedData(), and if used, stitch POSTed block data with existing block data, keeping track of which blocks are dirty
  • Update the field input
    • Block inputs should have a [blocks] sub-namespace (e.g. fields[myNeo][blocks][22][fields][myText] rather than fields[myNeo][22][fields][myText])
    • Ideally, block sort order & position would be submitted separately from the block data (e.g. name="fields[myNeo][sortOrder][]" value="<block ID>" so that entire blocks don’t need to be resaved if only their position changes.
    • The input should start registering a “delta name” for each block (e.g. myNeo[blocks][22]), so that element forms know to group their nested inputs together
    • The input should pass registerDeltas: true when rendering either _includes/fields.html or _includes/field.html so that sub-fields get their own delta names as well.
  • Fields::saveValue() should start only saving blocks that were marked as dirty by Field::_createBlocksFromSerializedData().

See the diff at craftcms/cms#5146 to see how Matrix was affected by this.

To get Craft 3.4 running locally, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "3.4.x-dev",
  "...": "..."
}

Then run composer update.

Let me know if you have any questions!

@brandonkelly brandonkelly deleted the feature/delta-updates branch October 28, 2019 23:06
@brandonkelly brandonkelly restored the feature/delta-updates branch October 28, 2019 23:11
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.

1 participant