summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2019-11-25 17:55:27 +0100
committerNathan Gass2019-11-25 17:55:27 +0100
commitaa0ed8e08c48573ef8be73ac4b2be7f7a95503e7 (patch)
tree9d89a97d9f8fc47f266b8120c94d645cb1ab8e39
parentbae768893487e4a39dfa5ca7da10f0390dafc0b7 (diff)
downloaditools-aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7.tar.gz
itools-aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7.tar.bz2
itools-aa0ed8e08c48573ef8be73ac4b2be7f7a95503e7.zip
each is deprecated and does not work for generators
-rw-r--r--it_url.class17
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);