CopyFiles("install/admin", "admin"); $updater->CopyFiles("install/components", "components"); $updater->CopyFiles("install/fonts", "fonts"); $updater->CopyFiles("install/gadgets", "gadgets"); $updater->CopyFiles("install/js", "js"); if ($updater->CanUpdateDatabase()) { if (!$updater->TableExists("b_user_field_permission")) { $DB->Query(" CREATE TABLE b_user_field_permission ( ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, ENTITY_TYPE_ID TINYINT(2) UNSIGNED NOT NULL, USER_FIELD_ID INT(10) UNSIGNED NOT NULL, ACCESS_CODE VARCHAR(8) NOT NULL, PERMISSION_ID VARCHAR(32) NOT NULL, VALUE TINYINT(3) UNSIGNED NOT NULL, PRIMARY KEY (ID), INDEX ROLE_ID(ENTITY_TYPE_ID), INDEX GROUP_ID(USER_FIELD_ID), INDEX PERMISSION_ID(PERMISSION_ID) ) "); } } if ($updater->CanUpdateKernel()) { $vendors = ["1c_bitrix_portal" => 1, "ua_bitrix_portal" => 1, "bitrix_portal" => 1, "1c_bitrix" => 1, "bitrix" => 1]; $vendor = COption::GetOptionString("main", "vendor", "1c_bitrix"); if(!isset($vendors[$vendor])) { $vendor = "1c_bitrix"; } CopyDirFiles($_SERVER['DOCUMENT_ROOT'].$updater->curPath."/".$vendor."/legal/", $_SERVER['DOCUMENT_ROOT']."/bitrix/legal/"); $configuration = \Bitrix\Main\Config\Configuration::getInstance(); if (!is_array($configuration->get('session'))) { $sessionConfig = [ 'mode' => 'default', ]; if (\Bitrix\Main\Config\Option::get('security', 'session', 'N') === 'Y' && IsModuleInstalled('security')) { /** @see \CSecuritySessionMC::isStorageEnabled */ if (defined("BX_SECURITY_SESSION_MEMCACHE_HOST")) { $sessionConfig['handlers']['general'] = [ '_fromSecurity' => true, 'type' => 'memcache', 'keyPrefix' => defined("BX_CACHE_SID") ? BX_CACHE_SID : "BX", 'port' => defined("BX_SECURITY_SESSION_MEMCACHE_PORT") ? intval(BX_SECURITY_SESSION_MEMCACHE_PORT) : 11211, 'host' => BX_SECURITY_SESSION_MEMCACHE_HOST, 'exclusiveLock' => defined('BX_SECURITY_SESSION_MEMCACHE_EXLOCK') && BX_SECURITY_SESSION_MEMCACHE_EXLOCK, ]; } /** @see \CSecuritySessionRedis::isStorageEnabled */ elseif (defined("BX_SECURITY_SESSION_REDIS_HOST")) { $sessionConfig['handlers']['general'] = [ '_fromSecurity' => true, 'type' => 'redis', 'keyPrefix' => defined("BX_CACHE_SID") ? BX_CACHE_SID : "BX", 'port' => defined("BX_SECURITY_SESSION_REDIS_PORT") ? intval(BX_SECURITY_SESSION_REDIS_PORT) : 11211, 'host' => BX_SECURITY_SESSION_REDIS_HOST, 'exclusiveLock' => defined('BX_SECURITY_SESSION_REDIS_EXLOCK') && BX_SECURITY_SESSION_REDIS_EXLOCK, ]; } else { $sessionConfig['handlers']['general'] = [ '_fromSecurity' => true, 'type' => 'database', ]; } } $content = file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/bitrix/.settings.php"); if ($content) { $sessionConfig = ['value' => $sessionConfig, 'readonly' => true]; $sessionConfigAsString = var_export($sessionConfig, true); $sessionConfigAsString = str_replace(['\\', '$'], ['\\\\', '\\$'], $sessionConfigAsString); $content = preg_replace("/return\\s+(array\\s*\\(|\\s*\[)/i", "return $1\n 'session' => {$sessionConfigAsString},", $content); try { $updatedSettings = eval(substr($content,5)); } catch (\Throwable $e) { $updatedSettings = null; } if (empty($updatedSettings['session'])) { throw new \Exception("#1 Could not update .settings.php automatically. At least add 'session' => ['value' => ['mode' => 'default'], 'readonly' => true] "); } $nC = clone $configuration; $reflectionClass = new \ReflectionClass($nC); $reflectionPropertyStoredData = $reflectionClass->getProperty('storedData'); $reflectionPropertyStoredData->setAccessible(true); $reflectionPropertyData = $reflectionClass->getProperty('data'); $reflectionPropertyData->setAccessible(true); $currentDataConfiguration = $reflectionPropertyData->getValue($nC); if ($reflectionPropertyStoredData->getValue($nC) !== null) { $currentDataConfiguration = $reflectionPropertyStoredData->getValue($nC); } unset($updatedSettings['session']); if ($updatedSettings === $currentDataConfiguration) { file_put_contents($_SERVER["DOCUMENT_ROOT"]."/bitrix/.settings.php", $content); } else { throw new \Exception("#2 Could not update .settings.php automatically. At least add 'session' => ['value' => ['mode' => 'default'], 'readonly' => true] "); } } } }