WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#19593 closed defect (bug) (fixed)

Incorrect plugin ratings on decimal comma locales

Reported by: SergeyBiryukov Owned by: nacin
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch commit
Focuses: Cc:

Description

On some PHP locales, comma is used as a decimal separator.

This creates visual problems with plugin ratings and tag cloud on Install Plugins screen (see the screenshot).

Browser fails to handle font-size attributes with commas properly, as CSS specification only supports decimal point as a separator:
http://www.w3.org/TR/CSS21/syndata.html#length-units

To reproduce, add this to wp-config.php:

setlocale(LC_ALL, 'fr_FR');

unserialize() in plugins_api() would then return values with commas, even if WP.org API returns them with points: http://core.trac.wordpress.org/browser/tags/3.3/wp-admin/includes/plugin-install.php#L48

Related: #18460

Attachments (3)

19593.plugin-ratings.png (115.6 KB) - added by SergeyBiryukov 8 years ago.
19593.patch (4.0 KB) - added by SergeyBiryukov 8 years ago.
19593.tag-cloud.png (118.8 KB) - added by SergeyBiryukov 8 years ago.

Download all attachments as: .zip

Change History (10)

#1 follow-up: @nacin
8 years ago

Perhaps the API call could return a string instead?

#2 in reply to: ↑ 1 @SergeyBiryukov
8 years ago

Replying to nacin:

Perhaps the API call could return a string instead?

I guess that would fix the ratings, but not the tag cloud (see the second screenshot).

#3 @nacin
8 years ago

That sounds like a problem with the tag cloud code, not here.

#5 @nacin
8 years ago

  • Keywords commit added

In the future, we should probably have a helper for this.

#6 @nacin
8 years ago

$theme->rating (which has moved to the customizer, so this patch no longer applies cleanly) is a number 1-100. It can be a float (the API simply takes the 1-5 rating and multiplies it by 20 to give a percentage), but the customizer intval()'s it. So we're good there.

#7 @nacin
8 years ago

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

In [20675]:

Replace commas with periods when converting ratings float values to strings, to avoid issues with localized decimal points.

In these cases, we want a period because it is going to be used by CSS.

props SergeyBiryukov.
fixes #19593.

Note: See TracTickets for help on using tickets.