diff --git a/config/install/field.storage.node.field_parent_page.yml b/config/install/field.storage.node.field_parent_page.yml index 3072f5b..e2057d1 100644 --- a/config/install/field.storage.node.field_parent_page.yml +++ b/config/install/field.storage.node.field_parent_page.yml @@ -8,7 +8,9 @@ id: node.field_parent_page field_name: field_parent_page entity_type: node type: dynamic_entity_reference -settings: { } +settings: + exclude_entity_types: false + entity_type_ids: [] module: dynamic_entity_reference locked: false cardinality: 1 diff --git a/structural_pages.install b/structural_pages.install index 73a7717..58c58f2 100644 --- a/structural_pages.install +++ b/structural_pages.install @@ -323,6 +323,52 @@ function _structural_pages_ensure_content_translation(): void { $config->save(); } +/** + * Corrige handler_settings nulo no field_parent_page (compatibilidade PHP 8). + * + * O widget DynamicEntityReferenceWidget faz $settings[$type]['handler_settings'] + * + array, que lança TypeError quando handler_settings é null no PHP 8. + * Re-aplica as settings completas a partir do YAML de install do módulo. + */ +function structural_pages_update_10006(): string { + $config = \Drupal::configFactory() + ->getEditable('field.field.node.content_page.field_parent_page'); + + if ($config->isNew()) { + return t('Campo field_parent_page não encontrado — nada a corrigir.'); + } + + // Re-aplica as settings completas a partir do YAML de install. + $module_path = \Drupal::service('extension.list.module')->getPath('structural_pages'); + $yaml_file = $module_path . '/config/install/field.field.node.content_page.field_parent_page.yml'; + + if (!file_exists($yaml_file)) { + return t('Arquivo YAML de install não encontrado.'); + } + + $yaml_settings = \Symfony\Component\Yaml\Yaml::parse(file_get_contents($yaml_file)); + $config->set('settings', $yaml_settings['settings']); + $config->save(TRUE); + + return t('Settings de field_parent_page re-sincronizadas a partir do YAML de install.'); +} + +/** + * Corrige exclude_entity_types no storage do field_parent_page (PHP 8 TypeError). + * + * defaultStorageSettings() retorna exclude_entity_types: TRUE, o que fazia + * getTargetTypes() retornar todos os entity types EXCETO node/taxonomy_term. + */ +function structural_pages_update_10007(): string { + $config = \Drupal::configFactory() + ->getEditable('field.storage.node.field_parent_page'); + if ($config->isNew()) { + return 'field.storage.node.field_parent_page não encontrado.'; + } + $config->set('settings.exclude_entity_types', FALSE)->save(TRUE); + return 'exclude_entity_types corrigido para FALSE em field_parent_page storage.'; +} + /** * Implements hook_requirements(). */