[TYPO3-core] RFC: fix for bug #2643

Wolfgang Klinger wolfgang at stufenlos.net
Tue Feb 21 11:20:11 CET 2006


 *hiya!*

 Type: bugfix

 Missing is_array checks
 BT reference: http://bugs.typo3.org/view.php?id=2643

 Attached are two additional files where several is_array checks before
 foreach loops are missing.


 bye
 Wolfgang

-------------- next part --------------
--- TYPO3core/typo3/sysext/lowlevel/class.tx_lowlevel_cleaner_core.php	2006-01-27 11:54:31.000000000 +0100
+++ TYPO3core_testing/typo3/sysext/lowlevel/class.tx_lowlevel_cleaner_core.php	2006-02-21 11:06:34.000000000 +0100
@@ -123,6 +123,7 @@
 		);
 
 			// Traverse the files and put into a large table:
+		if (is_array($recs)) {
 		foreach($recs as $rec)	{
 
 				// Compile info string for location of reference:
@@ -140,6 +141,7 @@
 				$resultArray[$resultArrayIndex][$rec['ref_string']][$rec['hash']] = $infoString;
 			}
 		}
+		}
 
 		return $resultArray;
 	}
@@ -202,6 +204,7 @@
 
 			// Traverse the files and put into a large table:
 		$tempExists = array();
+		if (is_array($recs)) {
 		foreach($recs as $rec)	{
 			$idx = $rec['ref_table'].':'.$rec['ref_uid'];
 
@@ -236,6 +239,7 @@
 				$resultArray['nonExistingRecords'][$idx][$rec['hash']] = $infoString;
 			}
 		}
+		}
 
 		return $resultArray;
 	}
@@ -288,6 +292,7 @@
 
 			// Traverse the files and put into a large table:
 		$tempCount = array();
+		if (is_array($recs)) {
 		foreach($recs as $rec)	{
 
 				// Compile info string for location of reference:
@@ -312,6 +317,7 @@
 				$tempCount[$rec['ref_string']] = array($infoString,$rec['hash']);
 			}
 		}
+		}
 
 			// Add count for multi-references:
 		$resultArray['multipleReferencesList_count'] = count($resultArray['multipleReferencesList']);
@@ -374,6 +380,7 @@
 		);
 
 			// Traverse the files and put into a large table:
+		if (is_array($recs)) {
 		foreach($recs as $rec)	{
 			$filename = basename($rec['ref_string']);
 			if (t3lib_div::isFirstPartOfStr($filename,'RTEmagicC_'))	{
@@ -396,6 +403,7 @@
 				}
 			}
 		}
+		}
 
 			// Now, ask for RTEmagic files inside uploads/ folder:
 		$resLostFiles = $this->clean_lost_files_analyze();
@@ -566,6 +574,7 @@
 		}
 
 			// Traverse headers for output:
+		if (is_array($res['headers'])) {
 		foreach($res['headers'] as $key => $value)	{
 
 			if ($detailLevel <= intval($value[2]))	{
@@ -594,6 +603,7 @@
 				}
 			}
 		}
+		}
 		
 		return $output;
 	}
@@ -685,6 +695,7 @@
 		}
 
 			// Traverse headers for output:
+		if (is_array($res['headers'])) {
 		foreach($res['headers'] as $key => $value)	{
 
 			if ($detailLevel <= intval($value[2]))	{
@@ -713,6 +724,7 @@
 		}
 	}
 }
+}
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php'])	{
 	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php']);
--- TYPO3core/typo3/class.file_list.inc	2006-02-02 08:41:01.000000000 +0100
+++ TYPO3core_testing/typo3/class.file_list.inc	2006-02-21 11:02:44.000000000 +0100
@@ -663,9 +663,11 @@
 		
 			// Compile information for title tag:
 		$infoData=array();
+		if (is_array($rows)) {
 		foreach($rows as $row)	{
 			$infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
 		}
+		}
 		
 		return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$theData['path'].$theData['file'].'\', \'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';		
 	}
--- TYPO3core/typo3/class.db_list_extra.inc	2006-02-09 15:22:05.000000000 +0100
+++ TYPO3core_testing/typo3/class.db_list_extra.inc	2006-02-21 11:08:56.000000000 +0100
@@ -501,6 +501,7 @@
 							);
 
 								// For each available translation, render the record:
+							if (is_array($translations)) {
 							foreach($translations as $lRow)	{
 								if ($GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']]))	{
 									$iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
@@ -508,6 +509,7 @@
 							}
 						}
 					}
+					}
 
 						// Counter of total rows incremented:
 					$this->eCounter++;


More information about the TYPO3-team-core mailing list