Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#41366 new enhancement

WordPress makes uses of decimal prefix and uses binary multiplicator for constant memory size value

Reported by: sebm78 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version: 4.8
Component: General Keywords: close
Focuses: ui Cc:


defined here: wp-includes/default-constants.php line 25-28
constants in: define('{decimal_prefix}_IN_BYTES' , 1024 * {decimal_prefix}_IN_BYTES );
should be: define('{binary_prefix}_IN_BYTES' , 1024 * {binary_prefix}_IN_BYTES );
or should be: define('{decimal_prefix}_IN_BYTES' , 1000* {decimal_prefix}_IN_BYTES );

where {decimal_prefix} is one of: ,K, M, G, T and {binary_prefix} is one of: ,Ki, Mi, Gi, Ti.

See https://en.wikipedia.org/wiki/Binary_prefix.

Change History (3)

#1 @SergeyBiryukov
4 years ago

Introduced in [35286], see #22405.

#2 @jnylen0
4 years ago

  • Keywords close added

This is unlikely to change for a couple of reasons.

  1. Backwards compatibility (with both core and plugins - a quick scan shows around 1.3 million installs of plugins that use these constants)
  2. While no longer considered technically correct, this is commonly accepted usage in the computer industry. From the linked Wikipedia article:

The computer industry has historically used the units kilobyte, megabyte, and gigabyte, and the corresponding symbols KB, MB, and GB, in at least two slightly different measurement systems. In citations of main memory (RAM) capacity, gigabyte customarily means 1073741824 bytes. As this is a power of 1024, and 1024 is a power of two (210), this usage is referred to as a binary measurement.

For future reference, it is also quite helpful to include a direct link to the code in the ticket description, like https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/default-constants.php?marks=25-28#L8. Note:

  • Linking to a specific released version rather than trunk, so that the line numbers won't change over time
  • Linking to a specific line number at the top of a section to provide context
  • Using ?marks=... to highlight a section of the code

#3 @sebm78
4 years ago

  • Severity changed from normal to trivial
  • Version changed from trunk to 4.8

There are many ways to circumvent the problem.
Correctness is useful.
The changes were introduced partly to normalize file size expression.
It's ironic when you look at what follows, isn't it.
Core is doable. Plugins are at runtime solvable.
Remember these constants were introduced 21 months ago, WP 4.4 introduced.
So there are, perhaps, potentially, 1.3 million deployed plugins impacted.

Thanks for the note.

Last edited 4 years ago by sebm78 (previous) (diff)
Note: See TracTickets for help on using tickets.