Make WordPress Core

Opened 16 years ago

Closed 15 years ago

#10607 closed defect (bug) (fixed)

return variable $new_array in wp-includes/wp-db.php is not initialized

Reported by: underwordpressure's profile UnderWordPressure Owned by: westi's profile westi
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.8.3
Component: Warnings/Notices Keywords: dev-feedback
Focuses: Cc:

Description

Concerns "function get_results($query = null, $output = OBJECT)".

If the query is valid, but the result is empty the "return $new_array"
$new_array is uninitialized.

You can see this, if you enable "error_reporting(E_ALL)".

"$new_array = array();" at the begin of the function will solve the error.

Attachments (1)

10607.patch (1.2 KB) - added by miqrogroove 15 years ago.
Finishes the fix, adds minimal improvements.

Download all attachments as: .zip

Change History (11)

#1 @miqrogroove
15 years ago

  • Component changed from General to Warnings/Notices
  • Keywords needs-patch added; variable initialization removed
  • Milestone changed from Unassigned to 3.0
  • Owner set to westi

+1 Also, put eyeballs on get_col_info()

#2 @nacin
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [13161]) Init array in wpdb:get_results() and get_col_info(). Props UnderWordPressure, miqrogroove, fixes #10607

#3 @hakre
15 years ago

Referenced: #11799

#4 @miqrogroove
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

@miqrogroove
15 years ago

Finishes the fix, adds minimal improvements.

#5 @westi
15 years ago

  • Status changed from reopened to accepted

#6 @westi
15 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [13671]) Ensure that wpdb::get_results() always returns an array when it should. Fixes #10607 props miqrogroove.

#7 @nacin
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#8 @nacin
15 years ago

(In [13681]) Check for empty(), not !is_array(), when trying to determine if wpdb::get_results() returned results. See #10607

#9 @nacin
15 years ago

  • Keywords dev-feedback added; needs-patch removed

During the dev chat today, it was brought up that is_null($result) could pose a problem for plugins as a result of [13671].

Checking for is_array() or !is_array() for whether there are or are not results is a similar situation. I made one fix in [13681].

While I doubt we do this elsewhere in core, I wanted to re-open for discussion, as this could definitely break some plugins and I'm not sure there's a good solution;.

#10 @nacin
15 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Per IRC discussion.

Note: See TracTickets for help on using tickets.