Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#4809 closed defect (bug) (fixed)

Returning WP_Error objects in unexpected places

Reported by: filosofo's profile filosofo Owned by: filosofo's profile filosofo
Milestone: 2.5 Priority: high
Severity: major Version: 2.3
Component: General Keywords: wp_error
Focuses: Cc:

Description

All of the functions listed below return WP_Error objects if something goes wrong. The problem is that in most of the many places where these functions appear throughout the WordPress codebase, whatever has called them is not expecting to get a WP_Error object.

So what happens is that you get a fatal error along the lines of "Fatal error: Cannot use object of type WP_Error as array in . . ." instead of the kind of helpful error handling WP_Error is supposed to provide.

I would like to use this ticket to create patches to address each of the areas where this occurs.


Functions that return WP_Error objects
(those marked with * have received the WP_Error object from elsewhere)


*get_bookmark_field
get_objects_in_term
*get_post_field
get_term
get_term_children
*get_term_field
*get_term_to_edit
get_terms
wp_get_object_terms
wp_insert_term
wp_set_object_terms
wp_update_term
wp_write_post

Attachments (1)

errors.diff (23.2 KB) - added by filosofo 17 years ago.

Download all attachments as: .zip

Change History (12)

#1 @filosofo
17 years ago

  • Owner changed from anonymous to filosofo

#2 @ryan
17 years ago

  • Priority changed from normal to high

#3 @filosofo
17 years ago

I've been working on this, but it's very involved--a wp error potentially gets returned in dozens of places. Would it be better to post one big patch or piecemeal as I'm doing it?

#4 @ryan
17 years ago

Piecemeal. For 2.3 we can probably only do the nastier ones.

#5 @santosj
17 years ago

Is it okay if someone submits a patch?

@filosofo
17 years ago

#6 @filosofo
17 years ago

I've attached what I've done so far.

#7 @ryan
17 years ago

(In [6125]) Add checks for WP_Error. Props filosofo. see #4809

#8 @ryan
17 years ago

general-template and widgets didn't apply cleanly.

#9 @ryan
17 years ago

(In [6148]) Add checks for WP_Error. Props filosofo. see #4809

#10 @ryan
17 years ago

  • Milestone changed from 2.3 to 2.4

I think we're good enough for 2.3. Moving to 2.4 to finish any remaining places.

#11 @ryan
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.