From 6bad9d56685e46264eed297310b26dfcabd26410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Wed, 14 Nov 2007 15:22:04 +0000 Subject: Wrap foreach(explode()) in empty() check, so if empty items are found, the foreach will not bail out on the explode(). Identified in upgrade testing. --- modules/system/system.install | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'modules/system/system.install') diff --git a/modules/system/system.install b/modules/system/system.install index 993e4bd1f..c0bd24b47 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -2342,14 +2342,17 @@ function system_update_164() { $result = db_query('SELECT nid, polled FROM {poll}'); while ($poll = db_fetch_object($result)) { - foreach (explode(' ', $poll->polled) as $polled) { - if ($polled[0] == '_') { - // $polled is a user id - db_query('INSERT INTO {poll_votes} (nid, uid) VALUES (%d, %d)', $poll->nid, substr($polled, 1, -1)); - } - else { - // $polled is a host - db_query("INSERT INTO {poll_votes} (nid, hostname) VALUES (%d, '%s')", $poll->nid, $polled); + if (!empty($poll->polled)) { + foreach (explode(' ', $poll->polled) as $polled) { + if ($polled[0] == '_') { + // $polled is a user id + db_query('INSERT INTO {poll_votes} (nid, uid) VALUES (%d, %d)', $poll->nid, substr($polled, +1, -1)); + } + else { + // $polled is a host + db_query("INSERT INTO {poll_votes} (nid, hostname) VALUES (%d, '%s')", $poll->nid, $polled); + } } } } -- cgit v1.2.3