GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
  • MediaWiki-Internationalization
  • (Backlog)
  • I18n

This view

  • Original page
  • New address

GeezerVison is showing phabricator.wikimedia.org — T181987 Thumbnails are broken (False decimal point in srcset when locale is not English)

Page MenuHomePhabricator
Log In
Create Task
Maniphest T181987

Thumbnails are broken (False decimal point in srcset when locale is not English)
Open, MediumPublicBUG REPORT
Actions

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Related Objects...
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
Assigned To
None
Authored By
vsandre
Dec 4 2017, 12:58 PM2017-12-04 12:58:36 (UTC+0)
Project Tags
  • MediaWiki-Internationalization (Backlog)
  • I18n (Untriaged)
  • Platform Engineering (Icebox)
Referenced Files
None
Subscribers
Aklapper
Aschroet
• Chealer
Christian75
Ciencia_Al_Poder
Helland
Hwboehm
View All 21 Subscribers

Description

Since update to MediaWiki 1.30 there is a problem with decimal point in the values of a srcset for images.

expected: srcset="URL1 1.5x, URL2 2x" [.]
but you get: srcset="URL1 1,5x, URL2 2x" [,]

The image display fails. For now I disabled the Responsiv Images. But I don't know where else this problem occurs.

Locale is set to:
$wgShellLocale = "de_DE.utf8";

mediawiki 1.29 and now 1.30rc

Related Objects

  • Mentions
  • Duplicates
Mentioned In
T310607: Try to migrate and upgrade wiki.wikimedia.it on server intreccio
T188541: mw.language:formatNum Lua function with noCommafy parameter does not localize decimal point
T189877: Cirrussearch Error "An error has occurred while searching" due to comma used as decimal separator
T241533: TimestampException: ConvertibleTimestamp::setTimestamp: Invalid timestamp (timestamp with decimal point represented with a comma)
T212942: Mediawiki. Html::srcSet(...). Invalid srcset creation depending on $wgShellLocale setting.
T208942: Thumbnail not displaying because of srcset attribute
T208473: srcset attribute output should not be dependent of underlying OS locale
Mentioned Here
T189877: Cirrussearch Error "An error has occurred while searching" due to comma used as decimal separator
T241533: TimestampException: ConvertibleTimestamp::setTimestamp: Invalid timestamp (timestamp with decimal point represented with a comma)
T183659: locale-aware float to string conversion in Html::srcSet
T183660: srcset uses incorrect radix character
T184458: Floats are badly interpreted in SQL when locale is not English
Duplicates Merged Here
T224105: The image sizing not work in $wgShellLocale="fr_FR.utf8" and return link image
T212942: Mediawiki. Html::srcSet(...). Invalid srcset creation depending on $wgShellLocale setting.
T208942: Thumbnail not displaying because of srcset attribute
T208473: srcset attribute output should not be dependent of underlying OS locale
T183659: locale-aware float to string conversion in Html::srcSet

Event Timeline

vsandre created this task.Dec 4 2017, 12:58 PM2017-12-04 12:58:36 (UTC+0)
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 4 2017, 12:58 PM2017-12-04 12:58:36 (UTC+0)
vsandre updated the task description. (Show Details)Dec 4 2017, 12:59 PM2017-12-04 12:59:28 (UTC+0)
Aklapper added projects: [DO NOT USE] NewPHP, MediaWiki-General.Dec 4 2017, 1:12 PM2017-12-04 13:12:51 (UTC+0)
Comment Actions

Thanks for reporting this!
"Responsive Images" means https://www.mediawiki.org/wiki/Manual:$wgResponsiveImages ?

Reedy moved this task from Unsorted to PHP 7.2 on the [DO NOT USE] NewPHP board.Dec 4 2017, 1:15 PM2017-12-04 13:15:19 (UTC+0)
Reedy subscribed.Dec 4 2017, 1:17 PM2017-12-04 13:17:56 (UTC+0)
Comment Actions

That looks like something is applying european style number formatting (. swapped for ,)

Reedy added a comment.Dec 4 2017, 1:19 PM2017-12-04 13:19:15 (UTC+0)
Comment Actions
	static function srcSet( array $urls ) {
		$candidates = [];
		foreach ( $urls as $density => $url ) {
			// Cast density to float to strip 'x', then back to string to serve
			// as array index.
			$density = (string)(float)$density;
			$candidates[$density] = $url;
		}

		// Remove duplicates that are the same as a smaller value
		ksort( $candidates, SORT_NUMERIC );
		$candidates = array_unique( $candidates );

		// Append density info to the url
		foreach ( $candidates as $density => $url ) {
			$candidates[$density] = $url . ' ' . $density . 'x';
		}

		return implode( ", ", $candidates );
	}

Does casting to a float if local is de cause this problem?

Reedy edited projects, added: MediaWiki-Internationalization, I18n; removed: MediaWiki-General.Dec 4 2017, 7:34 PM2017-12-04 19:34:08 (UTC+0)
Seb35 merged a task: T183659: locale-aware float to string conversion in Html::srcSet.Jan 8 2018, 4:55 PM2018-01-08 16:55:49 (UTC+0)
Seb35 added subscribers: Ciencia_Al_Poder, TheDJ.
Seb35 removed a project: [DO NOT USE] NewPHP.Jan 8 2018, 5:06 PM2018-01-08 17:06:05 (UTC+0)
Seb35 subscribed.
Comment Actions
In T183660#3859726, @TheDJ wrote:

We could either use number_format, but then we end up with 1.0x instead of 1x, or I guess we can do character replacement...
Neither is particularly ideal really...

In T183659, @Ciencia_Al_Poder wrote:

I wonder if it would be safe to simply set setlocale(LC_NUMERIC, "C") somewhere on the code. Who knows where else it may be happening.

I just opened an other but related issue T184458 with floats being truncated to their integer part in SQL when locale is not English. Setting setlocale(LC_NUMERIC, "C") would solve both issues, but it will probably have side-effects elsewhere.

This is probably a common issue in PHP world, perhaps other projects have fixed it in a nice manner.

PS: this is not related to PHP 7.2, it can be reproduced with older PHP versions.

Seb35 renamed this task from False decimal point in srcset #php7.2 to False decimal point in srcset when locale is not English.Jan 8 2018, 5:07 PM2018-01-08 17:07:24 (UTC+0)
TheDJ added a comment.Jan 29 2018, 1:27 PM2018-01-29 13:27:24 (UTC+0)
Comment Actions

Another report: https://www.mediawiki.org/wiki/Topic:U67iphtqgcy5fob4

Christian75 subscribed.Mar 1 2018, 10:41 AM2018-03-01 10:41:53 (UTC+0)
Magol subscribed.Jun 15 2018, 9:50 AM2018-06-15 09:50:32 (UTC+0)
Ciencia_Al_Poder added a comment.Jul 24 2018, 8:51 AM2018-07-24 08:51:34 (UTC+0)
Comment Actions

From a comment in https://www.mediawiki.org/wiki/Topic:U7h4x03lzgbzd2qd#flow-post-uhgx58vkowl5xsoh:

Setting setlocale(LC_NUMERIC, "C"); alone doesn't solve the problem (or not always?, I dunno). The user had to comment out/unset $wgShellLocale for this to work. Maybe MediaWiki does another setlocale with $wgShellLocale during setup, overriding any previous setlocale in LocalSettings.php.

Reise_Reise subscribed.Aug 6 2018, 5:41 PM2018-08-06 17:41:36 (UTC+0)
Reise_Reise added a comment.Aug 6 2018, 8:09 PM2018-08-06 20:09:16 (UTC+0)
Comment Actions

Our wiki (Marjorie-Wiki) is using (nearly) the same templates as de.wikipedia.org.
It is a German wiki, so we were using
$wgShellLocale = "de_DE.utf8";
$wgLanguageCode = "de";
We were using Mediawiki 1.28.3 (with PHP 7.0). $wgResponsiveImages was "true" (and working). The Template:Coordinate was working like expected (i.e. like at de.wikipedia.org).

After updating from 1.28.3 to 1.30.0 our thumbnails were broken.
Furthermore Template:Coordinate expanded to

<span class="geo microformat"><span class="body"></span><span class="latitude">48,46471</span><span class="longitude">8,6613</span><span class="elevation"></span></span><span id="coordinates" class="coordinates plainlinks-print"><span title="Koordinatensystem WGS84">…

(note the commas instead of colons)

First quick solution was $wgResponsiveImages=false, which brought the thumbnails back.

Setting
setlocale(LC_NUMERIC, "C");
together with
$wgShellLocale = "de_DE.utf8";
did not make responsive images or Coordinates working again.

However setting
$wgShellLocale = "C.UTF-8";
as described in
https://www.mediawiki.org/wiki/MediaWiki_1.30#Configuration_changes
and
https://www.mediawiki.org/wiki/Manual:$wgShellLocale
together with
$wgResponsiveImages=true
and without the
setlocale(LC_NUMERIC, "C");
made responsive images and Template:Coordinate work again.
(right now responsive images are intentionally deactivated for testing purposes)

Aklapper mentioned this in T208473: srcset attribute output should not be dependent of underlying OS locale.Oct 31 2018, 10:55 PM2018-10-31 22:55:01 (UTC+0)
Aklapper merged a task: T208473: srcset attribute output should not be dependent of underlying OS locale.Nov 1 2018, 7:19 AM2018-11-01 07:19:41 (UTC+0)
Aklapper added a subscriber: Helland.
Aklapper mentioned this in T208942: Thumbnail not displaying because of srcset attribute.Nov 7 2018, 12:03 PM2018-11-07 12:03:50 (UTC+0)
Aklapper merged a task: T208942: Thumbnail not displaying because of srcset attribute.
Aklapper added a subscriber: MaltemoSveg.
Aklapper mentioned this in T212942: Mediawiki. Html::srcSet(...). Invalid srcset creation depending on $wgShellLocale setting..Jan 4 2019, 4:08 PM2019-01-04 16:08:08 (UTC+0)
Aklapper merged a task: T212942: Mediawiki. Html::srcSet(...). Invalid srcset creation depending on $wgShellLocale setting..
Aklapper added a subscriber: Illovo.
Hwboehm subscribed.Feb 12 2019, 12:35 PM2019-02-12 12:35:34 (UTC+0)
Raymond subscribed.May 21 2019, 1:56 PM2019-05-21 13:56:34 (UTC+0)
Aklapper merged a task: T224105: The image sizing not work in $wgShellLocale="fr_FR.utf8" and return link image.May 22 2019, 12:21 PM2019-05-22 12:21:46 (UTC+0)
Aklapper added a subscriber: LaMottePicquet.
Aklapper added a project: Platform Engineering.Aug 9 2019, 5:58 AM2019-08-09 05:58:51 (UTC+0)
Comment Actions

As this task has many duplicates I'm boldly adding Platform Engineering and ask for feedback (though wondering if this could also be Language related)?

• mobrovac moved this task from Inbox to Triage Meeting Inbox on the Platform Engineering board.Aug 9 2019, 10:27 AM2019-08-09 10:27:14 (UTC+0)
• WDoranWMF triaged this task as Medium priority.Aug 13 2019, 6:06 PM2019-08-13 18:06:46 (UTC+0)
• WDoranWMF edited projects, added: Platform Team Workboards (Clinic Duty Team); removed: Platform Engineering.
Anomie subscribed.Aug 13 2019, 6:10 PM2019-08-13 18:10:09 (UTC+0)
Comment Actions
In T181987#4447120, @Ciencia_Al_Poder wrote:

Maybe MediaWiki does another setlocale with $wgShellLocale during setup, overriding any previous setlocale in LocalSettings.php.

At Setup.php line 141, the setting of LC_ALL overrides the LC_NUMERIC. I wonder whether there would be any drawback to MediaWiki doing setlocale( LC_NUMERIC, 'C' ) just after that line unconditionally.

• mobrovac moved this task from Inbox to Discussing on the Platform Team Workboards (Clinic Duty Team) board.Aug 14 2019, 10:54 AM2019-08-14 10:54:33 (UTC+0)
• mobrovac subscribed.
Comment Actions
In T181987#5412479, @Anomie wrote:
In T181987#4447120, @Ciencia_Al_Poder wrote:

Maybe MediaWiki does another setlocale with $wgShellLocale during setup, overriding any previous setlocale in LocalSettings.php.

At Setup.php line 141, the setting of LC_ALL overrides the LC_NUMERIC. I wonder whether there would be any drawback to MediaWiki doing setlocale( LC_NUMERIC, 'C' ) just after that line unconditionally.

Wouldn't that mess with the way decimal points are displayed then?

Anomie added a comment.Aug 14 2019, 1:52 PM2019-08-14 13:52:40 (UTC+0)
Comment Actions

It would mess with the way decimal points are displayed when PHP code casts a float to a string, as in the cases being complained about by this bug. It shouldn't affect code that is using Language::formatNum(), which is what anything in MediaWiki actually displaying decimal points for humans to read should be using.

More specifically, it shouldn't affect anything on Wikimedia wikis because those all already use C.UTF-8, and as far as I know C versus C.UTF-8 doesn't make a difference for LC_NUMERIC.

• Chealer subscribed.Dec 2 2019, 2:42 AM2019-12-02 02:42:58 (UTC+0)
• Chealer renamed this task from False decimal point in srcset when locale is not English to Thumbnails are broken (False decimal point in srcset when locale is not English).Dec 2 2019, 2:45 AM2019-12-02 02:45:55 (UTC+0)
• Chealer updated the task description. (Show Details)
Ciencia_Al_Poder mentioned this in T241533: TimestampException: ConvertibleTimestamp::setTimestamp: Invalid timestamp (timestamp with decimal point represented with a comma).Dec 29 2019, 11:59 AM2019-12-29 11:59:48 (UTC+0)
Ciencia_Al_Poder added a comment.Dec 29 2019, 12:02 PM2019-12-29 12:02:27 (UTC+0)
Comment Actions

Today a user on IRC came with a similar problem on 1.34, but this time an exception when saving an edit, where a timestamp was being represented with a comma instead of a dot: T241533

The solution was to set $wgShellLocale = "C.UTF-8"; the same as this problem.

Resolving the core issue will result both problems

• AMooney moved this task from Discussing to Teleport on the Platform Team Workboards (Clinic Duty Team) board.Mar 24 2020, 6:52 PM2020-03-24 18:52:19 (UTC+0)
• WDoranWMF edited projects, added: Platform Engineering (Icebox); removed: Platform Team Workboards (Clinic Duty Team).Mar 24 2020, 9:48 PM2020-03-24 21:48:17 (UTC+0)
taavi subscribed.Jul 23 2020, 3:22 PM2020-07-23 15:22:07 (UTC+0)
Aschroet subscribed.Oct 10 2020, 6:28 PM2020-10-10 18:28:54 (UTC+0)
Aschroet added a comment.Oct 10 2020, 6:36 PM2020-10-10 18:36:23 (UTC+0)
Comment Actions

For the current 1.35 we experienced the same problem as in the original description above. At the same time, we have a very similar locale-related issue with Cirrussearch which should have been solved already (T189877).
We are currently experimenting with the suggested workarounds. But anyway, it would be desirable to have a general solution for all these locale-related problems.

Aklapper removed a subscriber: Anomie.Oct 16 2020, 5:02 PM2020-10-16 17:02:18 (UTC+0) ·
Aschroet mentioned this in T189877: Cirrussearch Error "An error has occurred while searching" due to comma used as decimal separator.Oct 20 2020, 7:01 AM2020-10-20 07:01:45 (UTC+0)
Aklapper mentioned this in T188541: mw.language:formatNum Lua function with noCommafy parameter does not localize decimal point.Nov 5 2020, 3:22 PM2020-11-05 15:22:30 (UTC+0)
Tgr awarded a token.Jun 12 2022, 8:23 PM2022-06-12 20:23:21 (UTC+0)
Tgr subscribed.
valerio.bozzolan subscribed.Jul 23 2022, 11:54 AM2022-07-23 11:54:08 (UTC+0)
valerio.bozzolan mentioned this in T310607: Try to migrate and upgrade wiki.wikimedia.it on server intreccio.Jul 23 2022, 12:00 PM2022-07-23 12:00:50 (UTC+0)
• Chealer added a comment.Feb 13 2023, 4:23 PM2023-02-13 16:23:18 (UTC+0)
Comment Actions
In T181987#3808826, @Reedy wrote:
	static function srcSet( array $urls ) {
		$candidates = [];
		foreach ( $urls as $density => $url ) {
			// Cast density to float to strip 'x', then back to string to serve
			// as array index.
			$density = (string)(float)$density;
			$candidates[$density] = $url;
		}

		// Remove duplicates that are the same as a smaller value
		ksort( $candidates, SORT_NUMERIC );
		$candidates = array_unique( $candidates );

		// Append density info to the url
		foreach ( $candidates as $density => $url ) {
			$candidates[$density] = $url . ' ' . $density . 'x';
		}

		return implode( ", ", $candidates );
	}

Does casting to a float if local is de cause this problem?

Not casting to a float per se, but casting back to a string. It would be best to simply strip non-alphabetic characters, as done in the following commit: https://github.com/wikimedia/mediawiki/pull/152/commits/01596cdc19c660a7f26d30098e057b9946c5db45

• Chealer changed the subtype of this task from "Task" to "Bug Report".Jul 8 2025, 5:30 PM2025-07-08 17:30:02 (UTC+0)
Comment Actions

The problematic code has moved to includes/Html/Html.php. The function code still looks incorrect, but I must say I am not sure this still affects MediaWiki 1.39.13, given that:

  1. mine seems to work fine even now that I disabled my workaround
  2. there is a lot less activity in this report than it used to.

Thank you for reporting

All comments and attachments which I added to this ticket are offered under the terms of CC0 1.0. So is the fix I linked to.

• Chealer awarded a token.Jul 8 2025, 5:30 PM2025-07-08 17:30:14 (UTC+0)
Log In to Comment
Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.