Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#17459 closed defect (bug) (invalid)

wp_insert_post doesn't catch query failure

Reported by: lonnylot's profile lonnylot Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

When we insert the post into the DB in wp-includes/post.php on line 2565 we check to see if the return is === false. $wpdb->insert will NEVER return false. It will only return -1 or the number of affected rows.

Change History (4)

#1 @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This is simply not true. $wpdb->insert() returns FALSE on error.

-1 is usually returned in an AJAX request, so something else is going on in your case.

Please use the support forums for help with troubleshooting: http://wordpress.org/support/

Last edited 13 years ago by scribu (previous) (diff)

#2 @nacin
13 years ago

  • Milestone set to Awaiting Review
  • Resolution invalid deleted
  • Status changed from closed to reopened

$wpdb->insert() can return false, but it can also return mysql_affected_rows(), which on failure is -1.

#3 @lonnylot
13 years ago

I was looking at the code again and believe I was wrong w/ my initial statement. Before the call to mysql_affected_rows() there is a call to mysql_error() that will return false on an error. IMO this can be closed/deleted

#4 @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.