Project

General

Profile

Actions

Bug #21926

closed

t3lib_befunc::getFlexFormDS fails because of wrong inquiries

Added by David Bruchmann over 14 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2010-01-08
Due date:
% Done:

0%

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

Description

The incoming parameter $conf[ds] always has a syntax like
$conf[ds][ MODUL,TYPE] = VALUE;
Example:
$conf[ds][tt_address_pi1,list] = 'FILE:EXT:tt_address/pi1/flexform.xml';
The array $conf[ds] is mapped to $ds_array.

The incoming parameter $conf['ds_pointerField'] always has the syntax
$conf['ds_pointerField'] = 'FIELD1,FIELD2';

This Value is exploded in $pointerFields for WRONG usage:

1: if(count($pointerFields) == 2) {
2: if($ds_array[$row[$pointerFields0].','.$row[$pointerFields1]]) {
3: $srcPointer = $row[$pointerFields0].','.$row[$pointerFields1];
4: }

Whats Wrong?
the inquiry in line 2 always fails because the assumed syntax is wrong. The right syntax for a key in $conf[ds] is 'MODUL,TYPE' but the inquiry expects 'FIELD1,FIELD2'. Following Inquiries are wrong too.
So most Modules get the value "default" for $srcPointer which may work in most cases but not always.

(issue imported from #M13176)


Files

bug_13176_v1.diff (6.65 KB) bug_13176_v1.diff Administrator Admin, 2010-01-08 23:47
Actions #1

Updated by David Bruchmann over 14 years ago

An Example from ext_tables.php where the Extension itselfe works but disturbs other Extensions (don't know why):

$tempColumns = Array (
'select_key' => Array( // tx_mdbfeedit_pi1_datasource
'label' => 'Datenquelle',
'config' => array(
'type' => 'select',
'items' => array(
array('Auswahl-Menue','modeSelector'),
array('Datenbank-Tabelle','table'),
array('FlexForm','flexForm'),
),
)
),
'pi_flexform' => Array (
'config' => array(
'type' => 'flex',
'ds_pointerField' => 'list_type,select_key', //tx_mdbfeedit_pi1_datasource',
'ds' => array(
#'mdb_feedit_pi1,default' => 'FILE:EXT:mdb_feedit/pi1/flexform_ttcontent_ds_table.xml',
'mdb_feedit_pi1,modeSelector' => 'FILE:EXT:mdb_feedit/pi1/flexform_ttcontent_ds_modeSelector.xml',
'mdb_feedit_pi1,table' => 'FILE:EXT:mdb_feedit/pi1/flexform_ttcontent_ds_table.xml',
'mdb_feedit_pi1,flexForm' => 'FILE:EXT:mdb_feedit/pi1/flexform_ttcontent_ds_ff.xml',
),
),
),
);

Here the challenge is to get the second parameter from $tempColumns['select_key']['config']['items'][ x ] connected with the $srcPointer of my first post.
Actually I don't know from where to get it because I defined several files in an array, so there has to be the current one somewhere in a global array. In most cases the second parameter is 'list' but as you see, not in my case.

Actions #2

Updated by David Bruchmann over 14 years ago

Even if it's not the best way, I post the changed and tested code instead of a diff-file. I rearranged the inquiries because else the inquiries with "*" are omited. I tested only with two strings and never with "*" or one string for $pointerFields:

public static function getFlexFormDS($conf, $row, $table, $fieldName = '', $WSOL = TRUE, $newRecordPidValue = 0) {
global $TYPO3_CONF_VARS;
// Get pointer field etc from TCA-config:
$ds_pointerField = $conf['ds_pointerField'];
$ds_array = $conf['ds'];
$ds_tableField = $conf['ds_tableField'];
$ds_searchParentField = $conf['ds_pointerField_searchParent'];
// Find source value:
$dataStructArray = '';
if (is_array($ds_array)) { // If there is a data source array, that takes precedence
// If a pointer field is set, take the value from that field in the $row array and use as key.
if ($ds_pointerField) {
// Up to two pointer fields can be specified in a comma separated list.
$pointerFields = t3lib_div::trimExplode(',', $ds_pointerField);
// If we have two pointer fields, the array keys should contain both field values separated by comma. The asterisk "*" catches all values.
// For backwards compatibility, it's also possible to specify only the value of the first defined ds_pointerField.
if(count($pointerFields) 2) {
// Check if we have a DS for the value of the first pointer field suffixed with ",*"
if($ds_pointerField $pointerFields[0].',*') {
$srcPointer = $row[$pointerFields[0]].',*';
}
// Check if we have a DS for the value of the second pointer field prefixed with "*,"
elseif($ds_pointerField == '*,'.$pointerFields[1]) {
$srcPointer = '*';
if ($pointerFields[1]) $srcPointer .= ','.$row[$pointerFields[1]];
else $srcPointer .= ',list';
}
// Check if we have a DS for the combination of both pointer fields values
elseif($ds_pointerField == $pointerFields[0].','.$pointerFields[1]) {
$srcPointer = $row[$pointerFields[0]];
if ($row[$pointerFields[1]]) $srcPointer .= ','.$row[$pointerFields[1]];
else $srcPointer .= ',list';
}
// Check if we have a DS for just the value of the first pointer field (mainly for backwards compatibility)
elseif($pointerFields[0]) {
$srcPointer = $row[$pointerFields[0]];
}
} else {
$srcPointer = $row[$pointerFields[0]];
}
$srcPointer = isset($ds_array[$srcPointer]) ? $srcPointer : 'default';
} else $srcPointer = 'default';

[....]

Actions #3

Updated by David Bruchmann over 14 years ago

One open point:

when a plugin in BE was called where some code was inserted in a pointerfield (i.e. select_key) then this code is not deleted when the plugin is changed. This causes failure of getting the correct DS of the new plugin.
In the moment I have no idea how to fix it.

Actions #4

Updated by David Bruchmann over 14 years ago

provided patch bug_13176_v1.diff

Actions #5

Updated by David Bruchmann over 14 years ago

My Description in this Form isn't correct.

I had scenarios where my patch didn't work.

I'll post another patch with a better description...

Actions #6

Updated by Xavier Perseguers about 12 years ago

  • Assignee deleted (Steffen Kamper)
  • Target version deleted (0)
Actions #7

Updated by Alexander Opitz almost 11 years ago

  • Status changed from Accepted to Needs Feedback

The issue is very old, does this issue exists in newer versions of TYPO3 CMS (4.5 or 6.1)?

Actions #8

Updated by Alexander Opitz over 10 years ago

  • Status changed from Needs Feedback to Closed
  • Is Regression set to No

No feedback for over 90 days.

Actions

Also available in: Atom PDF