"- using a referencing foreach to loop over contacts in propfind to minimize memory usage

- some other cleanups"
This commit is contained in:
Ralf Becker 2009-10-16 08:01:28 +00:00
parent f7f902fcf1
commit ae3ecf9891

View File

@ -7,7 +7,7 @@
* @package addressbook
* @subpackage groupdav
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007/8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-9 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @version $Id$
*/
@ -36,10 +36,6 @@ class addressbook_groupdav extends groupdav_handler
* @var string
*/
var $charset = 'utf-8';
/**
*Profiling
*/
var $starttime;
/**
* What attribute is used to construct the path, default id, can be uid too
@ -58,7 +54,6 @@ class addressbook_groupdav extends groupdav_handler
parent::__construct($app,$debug,$base_uri);
$this->bo = new addressbook_bo();
//$this->starttime = microtime(true);
}
/**
@ -84,7 +79,8 @@ class addressbook_groupdav extends groupdav_handler
*/
function propfind($path,$options,&$files,$user,$id='')
{
$this->starttime = microtime(true);
//$starttime = microtime(true);
$filter = array();
// show addressbook of a single user?
if ($user && $path != '/addressbook/') $filter['contact_owner'] = $user;
@ -114,21 +110,20 @@ class addressbook_groupdav extends groupdav_handler
{
$handler = self::_get_handler();
}
$start = false;
//$start = array(0,7000); // limit the number of contacts to return
// we query etag and modified, as LDAP does not have the strong sql etag
if (($contacts =& $this->bo->search(array(),$address_data ? false : array('id','uid','etag','modified'),'contact_id','','',False,'AND',false,$filter)))
if (($contacts =& $this->bo->search(array(),$address_data ? false : array('id','uid','etag','modified'),'contact_id','','',False,'AND',$start,$filter)))
{
//$icount= 0;
foreach($contacts as $contact)
foreach($contacts as &$contact)
{
//$st = microtime(true);
$props = array(
HTTP_WebDAV_Server::mkprop('getetag',$this->get_etag($contact)),
HTTP_WebDAV_Server::mkprop('getcontenttype', 'text/x-vcard'),
// getlastmodified and getcontentlength are required by WebDAV and Cadaver eg. reports 404 Not found if not set
HTTP_WebDAV_Server::mkprop('getlastmodified', $contact['modified']),
);
////error_log("groupdav-props\n".print_r($props,true));
if ($address_data)
{
//$sta = microtime(true);
@ -146,15 +141,10 @@ class addressbook_groupdav extends groupdav_handler
'path' => self::get_path($contact),
'props' => $props,
);
//$end = microtime(true) - $st;
//$icount++;
//error_log("function propfind foreach : $end : $icount");
}
}
$endtime = microtime(true) - $this->starttime;
error_log(__FILE__ ."->". __METHOD__ ." elapsed time : $endtime");
//$endtime = microtime(true) - $starttime; error_log(__METHOD__."($path) elapsed time : $endtime, returning ".count($files['files']).' contacts');
return true;
}