mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-03 20:10:19 +01:00
fixed propfind_iterator sometimes not returning any item
This commit is contained in:
parent
31be31954e
commit
671a0293ef
@ -390,6 +390,13 @@ class groupdav_propfind_iterator implements Iterator
|
||||
*/
|
||||
const CHUNK_SIZE = 500;
|
||||
|
||||
/**
|
||||
* Log calls via error_log()
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $debug = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -399,6 +406,8 @@ class groupdav_propfind_iterator implements Iterator
|
||||
*/
|
||||
public function __construct(groupdav_handler $handler,array $filter,array &$files=null)
|
||||
{
|
||||
if ($this->debug) error_log(__METHOD__."(,".array2string($filter).",)");
|
||||
|
||||
$this->handler = $handler;
|
||||
$this->filter = $filter;
|
||||
$this->files = $files;
|
||||
@ -412,6 +421,8 @@ class groupdav_propfind_iterator implements Iterator
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files)));
|
||||
|
||||
return current($this->files);
|
||||
}
|
||||
|
||||
@ -424,6 +435,7 @@ class groupdav_propfind_iterator implements Iterator
|
||||
{
|
||||
$current = $this->current();
|
||||
|
||||
if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path']));
|
||||
return $current['path']; // we return path as key
|
||||
}
|
||||
|
||||
@ -434,10 +446,14 @@ class groupdav_propfind_iterator implements Iterator
|
||||
{
|
||||
if (next($this->files) !== false)
|
||||
{
|
||||
if ($this->debug) error_log(__METHOD__."() returning TRUE");
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!$this->handler)
|
||||
if (is_array($this->files) && count($this->files) < self::CHUNK_SIZE) // less entries then asked --> no further available
|
||||
{
|
||||
if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)");
|
||||
|
||||
return false; // no further entries
|
||||
}
|
||||
// try query further files via propfind callback of handler and store result in $this->files
|
||||
@ -445,10 +461,7 @@ class groupdav_propfind_iterator implements Iterator
|
||||
$this->start += self::CHUNK_SIZE;
|
||||
reset($this->files);
|
||||
|
||||
if (count($this->files) < self::CHUNK_SIZE) // less entries then asked --> no further available
|
||||
{
|
||||
unset($this->handler);
|
||||
}
|
||||
if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false));
|
||||
return current($this->files) !== false;
|
||||
}
|
||||
|
||||
@ -457,7 +470,13 @@ class groupdav_propfind_iterator implements Iterator
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
if ($this->debug) error_log(__METHOD__."()");
|
||||
|
||||
// query first set of files via propfind callback of handler and store result in $this->files
|
||||
$this->start = 0;
|
||||
$this->files = $this->handler->propfind_callback($this->filter,array($this->start,self::CHUNK_SIZE));
|
||||
$this->start += self::CHUNK_SIZE;
|
||||
reset($this->files);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -467,6 +486,7 @@ class groupdav_propfind_iterator implements Iterator
|
||||
*/
|
||||
public function valid ()
|
||||
{
|
||||
if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false));
|
||||
return current($this->files) !== false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user