50 'sys_history' => TRUE,
51 'tx_extensionmanager_domain_model_extension' => TRUE
67 'perms_userid' => TRUE,
68 'perms_groupid' => TRUE,
70 'perms_group' => TRUE,
71 'perms_everybody' => TRUE,
178 if (isset(static::$nonRelationTables[$tableName])) {
183 $cacheId = static::$cachePrefixTableRelationFields. $tableName;
184 if (!$this->runtimeCache->has($cacheId)) {
186 $this->runtimeCache->set($cacheId, $tableRelationFields);
188 $tableRelationFields = $this->runtimeCache->get($cacheId);
192 $currentRelations =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
195 'tablename=' .
$GLOBALS[
'TYPO3_DB']->fullQuoteStr($tableName,
'sys_refindex')
211 // First, check if already indexed and if so, unset that row (so in the end we know which rows to remove!) 212 if (isset($currentRelations[$relations[$k]['hash
']])) { 213 unset($currentRelations[$relations[$k]['hash
']]); 214 $result['keptNodes
']++; 215 $relations[$k]['_ACTION
'] = 'KEPT
'; 219 $GLOBALS['TYPO3_DB
']->exec_INSERTquery('sys_refindex
', $relations[$k]); 221 $result['addedNodes
']++; 222 $relations[$k]['_ACTION
'] = 'ADDED
'; 225 $result['relations
'] = $relations; 231 // If any old are left, remove them: 232 if (!empty($currentRelations)) { 233 $hashList = array_keys($currentRelations); 234 if (!empty($hashList)) { 235 $result['deletedNodes
'] = count($hashList); 236 $result['deletedNodes_hashList
'] = implode(',
', $hashList); 238 $GLOBALS['TYPO3_DB
']->exec_DELETEquery('sys_refindex
', 'hash IN (
' . implode(',
', $GLOBALS['TYPO3_DB
']->fullQuoteArray($hashList, 'sys_refindex
')) . ')
'); 255 public function generateRefIndexData($tableName, $uid) { 257 if (!isset($GLOBALS['TCA
'][$tableName])) { 261 $this->relations = array(); 263 // Fetch tableRelationFields and save them in cache if not there yet 264 $cacheId = static::$cachePrefixTableRelationFields . $tableName; 265 if (!$this->runtimeCache->has($cacheId)) { 266 $tableRelationFields = $this->fetchTableRelationFields($tableName); 267 $this->runtimeCache->set($cacheId, $tableRelationFields); 269 $tableRelationFields = $this->runtimeCache->get($cacheId); 272 // Return if there are no fields which could contain relations 273 if ($tableRelationFields === '') { 274 return $this->relations; 277 $deleteField = $GLOBALS['TCA
'][$tableName]['ctrl
']['delete']; 279 if ($tableRelationFields === '*
') { 280 // If one field of a record is of type flex, all fields have to be fetched to be passed to BackendUtility::getFlexFormDS 283 // otherwise only fields that might contain relations are fetched 284 $selectFields = 'uid,
' . $tableRelationFields . ($deleteField ? ',
' . $deleteField : ''); 287 // Get raw record from DB: 288 $record = $GLOBALS['TYPO3_DB
']->exec_SELECTgetSingleRow($selectFields, $tableName, 'uid=
' . (int)$uid); 289 if (!is_array($record)) { 294 $this->words_strings = array(); 295 $this->words = array(); 298 $deleted = $deleteField && $record[$deleteField] ? 1 : 0; 300 // Get all relations from record: 301 $recordRelations = $this->getRelations($tableName, $record); 302 // Traverse those relations, compile records to insert in table: 303 foreach ($recordRelations as $fieldName => $fieldRelations) { 305 switch ((string)$fieldRelations['type
']) { 307 $this->createEntryData_dbRels($tableName, $uid, $fieldName, '', $deleted, $fieldRelations['itemArray
']); 309 case 'file_reference
': 310 // not used (see getRelations()), but fallback to file 312 $this->createEntryData_fileRels($tableName, $uid, $fieldName, '', $deleted, $fieldRelations['newValueFiles
']); 316 if (is_array($fieldRelations['flexFormRels
']['db
'])) { 317 foreach ($fieldRelations['flexFormRels
']['db
'] as $flexPointer => $subList) { 318 $this->createEntryData_dbRels($tableName, $uid, $fieldName, $flexPointer, $deleted, $subList); 321 // File references in flexforms 322 // @todo #65463 Test correct handling of file references in flexforms 323 if (is_array($fieldRelations['flexFormRels
']['file
'])) { 324 foreach ($fieldRelations['flexFormRels
']['file
'] as $flexPointer => $subList) { 325 $this->createEntryData_fileRels($tableName, $uid, $fieldName, $flexPointer, $deleted, $subList); 328 // Soft references in flexforms 329 // @todo #65464 Test correct handling of soft references in flexforms 330 if (is_array($fieldRelations['flexFormRels
']['softrefs
'])) { 331 foreach ($fieldRelations['flexFormRels
']['softrefs
'] as $flexPointer => $subList) { 332 $this->createEntryData_softreferences($tableName, $uid, $fieldName, $flexPointer, $deleted, $subList['keys
']); 337 // Soft references in the field: 338 if (is_array($fieldRelations['softrefs
'])) { 339 $this->createEntryData_softreferences($tableName, $uid, $fieldName, '', $deleted, $fieldRelations['softrefs
']['keys
']); 343 return $this->relations; 364 public function createEntryData($table, $uid, $field, $flexpointer, $deleted, $ref_table, $ref_uid, $ref_string = '', $sort = -1, $softref_key = '', $softref_id = '') { 365 if (BackendUtility::isTableWorkspaceEnabled($table)) { 366 $element = BackendUtility::getRecord($table, $uid, 't3ver_wsid
'); 367 if ($element !== NULL && isset($element['t3ver_wsid
']) && (int)$element['t3ver_wsid
'] !== $this->getWorkspaceId()) { 368 //The given Element is ws-enabled but doesn't live in the selected workspace
374 'tablename' => $table,
377 'flexpointer' => $flexpointer,
378 'softref_key' => $softref_key,
379 'softref_id' => $softref_id,
381 'deleted' => $deleted,
383 'ref_table' => $ref_table,
384 'ref_uid' => $ref_uid,
385 'ref_string' => $ref_string
402 foreach ($items as $sort => $i) {
403 $this->relations[] = $this->
createEntryData($table, $uid, $fieldname, $flexpointer, $deleted, $i[
'table'], $i[
'id'],
'', $sort);
420 foreach ($items as $sort => $i) {
421 $filePath = $i[
'ID_absFile'];
425 $this->relations[] = $this->
createEntryData($table, $uid, $fieldname, $flexpointer, $deleted,
'_FILE', 0, $filePath, $sort);
442 if (is_array($keys)) {
443 foreach ($keys as $spKey => $elements) {
444 if (is_array($elements)) {
445 foreach ($elements as $subKey => $el) {
446 if (is_array($el[
'subst'])) {
447 switch ((
string) $el[
'subst'][
'type']) {
449 list($tableName, $recordId) = explode(
':', $el[
'subst'][
'recordRef']);
450 $this->relations[] = $this->
createEntryData($table, $uid, $fieldname, $flexpointer, $deleted, $tableName, $recordId,
'', -1, $spKey, $subKey);
452 case 'file_reference':
455 $this->relations[] = $this->
createEntryData($table, $uid, $fieldname, $flexpointer, $deleted,
'_FILE', 0, $el[
'subst'][
'relFileName'], -1, $spKey, $subKey);
458 $this->relations[] = $this->
createEntryData($table, $uid, $fieldname, $flexpointer, $deleted,
'_STRING', 0, $el[
'subst'][
'tokenValue'], -1, $spKey, $subKey);
489 foreach ($row as $field => $value) {
490 if (!isset(static::$nonRelationFields[$field]) && is_array(
$GLOBALS[
'TCA'][$table][
'columns'][$field]) && (!$onlyField || $onlyField === $field)) {
491 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
494 if (!empty($resultsFromFiles)) {
499 $fileResultsFromFiles = array();
500 $dbResultsFromFiles = array();
501 foreach ($resultsFromFiles as $resultFromFiles) {
502 if (isset($resultFromFiles[
'table']) && $resultFromFiles[
'table'] ===
'sys_file') {
503 $dbResultsFromFiles[] = $resultFromFiles;
506 $fileResultsFromFiles[] = $resultFromFiles;
509 if (!empty($fileResultsFromFiles)) {
510 $outRow[$field] = array(
512 'newValueFiles' => $fileResultsFromFiles
515 if (!empty($dbResultsFromFiles)) {
516 $outRow[$field] = array(
518 'itemArray' => $dbResultsFromFiles
523 if ($conf[
'type'] ===
'input' && isset($conf[
'wizards'][
'link']) && empty($conf[
'softref'])) {
524 $conf[
'softref'] =
'typolink';
528 if (!empty($resultsFromDatabase)) {
530 $outRow[$field] = array(
532 'itemArray' => $resultsFromDatabase
536 if ($conf[
'type'] ==
'flex') {
541 if (is_array($currentValueArray)) {
542 $this->temp_flexRelations = array(
545 'softrefs' => array()
549 $flexObj->traverseFlexFormXMLData($table, $field, $row, $this,
'getRelations_flexFormCallBack');
551 $outRow[$field] = array(
553 'flexFormRels' => $this->temp_flexRelations
558 if ((
string)$value !==
'') {
559 $softRefValue = $value;
561 if ($softRefs !== FALSE) {
562 foreach ($softRefs as $spKey => $spParams) {
564 if (is_object($softRefObj)) {
565 $resultArray = $softRefObj->findRef($table, $field, $uid, $softRefValue, $spKey, $spParams);
566 if (is_array($resultArray)) {
567 $outRow[$field][
'softrefs'][
'keys'][$spKey] = $resultArray[
'elements'];
568 if ((
string)$resultArray[
'content'] !==
'') {
569 $softRefValue = $resultArray[
'content'];
575 if (!empty($outRow[$field][
'softrefs']) && (
string)$value !== (
string)$softRefValue && strpos($softRefValue,
'{softref:') !== FALSE) {
576 $outRow[$field][
'softrefs'][
'tokenizedContent'] = $softRefValue;
598 $structurePath = substr($structurePath, 5) .
'/';
599 $dsConf = $dsArr[
'TCEforms'][
'config'];
601 list($table, $uid, $field) = array(
608 if (!empty($resultsFromFiles)) {
613 $fileResultsFromFiles = array();
614 $dbResultsFromFiles = array();
615 foreach ($resultsFromFiles as $resultFromFiles) {
616 if (isset($resultFromFiles[
'table']) && $resultFromFiles[
'table'] ===
'sys_file') {
617 $dbResultsFromFiles[] = $resultFromFiles;
619 $fileResultsFromFiles[] = $resultFromFiles;
622 if (!empty($fileResultsFromFiles)) {
623 $this->temp_flexRelations[
'file'][$structurePath] = $fileResultsFromFiles;
625 if (!empty($dbResultsFromFiles)) {
626 $this->temp_flexRelations[
'db'][$structurePath] = $dbResultsFromFiles;
630 if ($dsConf[
'type'] ===
'input' && isset($dsConf[
'wizards'][
'link']) && empty($dsConf[
'softref'])) {
631 $dsConf[
'softref'] =
'typolink';
634 $resultsFromDatabase = $this->
getRelations_procDB($dataValue, $dsConf, $uid, $table, $field);
635 if (!empty($resultsFromDatabase)) {
637 $this->temp_flexRelations[
'db'][$structurePath] = $resultsFromDatabase;
640 if (is_array($dataValue) || (
string)$dataValue !==
'') {
641 $softRefValue = $dataValue;
643 if ($softRefs !== FALSE) {
644 foreach ($softRefs as $spKey => $spParams) {
646 if (is_object($softRefObj)) {
647 $resultArray = $softRefObj->findRef($table, $field, $uid, $softRefValue, $spKey, $spParams, $structurePath);
648 if (is_array($resultArray) && is_array($resultArray[
'elements'])) {
649 $this->temp_flexRelations[
'softrefs'][$structurePath][
'keys'][$spKey] = $resultArray[
'elements'];
650 if ((
string)$resultArray[
'content'] !==
'') {
651 $softRefValue = $resultArray[
'content'];
657 if (!empty($this->temp_flexRelations[
'softrefs']) && (
string)$dataValue !== (
string)$softRefValue) {
658 $this->temp_flexRelations[
'softrefs'][$structurePath][
'tokenizedContent'] = $softRefValue;
673 if ($conf[
'type'] !==
'group' || ($conf[
'internal_type'] !==
'file' && $conf[
'internal_type'] !==
'file_reference')) {
679 $theFileValues = array();
681 $dbAnalysis->start(
'',
'files', $conf[
'MM'], $uid);
682 foreach ($dbAnalysis->itemArray as $someval) {
683 if ($someval[
'id']) {
684 $theFileValues[] = $someval[
'id'];
688 $theFileValues = explode(
',', $value);
691 $uploadFolder = $conf[
'internal_type'] ==
'file' ? $conf[
'uploadfolder'] :
'';
693 $newValueFiles = array();
694 foreach ($theFileValues as $file) {
696 $realFile = $dest .
'/' . trim($file);
697 $newValueFile = array(
698 'filename' => basename($file),
699 'ID' => md5($realFile),
700 'ID_absFile' => $realFile
703 if ($conf[
'internal_type'] ===
'file_reference') {
706 if ($file instanceof \
TYPO3\CMS\Core\Resource\FileInterface) {
709 $newValueFile = array(
710 'table' =>
'sys_file',
711 'id' => $file->getUid()
718 $newValueFiles[] = $newValueFile;
721 return $newValueFiles;
739 } elseif ($conf[
'type'] ===
'inline' && !empty($conf[
'foreign_table']) && empty($conf[
'MM'])) {
741 $dbAnalysis->setUseLiveReferenceIds(FALSE);
742 $dbAnalysis->start($value, $conf[
'foreign_table'],
'', $uid, $table, $conf);
743 return $dbAnalysis->itemArray;
746 $allowedTables = $conf[
'type'] ==
'group' ? $conf[
'allowed'] : $conf[
'foreign_table'] .
',' . $conf[
'neg_foreign_table'];
747 if ($conf[
'MM_opposite_field']) {
751 $dbAnalysis->start($value, $allowedTables, $conf[
'MM'], $uid, $table, $conf);
752 return $dbAnalysis->itemArray;
753 } elseif ($conf[
'type'] ==
'inline' && $conf[
'foreign_table'] ==
'sys_file_reference') {
755 $files = (array)
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
'uid_local',
'sys_file_reference', (
'tablenames=\'' . $table .
'\' AND fieldname=\
'' . $field .
'\' AND uid_foreign=
' . $uid . ' AND deleted=0
')); 756 $fileArray = array(); 757 foreach ($files as $fileUid) { 758 $fileArray[] = array( 759 'table
' => 'sys_file
', 760 'id' => $fileUid['uid_local
'] 767 /******************************* 771 *******************************/ 787 public function setReferenceValue($hash, $newValue, $returnDataArray = FALSE, $bypassWorkspaceAdminCheck = FALSE) { 788 if ($GLOBALS['BE_USER
']->workspace === 0 && $GLOBALS['BE_USER
']->isAdmin() || $bypassWorkspaceAdminCheck) { 789 // Get current index from Database: 790 $refRec = $GLOBALS['TYPO3_DB
']->exec_SELECTgetSingleRow('*
', 'sys_refindex
', 'hash=
' . $GLOBALS['TYPO3_DB
']->fullQuoteStr($hash, 'sys_refindex
')); 791 // Check if reference existed. 792 if (is_array($refRec)) { 793 if ($GLOBALS['TCA
'][$refRec['tablename
']]) { 794 // Get that record from database: 795 $record = $GLOBALS['TYPO3_DB
']->exec_SELECTgetSingleRow('*
', $refRec['tablename
'], 'uid=
' . (int)$refRec['recuid
']); 796 if (is_array($record)) { 797 // Get all relations from record, filter with fieldname: 798 $dbrels = $this->getRelations($refRec['tablename
'], $record, $refRec['field
']); 799 if ($dat = $dbrels[$refRec['field
']]) { 800 // Initialize data array that is to be sent to TCEmain afterwards: 801 $dataArray = array(); 803 switch ((string) $dat['type
']) { 805 $error = $this->setReferenceValue_dbRels($refRec, $dat['itemArray
'], $newValue, $dataArray); 810 case 'file_reference
': 811 // not used (see getRelations()), but fallback to file 813 $error = $this->setReferenceValue_fileRels($refRec, $dat['newValueFiles
'], $newValue, $dataArray); 820 if (is_array($dat['flexFormRels
']['db
'][$refRec['flexpointer
']])) { 821 $error = $this->setReferenceValue_dbRels($refRec, $dat['flexFormRels
']['db
'][$refRec['flexpointer
']], $newValue, $dataArray, $refRec['flexpointer
']); 827 if (is_array($dat['flexFormRels
']['file
'][$refRec['flexpointer
']])) { 828 $this->setReferenceValue_fileRels($refRec, $dat['flexFormRels
']['file
'][$refRec['flexpointer
']], $newValue, $dataArray, $refRec['flexpointer
']); 833 // Soft references in flexforms 834 if ($refRec['softref_key
'] && is_array($dat['flexFormRels
']['softrefs
'][$refRec['flexpointer
']]['keys
'][$refRec['softref_key
']])) { 835 $error = $this->setReferenceValue_softreferences($refRec, $dat['flexFormRels
']['softrefs
'][$refRec['flexpointer
']], $newValue, $dataArray, $refRec['flexpointer
']); 842 // Softreferences in the field: 843 if ($refRec['softref_key
'] && is_array($dat['softrefs
']['keys
'][$refRec['softref_key
']])) { 844 $error = $this->setReferenceValue_softreferences($refRec, $dat['softrefs
'], $newValue, $dataArray); 849 // Data Array, now ready to sent to TCEmain 850 if ($returnDataArray) { 853 // Execute CMD array: 854 $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler
'); 855 $tce->stripslashes_values = FALSE; 856 $tce->dontProcessTransformations = TRUE; 857 $tce->bypassWorkspaceRestrictions = TRUE; 858 $tce->bypassFileHandling = TRUE; 859 // Otherwise this cannot update things in deleted records... 860 $tce->bypassAccessCheckForRecords = TRUE; 861 // Check has been done previously that there is a backend user which is Admin and also in live workspace 862 $tce->start($dataArray, array()); 863 $tce->process_datamap(); 864 // Return errors if any: 865 if (count($tce->errorLog)) { 866 return LF . 'TCEmain:
' . implode((LF . 'TCEmain:
'), $tce->errorLog); 872 return 'ERROR: Tablename
"' . $refRec['tablename'] . '" was not in TCA!
'; 875 return 'ERROR: No reference record with hash=
"' . $hash . '" was found!
'; 878 return 'ERROR: BE_USER
object is not admin OR not in workspace 0 (Live)
'; 893 public function setReferenceValue_dbRels($refRec, $itemArray, $newValue, &$dataArray, $flexpointer = '') { 894 if ((int)$itemArray[$refRec['sorting
']]['id'] === (int)$refRec['ref_uid
'] && (string)$itemArray[$refRec['sorting
']]['table
'] === (string)$refRec['ref_table
']) { 895 // Setting or removing value: 897 if ($newValue === NULL) { 898 unset($itemArray[$refRec['sorting
']]); 900 list($itemArray[$refRec['sorting
']]['table
'], $itemArray[$refRec['sorting
']]['id']) = explode(':
', $newValue); 902 // Traverse and compile new list of records: 903 $saveValue = array(); 904 foreach ($itemArray as $pair) { 905 $saveValue[] = $pair['table
'] . '_
' . $pair['id']; 907 // Set in data array: 909 $flexToolObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools
'); 910 $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']]['data
'] = array(); 911 $flexToolObj->setArrayValueByPath(substr($flexpointer, 0, -1), $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']]['data
'], implode(',
', $saveValue)); 913 $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']] = implode(',
', $saveValue); 916 return 'ERROR: table:
id pair
"' . $refRec['ref_table'] . ':' . $refRec['ref_uid'] . '" did not match that of the record (
"' . $itemArray[$refRec['sorting']]['table'] . ':' . $itemArray[$refRec['sorting']]['id'] . '") in sorting index
"' . $refRec['sorting'] . '"'; 931 public function setReferenceValue_fileRels($refRec, $itemArray, $newValue, &$dataArray, $flexpointer = '') { 932 $ID_absFile = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($itemArray[$refRec['sorting
']]['ID_absFile
']); 933 if ($ID_absFile === (string)$refRec['ref_string
'] && $refRec['ref_table
'] === '_FILE
') { 934 // Setting or removing value: 936 if ($newValue === NULL) { 937 unset($itemArray[$refRec['sorting
']]); 939 $itemArray[$refRec['sorting
']]['filename
'] = $newValue; 941 // Traverse and compile new list of records: 942 $saveValue = array(); 943 foreach ($itemArray as $fileInfo) { 944 $saveValue[] = $fileInfo['filename
']; 946 // Set in data array: 948 $flexToolObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools
'); 949 $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']]['data
'] = array(); 950 $flexToolObj->setArrayValueByPath(substr($flexpointer, 0, -1), $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']]['data
'], implode(',
', $saveValue)); 952 $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']] = implode(',
', $saveValue); 955 return 'ERROR: either
"' . $refRec['ref_table'] . '" was not
"_FILE" or file PATH_site+
"' . $refRec['ref_string'] . '" did not match that of the record (
"' . $itemArray[$refRec['sorting']]['ID_absFile'] . '") in sorting index
"' . $refRec['sorting'] . '"'; 970 public function setReferenceValue_softreferences($refRec, $softref, $newValue, &$dataArray, $flexpointer = '') { 971 if (is_array($softref['keys
'][$refRec['softref_key
']][$refRec['softref_id
']])) { 973 $softref['keys
'][$refRec['softref_key
']][$refRec['softref_id
']]['subst
']['tokenValue
'] = '' . $newValue; 974 // Traverse softreferences and replace in tokenized content to rebuild it with new value inside: 975 foreach ($softref['keys
'] as $sfIndexes) { 976 foreach ($sfIndexes as $data) { 977 $softref['tokenizedContent
'] = str_replace('{softref:
' . $data['subst
']['tokenID
'] . '}
', $data['subst
']['tokenValue
'], $softref['tokenizedContent
']); 980 // Set in data array: 981 if (!strstr($softref['tokenizedContent
'], '{softref:
')) { 983 $flexToolObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools
'); 984 $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']]['data
'] = array(); 985 $flexToolObj->setArrayValueByPath(substr($flexpointer, 0, -1), $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']]['data
'], $softref['tokenizedContent
']); 987 $dataArray[$refRec['tablename
']][$refRec['recuid
']][$refRec['field
']] = $softref['tokenizedContent
']; 990 return 'ERROR: After substituting all found soft references there were still soft reference tokens in the text. (theoretically
this does not have to be an
error if the
string "{softref:" happens to be in the field
for another reason.)
'; 993 return 'ERROR: Soft reference parser key
"' . $refRec['softref_key'] . '" or the index
"' . $refRec['softref_id'] . '" was not found.
'; 997 /******************************* 1001 *******************************/ 1009 protected function isDbReferenceField(array $configuration) { 1011 ($configuration['type
'] === 'group
' && $configuration['internal_type
'] === 'db
') 1013 ($configuration['type
'] === 'select
' || $configuration['type
'] === 'inline') 1014 && !empty($configuration['foreign_table
']) 1026 public function isReferenceField(array $configuration) { 1028 $this->isDbReferenceField($configuration) 1030 ($configuration['type
'] === 'group
' && ($configuration['internal_type
'] === 'file
' || $configuration['internal_type
'] === 'file_reference
')) // getRelations_procFiles 1032 ($configuration['type
'] === 'input
' && isset($configuration['wizards
']['link
'])) // getRelations_procDB 1034 $configuration['type
'] === 'flex
' 1036 isset($configuration['softref
']) 1039 // @deprecated global soft reference parsers are deprecated since TYPO3 CMS 7 and will be removed in TYPO3 CMS 8 1040 is_array($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['GLOBAL
']['softRefParser_GL
']) 1041 && !empty($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['GLOBAL
']['softRefParser_GL
']) 1052 protected function fetchTableRelationFields($tableName) { 1053 if (!isset($GLOBALS['TCA
'][$tableName])) { 1059 foreach ($GLOBALS['TCA
'][$tableName]['columns
'] as $field => $fieldDefinition) { 1060 if (is_array($fieldDefinition['config
'])) { 1061 // Check for flex field 1062 if (isset($fieldDefinition['config
']['type
']) && $fieldDefinition['config
']['type
'] === 'flex
') { 1063 // Fetch all fields if the is a field of type flex in the table definition because the complete row is passed to 1064 // BackendUtility::getFlexFormDS in the end and might be needed in ds_pointerField or $hookObj->getFlexFormDS_postProcessDS 1067 // Only fetch this field if it can contain a reference 1068 if ($this->isReferenceField($fieldDefinition['config
'])) { 1074 return implode(',
', $fields); 1084 public function destPathFromUploadFolder($folder) { 1086 return substr(PATH_site, 0, -1); 1088 return PATH_site . $folder; 1098 public function error($msg) { 1099 $this->errorLog[] = $msg; 1109 public function updateIndex($testOnly, $cli_echo = FALSE) { 1111 $tableNames = array(); 1114 $headerContent = $testOnly ? 'Reference Index being TESTED (nothing written, use
"--refindex update" to update)
' : 'Reference Index being Updated
'; 1116 echo '*******************************************
' . LF . $headerContent . LF . '*******************************************
' . LF; 1118 // Traverse all tables: 1119 foreach ($GLOBALS['TCA
'] as $tableName => $cfg) { 1120 if (isset(static::$nonRelationTables[$tableName])) { 1123 // Traverse all records in tables, including deleted records: 1124 $fieldNames = (BackendUtility::isTableWorkspaceEnabled($tableName) ? 'uid,t3ver_wsid
' : 'uid
'); 1125 $res = $GLOBALS['TYPO3_DB
']->exec_SELECTquery($fieldNames, $tableName, '1=1
'); 1126 if ($GLOBALS['TYPO3_DB
']->sql_error()) { 1127 // Table exists in $TCA but does not exist in the database 1128 GeneralUtility::sysLog(sprintf('Table
"%s" exists in
$TCA but does not exist in the database. You should run the Database Analyzer in the Install Tool to fix this.
', $tableName), 'core
', GeneralUtility::SYSLOG_SEVERITY_ERROR); 1131 $tableNames[] = $tableName; 1133 $uidList = array(0); 1134 while ($recdat = $GLOBALS['TYPO3_DB
']->sql_fetch_assoc($res)) { 1137 if (isset($recdat['t3ver_wsid
'])) { 1138 $refIndexObj->setWorkspaceId($recdat['t3ver_wsid
']); 1140 $result = $refIndexObj->updateRefIndexTable($tableName, $recdat['uid
'], $testOnly); 1141 $uidList[] = $recdat['uid
']; 1143 if ($result['addedNodes
'] || $result['deletedNodes
']) { 1144 $Err = 'Record
' . $tableName . ':
' . $recdat['uid
'] . ' had
' . $result['addedNodes
'] . ' added indexes and
' . $result['deletedNodes
'] . ' deleted indexes
'; 1151 $GLOBALS['TYPO3_DB
']->sql_free_result($res); 1153 // Searching lost indexes for this table: 1154 $where = 'tablename=
' . $GLOBALS['TYPO3_DB
']->fullQuoteStr($tableName, 'sys_refindex
') . ' AND recuid NOT IN (
' . implode(',
', $uidList) . ')
'; 1155 $lostIndexes = $GLOBALS['TYPO3_DB
']->exec_SELECTgetRows('hash
', 'sys_refindex
', $where); 1156 if (count($lostIndexes)) { 1157 $Err = 'Table
' . $tableName . ' has
' . count($lostIndexes) . ' lost indexes which are now deleted
'; 1163 $GLOBALS['TYPO3_DB
']->exec_DELETEquery('sys_refindex
', $where); 1167 // Searching lost indexes for non-existing tables: 1168 $where = 'tablename NOT IN (
' . implode(',
', $GLOBALS['TYPO3_DB
']->fullQuoteArray($tableNames, 'sys_refindex
')) . ')
'; 1169 $lostTables = $GLOBALS['TYPO3_DB
']->exec_SELECTgetRows('hash
', 'sys_refindex
', $where); 1170 if (count($lostTables)) { 1171 $Err = 'Index table hosted
' . count($lostTables) . ' indexes
for non-existing tables, now removed
'; 1177 $GLOBALS['TYPO3_DB
']->exec_DELETEquery('sys_refindex
', $where); 1180 $testedHowMuch = $recCount . ' records from
' . $tableCount . ' tables were checked/updated.
' . LF; 1181 $bodyContent = $testedHowMuch . (count($errors) ? implode(LF, $errors) : 'Index Integrity was perfect!
'); 1183 echo $testedHowMuch . (count($errors) ? 'Updates:
' . count($errors) : 'Index Integrity was perfect!
') . LF; 1186 $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\
\Registry'); 1187 $registry->set('core
', 'sys_refindex_lastUpdate
', $GLOBALS['EXEC_TIME
']); 1189 return array($headerContent, $bodyContent, count($errors)); 1195 protected function getRelationHandler() {
getRelations_procFiles($value, $conf, $uid)
getRelations($table, $row, $onlyField='')
destPathFromUploadFolder($folder)
static isFirstPartOfStr($str, $partStr)
static explodeSoftRefParserList($parserList)
$TCA['tx_irretutorial_1ncsv_hotel']
static $cachePrefixTableRelationFields
static makeInstance($className)
static $nonRelationFields
isDbReferenceField(array $configuration)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
setWorkspaceId($workspaceId)
getRelations_procDB($value, $conf, $uid, $table='', $field='')
createEntryData_fileRels($table, $uid, $fieldname, $flexpointer, $deleted, $items)
static & softRefParserObj($spKey)
static $nonRelationTables
static getRecordRaw($table, $where='', $fields=' *')
createEntryData_softreferences($table, $uid, $fieldname, $flexpointer, $deleted, $keys)
getRelations_flexFormCallBack($dsArr, $dataValue, $PA, $structurePath, $pObj)
fetchTableRelationFields($tableName)
createEntryData_dbRels($table, $uid, $fieldname, $flexpointer, $deleted, $items)
createEntryData($table, $uid, $field, $flexpointer, $deleted, $ref_table, $ref_uid, $ref_string='', $sort=-1, $softref_key='', $softref_id='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static xml2array($string, $NSprefix='', $reportDocTag=FALSE)
generateRefIndexData($tableName, $uid)
static stripPathSitePrefix($path)
updateRefIndexTable($tableName, $uid, $testOnly=FALSE)