From aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Mon, 25 Nov 2019 17:55:27 +0100 Subject: each is deprecated and does not work for generators --- it_url.class | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/it_url.class b/it_url.class index c3786f1..94ac466 100644 --- a/it_url.class +++ b/it_url.class @@ -350,11 +350,16 @@ static function get_multi($p=null) if (!$p['noresults']) $keyorder = array_keys($p['urls']); - reset($p['urls']); + if (is_array($p['urls'])) + $iterator = (new ArrayObject($p['urls']))->getIterator(); + else + $iterator = $p['urls']; $parallel = $p['parallel'] ?: PHP_INT_MAX; - while (count($handles) < $parallel && ($next = each($p['urls']))) - $addhandle($next['key'], $next['value']); + while (count($handles) < $parallel && $iterator->valid()) { + $addhandle($iterator->key(), $iterator->current()); + $iterator->next(); + } $start = gettimeofday(true); @@ -398,8 +403,10 @@ static function get_multi($p=null) $closehandle($key); } - if (!$abort && count($handles) < $parallel && ($next = each($p['urls']))) - $addhandle($next['key'], $next['value']); + if (!$abort && count($handles) < $parallel && $iterator->valid()) { + $addhandle($iterator->key(), $iterator->current()); + $iterator->next(); + } } } } while ($mrc == CURLM_CALL_MULTI_PERFORM); -- cgit v1.2.3