Skip to content

Conversation

@michaelborn
Copy link
Contributor

This PR makes two improvements to Mementifier:

  1. Don't modify the source includes and excludes arguments. The calling code doesn't expect its arrays to be modified and (in our case) can cause sequential getMemento() calls on other entities to be processed with a bunch of invalid / missing includes that were added via the defaultIncludes on the first entity.
  2. De-duplicate the includes and excludes to prevent duplicate processing. For example, if you pass includes = [ "item_in_defaultIncludes" ], the item_in_defaultIncludes property will be processed and included twice. (Currently.)

Since arrays are passed by reference, and we modify these arrays, this actually causes the calling method's `includes` or `excludes` variable to be modified, potentially causing the next `getMemento()` call to use a wrong includes value.
Copy link
Contributor

@jclausen jclausen left a comment

Choose a reason for hiding this comment

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

We should be able to elminate some extra processing in de-duplication and I feel that we can perform the duplication in a way that avoids mutating the original args.

Per Jon C, this makes more sense if we want/need to reference the original argument.
@lmajano
Copy link
Contributor

lmajano commented Sep 6, 2022

Is it ready for review now?

@michaelborn
Copy link
Contributor Author

Is it ready for review now?

I would say so, go ahead. I just fixed it for ACF 16. 😁

@jclausen
Copy link
Contributor

jclausen commented Sep 6, 2022

I'm good with this as it stands

@michaelborn
Copy link
Contributor Author

Also added in a commit to filter out an empty string include. This resolves an issue where a getMemento() call with no includes will actually call a get() method (if exists) because arguments.includes is defaulted to an empty string.

@michaelborn
Copy link
Contributor Author

Updated to use native Java array streams for performance, per @lmajano 's PR review.

@lmajano
Copy link
Contributor

lmajano commented Sep 21, 2022

seems things are dying.

@michaelborn
Copy link
Contributor Author

seems things are dying.

Ok, looks like the .stream() is not supported in ACF16.

@lmajano lmajano merged commit ca5c75d into coldbox-modules:development Sep 23, 2022
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.

3 participants