Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi. I am getting the following error when trying to edit a field. Any ideas how to fix this?
Structure -> Content Types -> Manage Fields -> Edit
Recently upgraded to Drupal 8.2.7 and Domain alpha8 (see attached for all installed modules and versions).
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Drupal\domain_access\DomainAccessManager' does not have a method 'getDefaultAllValue' in Drupal\Core\Field\FieldConfigBase->getDefaultValue() (line 388 of core\lib\Drupal\Core\Field\FieldConfigBase.php).
Drupal\Core\Field\FieldConfigBase->getDefaultValue(Object) (Line: 180)
Drupal\Core\Field\FieldItemList->applyDefaultValue() (Line: 112)
Drupal\Core\Entity\ContentEntityStorageBase->initFieldValues(Object, Array) (Line: 88)
Drupal\Core\Entity\ContentEntityStorageBase->doCreate(Array) (Line: 184)
Drupal\Core\Entity\EntityStorageBase->create(Array) (Line: 299)
_field_create_entity_from_ids(Object) (Line: 80)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 115)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment | File | Size | Author |
---|---|---|---|
#2 | does_not_have_a_method_getDefaultAllValue-2862223-3.patch | 778 bytes | Znak |
Image 083.png | 176.52 KB | jtkunley | |
Image 082.png | 146.71 KB | jtkunley |
Comments
Comment #2
Znak CreditAttribution: Znak commentedMaybe, this patch will fix your problems. Please, check up.
Comment #3
agentrickardWe deliberately removed the default value callback for the "All" field. The field handler definitions have to be changed and the getDefaultAllValue() method has been removed.
Make sure you run domain_alpha_update_8004(), which you might have to manually force if that module was not enabled before you updated.
This change was made to allow the field value to be configurable on a per-node type basis.
See https://github.com/agentrickard/domain/pull/335.
Comment #4
jtkunley CreditAttribution: jtkunley commentedsee #5
Comment #5
jtkunley CreditAttribution: jtkunley commentedApplied #2 patch and changed method name to 8005 to force the update. Update went through. Now the problem appears when adding a new node. Any ideas?
Issue
Update DB
---------------------------
New Code
Comment #6
agentrickardWell, that error would mean that the update didn't work, though I can't really replicate that in DEV.
You could remove the IF condition
if ($field->get('default_value_callback') === 'Drupal\domain_access\DomainAccessManager::getDefaultValue') {
and run it again.Or use Config Synchronization to export the field, manually edit the YML and reload it.
The final YML should look like so. There will be one for each node type and for users:
Comment #7
jtkunley CreditAttribution: jtkunley commentedOkay, I got it now.
My config for all content types looked like this before update, so 'if' statement never executed (as you've rightly guessed!)
So I kept the
if
statement and just reverted to original version (check forgetDefaultAllValue
). Afterdrush updb
everything looks good now. Thanks Ken!Comment #8
jtkunley CreditAttribution: jtkunley commentedComment #9
jtkunley CreditAttribution: jtkunley commentedComment #11
agentrickardComment #12
Londova CreditAttribution: Londova commentedIt seems this error still exists after updating to "alpha10" version.
Comment #13
tancAn old issue but I just wanted to note I came across this problem while doing a Drupal 9 upgrade on someone's site. All hook updates had been run, but looking at the exported config I could see that
default_value_callback: 'Drupal\domain_access\DomainAccessManager::getDefaultAllValue'
still existed.I did a find and replace on the config/sync dir with the following:
From:
default_value_callback: 'Drupal\domain_access\DomainAccessManager::getDefaultAllValue'
To:
default_value_callback: ''
Then imported the config and confirmed that it fixed the error.