drupflare/worker - v1.0.4
    Preparing search index...

    Variable FIRST_RUN_CONFIG_PHPConst

    FIRST_RUN_CONFIG_PHP: "\nuse Drupal\\Core\\Cache\\Cache;\nuse Drupal\\Core\\Site\\Settings;\nuse Drupal\\drupflare\\Hook\\OwnerTier;\nuse Drupal\\user\\Entity\\User;\n\n// __CFW_FIBER_SHIM__\n// __CFW_HOST_HELPERS__\nchdir('/drupal');\n\n$opt = json_decode(__CFW_PAYLOAD__, true);\n$out = ['ok' => false, 'applied' => [], 'skipped' => []];\n\ntry {\n\t// __CFW_CLAIM_BOOT__\n\n\t// site name, mail and timezone are config, so go through the config factory\n\tif (empty($opt['migrated'])) {\n\t\t$editable = Drupal::configFactory()->getEditable('system.site');\n\t\tforeach (['siteName' => 'name', 'siteMail' => 'mail'] as $key => $configKey) {\n\t\t\tif (!empty($opt[$key])) {\n\t\t\t\t$editable->set($configKey, $opt[$key]);\n\t\t\t\t$out['applied'][] = 'system.site.' . $configKey;\n\t\t\t} else {\n\t\t\t\t$out['skipped'][] = 'system.site.' . $configKey;\n\t\t\t}\n\t\t}\n\t\t$editable->save();\n\t}\n\n\tif (!empty($opt['timezone'])) {\n\t\tDrupal::configFactory()\n\t\t\t->getEditable('system.date')\n\t\t\t->set('timezone.default', $opt['timezone'])\n\t\t\t->save();\n\t\t$out['applied'][] = 'system.date.timezone.default';\n\t}\n\n\t// MANDATORY, not tidiness. Completing the request lifecycle means calling\n\t// $kernel->terminate(), and automated_cron subscribes to TERMINATE. With\n\t// system.cron_last absent it fires drupal_cron() inline on the very first\n\t// request, cron reaches for outbound HTTP (update, announcements_feed), and the\n\t// wasm build dies with \"ReferenceError: Asyncify is not defined\" -- a JS\n\t// exception, so catch (Throwable) around terminate() does NOT contain it.\n\t// Measured: every terminate=1 render 500'd until this was set. Interval 0 is\n\t// core's own \"Never\" option. Cron runs from the Durable Object alarm instead.\n\tif (Drupal::moduleHandler()->moduleExists('automated_cron')) {\n\t\t$cronConfig = Drupal::configFactory()->getEditable('automated_cron.settings');\n\t\tif ((int) $cronConfig->get('interval') !== 0) {\n\t\t\t$cronConfig->set('interval', 0)->save();\n\t\t\t$out['applied'][] = 'automated_cron.settings.interval=0';\n\t\t} else {\n\t\t\t$out['skipped'][] = 'automated_cron.settings.interval (already 0)';\n\t\t}\n\t}\n\n\t// __CFW_SCHEMA_REPAIR__\n\n\t// __CFW_PACK_CONSISTENCY__\n\n\t// uid 1 through the entity API so the password hasher and the presave hooks run\n\t$admin = empty($opt['migrated']) ? User::load(1) : null;\n\tif (!empty($opt['migrated'])) {\n\t\t$out['skipped'][] = 'uid1 (migrated site keeps its administrator)';\n\t} elseif ($admin === null) {\n\t\t$out['skipped'][] = 'uid1 (not loadable)';\n\t} else {\n\t\tif (!empty($opt['adminName'])) {\n\t\t\t$admin->setUsername($opt['adminName']);\n\t\t\t$out['applied'][] = 'uid1.name';\n\t\t}\n\t\tif (!empty($opt['adminMail'])) {\n\t\t\t$admin->setEmail($opt['adminMail']);\n\t\t\t$out['applied'][] = 'uid1.mail';\n\t\t}\n\t\tif (!empty($opt['adminPass'])) {\n\t\t\t$admin->setPassword($opt['adminPass']);\n\t\t\t$out['applied'][] = 'uid1.pass';\n\t\t}\n\t\t// the pack was installed weeks before this site existed, so uid 1's birthday is the BAKE date\n\t\t// and the account reads as created before the site it belongs to\n\t\tif (!empty($opt['claimedAt'])) {\n\t\t\t$admin->set('created', (int) $opt['claimedAt']);\n\t\t\t$out['applied'][] = 'uid1.created';\n\t\t}\n\t\t$admin->activate();\n\t\t$admin->save();\n\t\t$out['adminName'] = $admin->getAccountName();\n\t\t$out['adminMail'] = $admin->getEmail();\n\t\t// the claimed account is the owner, as a role so a team can share it\n\t\tif (class_exists(OwnerTier::class)) {\n\t\t\t$out['owner'] = OwnerTier::establish($admin);\n\t\t}\n\t}\n\n\t// THE CLOCK IN THE PACK IS THE ONE FROM THE BAKE, and the status report reads it. install_time\n\t// shipped inside the packed database at the bake date, system.cron_last shipped absent, and\n\t// SystemRequirementsHooks falls back to install_time when cron_last is not numeric -- so a site\n\t// provisioned today opened with a red Cron row weeks old. Both are stamped at the claim, which is\n\t// the first moment this site has a real birthday\n\tif (!empty($opt['claimedAt'])) {\n\t\tDrupal::state()->set('install_time', (int) $opt['claimedAt']);\n\t\tDrupal::state()->set('system.cron_last', (int) $opt['claimedAt']);\n\t\t$out['applied'][] = 'state.install_time';\n\t\t$out['applied'][] = 'state.cron_last';\n\t}\n\n\t// MINTED HERE BECAUSE A REPLICA MAY NOT MINT IT, and until this line nothing did. Drupal creates\n\t// system.private_key lazily on the first render that needs a CSRF token, so a site that had been\n\t// migrated and claimed did not hold one -- and admissionVerdict() lists it as mandatory state,\n\t// correctly, since two objects each minting their own issue tokens the other rejects. Measured:\n\t// three lanes sat at CREATED through 40 provision steps each, then reached VERIFIED in 1 step\n\t// each once a single form render had minted it. Drupal's own service, so the value is\n\t// indistinguishable from a lazily minted one\n\t$out['privateKey'] = strlen(Drupal::service('private_key')->get()) > 0 ? 'present' : 'MISSING';\n\n\t// the salt is the HOST's now: src/ops/site-secrets.ts mints one per site at boot, persists it in\n\t// cfw_meta and appends the assignment to settings.php, so generating another here would replace a\n\t// live salt with one nothing stores and invalidate every session on the next remount\n\t$out['hashSalt'] = strlen(Settings::getHashSalt()) > 0 ? 'present' : 'MISSING';\n\n\t// config changes have to reach the render caches or the old site name persists\n\tCache::invalidateTags(['config:system.site', 'rendered']);\n\t$out['ok'] = true;\n} catch (Throwable $e) {\n\t$out['error'] = get_class($e) . ': ' . $e->getMessage();\n\t$out['trace'] = substr($e->getTraceAsString(), 0, 900);\n}\n\necho json_encode($out);\n"