Project

General

Profile

Actions

Bug #22334

closed

Empty page subtitle can't be saved using dbal

Added by Rens Admiraal over 14 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2010-03-28
Due date:
% Done:

0%

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

Description

Saving a page with an empty subtitle field is resulting in the error:
102: These fields are not properly updated in database: (subtitle) Probably value mismatch with fieldtype.
The value of the field after the update is 'als' (false minus first and last letter)

DBAL configuration:
$TYPO3_CONF_VARS['EXTCONF']['dbal']['handlerCfg'] = array (
'_DEFAULT' => array (
'type' => 'adodb',
'config' => array (
'driver' => 'postgres8',
'port' => 5432,
'username' => 'user',
'password' => 'password',
'host' => 'localhost'
)
)
);
(credentials are also set in normal TYPO3 vars $typo3_db_username and so on)

OS: Windows 7 64 bit
PHP: 5.3.0
PostgreSQL 8.4
TYPO3 4.3.2
DBAL: 1.0.4
adodb: 5.10.0

==============
Possible solution ==============
I've done some debugging myself, and found that the subtitle field is handled as being boolean false during save. This is not true, because it should be an empty string. Some further investigation learnt that the field is an empty string when I set the eval configuration of the field to 'trim'.

I've searched a bit deeper, and found that the substr method of t3lib_cs can return false instead of a string (which is the documented return type). This is because the php method substr() return false if the length of the string is shorter than the length to which is should be truncated...

For now I solved my problem by changing the first line of this method from:
if ($len===0) return '';
to:
if ($len===0 || empty($string)) return '';

I do know that this handles only empty strings, and not all strings in which the source length is shorter than the destination length, but the problem only occured using an empty string. It might be a core thing, and not really dbal, but I'm not sure about that because I never had this before using dbal.
(issue imported from #M13934)


Files

13934.diff (552 Bytes) 13934.diff Administrator Admin, 2010-05-24 11:47
Actions #1

Updated by Xavier Perseguers over 14 years ago

empty() is not the valid operator according to PHP documentation:

Returns FALSE if var  has a non-empty and non-zero value.

The following things are considered to be empty:

  • "" (an empty string)
  • 0 (0 as an integer)
  • "0" (0 as a string)
  • NULL
  • FALSE
  • array() (an empty array)
  • var $var; (a variable declared, but without a value in a class)

Problem here is with string "0", I used an explicit test against the empty string in my patch.

Actions #2

Updated by Xavier Perseguers over 14 years ago

Committed to:

- TYPO3_trunk (rev. 7694)
- TYPO3_4-3 (rev. 7695)
- TYPO3_4-2 (rev. 7696)

Thanks for your patch Rens.

Actions

Also available in: Atom PDF