-
Notifications
You must be signed in to change notification settings - Fork 625
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: Optional Personalization arguments handling #971
fix: Optional Personalization arguments handling #971
Conversation
Updated code base from upstream repository
Update repository using sendgrid/master
… and $personalizationIndex addRecipientEmails: Added missing null argument for substitutions in forwarding $emailFunctionCall() Implemented maximum number of 1000 Personalization instances (according to the docs) Added TypeException throw type hints for methods which rely on addRecipientEmail(s) - thrown by EmailAddress if email address is invalid Possible breaking: - Non-existent $personalizationIndex is allowed for 'addTo(s)', usage in other methods require existence of $personalizationIndex. Must be added in the notes/docs. Can be improved: - Merging Personalization (if using existing $personalizationIndex with different $personalization instance) Feedback is highly appreciated Signed-off-by: Alexander Kamp <[email protected]>
Sync local repository using original
Update repository using sendgrid/master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this is trying to make dealing with personalizations more intuitive (a primary part of what this library is supposed to do), but if we're going to make a breaking change (MV roll), I'd prefer it be really breaking and try to get it right.
There are parts of the old code which I simply think should not be supported, specifically passing in a personalization while setting some properties on it and adding to the array of personalizations but not even returning that thing that was added. I'd rather drop this ability all together.
Working from the end user backwards, how would they expect to use this helper functionality? Personally, I'd expect to be able to build out the personalizations in 1 of 3 ways:
- I'll create the personalization, populate it, then add it to the mail object.
- I'll ask the mail object to create and add a new (blank) personalization object, return it to me, and I'll populate it how I want.
- I'm only gonna be dealing with a single personalization (I don't even care about the notion of a personalization, I just want to send mail) so let me tell the mail object what should be in the email.
No dealing with personalization indices or hybrid add-and-update functions needed/wanted. To me this is simple and intuitive, but breaking.
That said, if the larger feeling is "don't break things and make us change our code" then I think tweaking the existing implementation is okay as suggested here, to keep the logic simple. No merging personalizations and whatnot. More code and logic is more cost.
Thanks for your extensive review and opinion. I've created my PR in mind to have the least possible chance of having a breaking change, but I can't rule out because of the variation of supported scenarios and code usage in the wild.
Well... user 1 creates a In the use cases docs, no sample code is present to use We may first start to create documentation how to code Personalizations right and declaring unwanted features deprecated, before forcing a breaking change. In addition to this, it might me helpful to add every code sample in an unit test.
I agree that providing a (Note: Maybe a check has to be implemented which prevents the addition of possible duplicated
Please don't consider this as real option. I'm using this library for transactional mail and bulk mailings. The
Perfect world scenario. But as you see, it's in use and useful as 'different/specific Personalization marker'. The
I'll customize this PR and will remove parts which aren't necessary anymore. (It will conflict upcoming PR which I mentioned above, so I have to update it again if merged.) |
Sync local repository using original
Added unit tests for verifying functionality of providing Personalization arguments using addTo() Personalization: updated actual property/return types Signed-off-by: Alexander Kamp <[email protected]>
I've applied the suggested solution including unit tests to cover multiple scenarios. Summary of fixes:
Maybe still point of attention:
will pass, but
will throw an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall.
Think the !
can be dropped from the title as I don't consider this breaking.
Yeah, that’s fine, but the array itself is publicly accessible so you could
just fiddle with the contents elsewhere and set things to null or unset
them.
|
If you mean the
Even if you're using the When earlier suggested validation is implemented, all entries of |
I thought there was a public method that returned the array itself.
|
Added unit tests
Never mind last comments; forgot PHP was pass-by-value by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇 Dropping the !
from the title as I don't consider this breaking.
Fixes
Fixes #961.
Methods
addTo
,addCc
,addBcc
,addTos
,addCcs
,addBccs
,setSubject
,addHeader
,addSubstitution
,addCustomArg
,setSendAt
offers support to link/reusePersonalization
instances using optional$personalization
and$personalizationIndex
arguments.Handling of linking/storing/fetching using these arguments have been rewritten to be more predictable.
Breaking change may be:
$personalizationIndex
is allowed foraddTo(s)
, usage in other methods require existence of$personalizationIndex
. According to the SendGrid API docs, at leastTo
must exists in aPersonalization
, so it makes sense to allow this scenario. (This must/may be added in the notes/docs.)Can be improved further:
Personalization
(if using existing$personalizationIndex
with different$personalization
instance)Other fixes while working on this fix:
null
argument for substitutions in forwarding$emailFunctionCall()
Personalization
instances (according to the API docs)TypeException
throw type hints for methods which rely onaddRecipientEmail(s)
- thrown byEmailAddress
if email address is invalid.Feedback is highly appreciated!
(I have to look for possible side effects to be sure it doesn't break anything)
Checklist