[wp-trac] [WordPress Trac] #16469: Cannot pass in ID for get_term_link() if using custom taxonomy

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 15 09:32:12 UTC 2011


#16469: Cannot pass in ID for get_term_link() if using custom taxonomy
--------------------------+------------------------------
 Reporter:  sparkweb      |       Owner:
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  3.0.4
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by mikeschinkel):

 Replying to [comment:15 dd32]:
 > Replying to [comment:14 mikeschinkel]:
 > Well no, Because that's not a term object is it? It's your data, as a
 plugin developer it's your responsibility to pass the correct parameters
 to functions. The documentation *may* (I haven't read it) may need to
 stress the fact it requires a integer value to be passed, not a numeric
 string.

 Code architecture really should strive to minimize accidental misuse.  To
 say ''"Yeah, it's easy to make that common mistake but it was documented
 otherwise"'' should at best be considered a short term hack and at work
 considered a failure of the code architect.

 Taken to an extreme assume that calling `wp_delete_post($args)` with an
 empty `$args` array would delete all posts but that it was documented to
 be that way. I doubt you'd argue that deleting all posts on a misuse of
 that function would be acceptable; why would you argue the same for a
 different function just because its result is less damaging?

 > In both cases you need to read the documentation, and then possibly read
 the first few lines of the function if you're not used to "int" meaning a
 literal integer..

 I've read the documentation, I know what it says and how to use it. That's
 not the issue; the issue is that it doesn't make sense to have such a
 distinction that invites misuse and hence unexpected bugs when few if any
 other functions in WordPress behave that way; most will accept numbers as
 string as if they were numbers.

 > Simple fact here, Is that the function cannot change to accept a
 numerical string for ID lookups, nor can any of the Taxonomy API's which
 accept multiple data types be changed to accept numerical strings (those
 which only take int's seem to all cast them appropriately).

 I must be missing something obvious.  Why can't `is_int()` be changed to
 'is_numeric()` to solve this issue simply?

  - http://jeremy.zawodny.com/blog/archives/001503.html

 -Mike

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16469#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list