[wp-trac] [WordPress Trac] #28786: wp_send_json silently fails on non UTF-8 strings

WordPress Trac noreply at wordpress.org
Sun Nov 2 04:05:29 UTC 2014


#28786: wp_send_json silently fails on non UTF-8 strings
------------------------------+-----------------------
 Reporter:  pento             |       Owner:  pento
     Type:  defect (bug)      |      Status:  reopened
 Priority:  normal            |   Milestone:  4.1
Component:  Formatting        |     Version:  3.5
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:
------------------------------+-----------------------

Comment (by pento):

 `wp_json_encode()` returns `false` on failure, to match the behaviour of
 `json_encode()`.

 I'm not wild about changing `wp_json_encode()`'s behaviour (to return 0 or
 an empty string on failure, perhaps), though there's possibly value in
 having a function that always returns valid JSON, I think there being a
 clear "this thing failed to encode" return value is more valuable.

 I think our better option is to fix the places that call
 `wp_json_encode()`, to ensure proper type checking.

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


More information about the wp-trac mailing list