Summary
In app/Models/Foundation/Summit/Factories/SummitPromoCodeFactory.php, approximately 8 calls to boolval() are used to coerce boolean fields (e.g. allows_to_delegate, allows_to_reassign, auto_apply) from user/CSV input into boolean values.
Problem
boolval("false") returns true in PHP because any non-empty string (other than "0") casts to true. This means CSV imports that provide auto_apply=false (or similar string values) will be incorrectly persisted as true.
filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) correctly recognises string values like "false", "0", "no", "off" as boolean false.
Proposed Fix
Replace every boolval($data[...] call in SummitPromoCodeFactory::populate() with:
filter_var($data['<field>'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)
Affected fields (approx. lines):
allows_to_delegate (~line 172)
allows_to_reassign (~line 175)
auto_apply in MemberSummitRegistrationPromoCode branch
auto_apply in SpeakerSummitRegistrationPromoCode branch
auto_apply in MemberSummitRegistrationDiscountCode branch
auto_apply in SpeakerSummitRegistrationDiscountCode branch
auto_apply in DomainAuthorizedSummitRegistrationDiscountCode branch
auto_apply in DomainAuthorizedSummitRegistrationPromoCode branch
Context
Identified during review of PR #525 (#525 (comment)). The fix was deferred from that PR to avoid a partial/inconsistent change — all occurrences should be updated together in a single cleanup PR.
Requested by: @caseylocker
Summary
In
app/Models/Foundation/Summit/Factories/SummitPromoCodeFactory.php, approximately 8 calls toboolval()are used to coerce boolean fields (e.g.allows_to_delegate,allows_to_reassign,auto_apply) from user/CSV input into boolean values.Problem
boolval("false")returnstruein PHP because any non-empty string (other than"0") casts totrue. This means CSV imports that provideauto_apply=false(or similar string values) will be incorrectly persisted astrue.filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)correctly recognises string values like"false","0","no","off"as booleanfalse.Proposed Fix
Replace every
boolval($data[...]call inSummitPromoCodeFactory::populate()with:Affected fields (approx. lines):
allows_to_delegate(~line 172)allows_to_reassign(~line 175)auto_applyinMemberSummitRegistrationPromoCodebranchauto_applyinSpeakerSummitRegistrationPromoCodebranchauto_applyinMemberSummitRegistrationDiscountCodebranchauto_applyinSpeakerSummitRegistrationDiscountCodebranchauto_applyinDomainAuthorizedSummitRegistrationDiscountCodebranchauto_applyinDomainAuthorizedSummitRegistrationPromoCodebranchContext
Identified during review of PR #525 (#525 (comment)). The fix was deferred from that PR to avoid a partial/inconsistent change — all occurrences should be updated together in a single cleanup PR.
Requested by: @caseylocker