Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#49690 closed defect (bug) (fixed)

Reconsider ja_JP usage in Tests_DB::test_locale_floats()

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.1
Component: Database Keywords:
Focuses: Cc:

Description

Background: [746/tests], [747/tests], #19861.

Tests_DB::test_locale_floats() ensures that floats formatted as 0,700 get sanitized properly by wpdb.

This is relevant for locales using comma as a decimal separator: ru_RU, fr_FR, de_DE, es_ES, and others.

[43359] / #43829 added ja_JP to the list. Per Wikipedia, Japan uses a dot, not a comma, as a decimal separator, so adding it here doesn't seem to serve any purpose and might cause some confusion.

Change History (3)

#1 @johnjamesjacoby
4 years ago

If I understand correctly, the goal with #43829 was to make multibyte testing easier, not necessarily intentionally related to locale specific formatting.

Are there float tests that are inadvertently failing when testing with ja_JP?

#2 @gh640
4 years ago

Are there float tests that are inadvertently failing when testing with ja_JP?

I'm not sure if there are failing tests but I think it doesn't make sense to use the locale ja_JP in Tests_DB::test_locale_floats(). Because Japan uses a dot as a decimal separator as mentioned. (I'm Japanese.)

Concretely, if $flag is set to ja_JP.utf8 or ja_JP in the following lines, it's better to skip the test with the message "No European languages available for testing" rather than to pass the test using the selected locale, I think.

<?php
    // Switch to Russian.
    $flag = setlocale( LC_ALL, 'ru_RU.utf8', 'rus', 'fr_FR.utf8', 'fr_FR', 'de_DE.utf8', 'de_DE', 'es_ES.utf8', 'es_ES', 'ja_JP.utf8', 'ja_JP' );
    if ( false === $flag ) {
      $this->markTestSkipped( 'No European languages available for testing' );
    }

So I think it's better to remove ja_JP.utf8 and ja_JP from there as proposed.

#3 @SergeyBiryukov
4 years ago

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

In 48317:

Tests: Remove ja_JP locale from Tests_DB::test_locale_floats().

This test is only relevant for locales using a comma as a decimal separator, while ja_JP uses a dot.

Props gh640, johnjamesjacoby, SergeyBiryukov.
Fixes #49690.

Note: See TracTickets for help on using tickets.