From ae3ecf9891fa037cee0acfaeb31276120ab3d918 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 16 Oct 2009 08:01:28 +0000 Subject: [PATCH] "- using a referencing foreach to loop over contacts in propfind to minimize memory usage - some other cleanups" --- .../inc/class.addressbook_groupdav.inc.php | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index b01b0f471a..0eeacbbeed 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -7,7 +7,7 @@ * @package addressbook * @subpackage groupdav * @author Ralf Becker - * @copyright (c) 2007/8 by Ralf Becker + * @copyright (c) 2007-9 by Ralf Becker * @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; }