Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#7783 closed defect (bug) (fixed)

get_post() assign by reference fails; should copy instead

Reported by: sam_a's profile Sam_a Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.6.1
Component: General Keywords: get_post has-patch tested e_notice
Focuses: Cc:

Description

get_post() tries to assign results of the $wpdb post query by reference (wp-includes/post.php#L218) —

$_post = & $wpdb->get_row( […]

— but this fails (with notice "Only variables should be assigned by reference") because $wpdb->get_row() doesn't return a reference.

I think this must be a mistake, because normal assignment would work just as well and doesn't raise an error:

$_post = $wpdb->get_row( […]

Attachments (1)

get_post.diff (614 bytes) - added by Sam_a 16 years ago.
get_post() assigns $wpdb row by value, not by reference. Stops E_NOTICEs in 2.6.2 and trunk

Download all attachments as: .zip

Change History (3)

@Sam_a
16 years ago

get_post() assigns $wpdb row by value, not by reference. Stops E_NOTICEs in 2.6.2 and trunk

#1 @ryan
16 years ago

  • Milestone changed from 2.8 to 2.7

#2 @ryan
16 years ago

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

(In [8966]) Don't try to assign non-ref return value by ref. Props Sam_a. fixes #7783

Note: See TracTickets for help on using tickets.