Index: branches/5.2.x/core/units/site_domains/site_domain_eh.php =================================================================== diff -u -N -r13840 -r14092 --- branches/5.2.x/core/units/site_domains/site_domain_eh.php (.../site_domain_eh.php) (revision 13840) +++ branches/5.2.x/core/units/site_domains/site_domain_eh.php (.../site_domain_eh.php) (revision 14092) @@ -1,6 +1,6 @@ Name == 'OnItemBuild') { + // check permission without using $event->getSection(), + // so first cache rebuild won't lead to "ldefault_Name" field being used + return true; + } - $permissions = Array ( - 'OnItemBuild' => Array ('self' => true), - ); - - $this->permMapping = array_merge($this->permMapping, $permissions); + return parent::CheckPermission($event); } /** @@ -56,10 +57,12 @@ function querySiteDomain($field, $value) { - $site_domains = $this->getSiteDomains(); + $site_helper =& $this->Application->recallObject('SiteHelper'); + /* @var $site_helper SiteHelper */ - $domain_by_name = $this->getDomainByName($field, $value); - $domain_by_ip = $this->getDomainByIP(); + $site_domains = $site_helper->getSiteDomains(); + $domain_by_name = $site_helper->getDomainByName($field, $value); + $domain_by_ip = $site_helper->getDomainByIP(); if ($domain_by_ip) { $site_domain = $site_domains[$domain_by_ip]; @@ -95,50 +98,6 @@ } /** - * Try to match visited domain to any of existing - * - * @param string $field - * @param string $value - * @return int - */ - function getDomainByName($field, $value) - { - $site_domains = $this->getSiteDomains(); - $name_fields = Array ('DomainName', 'SSLUrl'); - - foreach ($site_domains as $id => $site_domain) { - if (in_array($field, $name_fields) && $site_domain[$field . 'UsesRegExp']) { - if (preg_match('/^' . $site_domain[$field] . '$/', $value)) { - return $id; - } - } - elseif ($site_domain[$field] == $value) { - return $id; - } - } - - return false; - } - - /** - * Try to match domain settings based on visitor's IP address - * - * @return int - */ - function getDomainByIP() - { - $site_domains = $this->getSiteDomains(); - - foreach ($site_domains as $id => $site_domain) { - if (ipMatch($site_domain['DomainIPRange'], "\n")) { - return $id; - } - } - - return false; - } - - /** * Load item if id is available * * @param kEvent $event @@ -162,7 +121,10 @@ return ; } - $site_domains = $this->getSiteDomains(); + $site_helper =& $this->Application->recallObject('SiteHelper'); + /* @var $site_helper SiteHelper */ + + $site_domains = $site_helper->getSiteDomains(); $domain_data = array_key_exists($id, $site_domains) ? $site_domains[$id] : false; if ($object->LoadFromHash($domain_data)) { @@ -174,42 +136,6 @@ } } - function getSiteDomains() - { - static $cache = null; - - if (!isset($cache)) { - if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { - $cache = $this->Application->getCache('master:domains_parsed', false); - } - else { - $cache = $this->Application->getDBCache('domains_parsed'); - } - - if ($cache) { - $cache = unserialize($cache); - } - else { - $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); - $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName'); - - $sql = 'SELECT * - FROM ' . $table_name . ' - ORDER BY Priority DESC'; - $cache = $this->Conn->Query($sql, $id_field); - - if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { - $this->Application->setCache('master:domains_parsed', serialize($cache)); - } - else { - $this->Application->setDBCache('domains_parsed', serialize($cache)); - } - } - } - - return $cache; - } - /** * Removes In-Commerce related fields, when it's not installed *