Ticket #4826 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Change to wpdb::get_col() breaks documented behavior

Reported by: mdawaffe Assigned to: anonymous
Priority: normal Milestone: 2.3
Component: General Version:
Severity: normal Keywords: has-patch 2nd-opinion
Cc:

Description

[5858] [5861] Change get_col(), get_row(), and get_results() to return null if given an empty argument.

According to the documentation, get_col() should be able to be called with an empty argument in the following situation.

$a = get_col( "SELECT a, b FROM table" );
$b = get_col( '', 1 );

This is almost never needed since get_results() is almost always more efficient for grabbing data from multiple columns. Very ocassionally, this use of get_col() is more efficient and should still be supported. Otherwise, it will be necessary to write a wrapper function around get_results() to achieve the same thing. Since core WP does not make use of this type of call to get_col(), any plugin that does will have to write their own wrapper functions for the few cases where the old get_col() is more efficient than get_results().

I cannot think of when it would be useful for get_row() or get_results() to act in the old manner. It's only in the transformation of the data from row-centric to column-centric that this issue occurs.

Attached is a patch that reverts get_col() and fixes a PHP warning.

Attachments

4826.diff (0.7 kB) - added by mdawaffe on 08/27/07 19:38:34.

Change History

08/27/07 19:38:34 changed by mdawaffe

  • attachment 4826.diff added.

08/27/07 19:44:53 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [5950]) Revert get_col behavior. Props mdawaffe. fixes #4826