[wp-trac] [WordPress Trac] #55942: Add a "value type" parameter to get_option() and get_metadata()

WordPress Trac noreply at wordpress.org
Sat Apr 29 13:13:06 UTC 2023


#55942: Add a "value type" parameter to get_option() and get_metadata()
-------------------------------------------------+-------------------------
 Reporter:  azaozz                               |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  6.3
Component:  Options, Meta APIs                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing                                        |  performance
-------------------------------------------------+-------------------------

Comment (by Otto42):

 Replying to [comment:54 rjasdfiii]:
 > Be aware that MySQL has a "DECIMAL(m,n)" format for things such as
 currency, but PHP simply throws them into "DOUBLE".  This can lead to
 roundoff errors and other rare monetary errors.

 I don't believe we are using a decimal column anywhere in WordPress. So
 such a thing would likely be for completionist only.

 However, the solutions I've seen to this, that do not involve weird or
 extra type systems, have usually been to represent the value as a string.
 This generally avoids people doing math with them, essentially. Which is
 where the problem would come in to messing with currency in such a manner.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55942#comment:55>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list