[wp-trac] [WordPress Trac] #54327: Support wp_die from array print

WordPress Trac noreply at wordpress.org
Thu Oct 28 20:01:20 UTC 2021


#54327: Support wp_die from array print
-------------------------------------+------------------------------
 Reporter:  myousefi08               |       Owner:  (none)
     Type:  feature request          |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  General                  |     Version:  5.8.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+------------------------------

Comment (by sabbirshouvo):

 @SergeyBiryukov I took a look into `_wp_die_process_input()`. I think
 there is nothing to modify to achieve the proposed result. that mentioned
 method nicely handling the `$message` returning as an array. In order to
 display the user input array, we must print it in some way. I think
 `print_r()` is a decent way to print the array. `_wp_die_process_input()`
 already checking if it's an error object coming from WordPress itself or
 not and the `$message` is always a string unless the user inputs an array
 as $message.

 I agree with you regarding modifying all error handlers.

  * `_default_wp_die_handler()` : Current patch should work fine. But
 output can be nicer with `<pre></pre>`
  * `_ajax_wp_die_handler()` :
  * `_json_wp_die_handler()` : Current code should work just fine
  * `_jsonp_wp_die_handler()` : Current code should work just fine
  * `_xmlrpc_wp_die_handler()` : As error output is always string for
 `IXR_Error` we can `json_encode` the $message if is an array.
  * `_xml_wp_die_handler()` : same solution as `_xmlrpc_wp_die_handler`
  * `_scalar_wp_die_handler()` : I couldn't find any use of this handler. I
 think it's possible to skip this or remove this.


 I'll be adding a patch with my update across all handlers.

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


More information about the wp-trac mailing list