Ejemplo n.º 1
0
 function __construct(GROUPRequest &$props, READER &$reader = NULL, $flags = 0)
 {
     global $DEFAULT_MISSING_VALUE;
     parent::__construct($props);
     $opts = $this->req->GetOptions();
     $this->md5_postfix = $opts->Get('use_md5_postfix');
     if ($reader) {
         $this->reader =& $reader;
     } else {
         if ($this->req->srv['disconnected']) {
             if ($flags & CACHE::CREATE_UPDATER) {
                 throw new ADEIException(translate("It is not possible to create CACHE updater on disconnected data source"));
             }
             $this->reader = NULL;
         } else {
             if ($this->cache_reader) {
                 $this->reader = NULL;
             } else {
                 try {
                     $this->reader = $props->CreateReader(REQUEST::READER_FORBID_CACHEREADER);
                 } catch (ADEIException $ae) {
                     if ($flags & CACHE::CREATE_UPDATER) {
                         throw $ae;
                     }
                     if ($opts->Get('overcome_reader_faults')) {
                         $this->reader = NULL;
                         $reader_exception = $ae;
                     } else {
                         throw $ae;
                     }
                 }
             }
         }
         if (!$this->reader) {
             try {
                 $this->reader = $props->CreateCacheReader($this);
             } catch (ADEIException $ae) {
                 if ($reader_exception) {
                     $reader_exception->MergeRecoveryException($ae);
                     throw $reader_exception;
                 }
                 throw $ae;
             }
         }
     }
     if ($this->reader) {
         if (!$this->reader->srvid || !$this->reader->dbname) {
             throw new ADEIException(translate("Invalid READER is supplied to the caching engine"));
         }
         $grinfo = $props->GetGroupInfo();
         $this->group = $this->reader->CreateGroup($grinfo);
         $this->default_db_server = $this->reader->srvid;
         $this->default_db_name = $this->reader->dbname;
         $this->default_db_group = $this->group->gid;
         $this->SetDefaultPostfix();
         /*
         	We don't expect any changes here at the moment	
         	$opts = $this->req->GetCustomOptions($this->default_db_server, $this->default_db_name, $this->default_db_group);
         */
         $mres = $opts->Get("min_resolution");
         if ($mres && is_array($mres)) {
             $mres = $mres[$this->group->gid];
         }
         $cache_config = $opts->Get('cache_config');
         $this->resolution = new RESOLUTION($mres, $cache_config);
     } else {
         $this->group = false;
         $this->resolution = false;
     }
     $this->use_subseconds = !$opts->Get('ignore_subseconds');
     $this->omit_raw_cache = $opts->Get('omit_raw_cache');
     if ($this->omit_raw_cache) {
         throw new ADEIException(translate("Option 'omit_raw_cache' is not supported yet"));
         $this->fill_raw_first = false;
     } else {
         $this->fill_raw_first = $opts->Get('fill_raw_first');
     }
     $this->optimize_empty_cache = $opts->Get('optimize_empty_cache');
     $this->cache_reader = $opts->Get('use_cache_reader');
     $this->ignore_invalid_data = $opts->Get('ignore_invalid_data');
     $this->items = 0;
     if ($flags & CACHE::CREATE_UPDATER) {
         if ($opts->Get("disable_caching")) {
             throw new ADEIException(translate("Caching is disabled"), ADEIException::DISABLED);
         }
         $this->current_raw_end = false;
         $this->current_cache_end = false;
         $this->current_cache_resolution = false;
         if ($this->md5_postfix) {
             $this->MD5Check();
         }
         if ($this->fill_raw_first) {
             $this->all_mask = false;
         }
         $this->trace_timings = $opts->Get("trace_timings");
         $this->data_filter = $this->reader->CreateDataFilter($this->group);
     }
 }