12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468 |
- <?php
- use Drupal\Component\Utility\UrlHelper;
- use Drupal\Core\Batch\BatchBuilder;
- use Drupal\Core\Config\ConfigImporter;
- use Drupal\Core\Config\ConfigImporterException;
- use Drupal\Core\Config\Importer\ConfigImporterBatch;
- use Drupal\Core\Config\FileStorage;
- use Drupal\Core\Config\StorageComparer;
- use Drupal\Core\DrupalKernel;
- use Drupal\Core\Database\Database;
- use Drupal\Core\Database\DatabaseExceptionWrapper;
- use Drupal\Core\File\FileSystemInterface;
- use Drupal\Core\Form\FormState;
- use Drupal\Core\Installer\Exception\AlreadyInstalledException;
- use Drupal\Core\Installer\Exception\InstallerException;
- use Drupal\Core\Installer\Exception\NoProfilesException;
- use Drupal\Core\Installer\Form\SiteSettingsForm;
- use Drupal\Core\Installer\InstallerKernel;
- use Drupal\Core\Language\Language;
- use Drupal\Core\Language\LanguageManager;
- use Drupal\Core\Logger\LoggerChannelFactory;
- use Drupal\Core\Site\Settings;
- use Drupal\Core\StringTranslation\Translator\FileTranslation;
- use Drupal\Core\StackMiddleware\ReverseProxyMiddleware;
- use Drupal\Core\Extension\ExtensionDiscovery;
- use Drupal\Core\DependencyInjection\ContainerBuilder;
- use Drupal\Core\Url;
- use Drupal\language\Entity\ConfigurableLanguage;
- use Symfony\Cmf\Component\Routing\RouteObjectInterface;
- use Symfony\Component\DependencyInjection\Reference;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Routing\Route;
- use Drupal\user\Entity\User;
- use GuzzleHttp\Exception\RequestException;
- const INSTALL_TASK_SKIP = 1;
- const INSTALL_TASK_RUN_IF_REACHED = 2;
- const INSTALL_TASK_RUN_IF_NOT_COMPLETED = 3;
- function install_drupal($class_loader, $settings = [], callable $callback = NULL) {
- global $install_state;
-
-
-
- $interactive = empty($settings);
- $install_state = $settings + ['interactive' => $interactive] + install_state_defaults();
- try {
-
-
- install_begin_request($class_loader, $install_state);
-
-
- $output = install_run_tasks($install_state, $callback);
- }
- catch (InstallerException $e) {
-
- if (!$install_state['interactive']) {
- throw $e;
- }
- $output = [
- '#title' => $e->getTitle(),
- '#markup' => $e->getMessage(),
- ];
- }
-
-
-
-
-
- $state = $install_state;
- if (!empty($install_state['installation_finished'])) {
- unset($GLOBALS['install_state']);
-
-
- unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']);
- }
-
-
-
- if ($state['interactive']) {
-
- if (\Drupal::request()->hasSession()) {
- \Drupal::request()->getSession()->save();
- }
- if ($state['parameters_changed']) {
-
- install_goto(install_redirect_url($state));
- }
- elseif (isset($output)) {
-
-
-
- install_display_output($output, $state);
- }
- elseif ($state['installation_finished']) {
-
- $finish_url = '';
- if (isset($install_state['profile_info']['distribution']['install']['finish_url'])) {
- $finish_url = $install_state['profile_info']['distribution']['install']['finish_url'];
- }
- install_goto($finish_url);
- }
- }
- }
- function install_state_defaults() {
- $defaults = [
-
- 'active_task' => NULL,
-
-
- 'completed_task' => NULL,
-
- 'config' => NULL,
-
- 'config_install_path' => NULL,
-
- 'config_verified' => FALSE,
-
- 'database_verified' => FALSE,
-
-
- 'settings_verified' => FALSE,
-
- 'base_system_verified' => FALSE,
-
-
- 'download_translation' => FALSE,
-
-
-
-
-
- 'forms' => [],
-
-
-
-
-
-
- 'installation_finished' => FALSE,
-
-
- 'interactive' => TRUE,
-
-
-
-
-
-
- 'parameters' => [],
-
-
-
- 'parameters_changed' => FALSE,
-
-
- 'profile_info' => [],
-
- 'profiles' => [],
-
- 'theme' => 'seven',
-
-
-
- 'server_pattern' => 'http://ftp.drupal.org/files/translations/%core/%project/%project-%version.%language.po',
-
-
-
-
-
-
-
-
- 'stop_page_request' => FALSE,
-
-
-
-
-
-
-
-
-
- 'task_not_complete' => FALSE,
-
-
- 'tasks_performed' => [],
-
-
- 'translations' => [],
- ];
- return $defaults;
- }
- function install_begin_request($class_loader, &$install_state) {
- $request = Request::createFromGlobals();
-
- if ($install_state['interactive']) {
- $install_state['parameters'] += $request->query->all();
- }
-
- if (!empty($install_state['parameters']['profile'])) {
- $install_state['parameters']['profile'] = preg_replace('/[^a-zA-Z_0-9]/', '', $install_state['parameters']['profile']);
- }
- if (!empty($install_state['parameters']['langcode'])) {
- $install_state['parameters']['langcode'] = preg_replace('/[^a-zA-Z_0-9\-]/', '', $install_state['parameters']['langcode']);
- }
-
- require_once __DIR__ . '/bootstrap.inc';
-
-
-
-
-
- $user_agent = $request->cookies->get('SIMPLETEST_USER_AGENT') ?: $request->server->get('HTTP_USER_AGENT');
- if ($install_state['interactive'] && strpos($user_agent, 'simpletest') !== FALSE && !drupal_valid_test_ua()) {
- header($request->server->get('SERVER_PROTOCOL') . ' 403 Forbidden');
- exit;
- }
- if ($install_state['interactive'] && drupal_valid_test_ua()) {
-
-
-
-
-
- date_default_timezone_set('Australia/Sydney');
- }
- $site_path = empty($install_state['site_path']) ? DrupalKernel::findSitePath($request, FALSE) : $install_state['site_path'];
- Settings::initialize(dirname(dirname(__DIR__)), $site_path, $class_loader);
-
-
- require_once __DIR__ . '/../modules/system/system.install';
- require_once __DIR__ . '/common.inc';
- require_once __DIR__ . '/file.inc';
- require_once __DIR__ . '/install.inc';
- require_once __DIR__ . '/schema.inc';
- require_once __DIR__ . '/database.inc';
- require_once __DIR__ . '/form.inc';
- require_once __DIR__ . '/batch.inc';
-
- include_once __DIR__ . '/module.inc';
- require_once __DIR__ . '/entity.inc';
-
-
-
-
- $container = new ContainerBuilder();
- $container->setParameter('language.default_values', Language::$defaultValues);
- $container
- ->register('language.default', 'Drupal\Core\Language\LanguageDefault')
- ->addArgument('%language.default_values%');
- $container
- ->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager')
- ->addArgument(new Reference('language.default'));
-
- $container
- ->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager')
- ->addMethodCall('setContainer', [new Reference('service_container')]);
- $container
- ->register('file_system', 'Drupal\Core\File\FileSystem')
- ->addArgument(new Reference('stream_wrapper_manager'))
- ->addArgument(Settings::getInstance())
- ->addArgument((new LoggerChannelFactory())->get('file'));
-
-
-
- $container->set('class_loader', $class_loader);
- \Drupal::setContainer($container);
-
- try {
- $sync_directory = Settings::get('config_sync_directory', FALSE);
- $install_state['config_verified'] = file_exists($sync_directory);
- }
- catch (Exception $e) {
- $install_state['config_verified'] = FALSE;
- }
- $install_state['database_verified'] = install_verify_database_settings($site_path);
-
-
- $install_state['settings_verified'] = $install_state['database_verified'] && (bool) Settings::get('hash_salt', FALSE);
- if ($install_state['settings_verified']) {
- try {
- $system_schema = system_schema();
- end($system_schema);
- $table = key($system_schema);
- $install_state['base_system_verified'] = Database::getConnection()->schema()->tableExists($table);
- }
- catch (DatabaseExceptionWrapper $e) {
-
-
-
-
-
- }
- }
-
-
- if (!$install_state['base_system_verified']) {
- $environment = 'install';
- $GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\InstallerServiceProvider';
- }
- else {
- $environment = 'prod';
- $GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\NormalInstallerServiceProvider';
- }
- $GLOBALS['conf']['container_service_providers']['InstallerConfigOverride'] = 'Drupal\Core\Installer\ConfigOverride';
-
-
- $kernel = new InstallerKernel($environment, $class_loader, FALSE);
- $kernel::bootEnvironment();
- $kernel->setSitePath($site_path);
- $kernel->boot();
- $container = $kernel->getContainer();
-
- ReverseProxyMiddleware::setSettingsOnRequest($request, Settings::getInstance());
-
- if (isset($GLOBALS['config']['locale.settings']['translation']['path'])) {
- $directory = $GLOBALS['config']['locale.settings']['translation']['path'];
- }
- else {
- $directory = $site_path . '/files/translations';
- }
-
- $file_system = $container->get('file_system');
- $container->set('string_translator.file_translation', new FileTranslation($directory, $file_system));
- $container->get('string_translation')
- ->addTranslator($container->get('string_translator.file_translation'));
-
- $listing = new ExtensionDiscovery($container->get('app.root'));
- $listing->setProfileDirectories([]);
- $install_state['profiles'] += $listing->scan('profile');
-
- foreach ($install_state['profiles'] as $name => $profile) {
- drupal_get_filename('profile', $name, $profile->getPathname());
-
-
- drupal_get_filename('module', $name, $profile->getPathname());
- }
- if ($profile = _install_select_profile($install_state)) {
- $install_state['parameters']['profile'] = $profile;
- install_load_profile($install_state);
- if (isset($install_state['profile_info']['distribution']['install']['theme'])) {
- $install_state['theme'] = $install_state['profile_info']['distribution']['install']['theme'];
- }
- }
-
-
-
-
- drupal_get_filename('module', 'system', 'core/modules/system/system.info.yml');
-
- if (!empty($install_state['config_install_path']) && $install_state['config']['system.site']) {
- $install_state['parameters']['langcode'] = $install_state['config']['system.site']['default_langcode'];
- }
- elseif (isset($install_state['profile_info']['distribution']['langcode'])) {
-
-
- $install_state['parameters']['langcode'] = $install_state['profile_info']['distribution']['langcode'];
- }
-
- if (isset($install_state['parameters']['langcode'])) {
- $default_language = new Language(['id' => $install_state['parameters']['langcode']]);
- $container->get('language.default')->set($default_language);
- \Drupal::translation()->setDefaultLangcode($install_state['parameters']['langcode']);
- }
-
- $module_handler = \Drupal::moduleHandler();
- if (!$module_handler->moduleExists('system')) {
- $module_handler->addModule('system', 'core/modules/system');
- }
- if ($profile && !$module_handler->moduleExists($profile)) {
- $module_handler->addProfile($profile, $install_state['profiles'][$profile]->getPath());
- }
-
- $kernel->preHandle($request);
-
-
-
- $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('<none>'));
- $request->attributes->set(RouteObjectInterface::ROUTE_NAME, '<none>');
-
-
-
-
-
- drupal_maintenance_theme();
- if (!$install_state['database_verified']) {
-
-
-
- install_verify_database_ready();
- }
-
- $task = install_verify_completed_task();
-
- if ($install_state['config_verified'] && empty($task)) {
- if (count($kernel->getConfigStorage()->listAll())) {
- $task = NULL;
- throw new AlreadyInstalledException($container->get('string_translation'));
- }
- }
-
- $install_state['completed_task'] = $task;
- }
- function install_run_tasks(&$install_state, callable $callback = NULL) {
- do {
-
-
-
-
-
- $tasks_to_perform = install_tasks_to_perform($install_state);
-
- reset($tasks_to_perform);
- $task_name = key($tasks_to_perform);
- $task = array_shift($tasks_to_perform);
- $install_state['active_task'] = $task_name;
- $original_parameters = $install_state['parameters'];
- $output = install_run_task($task, $install_state);
-
-
-
- drupal_maintenance_theme();
- $install_state['parameters_changed'] = ($install_state['parameters'] != $original_parameters);
-
-
-
-
- if (!$install_state['task_not_complete']) {
- $install_state['tasks_performed'][] = $task_name;
- $install_state['installation_finished'] = empty($tasks_to_perform);
- if ($task['run'] == INSTALL_TASK_RUN_IF_NOT_COMPLETED || $install_state['installation_finished']) {
- \Drupal::state()->set('install_task', $install_state['installation_finished'] ? 'done' : $task_name);
- }
- }
- if ($callback) {
- $callback($install_state);
- }
-
-
-
-
- $finished = empty($tasks_to_perform) || ($install_state['interactive'] && (isset($output) || $install_state['parameters_changed'] || $install_state['stop_page_request']));
- } while (!$finished);
- return $output;
- }
- function install_run_task($task, &$install_state) {
- $function = $task['function'];
- if ($task['type'] == 'form') {
- return install_get_form($function, $install_state);
- }
- elseif ($task['type'] == 'batch') {
-
-
- $current_batch = \Drupal::state()->get('install_current_batch');
- if (!$install_state['interactive'] || !$current_batch) {
- $batches = $function($install_state);
- if (empty($batches)) {
-
-
- return;
- }
-
- if (isset($batches['operations'])) {
- $batches = [$batches];
- }
- foreach ($batches as $batch) {
- batch_set($batch);
-
-
-
- if ($install_state['interactive']) {
- \Drupal::state()->set('install_current_batch', $function);
- }
- else {
- $batch =& batch_get();
- $batch['progressive'] = FALSE;
- }
- }
-
-
-
-
- $url = Url::fromUri('base:install.php', ['query' => $install_state['parameters'], 'script' => '']);
- $response = batch_process($url, clone $url);
- if ($response instanceof Response) {
- if (\Drupal::request()->hasSession()) {
- \Drupal::request()->getSession()->save();
- }
-
- $response->send();
- exit;
- }
- }
-
-
- elseif ($current_batch == $function) {
- $output = _batch_page(\Drupal::request());
-
-
-
-
-
- if ($output instanceof Response) {
- $output->send();
- $output = NULL;
- }
-
-
-
- if ($output === FALSE) {
-
- \Drupal::state()->delete('install_current_batch');
- return;
- }
- else {
-
-
-
- $install_state['task_not_complete'] = $install_state['stop_page_request'] = TRUE;
- return $output;
- }
- }
- }
- else {
-
- return $function($install_state);
- }
- }
- function install_tasks_to_perform($install_state) {
-
- $tasks = install_tasks($install_state);
- foreach ($tasks as $name => $task) {
-
-
-
-
- if ($task['run'] == INSTALL_TASK_SKIP || in_array($name, $install_state['tasks_performed']) || (!empty($install_state['completed_task']) && empty($completed_task_found) && $task['run'] != INSTALL_TASK_RUN_IF_REACHED)) {
- unset($tasks[$name]);
- }
- if (!empty($install_state['completed_task']) && $name == $install_state['completed_task']) {
- $completed_task_found = TRUE;
- }
- }
- return $tasks;
- }
- function install_tasks($install_state) {
-
-
-
-
- $locale_module_installed = \Drupal::moduleHandler()->moduleExists('locale');
- $needs_translations = $locale_module_installed && ((count($install_state['translations']) > 1 && !empty($install_state['parameters']['langcode']) && $install_state['parameters']['langcode'] != 'en') || \Drupal::languageManager()->isMultilingual());
-
-
-
- $needs_download = isset($install_state['parameters']['langcode']) && !isset($install_state['translations'][$install_state['parameters']['langcode']]) && $install_state['parameters']['langcode'] != 'en';
-
-
- $tasks = [
- 'install_select_language' => [
- 'display_name' => t('Choose language'),
- 'run' => INSTALL_TASK_RUN_IF_REACHED,
- ],
- 'install_download_translation' => [
- 'run' => $needs_download ? INSTALL_TASK_RUN_IF_REACHED : INSTALL_TASK_SKIP,
- ],
- 'install_select_profile' => [
- 'display_name' => t('Choose profile'),
- 'display' => empty($install_state['profile_info']['distribution']['name']) && count($install_state['profiles']) != 1,
- 'run' => INSTALL_TASK_RUN_IF_REACHED,
- ],
- 'install_load_profile' => [
- 'run' => INSTALL_TASK_RUN_IF_REACHED,
- ],
- 'install_verify_requirements' => [
- 'display_name' => t('Verify requirements'),
- ],
- 'install_settings_form' => [
- 'display_name' => t('Set up database'),
- 'type' => 'form',
-
-
-
- 'run' => $install_state['settings_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
- 'function' => 'Drupal\Core\Installer\Form\SiteSettingsForm',
- ],
- 'install_write_profile' => [],
- 'install_verify_database_ready' => [
- 'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
- ],
- 'install_base_system' => [
- 'run' => $install_state['base_system_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED,
- ],
-
- 'install_bootstrap_full' => [
- 'run' => INSTALL_TASK_RUN_IF_REACHED,
- ],
- 'install_profile_modules' => [
- 'display_name' => t('Install site'),
- 'type' => 'batch',
- ],
- 'install_profile_themes' => [],
- 'install_install_profile' => [],
- 'install_import_translations' => [
- 'display_name' => t('Set up translations'),
- 'display' => $needs_translations,
- 'type' => 'batch',
- 'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
- ],
- 'install_configure_form' => [
- 'display_name' => t('Configure site'),
- 'type' => 'form',
- 'function' => 'Drupal\Core\Installer\Form\SiteConfigureForm',
- ],
- ];
- if (!empty($install_state['config_install_path'])) {
-
-
-
-
-
- unset($tasks['install_download_translation']);
- $key = array_search('install_profile_modules', array_keys($tasks), TRUE);
- unset($tasks['install_profile_modules']);
- unset($tasks['install_profile_themes']);
- unset($tasks['install_install_profile']);
- $config_tasks = [
- 'install_config_import_batch' => [
- 'display_name' => t('Install configuration'),
- 'type' => 'batch',
- ],
- 'install_config_download_translations' => [],
- 'install_config_revert_install_changes' => [],
- ];
- $tasks = array_slice($tasks, 0, $key, TRUE) +
- $config_tasks +
- array_slice($tasks, $key, NULL, TRUE);
- }
-
- if (!empty($install_state['parameters']['profile'])) {
-
-
- $profile = $install_state['parameters']['profile'];
- $profile_install_file = $install_state['profiles'][$profile]->getPath() . '/' . $profile . '.install';
- if (file_exists($profile_install_file)) {
- include_once \Drupal::root() . '/' . $profile_install_file;
- }
- $function = $install_state['parameters']['profile'] . '_install_tasks';
- if (function_exists($function)) {
- $result = $function($install_state);
- if (is_array($result)) {
- $tasks += $result;
- }
- }
- }
-
- $tasks += [
- 'install_finish_translations' => [
- 'display_name' => t('Finish translations'),
- 'display' => $needs_translations,
- 'type' => 'batch',
- 'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
- ],
- 'install_finished' => [],
- ];
-
- if (!empty($install_state['parameters']['profile'])) {
- $profile = $install_state['parameters']['profile'];
- if ($install_state['profiles'][$profile]->load()) {
- $function = $install_state['parameters']['profile'] . '_install_tasks_alter';
- if (function_exists($function)) {
- $function($tasks, $install_state);
- }
- }
- }
-
- foreach ($tasks as $task_name => &$task) {
- $task += [
- 'display_name' => NULL,
- 'display' => !empty($task['display_name']),
- 'type' => 'normal',
- 'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED,
- 'function' => $task_name,
- ];
- }
- return $tasks;
- }
- function install_tasks_to_display($install_state) {
- $displayed_tasks = [];
- foreach (install_tasks($install_state) as $name => $task) {
- if ($task['display']) {
- $displayed_tasks[$name] = $task['display_name'];
- }
- }
- return $displayed_tasks;
- }
- function install_get_form($form_id, array &$install_state) {
-
-
- $form_state = (new FormState())
- ->addBuildInfo('args', [&$install_state])
- ->disableRedirect();
- $form_builder = \Drupal::formBuilder();
- if ($install_state['interactive']) {
- $form = $form_builder->buildForm($form_id, $form_state);
-
-
- if (!$form_state->isExecuted()) {
- $install_state['task_not_complete'] = TRUE;
- return $form;
- }
- }
- else {
-
-
- $install_form_id = $form_builder->getFormId($form_id, $form_state);
- if (!empty($install_state['forms'][$install_form_id])) {
- $form_state->setValues($install_state['forms'][$install_form_id]);
- }
- $form_builder->submitForm($form_id, $form_state);
-
- if ($errors = $form_state->getErrors()) {
- throw new InstallerException(implode("\n", $errors));
- }
- }
- }
- function install_redirect_url($install_state) {
- return 'core/install.php?' . UrlHelper::buildQuery($install_state['parameters']);
- }
- function install_full_redirect_url($install_state) {
- global $base_url;
- return $base_url . '/' . install_redirect_url($install_state);
- }
- function install_display_output($output, $install_state) {
-
-
-
- drupal_maintenance_theme();
-
-
-
-
-
- $noindex_meta_tag = [
- '#tag' => 'meta',
- '#attributes' => [
- 'name' => 'robots',
- 'content' => 'noindex, nofollow',
- ],
- ];
- $output['#attached']['html_head'][] = [$noindex_meta_tag, 'install_meta_robots'];
-
-
-
- $regions = [];
- if (isset($install_state['active_task'])) {
-
-
- $active_task = $install_state['installation_finished'] ? NULL : $install_state['active_task'];
- $task_list = [
- '#theme' => 'maintenance_task_list',
- '#items' => install_tasks_to_display($install_state),
- '#active' => $active_task,
- ];
- $regions['sidebar_first'] = $task_list;
- }
- $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer');
- $response = $bare_html_page_renderer->renderBarePage($output, $output['#title'], 'install_page', $regions);
- $default_headers = [
- 'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT',
- 'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME),
- 'Cache-Control' => 'no-cache, must-revalidate',
- 'ETag' => '"' . REQUEST_TIME . '"',
- ];
- $response->headers->add($default_headers);
- $response->send();
- exit;
- }
- function install_verify_requirements(&$install_state) {
-
- $requirements = install_check_requirements($install_state);
-
- $requirements += drupal_verify_profile($install_state);
- return install_display_requirements($install_state, $requirements);
- }
- function install_base_system(&$install_state) {
-
- drupal_install_system($install_state);
-
-
-
-
-
-
-
- \Drupal::service('file.htaccess_writer')->ensure();
-
-
-
- drupal_get_filename('module', 'user', 'core/modules/user/user.info.yml');
-
-
- \Drupal::service('module_installer')->install(['user'], FALSE);
-
-
- $modules = $install_state['profile_info']['install'];
- \Drupal::state()->set('install_profile_modules', array_diff($modules, ['system']));
- $install_state['base_system_verified'] = TRUE;
- }
- function install_verify_completed_task() {
- try {
- $task = \Drupal::state()->get('install_task');
- }
-
-
- catch (\Exception $e) {
- }
- if (isset($task)) {
- if ($task == 'done') {
- throw new AlreadyInstalledException(\Drupal::service('string_translation'));
- }
- return $task;
- }
- }
- function install_verify_database_settings($site_path) {
- if ($database = Database::getConnectionInfo()) {
- $database = $database['default'];
- $settings_file = './' . $site_path . '/settings.php';
- $errors = install_database_errors($database, $settings_file);
- if (empty($errors)) {
- return TRUE;
- }
- }
- return FALSE;
- }
- function install_verify_database_ready() {
- $system_schema = system_schema();
- end($system_schema);
- $table = key($system_schema);
- $existing_install = FALSE;
- if ($database = Database::getConnectionInfo()) {
- try {
- $existing_install = Database::getConnection()->schema()->tableExists($table);
- }
-
-
- catch (\Exception $e) {
- }
- }
- if ($existing_install) {
- throw new AlreadyInstalledException(\Drupal::service('string_translation'));
- }
- }
- function install_database_errors($database, $settings_file) {
- $errors = [];
-
- $database_types = drupal_get_database_types();
- $driver = $database['driver'];
- if (!isset($database_types[$driver])) {
- $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", ['%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver]);
- }
- else {
-
- $errors += $database_types[$driver]->validateDatabaseSettings($database);
- if (!empty($errors)) {
-
- return $errors;
- }
-
-
- Database::addConnectionInfo('default', 'default', $database);
- $errors = db_installer_object($driver, $database['namespace'] ?? NULL)->runTasks();
- }
- return $errors;
- }
- function install_select_profile(&$install_state) {
- if (empty($install_state['parameters']['profile'])) {
-
- if (empty($install_state['profiles'])) {
- throw new NoProfilesException(\Drupal::service('string_translation'));
- }
-
- if ($profile = _install_select_profile($install_state)) {
- $install_state['parameters']['profile'] = $profile;
- }
- else {
-
- if (!$install_state['interactive']) {
- throw new InstallerException('Missing profile parameter.');
- }
-
- return install_get_form('Drupal\Core\Installer\Form\SelectProfileForm', $install_state);
- }
- }
- }
- function _install_select_profile(&$install_state) {
-
- if (count($install_state['profiles']) == 1) {
- return key($install_state['profiles']);
- }
-
- if (!empty($install_state['parameters']['profile'])) {
- $profile = $install_state['parameters']['profile'];
- if (isset($install_state['profiles'][$profile])) {
- return $profile;
- }
- }
-
- foreach ($install_state['profiles'] as $profile) {
- $profile_info = install_profile_info($profile->getName());
- if (!empty($profile_info['distribution'])) {
- return $profile->getName();
- }
- }
-
- $visible_profiles = array_filter($install_state['profiles'], function ($profile) {
- $profile_info = install_profile_info($profile->getName());
- return !isset($profile_info['hidden']) || !$profile_info['hidden'];
- });
-
- if (count($visible_profiles) == 1) {
- return (key($visible_profiles));
- }
- }
- function install_find_translations() {
- $translations = [];
- $files = \Drupal::service('string_translator.file_translation')->findTranslationFiles();
-
- array_unshift($files, (object) ['name' => 'en']);
- foreach ($files as $uri => $file) {
-
- $langcode = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $file->name);
-
-
- if (strlen($langcode) <= 12) {
- $translations[$langcode] = $uri;
- }
- }
- return $translations;
- }
- function install_select_language(&$install_state) {
-
- $files = install_find_translations();
- $install_state['translations'] += $files;
-
-
-
-
-
-
- if (!empty($install_state['parameters']['langcode'])) {
- $standard_languages = LanguageManager::getStandardLanguageList();
- $langcode = $install_state['parameters']['langcode'];
- if ($langcode == 'en' || isset($files[$langcode]) || isset($standard_languages[$langcode])) {
- $install_state['parameters']['langcode'] = $langcode;
- return;
- }
- }
- if (empty($install_state['parameters']['langcode'])) {
-
-
-
-
-
- if ($install_state['interactive']) {
- return install_get_form('Drupal\Core\Installer\Form\SelectLanguageForm', $install_state);
- }
-
-
-
- else {
- if (count($files) == 1) {
- $install_state['parameters']['langcode'] = current(array_keys($files));
- return;
- }
- else {
- throw new InstallerException('You must select a language to continue the installation.');
- }
- }
- }
- }
- function install_download_translation(&$install_state) {
-
-
- $requirements = install_check_translations($install_state['parameters']['langcode'], $install_state['server_pattern']);
- if ($output = install_display_requirements($install_state, $requirements)) {
- return $output;
- }
-
- $install_state['translations'][$install_state['parameters']['langcode']] = TRUE;
- if ($install_state['interactive']) {
- install_goto(install_redirect_url($install_state));
- }
- }
- function install_retrieve_file($uri, $destination) {
- $parsed_url = parse_url($uri);
-
- $file_system = \Drupal::service('file_system');
- if (is_dir($file_system->realpath($destination))) {
-
- $path = str_replace('///', '//', "$destination/") . $file_system->basename($parsed_url['path']);
- }
- else {
- $path = $destination;
- }
- try {
- $response = \Drupal::httpClient()->get($uri, ['headers' => ['Accept' => 'text/plain']]);
- $data = (string) $response->getBody();
- if (empty($data)) {
- return FALSE;
- }
- }
- catch (RequestException $e) {
- return FALSE;
- }
- return file_put_contents($path, $data) !== FALSE;
- }
- function install_check_localization_server($uri) {
- try {
- \Drupal::httpClient()->head($uri);
- return TRUE;
- }
- catch (RequestException $e) {
- return FALSE;
- }
- }
- function _install_get_version_info($version) {
- preg_match('/
- (
- (?P<major>[0-9]+) # Major release number.
- \. # .
- (?P<minor>[0-9]+) # Minor release number.
- \. # .
- (?P<patch>[0-9]+|x) # Patch release number.
- ) #
- ( #
- - # - separator for "extra" version information.
- (?P<extra> #
- (?P<extra_text>[a-z]+) # Release extra text (e.g., "alpha").
- (?P<extra_number>[0-9]*) # Release extra number (no separator between text and number).
- ) #
- | # OR no "extra" information.
- )
- /sx', $version, $matches);
- return $matches;
- }
- function install_load_profile(&$install_state) {
- $profile = $install_state['parameters']['profile'];
- $install_state['profiles'][$profile]->load();
- $install_state['profile_info'] = install_profile_info($profile, isset($install_state['parameters']['langcode']) ? $install_state['parameters']['langcode'] : 'en');
- $sync_directory = Settings::get('config_sync_directory');
- if (!empty($install_state['parameters']['existing_config']) && !empty($sync_directory)) {
- $install_state['config_install_path'] = $sync_directory;
- }
-
-
- elseif (!empty($install_state['profile_info']['config_install_path'])) {
- $install_state['config_install_path'] = $install_state['profile_info']['config_install_path'];
- }
- if (!empty($install_state['config_install_path'])) {
- $sync = new FileStorage($install_state['config_install_path']);
- $install_state['config']['system.site'] = $sync->read('system.site');
- }
- }
- function install_bootstrap_full() {
-
-
- $session = \Drupal::service('session');
- \Drupal::request()->setSession($session);
- $session->start();
- }
- function install_profile_modules(&$install_state) {
-
-
- install_core_entity_type_definitions();
- $modules = \Drupal::state()->get('install_profile_modules') ?: [];
- $files = \Drupal::service('extension.list.module')->getList();
- \Drupal::state()->delete('install_profile_modules');
-
-
- $required = [];
- $non_required = [];
-
- foreach ($modules as $module) {
- if ($files[$module]->requires) {
- $modules = array_merge($modules, array_keys($files[$module]->requires));
- }
- }
- $modules = array_unique($modules);
- foreach ($modules as $module) {
- if (!empty($files[$module]->info['required'])) {
- $required[$module] = $files[$module]->sort;
- }
- else {
- $non_required[$module] = $files[$module]->sort;
- }
- }
- arsort($required);
- arsort($non_required);
- $operations = [];
- foreach ($required + $non_required as $module => $weight) {
- $operations[] = ['_install_module_batch', [$module, $files[$module]->info['name']]];
- }
- $batch = [
- 'operations' => $operations,
- 'title' => t('Installing @drupal', ['@drupal' => drupal_install_profile_distribution_name()]),
- 'error_message' => t('The installation has encountered an error.'),
- ];
- return $batch;
- }
- function install_core_entity_type_definitions() {
- $update_manager = \Drupal::entityDefinitionUpdateManager();
- foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type) {
- if ($entity_type->getProvider() == 'core') {
- $update_manager->installEntityType($entity_type);
- }
- }
- }
- function install_profile_themes(&$install_state) {
-
- $themes = $install_state['profile_info']['themes'];
- \Drupal::service('theme_installer')->install($themes);
-
-
- \Drupal::theme()->resetActiveTheme();
- }
- function install_install_profile(&$install_state) {
- \Drupal::service('module_installer')->install([$install_state['parameters']['profile']], FALSE);
-
-
-
-
-
-
-
- \Drupal::service('config.installer')->installOptionalConfig();
-
-
- \Drupal::theme()->resetActiveTheme();
- }
- function install_download_additional_translations_operations(&$install_state) {
- \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
- $langcode = $install_state['parameters']['langcode'];
- if (!($language = ConfigurableLanguage::load($langcode))) {
-
- $language = ConfigurableLanguage::createFromLangcode($langcode);
- }
- $language->save();
-
-
- if ($langcode != 'en') {
- \Drupal::configFactory()->getEditable('system.site')
- ->set('langcode', $langcode)
- ->set('default_langcode', $langcode)
- ->save();
- \Drupal::service('language.default')->set($language);
- if (empty($install_state['profile_info']['keep_english'])) {
- if ($lang = ConfigurableLanguage::load('en')) {
- $lang->delete();
- }
- }
- }
-
-
- $languages = \Drupal::languageManager()->getLanguages();
- $operations = [];
- foreach ($languages as $langcode => $language) {
-
-
-
-
- if ($langcode != 'en' && $langcode != $install_state['parameters']['langcode']) {
- $operations[] = ['install_check_translations', [$langcode, $install_state['server_pattern']]];
- }
- }
- return $operations;
- }
- function install_import_translations(&$install_state) {
- \Drupal::moduleHandler()->loadInclude('locale', 'translation.inc');
-
-
- $operations = install_download_additional_translations_operations($install_state);
- $languages = \Drupal::languageManager()->getLanguages();
- if (count($languages) > 1 || !isset($languages['en'])) {
- $operations[] = ['_install_prepare_import', [array_keys($languages), $install_state['server_pattern']]];
-
-
- foreach ($languages as $language) {
- if (locale_translation_use_remote_source()) {
- $operations[] = ['locale_translation_batch_fetch_download', ['drupal', $language->getId()]];
- }
- $operations[] = ['locale_translation_batch_fetch_import', ['drupal', $language->getId(), []]];
- }
- module_load_include('fetch.inc', 'locale');
- $batch = [
- 'operations' => $operations,
- 'title' => t('Updating translations.'),
- 'progress_message' => '',
- 'error_message' => t('Error importing translation files'),
- 'finished' => 'locale_translation_batch_fetch_finished',
- 'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc',
- ];
- return $batch;
- }
- }
- function _install_prepare_import($langcodes, $server_pattern) {
- \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
- $matches = [];
- foreach ($langcodes as $langcode) {
-
- $files = locale_translate_get_interface_translation_files(['drupal'], [$langcode]);
-
- $file = reset($files);
- if (is_object($file)) {
- $filename = $file->filename;
- preg_match('/drupal-([0-9a-z\.-]+)\.' . $langcode . '\.po/', $filename, $matches);
-
- if ($version = $matches[1]) {
- $info = _install_get_version_info($version);
-
-
- if ($info['major']) {
- $core = $info['major'] . '.x';
- $data = [
- 'name' => 'drupal',
- 'project_type' => 'module',
- 'core' => $core,
- 'version' => $version,
- 'server_pattern' => $server_pattern,
- 'status' => 1,
- ];
- \Drupal::service('locale.project')->set($data['name'], $data);
- module_load_include('compare.inc', 'locale');
-
-
- locale_translation_clear_cache_projects();
- locale_translation_check_projects_local(['drupal'], [$langcode]);
- }
- }
- }
- }
- }
- function install_finish_translations(&$install_state) {
- \Drupal::moduleHandler()->loadInclude('locale', 'fetch.inc');
- \Drupal::moduleHandler()->loadInclude('locale', 'compare.inc');
- \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc');
-
-
-
- $projects = locale_translation_build_projects();
- $languages = \Drupal::languageManager()->getLanguages();
- $batches = [];
- if (count($projects) > 1) {
- $options = _locale_translation_default_update_options();
- if ($batch = locale_translation_batch_update_build([], array_keys($languages), $options)) {
- $batches[] = $batch;
- }
- }
-
- $batches[] = locale_config_batch_update_components([], array_keys($languages));
- return $batches;
- }
- function install_finished(&$install_state) {
- $profile = $install_state['parameters']['profile'];
-
- module_set_weight($profile, 1000);
-
-
-
- \Drupal::service('router.builder')->rebuild();
-
-
-
- \Drupal::service('cron')->run();
- if ($install_state['interactive']) {
-
-
-
- $account = User::load(1);
- user_login_finalize($account);
- }
- $success_message = t('Congratulations, you installed @drupal!', [
- '@drupal' => drupal_install_profile_distribution_name(),
- ]);
- \Drupal::messenger()->addStatus($success_message);
- }
- function _install_module_batch($module, $module_name, &$context) {
- \Drupal::service('module_installer')->install([$module], FALSE);
- $context['results'][] = $module;
- $context['message'] = t('Installed %module module.', ['%module' => $module_name]);
- }
- function install_check_translations($langcode, $server_pattern) {
- $requirements = [];
- $readable = FALSE;
- $writable = FALSE;
-
- $site_path = \Drupal::service('site.path');
- $files_directory = $site_path . '/files';
- $translations_directory = $site_path . '/files/translations';
- $translations_directory_exists = FALSE;
- $online = FALSE;
-
-
- $file_system = \Drupal::service('file_system');
- $file_system->prepareDirectory($files_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
-
- $file_system->prepareDirectory($translations_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
-
- if (drupal_verify_install_file($translations_directory, FILE_EXIST, 'dir')) {
- $readable = is_readable($translations_directory);
- $writable = is_writable($translations_directory);
- $translations_directory_exists = TRUE;
- }
-
- if ($existing_file = glob($translations_directory . '/drupal-*.' . $langcode . '.po')) {
- return;
- }
- $version = \Drupal::VERSION;
-
-
-
- if (preg_match("/^(\d+\.\d+\.).*-dev$/", $version, $matches)) {
-
- $version = $matches[1] . 'x';
- }
-
- $variables = [
- '%project' => 'drupal',
- '%version' => $version,
- '%core' => 'all',
- '%language' => $langcode,
- ];
- $translation_url = strtr($server_pattern, $variables);
- $elements = parse_url($translation_url);
- $server_url = $elements['scheme'] . '://' . $elements['host'];
-
- $languages = LanguageManager::getStandardLanguageList();
- $language = isset($languages[$langcode]) ? $languages[$langcode][0] : $langcode;
-
-
-
- if ($translation_available = install_check_localization_server($translation_url)) {
- $online = TRUE;
- }
- if (!$translation_available) {
- if (install_check_localization_server($server_url)) {
- $online = TRUE;
- }
- }
-
- if (!$translations_directory_exists) {
- $requirements['translations directory exists'] = [
- 'title' => t('Translations directory'),
- 'value' => t('The translations directory does not exist.'),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', ['%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt']),
- ];
- }
- else {
- $requirements['translations directory exists'] = [
- 'title' => t('Translations directory'),
- 'value' => t('The directory %translations_directory exists.', ['%translations_directory' => $translations_directory]),
- ];
-
- if (!$readable) {
- $requirements['translations directory readable'] = [
- 'title' => t('Translations directory'),
- 'value' => t('The translations directory is not readable.'),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires read permissions to %translations_directory at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']),
- ];
- }
-
- if (!$writable) {
- $requirements['translations directory writable'] = [
- 'title' => t('Translations directory'),
- 'value' => t('The translations directory is not writable.'),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires write permissions to %translations_directory during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']),
- ];
- }
- else {
- $requirements['translations directory writable'] = [
- 'title' => t('Translations directory'),
- 'value' => t('The translations directory is writable.'),
- ];
- }
- }
-
- if (!$online) {
- $requirements['online'] = [
- 'title' => t('Internet'),
- 'value' => t('The translation server is offline.'),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at <a href=":server_url">@server_url</a>.', [':server_url' => $server_url, '@server_url' => $server_url]),
- ];
- }
- else {
- $requirements['online'] = [
- 'title' => t('Internet'),
- 'value' => t('The translation server is online.'),
- ];
-
-
- if (!$translation_available) {
- $requirements['translation available'] = [
- 'title' => t('Translation'),
- 'value' => t('The %language translation is not available.', ['%language' => $language]),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The %language translation file is not available at the translation server. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]),
- ];
- }
- else {
- $requirements['translation available'] = [
- 'title' => t('Translation'),
- 'value' => t('The %language translation is available.', ['%language' => $language]),
- ];
- }
- }
- if ($translations_directory_exists && $readable && $writable && $translation_available) {
- $translation_downloaded = install_retrieve_file($translation_url, $translations_directory);
- if (!$translation_downloaded) {
- $requirements['translation downloaded'] = [
- 'title' => t('Translation'),
- 'value' => t('The %language translation could not be downloaded.', ['%language' => $language]),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The %language translation file could not be downloaded. <a href=":url">Choose a different language</a> or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]),
- ];
- }
- }
- return $requirements;
- }
- function install_check_requirements($install_state) {
- $profile = $install_state['parameters']['profile'];
-
- $requirements = drupal_check_profile($profile);
- if ($install_state['settings_verified']) {
- return $requirements;
- }
-
-
- $default_files = [];
- $default_files['settings.php'] = [
- 'file' => 'settings.php',
- 'file_default' => 'default.settings.php',
- 'title_default' => t('Default settings file'),
- 'description_default' => t('The default settings file does not exist.'),
- 'title' => t('Settings file'),
- ];
- $file_system = \Drupal::service('file_system');
- foreach ($default_files as $default_file_info) {
- $readable = FALSE;
- $writable = FALSE;
- $site_path = './' . \Drupal::service('site.path');
- $file = $site_path . "/{$default_file_info['file']}";
- $default_file = "./sites/default/{$default_file_info['file_default']}";
- $exists = FALSE;
-
- if (drupal_verify_install_file($site_path, FILE_EXIST, 'dir')) {
- if (drupal_verify_install_file($file, FILE_EXIST)) {
-
- $readable = drupal_verify_install_file($file, FILE_READABLE);
- $writable = drupal_verify_install_file($file, FILE_WRITABLE);
- $exists = TRUE;
- }
- }
-
-
- if (!drupal_verify_install_file($default_file, FILE_EXIST | FILE_READABLE)) {
- $requirements["default $file file exists"] = [
- 'title' => $default_file_info['title_default'],
- 'value' => $default_file_info['description_default'],
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer requires that the %default-file file must not be deleted or modified from the original download.', [
- '@drupal' => drupal_install_profile_distribution_name(),
- '%default-file' => $default_file,
- ]),
- ];
- }
-
-
- elseif (!$exists) {
- $copied = drupal_verify_install_file($site_path, FILE_EXIST | FILE_WRITABLE, 'dir') && @copy($default_file, $file);
- if ($copied) {
-
-
-
-
-
-
-
-
-
- if (fileowner($default_file) === fileowner($file) || DRUPAL_TEST_IN_CHILD_SITE) {
- $readable = drupal_verify_install_file($file, FILE_READABLE);
- $writable = drupal_verify_install_file($file, FILE_WRITABLE);
- $exists = TRUE;
- }
-
-
-
-
-
-
-
-
-
-
- else {
- $deleted = @$file_system->unlink($file);
-
-
-
-
-
-
- $exists = !$deleted;
- if ($exists) {
- $settings_file_ownership_error = TRUE;
- $readable = drupal_verify_install_file($file, FILE_READABLE);
- $writable = drupal_verify_install_file($file, FILE_WRITABLE);
- }
- }
- }
- }
-
- if (!$exists) {
- $requirements["$file file exists"] = [
- 'title' => $default_file_info['title'],
- 'value' => t('The %file does not exist.', ['%file' => $default_file_info['title']]),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>.', [
- '@drupal' => drupal_install_profile_distribution_name(),
- '%file' => $file,
- '%default_file' => $default_file,
- ':install_txt' => base_path() . 'core/INSTALL.txt',
- ]),
- ];
- }
- else {
- $requirements["$file file exists"] = [
- 'title' => $default_file_info['title'],
- 'value' => t('The %file exists.', ['%file' => $file]),
- ];
-
- if (!$readable) {
- $requirements["$file file readable"] = [
- 'title' => $default_file_info['title'],
- 'value' => t('The %file is not readable.', ['%file' => $default_file_info['title']]),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('@drupal requires read permissions to %file at all times. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
- '@drupal' => drupal_install_profile_distribution_name(),
- '%file' => $file,
- ':handbook_url' => 'https://www.drupal.org/server-permissions',
- ]),
- ];
- }
-
- if (!$writable) {
- $requirements["$file file writeable"] = [
- 'title' => $default_file_info['title'],
- 'value' => t('The %file is not writable.', ['%file' => $default_file_info['title']]),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer requires write permissions to %file during the installation process. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
- '@drupal' => drupal_install_profile_distribution_name(),
- '%file' => $file,
- ':handbook_url' => 'https://www.drupal.org/server-permissions',
- ]),
- ];
- }
- else {
- $requirements["$file file"] = [
- 'title' => $default_file_info['title'],
- 'value' => t('The @file is writable.', ['@file' => $default_file_info['title']]),
- ];
- }
- if (!empty($settings_file_ownership_error)) {
- $requirements["$file file ownership"] = [
- 'title' => $default_file_info['title'],
- 'value' => t('The @file is owned by the web server.', ['@file' => $default_file_info['title']]),
- 'severity' => REQUIREMENT_ERROR,
- 'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in <a href=":install_txt">INSTALL.txt</a>. The <a href=":handbook_url">webhosting issues</a> documentation section offers help on this and other topics.', [
- '@drupal' => drupal_install_profile_distribution_name(),
- '%file' => $file,
- '%default_file' => $default_file,
- ':install_txt' => base_path() . 'core/INSTALL.txt',
- ':handbook_url' => 'https://www.drupal.org/server-permissions',
- ]),
- ];
- }
- }
-
-
- if ($database = Database::getConnectionInfo()) {
- $request = Request::createFromGlobals();
- $site_path = empty($install_state['site_path']) ? DrupalKernel::findSitePath($request, FALSE) : $install_state['site_path'];
- $database = $database['default'];
- $settings_file = './' . $site_path . '/settings.php';
- $errors = install_database_errors($database, $settings_file);
- if (count($errors)) {
- $error_message = SiteSettingsForm::getDatabaseErrorsTemplate($errors);
- $requirements['database_install_errors'] = [
- 'title' => t('Database settings'),
- 'description' => $error_message,
- 'severity' => REQUIREMENT_ERROR,
- ];
- }
- }
- }
- return $requirements;
- }
- function install_display_requirements($install_state, $requirements) {
-
- $severity = drupal_requirements_severity($requirements);
-
-
-
- if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) {
- if ($install_state['interactive']) {
- $build['report']['#type'] = 'status_report';
- $build['report']['#requirements'] = $requirements;
- if ($severity == REQUIREMENT_WARNING) {
- $build['#title'] = t('Requirements review');
- $build['#suffix'] = t('Check the messages and <a href=":retry">retry</a>, or you may choose to <a href=":cont">continue anyway</a>.', [':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)]);
- }
- else {
- $build['#title'] = t('Requirements problem');
- $build['#suffix'] = t('Check the messages and <a href=":url">try again</a>.', [':url' => drupal_requirements_url($severity)]);
- }
- return $build;
- }
- else {
-
- $failures = [];
- foreach ($requirements as $requirement) {
-
-
-
- if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
- $failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];
- }
- }
- if (!empty($failures)) {
- throw new InstallerException(implode("\n\n", $failures));
- }
- }
- }
- }
- function install_write_profile($install_state) {
-
-
-
-
- $settings_path = \Drupal::service('site.path') . '/settings.php';
- if (is_writable($settings_path) && array_key_exists('install_profile', Settings::getAll())) {
-
- $settings['settings']['install_profile'] = (object) [
- 'value' => $install_state['parameters']['profile'],
- 'required' => TRUE,
- ];
- drupal_rewrite_settings($settings);
- }
- }
- function install_config_import_batch() {
-
-
-
- install_core_entity_type_definitions();
-
- $sync = \Drupal::service('config.storage.sync');
-
-
- $system_site = $sync->read('system.site');
-
-
-
-
- if ($system_site !== FALSE) {
- \Drupal::configFactory()->getEditable('system.site')->set('uuid', $system_site['uuid'])->save();
- }
-
- $storage_comparer = new StorageComparer($sync, \Drupal::service('config.storage'));
- $storage_comparer->createChangelist();
- $config_importer = new ConfigImporter(
- $storage_comparer,
- \Drupal::service('event_dispatcher'),
- \Drupal::service('config.manager'),
- \Drupal::service('lock.persistent'),
- \Drupal::service('config.typed'),
- \Drupal::service('module_handler'),
- \Drupal::service('module_installer'),
- \Drupal::service('theme_handler'),
- \Drupal::service('string_translation'),
- \Drupal::service('extension.list.module')
- );
- try {
- $sync_steps = $config_importer->initialize();
- $batch_builder = new BatchBuilder();
- $batch_builder
- ->setFinishCallback([ConfigImporterBatch::class, 'finish'])
- ->setTitle(t('Importing configuration'))
- ->setInitMessage(t('Starting configuration import.'))
- ->setErrorMessage(t('Configuration import has encountered an error.'));
- foreach ($sync_steps as $sync_step) {
- $batch_builder->addOperation([ConfigImporterBatch::class, 'process'], [$config_importer, $sync_step]);
- }
- return $batch_builder->toArray();
- }
- catch (ConfigImporterException $e) {
- global $install_state;
-
- $messenger = \Drupal::messenger();
- $messenger->addError(t('The configuration synchronization failed validation.'));
- foreach ($config_importer->getErrors() as $message) {
- $messenger->addError($message);
- }
- install_display_output(['#title' => t('Configuration validation')], $install_state);
- }
- }
- function install_config_download_translations(&$install_state) {
- $needs_download = isset($install_state['parameters']['langcode']) && !isset($install_state['translations'][$install_state['parameters']['langcode']]) && $install_state['parameters']['langcode'] !== 'en';
- if ($needs_download) {
- return install_download_translation($install_state);
- }
- }
- function install_config_revert_install_changes() {
- global $install_state;
- $storage_comparer = new StorageComparer(\Drupal::service('config.storage.sync'), \Drupal::service('config.storage'));
- $storage_comparer->createChangelist();
- if ($storage_comparer->hasChanges()) {
- $config_importer = new ConfigImporter(
- $storage_comparer,
- \Drupal::service('event_dispatcher'),
- \Drupal::service('config.manager'),
- \Drupal::service('lock.persistent'),
- \Drupal::service('config.typed'),
- \Drupal::service('module_handler'),
- \Drupal::service('module_installer'),
- \Drupal::service('theme_handler'),
- \Drupal::service('string_translation'),
- \Drupal::service('extension.list.module')
- );
- try {
- $config_importer->import();
- }
- catch (ConfigImporterException $e) {
- global $install_state;
- $messenger = \Drupal::messenger();
-
- $messenger->addError(t('The configuration synchronization failed validation.'));
- foreach ($config_importer->getErrors() as $message) {
- $messenger->addError($message);
- }
- install_display_output(['#title' => t('Configuration validation')], $install_state);
- }
-
- if (\Drupal::moduleHandler()->moduleExists('language')) {
-
-
-
- if (ConfigurableLanguage::load('en')) {
- $install_state['profile_info']['keep_english'] = TRUE;
- }
- }
- }
- }
|