mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/structural_pages.git
synced 2026-05-05 08:30:40 -03:00
Corrige handler_settings e exclude_entity_types no field_parent_page (PHP 8)
Adiciona hook_update_10006 que re-sincroniza settings de field_parent_page a partir do YAML de install, e hook_update_10007 que corrige exclude_entity_types no storage para FALSE. Ambos evitam TypeError no PHP 8 no widget de referência dinâmica. Atualiza também o YAML de install com a configuração correta. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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().
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user