Customfield as textarea - only first 2 chars arrive in dbase

Ask community to help.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
rkorinth
TestLink user
Posts: 8
Joined: Wed Feb 27, 2008 2:56 pm

Customfield as textarea - only first 2 chars arrive in dbase

Post by rkorinth »

Hi there. We have just started playing with your testcase tracker. Very good impression so far.

We are using MS SQL Server 2005 as database server and version 1.7.4 of TestLink. The admin has created a customfield named Precondition for testcases -> looks fine on the testcase editor.

I have created a testcase and added a text in the Precondition field. When I look at the test case after saving all but the first two characters of the Precondition have disappeared. We checked in the databse - also only two characters. As far as I can see this applies to inserts and updates.

Any idea? Are we doing anything wrong?

Thanks a lot for your help and greetings from Zurich.

Ralf
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Post by fman »

No idea,
please add some echos to code to display sql statement
rkorinth
TestLink user
Posts: 8
Joined: Wed Feb 27, 2008 2:56 pm

Post by rkorinth »

I have located cfield_mgr.class and the method design_values_to_db() as the relevant place to check the sql statement. So I put in

echo($sql);

right before the query is executed.

I was hoping to see the sql statement in my browser - but no such luck. Not being a PHP expert by any account I'm not sure where I went wrong. Are the classes compiled and cached by any chance so that the server ignores my changes?

Thanks for your help.
rkorinth
TestLink user
Posts: 8
Joined: Wed Feb 27, 2008 2:56 pm

Post by rkorinth »

Sorry, my mistake. I think I saved the wrong file. echo($sql); is working now.

Result is:

UPDATE cfield_design_values SET value=' 123' WHERE field_id=1 AND node_id=3
UPDATE cfield_design_values SET value='12345678901234567890' WHERE field_id=2 AND node_id=3

The second statement is for a customfield defined as string - all working as expected.

The first statement is for a customfield defined as textarea. My input again was 12345678901234567890. But only 123 is sent to the database.

Any ideas?
rkorinth
TestLink user
Posts: 8
Joined: Wed Feb 27, 2008 2:56 pm

Post by rkorinth »

I added a few more echo statements to zoom into the problem.

Surprisingly the length of the string turns out to be 272 where I was only expecting 20. $this->max_length_value is 255 as set at the top of the file. So the substr in the if statement is executed.

When I check $value after the substr has been executed all but the first three characters have been cut off.

Not sure whether there are issues in PHP with the substr function. Maybe $value is not a string and there is an implicit cast happening on the way?

Very much looking forward to your opinion.

Ralf
rkorinth
TestLink user
Posts: 8
Joined: Wed Feb 27, 2008 2:56 pm

Post by rkorinth »

I just managed to drag a colleague with some good PHP knowledge to my screen. He suggested adding a trim to the following line:

$value = $type_and_value['cf_value'];

becomes

$value = trim($type_and_value['cf_value']);

The problem then disappears.
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Post by fman »

Thanks for your help, we will try to add some new checks.
Doing trim is a workaround, but can cause other problems like:
if your intention was adding 4 spaces before firts letter you will loose it.


regards
rkorinth
TestLink user
Posts: 8
Joined: Wed Feb 27, 2008 2:56 pm

Post by rkorinth »

So that'll appear in one of the next releases automatically? We will be keen to upgrade to the new version once this is fixed.

True - trim() is not more than a workaround.
Post Reply