On entity forms that are not edit or delete, XML sitemap attempts to add its form fields and functionality, resulting in this errors similar to:
Warning: array_unshift() expects parameter 1 to be array, null given in xmlsitemap_add_form_link_options() (line 1256 of modules/contrib/xmlsitemap/xmlsitemap.module).
xmlsitemap_add_form_link_options(Array, 'node', 'test', '1983') (Line: 1580)
xmlsitemap_form_alter(Array, Object, 'node_test_entity_hierarchy_reorder_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'node_test_entity_hierarchy_reorder_form') (Line: 834)
Drupal\Core\Form\FormBuilder->prepareForm('node_test_entity_hierarchy_reorder_form', Array, Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('node_test_entity_hierarchy_reorder_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
...
The above error is from an entity form provided by Entity Hierarchy, but is also present for the entity form provided by Scheduled Transitions.
Fix is to make sure XML sitemap doesnt add its fields to forms that return NULL for \Drupal\Core\Form\BaseFormIdInterface::getBaseFormId
(see docs).
Patch also changes order of conditions to reduce processing.
Comment | File | Size | Author |
---|---|---|---|
#9 | 3017153-fix-form-alter-too-greedy.patch | 2.77 KB | Dave Reid |
| |||
#8 | 3017153-fix-form-alter-too-greedy.patch | 2.65 KB | Dave Reid |
| |||
#7 | 3017153-fix-form-alter-too-greedy.patch | 2.58 KB | Dave Reid |
#3 | 3017153-xmlsitemap-forms.patch | 1.3 KB | dpi |
Comments
Comment #2
dpiComment #3
dpiComment #5
rp7 CreditAttribution: rp7 for Government of Flanders commentedExperiencing the same issue (when using Scheduled Transitions module) Patch in #3 fixed it for me.
Comment #6
Dave ReidComment #7
Dave ReidI think this could be cleaned up a little bit more. We can get rid of xmlsitemap_form_controller() and do the logic all inline with xmlsitemap_form_alter().
Comment #8
Dave ReidTests expose that some entity types do not use an 'edit' operation, but use 'default' (why????).
Comment #9
Dave ReidLittle bit better logic.
Comment #11
Dave ReidCommitted #9 to 8.x-1.x. Thanks!