[wp-trac] [WordPress Trac] #25155: All functions returning string|WP_Error -- there is no WP_Error::__toString

WordPress Trac noreply at wordpress.org
Sat Sep 7 06:10:27 UTC 2013


#25155: All functions returning string|WP_Error -- there is no WP_Error::__toString
--------------------------+------------------------------
 Reporter:  tivnet        |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  2.1
 Severity:  minor         |  Resolution:  wontfix
 Keywords:                |
--------------------------+------------------------------
Changes (by c3mdigital):

 * status:  new => closed
 * version:   => 2.1
 * resolution:   => wontfix


Comment:

 Replying to [comment:2 tivnet]:
 > Replying to [comment:1 nacin]:
 > > In this case, we know the term exists.
 > That's great, as long as the same people, who remember every bit of the
 core code, remain on the project.... A safe approach would be to check
 anyway.

 In this case WE KNOW the term exists because it is in core and if the term
 didn't exist you would get a  notice for trying to get property of non
 object and a  `Catchable fatal error: Object of class WP_Error could not
 be converted to string message inside your list table (with WP_DEBUG set
 to false).  If the term doesn't exist when calling that line you have much
 bigger problems than an array to string error.

 When using functions in your own code that could return WP_Error you get
 to decide how to handle it.  You could ignore it by doing:
 `if ( ! is_wp_error( $thingy ) ) { //do stuff ` or you could convert it to
 a string and return it.

 We shouldn't be supporting bad coding habits in core.  Closing as wontfix.

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


More information about the wp-trac mailing list