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

    Variable SUBMISSION_PROBE_PHPConst

    SUBMISSION_PROBE_PHP: "\nuse Drupal\\Core\\DrupalKernel;\nuse Drupal\\Core\\Site\\Settings;\nuse Symfony\\Component\\HttpFoundation\\Request;\n\n// __CFW_FIBER_SHIM__\n// __CFW_HOST_HELPERS__\n// __CFW_PW_SERVE_INLINE__\nchdir('/drupal');\n\n$opt = json_decode(__CFW_OPTIONS__, true);\n$out = ['ok' => false, 'wall' => 'unknown'];\n\n$_SERVER['HTTP_HOST'] = 'localhost';\n$_SERVER['SERVER_NAME'] = 'localhost';\n$_SERVER['SERVER_PORT'] = '80';\n$_SERVER['REQUEST_URI'] = $opt['path'];\n$_SERVER['REQUEST_METHOD'] = $opt['method'];\n$_SERVER['SCRIPT_NAME'] = '/index.php';\n$_SERVER['SCRIPT_FILENAME'] = '/drupal/index.php';\n$_SERVER['PHP_SELF'] = '/index.php';\n$_SERVER['DOCUMENT_ROOT'] = '/drupal';\n$_SERVER['REMOTE_ADDR'] = '127.0.0.1';\n$_SERVER['SERVER_SOFTWARE'] = 'workerd';\n$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';\n\ntry {\n\tif (!isset($GLOBALS['__pw_autoloader']) || !is_object($GLOBALS['__pw_autoloader'])) {\n\t\t$GLOBALS['__pw_autoloader'] = require '/drupal/autoload.php';\n\t}\n\t$autoloader = $GLOBALS['__pw_autoloader'];\n\n\tif (!isset($GLOBALS['__pw_kernel'])) {\n\t\t$boot = Request::create('/', 'GET');\n\t\t$kernel = new DrupalKernel('prod', $autoloader);\n\t\tDrupalKernel::bootEnvironment();\n\t\t$sitePath = DrupalKernel::findSitePath($boot);\n\t\t$kernel->setSitePath($sitePath);\n\t\tSettings::initialize('/drupal', $sitePath, $autoloader);\n\t\t$kernel->boot();\n\t\t$GLOBALS['__pw_kernel'] = $kernel;\n\t\t$out['bootedKernel'] = 1;\n\t}\n\t$kernel = $GLOBALS['__pw_kernel'];\n\n\t// #region wall 1: does Drupal see the POST and its values\n\t$parameters = [];\n\t$isForm = stripos($opt['contentType'], 'application/x-www-form-urlencoded') !== false;\n\tif ($opt['method'] !== 'GET' && $opt['body'] !== '' && $isForm) {\n\t\tparse_str($opt['body'], $parameters);\n\t}\n\t$server = [];\n\tif ($opt['contentType'] !== '') {\n\t\t$server['CONTENT_TYPE'] = $opt['contentType'];\n\t}\n\tif ($opt['body'] !== '') {\n\t\t$server['CONTENT_LENGTH'] = (string) strlen($opt['body']);\n\t}\n\n\t$request = Request::create(\n\t\t$opt['path'],\n\t\t$opt['method'],\n\t\t$parameters,\n\t\t[],\n\t\t[],\n\t\t$server,\n\t\t$opt['body'],\n\t);\n\n\t$out['methodSeen'] = $request->getMethod();\n\t$out['requestKeys'] = array_keys($request->request->all());\n\t$out['parsedKeys'] = array_keys($parameters);\n\t$out['contentLength'] = strlen($request->getContent());\n\t$out['isMethodPost'] = $request->isMethod('POST');\n\t// #endregion\n\n\t// #region wall 4: is there a session, and is the request treated as cacheable\n\ttry {\n\t\t$out['hasSession'] = $request->hasSession() ? 1 : 0;\n\t\t$out['hasPreviousSession'] = $request->hasPreviousSession() ? 1 : 0;\n\t} catch (Throwable $e) {\n\t\t$out['sessionError'] = $e->getMessage();\n\t}\n\ttry {\n\t\t$policy = Drupal::service('page_cache_request_policy');\n\t\t$verdict = $policy->check($request);\n\t\t// ALLOW means Drupal considers this cacheable, which is only correct for an anonymous GET\n\t\t$out['pageCachePolicy'] = is_string($verdict) ? $verdict : json_encode($verdict);\n\t} catch (Throwable $e) {\n\t\t$out['policyError'] = $e->getMessage();\n\t}\n\ttry {\n\t\t$out['currentUserId'] = (int) Drupal::currentUser()->id();\n\t\t$out['isAuthenticated'] = Drupal::currentUser()->isAuthenticated() ? 1 : 0;\n\t} catch (Throwable $e) {\n\t\t$out['userError'] = $e->getMessage();\n\t}\n\t// #endregion\n\n\t// #region walls 2 and 3: build id and token, read off what the handler answers\n\ttry {\n\t\t$rp = new ReflectionProperty(DrupalKernel::class, 'prepared');\n\t\t$rp->setValue($kernel, false);\n\t} catch (Throwable $e) {\n\t}\n\ttry {\n\t\t$stack = Drupal::service('request_stack');\n\t\twhile ($stack->getCurrentRequest() !== null) {\n\t\t\t$stack->pop();\n\t\t}\n\t} catch (Throwable $e) {\n\t}\n\tif (function_exists('drupal_static_reset')) {\n\t\tdrupal_static_reset();\n\t}\n\n\ttry {\n\t\t$response = $kernel->handle($request);\n\t\t$status = $response->getStatusCode();\n\t\t$content = (string) $response->getContent();\n\t\t$out['status'] = $status;\n\t\t$out['bytes'] = strlen($content);\n\t\t$out['location'] = $response->headers->get('location');\n\n\t\t// the phrases Drupal uses, each of which names a DIFFERENT wall\n\t\t$out['saysOutdated'] = stripos($content, 'form has become outdated') !== false ? 1 : 0;\n\t\t$out['saysTokenInvalid'] = stripos($content, 'security token') !== false ? 1 : 0;\n\t\t$out['saysAccessDenied'] =\n\t\t\t$status === 403 || stripos($content, 'Access denied') !== false ? 1 : 0;\n\t\t$out['saysNotFound'] = $status === 404 ? 1 : 0;\n\t\t$out['hasFormBuildId'] = stripos($content, 'form_build_id') !== false ? 1 : 0;\n\t\t$out['hasFormToken'] = stripos($content, 'form_token') !== false ? 1 : 0;\n\n\t\tif ($out['saysNotFound']) {\n\t\t\t$out['wall'] = 'route-not-found';\n\t\t} elseif ($out['saysAccessDenied']) {\n\t\t\t$out['wall'] = 'access-denied';\n\t\t} elseif ($out['saysOutdated']) {\n\t\t\t$out['wall'] = 'form-build-id';\n\t\t} elseif ($out['saysTokenInvalid']) {\n\t\t\t$out['wall'] = 'csrf-token';\n\t\t} elseif ($status >= 300 && $status < 400) {\n\t\t\t$out['wall'] = 'none-redirected';\n\t\t} else {\n\t\t\t$out['wall'] = 'handled-no-effect';\n\t\t}\n\t\t$out['ok'] = true;\n\t} catch (Throwable $e) {\n\t\t$out['wall'] = 'exception';\n\t\t$out['error'] = get_class($e) . ': ' . $e->getMessage();\n\t\t$out['at'] = $e->getFile() . ':' . $e->getLine();\n\t}\n\t// #endregion\n} catch (Throwable $e) {\n\t$out['error'] = get_class($e) . ': ' . $e->getMessage();\n\t$out['at'] = $e->getFile() . ':' . $e->getLine();\n}\n\necho json_encode($out);\n"