Variable FILES_PROBE_PHPConst
FILES_PROBE_PHP: "$out = ['ok' => true];\n\n// which class the container bound. If this is not CfwFileStreamWrapper the override did not take,\n// and everything below would be measuring MEMFS while looking like a pass.\ntry {\n\t$manager = Drupal::service('stream_wrapper_manager');\n\t$public = $manager->getViaScheme('public');\n\t$out['publicClass'] = $public === false ? null : get_class($public);\n\t$private = $manager->getViaScheme('private');\n\t$out['privateClass'] = $private === false ? null : get_class($private);\n\t$out['schemes'] = array_keys($manager->getWrappers());\n\t// PHP-level registration is a separate step from the container binding, and leaving it out is\n\t// how this probe first reported a bound class and a failed write in the same breath. The\n\t// container knows stream_wrapper.public is our class; PHP does not know the public scheme\n\t// exists until StreamWrapperManager::register() calls stream_wrapper_register(). A real\n\t// request triggers that during kernel boot, so production is fine, a bare BOOT_KERNEL is not.\n\t$out['wrappersBefore'] = stream_get_wrappers();\n\tif (method_exists($manager, 'register')) {\n\t\t$manager->register();\n\t}\n\t$out['wrappersAfter'] = stream_get_wrappers();\n} catch (Throwable $e) {\n\t$out['managerError'] = $e->getMessage();\n}\n\n$op = $GLOBALS['__cfw_files_op'] ?? 'write';\n$uri = $GLOBALS['__cfw_files_uri'] ?? 'public://cfw-probe/note.txt';\n$out['op'] = $op;\n$out['uri'] = $uri;\n\nif ($op === 'write') {\n\t$body = $GLOBALS['__cfw_files_body'] ?? 'durable';\n\t// through Drupal's API, not through the wrapper class, so a container that ignored the override\n\t// is what fails rather than what gets bypassed\n\t$wrote = @file_put_contents($uri, $body);\n\t$out['bytesWritten'] = $wrote === false ? -1 : $wrote;\n\t$out['existsAfterWrite'] = @file_exists($uri);\n\t$out['sizeAfterWrite'] = @filesize($uri);\n\t$out['ok'] = $wrote !== false;\n} elseif ($op === 'read') {\n\t$body = @file_get_contents($uri);\n\t$out['found'] = $body !== false;\n\t$out['body'] = $body === false ? null : $body;\n\t$out['bytes'] = $body === false ? -1 : strlen($body);\n\t$out['sha1'] = $body === false ? null : sha1($body);\n\t$out['ok'] = $body !== false;\n} elseif ($op === 'unlink') {\n\t$out['unlinked'] = @unlink($uri);\n\t$out['existsAfter'] = @file_exists($uri);\n\t$out['ok'] = $out['unlinked'] === true && $out['existsAfter'] === false;\n} elseif ($op === 'dir') {\n\t// is_dir() on a keyspace with no directory records is the case url_stat() has to synthesise\n\t$dir = dirname($uri);\n\t$out['isDir'] = @is_dir($dir);\n\t$names = [];\n\t$handle = @opendir($dir);\n\tif ($handle !== false) {\n\t\twhile (($name = readdir($handle)) !== false) {\n\t\t\t$names[] = $name;\n\t\t}\n\t\tclosedir($handle);\n\t}\n\t$out['entries'] = $names;\n\t$out['ok'] = $out['isDir'] === true;\n} elseif ($op === 'url') {\n\t// the URL a theme or an image style would emit; a wrong one is a broken <img> rather than an error\n\ttry {\n\t\t$out['externalUrl'] = Drupal::service('file_url_generator')->generateString($uri);\n\t} catch (Throwable $e) {\n\t\t$out['urlError'] = $e->getMessage();\n\t}\n\t$out['ok'] = isset($out['externalUrl']);\n}\n\necho json_encode($out);\n"