Esempio n. 1
0
 /**
  * Potential conflicts are only loaded when really necessary,
  * e.g. on ADD or MODIFY
  *
  * @access private
  * @return
  */
 private function lazyLoadConflicts()
 {
     if (!isset($this->session) || !isset($this->store) || !isset($this->folderid) || !isset($this->conflictsContentParameters) || $this->conflictsState === false) {
         ZLog::Write(LOGLEVEL_WARN, "ImportChangesICS->lazyLoadConflicts(): can not load potential conflicting changes in lazymode for conflict detection. Missing information");
         return false;
     }
     if (!$this->conflictsLoaded) {
         ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesICS->lazyLoadConflicts(): loading..");
         // configure an exporter so we can detect conflicts
         $exporter = new ExportChangesICS($this->session, $this->store, $this->folderid);
         $exporter->Config($this->conflictsState);
         $exporter->ConfigContentParameters($this->conflictsContentParameters);
         $exporter->InitializeExporter($this->memChanges);
         // monitor how long it takes to export potential conflicts
         // if this takes "too long" we cancel this operation!
         $potConflicts = $exporter->GetChangeCount();
         $started = time();
         $exported = 0;
         while (is_array($exporter->Synchronize())) {
             $exported++;
             // stop if this takes more than 15 seconds and there are more than 5 changes still to be exported
             // within 20 seconds this should be finished or it will not be performed
             if (time() - $started > 15 && $potConflicts - $exported > 5) {
                 ZLog::Write(LOGLEVEL_WARN, sprintf("ImportChangesICS->lazyLoadConflicts(): conflict detection cancelled as operation is too slow. In %d seconds only %d from %d changes were processed.", time() - $started, $exported, $potConflicts));
                 $this->conflictsLoaded = true;
                 return;
             }
         }
         $this->conflictsLoaded = true;
     }
 }