[wp-trac] [WordPress Trac] #56516: calendar_week_mod function is not type safe

WordPress Trac noreply at wordpress.org
Mon Aug 7 23:36:13 UTC 2023


#56516: calendar_week_mod function is not type safe
--------------------------------------------+-------------------------
 Reporter:  dingo_d                         |       Owner:  (none)
     Type:  defect (bug)                    |      Status:  closed
 Priority:  normal                          |   Milestone:
Component:  General                         |     Version:
 Severity:  normal                          |  Resolution:  maybelater
 Keywords:  needs-patch needs-testing php8  |     Focuses:
--------------------------------------------+-------------------------
Changes (by hellofromTonya):

 * status:  new => closed
 * resolution:   => maybelater
 * milestone:  Awaiting Review =>


Comment:

 The function `calendar_week_mod()` is documented as requiring a `int`.
 Passing anything else is doing it wrong. I agree with @malthert.

 The topic of input (parameter) validation is more of an architectural
 discussion. I think (maybe) there's a Trac ticket for it (if no, will
 create it). Rather than adding the validation in this one function, I
 think a project wide discussion and consensus needs to happen first. Then
 the implementation can be applied to this function and all others in Core.

 I do agree with you @dingo_d that defensive coding is better and that
 tests are needed. Would you be interested in creating the unit tests?

 Rather than solving type safe in one ticket for one specific function, I
 think this topic needs a project-wide architectural proposal, discussion,
 and consensus. Then once there's consensus of a way forward, the changes
 can be applied to all Core functions. I think (maybe) there's a Trac
 ticket open for this architectural discussion, though I'm currently not
 finding it. @jrf likely knows off the top of her head. If the ticket
 doesn't currently exist, it is something that has been discussed and thus
 a ticket and/or proposal will be coming.

 I'll close this ticket as I agree it's not an "issue" to solve at an
 individual function level, but am marking it as `maybelayer`.

 Thank you for the suggestion @dingo_d!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56516#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list