Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#10536 closed defect (bug) (worksforme)

errors surfacing when using set_error_handler

Reported by: aaronasachimp's profile AaronAsAChimp Owned by: westi's profile westi
Milestone: Priority: normal
Severity: normal Version:
Component: Warnings/Notices Keywords: reporter-feedback close
Focuses: Cc:


So, I've been getting some strange errors surfacing while developing a plugin. Three errors along the lines of "mysql_free_result(): supplied argument is not a valid MySQL result resource."

They seem to be normally suppressed, but surface when using set_error_handler(), and only when trying to create a table. It appears that in "wp-includes/wp-db.php" that the result of the query isn't being checked before being passed to the MySQL functions.

Attachments (1)

wordpress-patch.diff (463 bytes) - added by AaronAsAChimp 15 years ago.
check if the result is valid for passing to mysql_fetch_field(), etc.

Download all attachments as: .zip

Change History (8)

15 years ago

check if the result is valid for passing to mysql_fetch_field(), etc.

#1 @AaronAsAChimp
15 years ago

  • Keywords has-patch added

#2 @westi
15 years ago

  • Milestone changed from Unassigned to 2.9
  • Owner set to westi
  • Status changed from new to reviewing

#3 @westi
14 years ago

  • Milestone changed from 2.9 to 3.0

Move to 3.0 for now.

#4 @westi
14 years ago

  • Keywords reporter-feedback added; has-patch removed

Looking at the code in $wpdb and php docs we should only every get false returned from mysql_query if there is an error.

In this case this code will mean we never reach the branch the patch changes:

		if ( $this->last_error = mysql_error($this->dbh) ) {
			return false;

Do you know what the query was that produced this notice?

#5 @Denis-de-Bernardy
14 years ago

  • Keywords close added

might be this:

some error can't handle. Example:

ERROR 1044: Access denied for user: 'ituser@…' to database 'itcom'

This error ocurrs when a intent of a sql insert of no authorized user. The results: mysql_errno = 0 and the mysql_error = "" .

seems quite rare, though. wontfix?

#6 @hakre
14 years ago

Which lines you get the error from? can you provide your set_error_handler() routine? Those callback will reveal notices / errors even the @ operator is in use.

It might be possible to flag those cases out by configuring the callback / validating against a callbacks parameter value. That might depend on your PHP version you use on your blog.

To learn more about set_error_handler() please see the PHP documentation.

Until no more details are provided in the bug reprot I suggest to close as wontfix unless more concrete information is provided.

#7 @nacin
14 years ago

  • Milestone 3.0 deleted
  • Resolution set to worksforme
  • Status changed from reviewing to closed

Reopen with steps to reproduce.

Note: See TracTickets for help on using tickets.