[TYPO3-core] RFC: is_array and foreach
Wolfgang Klinger
wolfgang at stufenlos.net
Wed Mar 15 16:34:24 CET 2006
*hiya!*
As I found some errors related to this issue again (see below) I have
to say that is_array should always be used before foreach if it's not
sure (e.g. the array comes from outside) that the passed variable is an
array, please!
Here's a patch that fixes some warnings when installing an extension:
-----
--- TYPO3core/t3lib/class.t3lib_install.php 2006-02-26 11:14:25.000000000 +0100
+++ TYPO3core_testing/t3lib/class.t3lib_install.php 2006-03-15 16:26:24.000000000 +0100
@@ -363,7 +363,9 @@
// Init SQL parser:
$sqlParser = t3lib_div::makeInstance('t3lib_sqlparser');
+ if (is_array($total)) {
foreach($total as $table => $cfg) {
+ if (is_array($cfg['fields'])) {
foreach($cfg['fields'] as $fN => $fType) {
$orig_fType = $fType;
$fInfo = $sqlParser->parseFieldDef($fType);
@@ -397,6 +399,8 @@
}
}
}
+ }
+ }
/**
* Reads the field definitions for the current database
-----
I think I need no review to fix such issues, do I?
bye
Wolfgang
More information about the TYPO3-team-core
mailing list