WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#10536 closed defect (bug) (worksforme)

errors surfacing when using set_error_handler

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

Description

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 5 years ago.
check if the result is valid for passing to mysql_fetch_field(), etc.

Download all attachments as: .zip

Change History (8)

AaronAsAChimp5 years ago

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

comment:1 AaronAsAChimp5 years ago

  • Keywords has-patch added

comment:2 westi5 years ago

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

comment:3 westi5 years ago

  • Milestone changed from 2.9 to 3.0

Move to 3.0 for now.

comment:4 westi5 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) ) {
			$this->print_error();
			return false;
		}

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

comment:5 Denis-de-Bernardy5 years ago

  • Keywords close added

might be this:

http://www.php.net/manual/en/function.mysql-error.php#12831

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?

comment:6 hakre5 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.

comment:7 nacin4 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.