Project

General

Profile

Actions

Bug #16987

closed

TCE: wrong error message: "These fields are not properly updated in database"

Added by Franz Holzinger about 17 years ago. Updated about 17 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2007-02-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
5
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Since 4.1RC1 always an error message gets shown when you edit products with tt_products and save them. Only the fields with conf.eval = double2 have this problem, when nothing has been entered.

102: These fields are not properly updated in database: (price2,directcost,tax,weight,shipping,shipping2,handling) Probably value mismatch with fieldtype.

E.g. if you enter 2.34 as price2, then there is not error with price2. But if you enter 0.00, then you again get an error message. If you close the product editor and reopen it or just press continue at the error message, then everything has been saved correctly.

(issue imported from #M4987)


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #16805: Error while entering a numbers like 50 or 50.00 into a double2 fieldClosed2006-12-22

Actions
Actions #1

Updated by Franz Holzinger about 17 years ago

When $value is passed as '0.00' as a parameter, $theDec has '0000', but $value will be '0' instead of '0.00'.

t3lib/class.t3lib_tcemain.php:
checkValue_input_Eval($value,$evalArray,$is_in)

case 'double2':
$theDec = 0;
for ($a=strlen($value); $a>0; $a--) {
if (substr($value,$a-1,1)=='.' || substr($value,$a-1,1)==',') {
$theDec = substr($value,$a);
$value = substr($value,0,$a-1);
break;
}
}
$theDec = ereg_replace('[^0-9]','',$theDec).'00';
$value = (float)(intval(str_replace(' ','',$value)).'.'.substr($theDec,0,2));
break;

The then here it comes to this error message:
checkStoredRecord($table,$id,$fieldArray,$action) {

The fieldarray value is '0' and will be compared as a string with '0.00' which comes to a wrong result.

I do not know how this has been intended to work. The $value is a float '0' and comes from the $fieldArray, but the$row stores a string '0.00'. I would rather say that a float type should be used instead of a string datatype here.

price2 decimal(19,2) DEFAULT '0.00' NOT NULL,

tca.php:
'price2' => Array (
'exclude' => 1,
'label' => 'LLL:EXT:'.TT_PRODUCTS_EXTkey.'/locallang_db.xml:tt_products.price2',
'config' => Array (
'type' => 'input',
'size' => '12',
'eval' => 'trim,double2',
'max' => '20'
)
),

-------------------------
} elseif (strcmp($value,$row[$key])) {
$errorString[] = $key;
}

The Core-API document says:
double2 : Converts the input to a floating point with 2 decimal positions, using the "." (period) as the decimal delimited (accepts also "," for the same).
So I think a float data type should be used instead of a string.

Actions #2

Updated by Stefano Cecere about 17 years ago

i can confirm this but under RC1 (have several double2 fields that give error, whatever values i put in)

Actions #3

Updated by Stefano Cecere about 17 years ago

Franz: i don't understad: could you find a patch for this problem?

i'm investigating but no clue..

i confimr that data gets stored in the DB.. but typo3 ALWAYS reports error when saving a form..

i'm going looking into CVS to check what what modified in class.t3lib_tcemain.php

Actions #4

Updated by Stefano Cecere about 17 years ago

i could fix the problem going back to previous code:

$value = intval(str_replace(' ','',$value)).'.'.substr($theDec,0,2);

(i'm with PHP 5.1.8)

Actions #5

Updated by Michael Stucki about 17 years ago

Test (seems like mails can't be sent currently)

Actions #6

Updated by Oliver Hader about 17 years ago

I can confirm this. Removing the casting operator "(float)" solves the problem.
Tested on MySQL 5.0.32

Actions #7

Updated by Franz Holzinger about 17 years ago

I think it is correct to use it internally as a float when a double2 check has been demanded.

The strcmp should be replaced by a more complex function which considers the datatype of $value.
"} elseif (strcmp($value,$row[$key])) {"

In case of float type, both sides should be casted into float and compared afterwards.

Actions #8

Updated by Michael Stucki about 17 years ago

OK I will just revert the change.

Actions #9

Updated by Michael Stucki about 17 years ago

Reverted in TYPO3_4-0 and Trunk.

Actions

Also available in: Atom PDF