[wp-trac] [WordPress Trac] #25155: All functions returning string|WP_Error -- there is no WP_Error::__toString
WordPress Trac
noreply at wordpress.org
Tue Aug 27 13:05:06 UTC 2013
#25155: All functions returning string|WP_Error -- there is no WP_Error::__toString
--------------------------+------------------------------
Reporter: tivnet | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: minor | Resolution:
Keywords: |
--------------------------+------------------------------
Comment (by 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.
>
> I'm not sure if `__toString()` for WP_Error is a good idea. Right now,
failing to catch a WP_Error often leads to a fatal error — which is often
good, rather than bad, as it alerts developers to problems as they write
their code. But more so, as you state — I'm not sure if it should be
get_error_message(), or an empty string.
Yes, but still, a function cannot return string|Something, if Something
cannot be converted to a string. That's a major "boo-boo" in my opinion,
and any PHP code validator should explode with warnings about that. (At
least my IDE complains quite loudly).
I remember days when errors were raised, but not returned as objects ;-)
As for the fatal errors, they usually happen on production... when you are
on vacation in a desert, with no internet connection.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25155#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list