From 1bece9174c7a94e212be1b7d105a7512e8899d70 Mon Sep 17 00:00:00 2001 From: nfreear Date: Tue, 10 Oct 2006 11:03:35 +0000 Subject: [PATCH] Fixes bug, "Warning: Invalid argument supplied for foreach() in /var/www/html/ndf42/head/lib/blocklib.php on line 174" --- lib/blocklib.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/blocklib.php b/lib/blocklib.php index e7a8930f7f..80e55cc551 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -171,13 +171,15 @@ function blocks_name_allowed_in_format($name, $pageformat) { $formats = block_method_result($name, 'applicable_formats'); $accept = NULL; $depth = -1; - foreach($formats as $format => $allowed) { - $thisformat = '^'.str_replace('*', '[^-]*', $format).'.*$'; - if(ereg($thisformat, $pageformat)) { - if(($scount = substr_count($format, '-')) > $depth) { - $depth = $scount; - $accept = $allowed; - } + if (isset($formats)) { + foreach($formats as $format => $allowed) { + $thisformat = '^'.str_replace('*', '[^-]*', $format).'.*$'; + if(ereg($thisformat, $pageformat)) { + if(($scount = substr_count($format, '-')) > $depth) { + $depth = $scount; + $accept = $allowed; + } + } } } if($accept === NULL) { -- 2.39.5