WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#18407 closed defect (bug) (fixed)

WPDB Prepare(), update(), insert() refer to %d as a decimal

Reported by: dd32 Owned by: dd32
Milestone: 3.3 Priority: normal
Severity: normal Version:
Component: Inline Docs Keywords: has-patch
Focuses: Cc:

Description

%d is refered to as a decimal in the inline docs for functions which use prepare().

%d is also refered to as a decimal in the PHP docs as well, however, %d represents the input as a Integer, not a Decimal, resulting in the loss of the fraction part of the number.

Mentioned by 24/7 on wp-hackers

Attachments (3)

tests.png.png (32.4 KB) - added by dllh 3 years ago.
Display of some values tested with %f specifier
wpdb_float_test.php (2.0 KB) - added by dllh 3 years ago.
A little plugin that adds a Tools menu to test insertion of %f values
18407.patch (5.2 KB) - added by dllh 3 years ago.
Patch to update wp-db.php docs

Download all attachments as: .zip

Change History (9)

comment:1 nacin3 years ago

In return, we should probably add %f. I think there's another ticket for that.

comment:2 dd323 years ago

In return, we should probably add %f. I think there's another ticket for that.

Sounds good to me, But I don't recall seeing, and can't find, another ticket referencing that.

comment:3 dd323 years ago

In [18573]:

Clarify %d is an integer in wpdb documentation. See #18407

comment:4 dd323 years ago

Still needs some extra testing for %f and adding to the docs if it's appropriate.

dllh3 years ago

Display of some values tested with %f specifier

dllh3 years ago

A little plugin that adds a Tools menu to test insertion of %f values

dllh3 years ago

Patch to update wp-db.php docs

comment:5 dllh3 years ago

  • Cc daryl@… added
  • Keywords has-patch added; needs-patch removed

I've attached three files. One is a little plugin that makes it easy to test insertion of floats using the %f specifier. Another is graphic display of some values I tested (positive, negative, alphabetical, 0, and incorrect precision). The last is a patch that would update the phpdoc in wp-db.php should my testing prove of value.

comment:6 dd323 years ago

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

In [18714]:

Add documentation for floats (%f) to wpdb::prepare() and friends. Props dllh. Fixes #18407

Note: See TracTickets for help on using tickets.