diff options
author | Nathan Gass | 2019-11-25 17:55:27 +0100 |
---|---|---|
committer | Nathan Gass | 2019-11-25 17:55:27 +0100 |
commit | aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7 (patch) | |
tree | 9d89a97d9f8fc47f266b8120c94d645cb1ab8e39 | |
parent | bae768893487e4a39dfa5ca7da10f0390dafc0b7 (diff) | |
download | itools-aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7.tar.gz itools-aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7.tar.bz2 itools-aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7.zip |
each is deprecated and does not work for generators
-rw-r--r-- | it_url.class | 17 |
1 files 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); |