Bug #63959
closedt3lib_div->trimExplode fills database table sys_log
0%
Description
There are several more bugs that are related to issue #50913 in TYPO3 4.5 which will fill the sys_log database.
In the official php documentation explode must have at least two parameters that must be of type string.
I found this issues in the TYPO3 4.5 Project that does return php errors because of giving NULL or integer values to the trimExplode
method of the t3lib_div
class.
Perhaps there could be even more bugs, i did not found yet. Therefore i fixed the trimExplode
method as well.
File: t3lib/class.t3lib_befunc.php
:
line 2161-2166 public static function getLabelsFromItemsList($table, $column, $key) { $labels = array(); - $values = t3lib_div::trimExplode(',', $key, TRUE); + $values = $key + ? t3lib_div::trimExplode(',', $key, TRUE) + : array(); if (count($values) > 0) { // Load full TCA for $table t3lib_div::loadTCA($table); line 2404-2409 if ($noRecordLookup) { $l = $value; } else { - $rParts = t3lib_div::trimExplode(',', $value, 1); + $rParts = $value + ? t3lib_div::trimExplode(',', $value, 1) + : array(); $lA = array(); foreach ($rParts as $rVal) { line 2427-2429 case 'group': - $l = implode(', ', t3lib_div::trimExplode(',', $value, 1)); + $l = $value + ? implode(', ', t3lib_div::trimExplode(',', $value, 1)) + : ''; break;
File: t3lib/class.t3lib_db.php
:
line 855-857 function cleanIntList($list) { - return implode(',', t3lib_div::intExplode(',', $list)); + return $list ? implode(',', t3lib_div::intExplode(',', $list)) : ''; }
File: t3lib/class.t3lib_div.php
:
line 1961-1964 public static function trimExplode($delim, $string, $removeEmptyValues = FALSE, $limit = 0) { if (empty($string)) { return array(); } - $explodedValues = explode($delim, $string); + $explodedValues = explode($delim, (string)$string); $result = array_map('trim', $explodedValues);
File: t3lib/class.t3lib_parsehtml_proc.php
:
line 208-213 function RTE_transform($value, $specConf, $direction = 'rte', $thisConfig = array()) { // Init: $this->tsConfig = $thisConfig; $this->procOptions = (array) $thisConfig['proc.']; - $this->preserveTags = strtoupper(implode(',', t3lib_div::trimExplode(',', $this->procOptions['preserveTags']))); + if ($this->procOptions['preserveTags']) { + $this->preserveTags = strtoupper(implode(',', t3lib_div::trimExplode(',', $this->procOptions['preserveTags']))); + } line 1116-1120 // For tags to deny, remove them from $keepTags array: - $denyTags = t3lib_div::trimExplode(',', $this->procOptions['denyTags'], 1); + $denyTags = $this->procOptions['denyTags'] + ? t3lib_div::trimExplode(',', $this->procOptions['denyTags'], 1) + : array(); foreach ($denyTags as $dKe) { unset($keepTags[$dKe]); } line 1174-1777 // Setting up font tags if they are allowed: if (isset($keepTags['font'])) { - $colors = array_merge(array(''), t3lib_div::trimExplode(',', $this->procOptions['allowedFontColors'], 1)); + $colors = $this->procOptions['allowedFontColor'] + ? array_merge(array(''), t3lib_div::trimExplode(',', $this->procOptions['allowedFontColors'], 1)) + : array(''); $keepTags['font'] = array(
File: t3lib/class.t3lib_tceforms.php
:
line 515-519 // Exploding subparts of the field configuration: - $parts = explode(';', $fieldInfo); + $parts = explode(';', $fieldInfo.';;;;'); // Getting the style information out: $color_style_parts = t3lib_div::trimExplode('-', $parts[4]); line 609-611 // Rendering Main palettes, if any - $mParr = t3lib_div::trimExplode(',', $TCA[$table]['ctrl']['mainpalette']); + $mParr = $TCA[$table]['ctrl']['mainpalette'] ? t3lib_div::trimExplode(',', $TCA[$table]['ctrl']['mainpalette']) : array(); $i = 0; line 1049-1052 $specConf = $this->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']); $size = t3lib_div::intInRange($config['size'] ? $config['size'] : 30, 5, $this->maxInputWidth); - $evalList = t3lib_div::trimExplode(',', $config['eval'], 1); + $evalList = $config['eval'] + ? t3lib_div::trimExplode(',', $config['eval'], 1) + : array(); $classAndStyleAttributes = $this->formWidthAsArray($size); line 1224-1226 // Init config: $config = $PA['fieldConf']['config']; - $evalList = t3lib_div::trimExplode(',', $config['eval'], 1); + $evalList = $config['eval'] + ? t3lib_div::trimExplode(',', $config['eval'], 1) + : array(); line 1342-1343 - $evalList = t3lib_div::trimExplode(',', $config['eval'], 1); + $evalList = $config['eval'] + ? t3lib_div::trimExplode(',', $config['eval'], 1) + : array(); foreach ($evalList as $func) { line 1533-1535 // Possibly remove some items: - $removeItems = t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1); + $removeItems = $PA['fieldTSConfig']['removeItems'] + ? t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1) + : array(); foreach ($selItems as $tk => $p) { line 2079-2083 // Get "removeItems": - $removeItems = t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1); + $removeItems = $PA['fieldTSConfig']['removeItems'] + ? t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1) + : array(); // Get the array with selected items: - $itemArray = t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1); + $itemArray = $PA['itemFormElValue'] + ? t3lib_div::trimExplode(',', $PA['itemFormElValue'], 1) + : array();
File: t3lib/class.t3lib_tcemain.php
:
line 1358-1362 function checkValue_text($res, $value, $tcaFieldConf, $PP, $field = '') { - $evalCodesArray = t3lib_div::trimExplode(',', $tcaFieldConf['eval'], 1); + $evalCodesArray = $tcaFieldConf['eval'] + ? t3lib_div::trimExplode(',', $tcaFieldConf['eval'], 1) + : array(); $res = $this->checkValue_text_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']); return $res; } line 1392-1394 // Process evaluation settings: - $evalCodesArray = t3lib_div::trimExplode(',', $tcaFieldConf['eval'], 1); + $evalCodesArray = $tcaFieldConf['eval'] + ? t3lib_div::trimExplode(',', $tcaFieldConf['eval'], 1) + : array(); $res = $this->checkValue_input_Eval($value, $evalCodesArray, $tcaFieldConf['is_in']); line 1642-1653 if ($tcaFieldConf['MM']) { // If MM relations for the files also! $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup'); /* @var $dbAnalysis t3lib_loadDBGroup */ $dbAnalysis->start('', 'files', $tcaFieldConf['MM'], $id); foreach ($dbAnalysis->itemArray as $item) { if ($item['id']) { $theFileValues[] = $item['id']; } } - } else { + } elseif ($curValue) { $theFileValues = t3lib_div::trimExplode(',', $curValue, 1); } line 3308-3310 } else { - $theFileValues = t3lib_div::trimExplode(',', $value, 1); + $theFileValues = $value + ? t3lib_div::trimExplode(',', $value, 1) + : array(); }
File: t3lib/class.t3lib_transferdata.php
:
line 365-382 // Now, load the files into the $dataAcc array, whether stored by MM or as a list of filenames: if ($fieldConfig['config']['MM']) { $loadDB = t3lib_div::makeInstance('t3lib_loadDBGroup'); $loadDB->start('', 'files', $fieldConfig['config']['MM'], $row['uid']); // Setting dummy startup foreach ($loadDB->itemArray as $value) { if ($value['id']) { $dataAcc[] = rawurlencode($value['id']) . '|' . rawurlencode($value['id']); } } - } else { + } elseif ($data) { $fileList = t3lib_div::trimExplode(',', $data, 1); foreach ($fileList as $value) { if ($value) { $dataAcc[] = rawurlencode($value) . '|' . rawurlencode($value); } } } line 411-416 function renderRecord_selectProc($data, $fieldConfig, $TSconfig, $table, $row, $field) { global $TCA; // Initialize: - $elements = t3lib_div::trimExplode(',', $data, 1); // Current data set. + $elements = $data // Current data set. + ? t3lib_div::trimExplode(',', $data, 1) + : array(); $dataAcc = array(); // New data set, ready for interface (list of values, rawurlencoded)
File: t3lib/class.t3lib_tsparser.php
:
line 293-298 case 'removeFromList': - $existingElements = t3lib_div::trimExplode(',', $currentValue); + $existingElements = $currentValue + ? t3lib_div::trimExplode(',', $currentValue) + : array(); - $removeElements = t3lib_div::trimExplode(',', $tsFuncArg); + $removeElements = $tsFuncArg + ? t3lib_div::trimExplode(',', $tsFuncArg) + : array(); if (count($removeElements)) { $newValue = implode(',', array_diff($existingElements, $removeElements)); }
File: t3lib/class.t3lib_userauth.php
:
line 1298-1299 - $authInfo['db_user']['checkPidList'] = $this->checkPid ? $this->checkPid_value : ''; - $authInfo['db_user']['check_pid_clause'] = $this->checkPid ? ' AND pid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($authInfo['db_user']['checkPidList']) . ')' : ''; + if ($this->checkPid && ($this->checkPid_value || $this->checkPid_value === '0')) { + $authInfo['db_user']['checkPidList'] = $this->checkPid_value; + $authInfo['db_user']['check_pid_clause'] = ' AND pid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($authInfo['db_user']['checkPidList']) . ')'; + } else { + $authInfo['db_user']['checkPidList'] = ''; + $authInfo['db_user']['check_pid_clause'] = ''; + }
File: t3lib/tree/pagetree/class.t3lib_tree_pagetree_dataprovider.php
:
line 62-72 public function __construct($nodeLimit = NULL) { if ($nodeLimit === NULL) { $nodeLimit = $GLOBALS['TYPO3_CONF_VARS']['BE']['pageTree']['preloadLimit']; } $this->nodeLimit = abs(intval($nodeLimit)); - $this->hiddenRecords = t3lib_div::trimExplode( - ',', - $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages') - ); + $hideRecords_page = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages'); + if ($hideRecords_page) { + $this->hiddenRecords = t3lib_div::trimExplode(',', $hideRecords_page); + }; }
File: typo3/alt_clickmenu.php
:
line 188-195 // Setting flags: if ($this->iParts[2]) $this->listFrame=1; if ($GLOBALS['BE_USER']->uc['condensedMode'] || $this->iParts[2]==2) $this->alwaysContentFrame=1; if (strcmp($this->iParts[1],'')) $this->isDBmenu=1; $TSkey =($this->isDBmenu?'page':'folder').($this->listFrame?'List':'Tree'); - $this->disabledItems = t3lib_div::trimExplode(',',$GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'),1); + $TSConfigVal_disableItems = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.'.$TSkey.'.disableItems'); + $this->disabledItems = $TSConfigVal_disableItems + ? t3lib_div::trimExplode(',', $TSConfigVal_disableItems, 1) + : array(); $this->leftIcons = $GLOBALS['BE_USER']->getTSConfigVal('options.contextMenu.options.leftIcons');
File: typo3/class.db_list.inc
should be patched:
line 257-260 // Don't show table if hidden by pageTSconfig mod.web_list.hideTables - if (in_array($tableName, t3lib_div::trimExplode(',', $this->hideTables))) { + if ($this->hideTables && in_array($tableName, t3lib_div::trimExplode(',', $this->hideTables))) { $hideTable = TRUE; }
File: typo3/db_new.php
:
line 229-237 // Acquiring TSconfig for this module/current page: $this->web_list_modTSconfig = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list'); - $this->allowedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['allowedNewTables'],1); + if ($this->web_list_modTSconfig['properties']['allowedNewTables']) { + $this->allowedNewTables = t3lib_div::trimExplode(',', $this->web_list_modTSconfig['properties']['allowedNewTables'], 1); + } - $this->deniedNewTables = t3lib_div::trimExplode(',',$this->web_list_modTSconfig['properties']['deniedNewTables'],1); + if ($this->web_list_modTSconfig['properties']['deniedNewTables']) { + $this->deniedNewTables = t3lib_div::trimExplode(',', $this->web_list_modTSconfig['properties']['deniedNewTables'], 1); + } // Acquiring TSconfig for this module/parent page: $this->web_list_modTSconfig_pid = t3lib_BEfunc::getModTSconfig($this->pageinfo['pid'],'mod.web_list'); - $this->allowedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['allowedNewTables'],1); + if ($this->web_list_modTSconfig_pid['properties']['allowedNewTables']) { + $this->allowedNewTables_pid = t3lib_div::trimExplode(',', $this->web_list_modTSconfig_pid['properties']['allowedNewTables'], 1); + } - $this->deniedNewTables_pid = t3lib_div::trimExplode(',',$this->web_list_modTSconfig_pid['properties']['deniedNewTables'],1); + if ($this->web_list_modTSconfig_pid['properties']['deniedNewTables']) { + $this->deniedNewTables_pid = t3lib_div::trimExplode(',', $this->web_list_modTSconfig_pid['properties']['deniedNewTables'], 1); + }
File: typo3/sysext/cms/tslib/class.tslib_content.php
:
line 1234-1253 foreach ($flexData as $key => $value) { if (is_array($value['el']) && count($value['el']) > 0) { foreach ($value['el'] as $ekey => $element) { if (isset($element['vDEF'])) { $conf[$ekey] = $element['vDEF']; } else { if (is_array($element)) { $this->readFlexformIntoConf($element, $conf[$key][key($element)][$ekey], TRUE); } else { $this->readFlexformIntoConf($element, $conf[$key][$ekey], TRUE); } } } - } else { + } elseif (isset($value['el'])) { $this->readFlexformIntoConf($value['el'], $conf[$key], TRUE); } - if ($value['vDEF']) { + if (isset($value['vDEF']) && $value['vDEF']) { $conf[$key] = $value['vDEF']; } } line 3436-3441 $items = array( 'files' => array(), 'sorting' => array() ); - $ext_list = strtolower(t3lib_div::uniqueList($data_arr[1])); + $ext_list = $data_arr[1] + ? strtolower(t3lib_div::uniqueList($data_arr[1])) + : array(); $sorting = trim($data_arr[2]); line 4284-4294 - if ($conf['token'] === '') { + if ($conf['token'] === '' || strlen($conf['token']) == 0) { return $value; } $conf['max'] = isset($conf['max.']) ? intval($this->stdWrap($conf['max'], $conf['max.'])) : intval($conf['max']); $conf['min'] = isset($conf['min.']) ? intval($this->stdWrap($conf['min'], $conf['min.'])) : intval($conf['min']); - $valArr = explode($conf['token'], $value); + $valArr = explode((string)$conf['token'], $value);
File: typo3/sysext/cms/tslib/class.tslib_fe.php
:
line 2335-2338 // Get values from TypoScript: $this->sys_language_uid = $this->sys_language_content = intval($this->config['config']['sys_language_uid']); - list($this->sys_language_mode,$sys_language_content) = t3lib_div::trimExplode(';', $this->config['config']['sys_language_mode']); + $sys_language_content = ''; + if ($this->config['config']['sys_language_mode']) { + list($this->sys_language_mode, $sys_language_content) = t3lib_div::trimExplode(';', $this->config['config']['sys_language_mode']); + } $this->sys_language_contentOL = $this->config['config']['sys_language_overlay']; line 2363-2370 case 'content_fallback': - $fallBackOrder = t3lib_div::intExplode(',', $sys_language_content); - foreach($fallBackOrder as $orderValue) { - if (!strcmp($orderValue,'0') || count($this->sys_page->getPageOverlay($this->id, $orderValue))) { - $this->sys_language_content = $orderValue; // Setting content uid (but leaving the sys_language_uid) - break; + if ($sys_language_content) { + $fallBackOrder = t3lib_div::intExplode(',', $sys_language_content); + foreach($fallBackOrder as $orderValue) { + if (!strcmp($orderValue,'0') || count($this->sys_page->getPageOverlay($this->id, $orderValue))) { + $this->sys_language_content = $orderValue; // Setting content uid (but leaving the sys_language_uid) + break; + } } } line 2419-2431 // Setting softMergeIfNotBlank: - $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softMergeIfNotBlank'],1); - foreach($table_fields as $TF) { - list($tN,$fN) = explode(':',$TF); - $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'mergeIfNotBlank'; + if ($this->config['config']['sys_language_softMergeIfNotBlank']) { + $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softMergeIfNotBlank'],1); + foreach($table_fields as $TF) { + list($tN,$fN) = explode(':',$TF); + $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'mergeIfNotBlank'; + } } // Setting softExclude: - $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softExclude'],1); - foreach($table_fields as $TF) { - list($tN,$fN) = explode(':',$TF); - $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'exclude'; + if ($this->config['config']['sys_language_softExclude']) { + $table_fields = t3lib_div::trimExplode(',', $this->config['config']['sys_language_softExclude'],1); + foreach($table_fields as $TF) { + list($tN,$fN) = explode(':',$TF); + $this->TCAcachedExtras[$tN]['l10n_mode'][$fN] = 'exclude'; + } }
File: typo3/sysext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php
:
line 316-317 // Get the descriptions for the files (if any): - $descriptions = t3lib_div::trimExplode(LF,$this->cObj->data['imagecaption']); + $descriptions = $this->cObj->data['imagecaption'] + ? t3lib_div::trimExplode(LF, $this->cObj->data['imagecaption']) + : array();
File: typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
:
line 562-571 // Override buttons from previously registered plugins - $pluginButtons = t3lib_div::trimExplode(',', $plugin->getPluginButtons(), 1); + $pluginButtons = $plugin->getPluginButtons() + ? t3lib_div::trimExplode(',', $plugin->getPluginButtons(), 1) + : array(); foreach ($this->pluginButton as $previousPluginId => $buttonList) { - $this->pluginButton[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginButton[$previousPluginId], 1), $pluginButtons)); + $this->pluginButton[$previousPluginId] = implode(',', array_diff( + ($this->pluginButton[$previousPluginId] ? t3lib_div::trimExplode(',', $this->pluginButton[$previousPluginId], 1) : array()), + $pluginButtons + )); } $this->pluginButton[$pluginId] = $plugin->getPluginButtons(); - $pluginLabels = t3lib_div::trimExplode(',', $plugin->getPluginLabels(), 1); + $pluginLabels = $plugin->getPluginLabels() + ? t3lib_div::trimExplode(',', $plugin->getPluginLabels(), 1) + : array(); foreach ($this->pluginLabel as $previousPluginId => $labelList) { - $this->pluginLabel[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginLabel[$previousPluginId], 1), $pluginLabels)); + $this->pluginLabel[$previousPluginId] = implode(',', array_diff( + ($this->pluginLabel[$previousPluginId] ? t3lib_div::trimExplode(',', $this->pluginLabel[$previousPluginId], 1) : array()), + $pluginLabels + )); } line 1474-1581 public function cleanList($str) { if (strstr($str,'*')) { $str = '*'; } else { - $str = implode(',',array_unique(t3lib_div::trimExplode(',',$str,1))); + $str = $str + ? implode(',', array_unique(t3lib_div::trimExplode(',', $str, 1))) + : ''; } return $str; }
File: typo3/sysext/rtehtmlarea/class.tx_rtehtmlareaapi.php
:
line 93-97 public function addButtonsToToolbar() { //Add only buttons not yet in the default toolbar order - $addButtons = implode(',', array_diff(t3lib_div::trimExplode(',', $this->pluginButtons, 1), t3lib_div::trimExplode(',', $this->htmlAreaRTE->defaultToolbarOrder, 1))); + $addButtons = implode(',', array_diff( + ($this->pluginButtons + ? t3lib_div::trimExplode(',', $this->pluginButtons, 1) + : array()), + ($this->htmlAreaRTE->defaultToolbarOrder + ? t3lib_div::trimExplode(',', $this->htmlAreaRTE->defaultToolbarOrder, 1) + : array()) + )); return (($addButtons ? ('bar,' . $addButtons . ',linebreak,') : '') . $this->htmlAreaRTE->defaultToolbarOrder); }
File: typo3/sysext/recordlist/mod1/index.php
:
line 244-245 - $dblist->allowedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], 1); + if ($this->modTSconfig['properties']['allowedNewTables']) { + $dblist->allowedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['allowedNewTables'], 1); + } - $dblist->deniedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], 1); + if ($this->modTSconfig['properties']['deniedNewTables']) { + $dblist->deniedNewTables = t3lib_div::trimExplode(',', $this->modTSconfig['properties']['deniedNewTables'], 1); + }
File: typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php
:
line 618-622 if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['removeItems']) { $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->buttonConfig['options.']['removeItems'],1)); - } else { + } elseif ($this->thisConfig['blindLinkOptions']) { $this->allowedItems = array_diff($this->allowedItems,t3lib_div::trimExplode(',',$this->thisConfig['blindLinkOptions'],1)); }