Skip to content

Conversation

veryspry
Copy link
Contributor

@veryspry veryspry commented Sep 28, 2022

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/2011825626/38759/

Summary

  • Refactors gpnf-auto-attach-child-files into a class.
  • Moves configuration logic to constructor args so that users can easily create multiple, unique configurations.
  • Adds child_form_upload_field_ids config option to limit which child form upload fields are included in a notification.

Copy link
Contributor

@claygriffiths claygriffiths left a comment

Choose a reason for hiding this comment

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

Awesome work!

I'm going to give this a functional test here shortly. In the meantime, here are a couple of minor suggestions for the code.

Copy link
Contributor

@claygriffiths claygriffiths left a comment

Choose a reason for hiding this comment

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

Just noticed a typo in a method name and now PHPCS is barking about a couple of things.

I did a functional test and it looks good! I did notice that it slowed down submission a bit, but I'm not sure if that's an issue with the refactor itself.

I went ahead and approved this pending the two small things mentioned above.

@veryspry
Copy link
Contributor Author

I did a functional test and it looks good! I did notice that it slowed down submission a bit, but I'm not sure if that's an issue with the refactor itself.

Thanks for doing that! All was looking good during my tests but it's always nice to get an extra set of eyes on it 🙌

As far as the slowdown goes, my guess is that it isn't due to the refactor as the logic is essentially the same as before. The main difference is the way that configuration options are set

If I had to guess why, database reads are probably the main culprit. For instance:

We also make a call to preg_replace() for each attachment we find which might impact speed noticeably?

That said, PCRE is supposed to cache compiled regex's which should be helpful since we pass the same regex string to each call of preg_replace()

https://stackoverflow.com/a/210086

@veryspry
Copy link
Contributor Author

Just waiting on confirmation from a user that this works well for them before merging!

@veryspry
Copy link
Contributor Author

veryspry commented Oct 3, 2022

Feature request:

Support for multiple child forms (in one parent form) whose upload fields have different id's.

For example: Parent Form has two child forms, A and B. A's file upload field has id of 1 and B's has a file upload field with id of 2.

I'm going to go ahead and add that functionality to this snippet before merging!

@veryspry veryspry force-pushed the matt/child-file-refactor branch 2 times, most recently from 8987a33 to a21e3aa Compare October 6, 2022 21:35
@veryspry veryspry requested a review from claygriffiths October 7, 2022 19:47
@veryspry
Copy link
Contributor Author

veryspry commented Oct 7, 2022

@claygriffiths just a heads up that I changed the API here a bit so that this works with more complex child form configurations.

See here for more details: #535 (comment)

@veryspry veryspry changed the title Refactored gpnf-auto-attach-child-files for greater configuration flexibility gpnf-auto-attach-child-files: Refactored for greater configuration flexibility. Oct 10, 2022
@veryspry veryspry force-pushed the matt/child-file-refactor branch from a21e3aa to a9e0835 Compare October 10, 2022 16:29
@veryspry veryspry force-pushed the matt/child-file-refactor branch from a9e0835 to a1d860b Compare October 10, 2022 18:37
@veryspry
Copy link
Contributor Author

veryspry commented Oct 14, 2022

We're just waiting for a user to confirm this works for them

@veryspry
Copy link
Contributor Author

veryspry commented Nov 8, 2022

This is confirmed to work as intended. I'm mergin' it!

@veryspry veryspry merged commit 4a8502b into master Nov 8, 2022
@veryspry veryspry deleted the matt/child-file-refactor branch November 8, 2022 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants