Project

General

Profile

Actions

Bug #75780

closed

Invalid number format because of miscellaneous decimal separator

Added by D. Röhrig about 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Fluid
Target version:
Start date:
2016-04-19
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

The fluid method format.number is not working properly anymore since this commit [[https://forge.typo3.org/projects/typo3cms-core/repository/revisions/608631a3a080ccb6436c7e277af036a0c6a0ccaa]]. The reason is, that this change specifies the LC_NUMERIC now correctly.

But the resulting problem is, that format.number only works with numbers, which have a point as decimal separator. But with a comma as saparator like in the locale de_DE, it won't work anymore. I resolved the problem with


setlocale(LC_NUMERIC, 'C');

but this is not a proper solution, because the bug is somewhere in fluid. It is also a problem for the VHS viewhelper (<v:math.round decimals="2">).

My example code:


<f:format.number decimals="2">
<v:math.division b="1048576">
<v:media.size path="public{downloadfile.identifier}"/>
</v:math.division>
</f:format.number>


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #75141: config.locale_all does not set LC_ALLClosed2016-03-16

Actions
Has duplicate TYPO3 Core - Bug #75920: Extbase generic persistence casting float value to string causes wrong values if system locale is germanClosed2016-04-26

Actions
Actions #1

Updated by Mathias Schreiber about 8 years ago

  • Target version changed from 7.6.5 to Candidate for patchlevel
Actions #2

Updated by Christian Kuhn about 8 years ago

  • Target version changed from Candidate for patchlevel to 7.6.5

linked to the offending issue for now.

at first glance it looks as if we should definitely revert the patch in 7.6, for master i'm not sure yet.

Actions #3

Updated by Nicole Cordes about 8 years ago

  • Status changed from New to Needs Feedback
  • Assignee set to Nicole Cordes

Hi,

can you please describe what your exact problem is?

I have following settings and can't reproduce any error:

config.locale_all = deu_deu (I'm on a windows system)

incoming value in NumberViewHelper: 24966,095238095
outcoming result (without warnings/errors): 24,966.00

Following fluid:
<f:format.number decimals="2"><f:cObject typoscriptObjectPath="lib.someLibObject" /></f:format.number>

Following TypoScript:
lib.someLibObject = TEXT
lib.someLibObject {
value = 1048576 / 42
prioriCalc = 1
}

Actions #4

Updated by Thomas Kieslich about 8 years ago

Hi
Displaying is not a Problem.
But if you have a FE Form to edit a extbase Object with float properties validating and saving are broken.

In the FloatConverter.php i found this line:
// We won't backport the full flavored locale parsing of floats from Flow here

Perhaps it help to start.

Actions #5

Updated by Gerrit Code Review about 8 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47825

Actions #6

Updated by Gerrit Code Review about 8 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47825

Actions #7

Updated by Nicole Cordes about 8 years ago

  • Status changed from Under Review to New

Hi Thomas,

we found out, your problem is not related to the topic. Would you mind to add a new bug report for this problem?

Actions #8

Updated by Nicole Cordes about 8 years ago

  • Status changed from New to Needs Feedback

Hi D. Röhrig,

D. Röhrig wrote:

But the resulting problem is, that format.number only works with numbers, which have a point as decimal separator. But with a comma as saparator like in the locale de_DE, it won't work anymore. I resolved the problem with

can you please explain what is your incoming value before the patch and afterwards? It seems that neither vhs nor fluid convert any number with a comma as decimal separator. Unfortunately we haven't found any error this far.

Actions #9

Updated by Thomas Kieslich about 8 years ago

Hi Nicole,
you're right my problem is not primary format.number. But i think the root of the Problem is setlocale to.
I will add a new bug report.

Actions #10

Updated by Gerrit Code Review about 8 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47828

Actions #11

Updated by Gerrit Code Review about 8 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47828

Actions #12

Updated by D. Röhrig about 8 years ago

Hi,

Nicole Cordes wrote:
It seems that neither vhs nor fluid convert any number with a comma as decimal separator. Unfortunately we haven't found any error this far.

when I understand you correctly, than you found the error already. vhs and fluid convert only numbers with point as decimal separator and not with comma as separator. This is the problem. I didn't find any limitation in docu and hope this was not intended.

Before the change not all values of localeconv() were changed. Specially 'decimal_point' was set to '.' (default value), although I set de_DE.UTF-8 in typoscript.
But now, it is set to ',', and all values in fluid are separated with comma and so the returning value is always zero for format.number.

Nicole Cordes wrote:
can you please explain what is your incoming value before the patch and afterwards?

Here are some more in and outcoming values:

<v:math.division b="1048576">
<v:media.size path="public{downloadfile.identifier}"/>
</v:math.division>

Before I got for example 0.644345364 and after 0,644345364.

When I wrap it with

<v:math.round></v:math.round>
or
<f:format.number decimals="2"></f:format.number>

before I got 0.64 and after only 0.

Is it comprehensible now?

Actions #13

Updated by Gerrit Code Review about 8 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/47841

Actions #14

Updated by Nicole Cordes about 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #15

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF