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

    Variable SCHEMA_REPAIR_PHPConst

    SCHEMA_REPAIR_PHP: "\nuse Drupal\\Core\\Batch\\BatchStorage;\nuse Drupal\\Core\\Flood\\DatabaseBackend;\nuse Drupal\\Core\\KeyValueStore\\DatabaseStorageExpirable;\nuse Drupal\\Core\\Lock\\DatabaseLockBackend;\nuse Drupal\\Core\\Queue\\DatabaseQueue;\n\n$db = Drupal::database();\n$moduleHandler = Drupal::moduleHandler();\n$moduleHandler->loadAllIncludes('install');\n$created = [];\n$failed = [];\n$walked = 0;\n$defined = 0;\nforeach (array_keys($moduleHandler->getModuleList()) as $module) {\n\t$walked++;\n\t$fn = $module . '_schema';\n\tif (!function_exists($fn)) {\n\t\tcontinue;\n\t}\n\t$defined++;\n\t$schema = $fn();\n\tif (!is_array($schema)) {\n\t\tcontinue;\n\t}\n\tforeach ($schema as $table => $spec) {\n\t\ttry {\n\t\t\tif (!$db->schema()->tableExists($table)) {\n\t\t\t\t$db->schema()->createTable($table, $spec);\n\t\t\t\t$created[] = $table;\n\t\t\t}\n\t\t} catch (Throwable $e) {\n\t\t\t$failed[$table] = substr($e->getMessage(), 0, 140);\n\t\t}\n\t}\n}\n// The other half, and the reason the hook walk found nothing. Drupal's database\n// backends for flood, queue, semaphore, batch and expirable key-value do NOT\n// declare hook_schema. Each keeps its schema in a class method and creates the\n// table ON DEMAND by catching a failed query -- which cannot work here, because\n// the failure surfaces inside a transaction replay where the catch-and-create\n// path is exactly what the replay refuses. So they are pre-created.\n//\n// Mapped explicitly rather than discovered, because there is nothing to discover\n// from: a class method is not registered anywhere a hook system can see.\n$classTables = [\n\t'flood' => DatabaseBackend::class,\n\t'queue' => DatabaseQueue::class,\n\t'semaphore' => DatabaseLockBackend::class,\n\t'batch' => BatchStorage::class,\n\t'key_value_expire' => DatabaseStorageExpirable::class,\n];\nforeach ($classTables as $table => $class) {\n\ttry {\n\t\tif ($db->schema()->tableExists($table)) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (!class_exists($class)) {\n\t\t\t$failed[$table] = 'class absent: ' . $class;\n\t\t\tcontinue;\n\t\t}\n\t\t$rm = new ReflectionMethod($class, 'schemaDefinition');\n\t\t$spec = $rm->isStatic()\n\t\t\t? $rm->invoke(null)\n\t\t\t: $rm->invoke($rm->getDeclaringClass()->newInstanceWithoutConstructor());\n\t\t// some return one table spec, some a map of them\n\t\t$specs = isset($spec['fields']) ? [$table => $spec] : $spec;\n\t\tforeach ($specs as $name => $definition) {\n\t\t\tif (\n\t\t\t\tis_array($definition) &&\n\t\t\t\tisset($definition['fields']) &&\n\t\t\t\t!$db->schema()->tableExists($name)\n\t\t\t) {\n\t\t\t\t$db->schema()->createTable($name, $definition);\n\t\t\t\t$created[] = $name;\n\t\t\t}\n\t\t}\n\t} catch (Throwable $e) {\n\t\t$failed[$table] = substr($e->getMessage(), 0, 140);\n\t}\n}\n\n$out['schemaRepair'] = [\n\t'modulesWalked' => $walked,\n\t'withSchemaHook' => $defined,\n\t'created' => $created,\n];\nif ($failed) {\n\t$out['schemaRepair']['failed'] = $failed;\n}\n"