I am getting the following error when an unauthenticated visitor clicks on the /user/register link:

Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Drupal\workbench_access\WorkbenchAccessManager' does not have a method 'getDefaultValue' in Drupal\Core\Field\FieldConfigBase->getDefaultValue() (line 396 of core/lib/Drupal/Core/Field/FieldConfigBase.php).

Drupal Version: 8.4.2
Workbench: Version: 8.x-1.0
Workbench_moderation: Version: 8.x-1.3
Workbench_access: Version: 8.x-1.0-alpha7

Comments

bas123 created an issue. See original summary.

agentrickard’s picture

Project: Workbench » Workbench Access

Moving to the proper queue.

agentrickard’s picture

That code has been removed as part of the refactor, but I don't see that error in Drupal 8.4.4.

That might be a registry cache issue, so try clearing the cache drush cr.

Please make sure that you have followed the update instructions.

https://www.drupal.org/project/workbench_access/releases/8.x-1.0-alpha7

agentrickard’s picture

Category: Bug report » Support request
Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)
agentrickard’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)
bas123’s picture

Hello,

The error began following a recent Module update to Workbench_access: Version: 8.x-1.0-alpha7

It only appears on the /user/register page.

I just updated Drupal Core to 8.4.5 (following Option #3) and was hoping the error would go away.
Indeed I ran cr

Here is the complete error message:

WARNING: CALL_USER_FUNC() EXPECTS PARAMETER 1 TO BE A VALID CALLBACK, CLASS 'DRUPAL\WORKBENCH_ACCESS\WORKBENCHACCESSMANAGER' DOES NOT HAVE A METHOD 'GETDEFAULTVALUE' IN DRUPAL\CORE\FIELD\FIELDCONFIGBASE->GETDEFAULTVALUE() (LINE 396 OF CORE/LIB/DRUPAL/CORE/FIELD/FIELDCONFIGBASE.PHP).
DRUPAL\CORE\FIELD\FIELDCONFIGBASE->GETDEFAULTVALUE(OBJECT) (LINE: 181)
DRUPAL\CORE\FIELD\FIELDITEMLIST->APPLYDEFAULTVALUE() (LINE: 102)
DRUPAL\CORE\ENTITY\CONTENTENTITYSTORAGEBASE->INITFIELDVALUES(OBJECT, ARRAY) (LINE: 78)
DRUPAL\CORE\ENTITY\CONTENTENTITYSTORAGEBASE->DOCREATE(ARRAY) (LINE: 184)
DRUPAL\CORE\ENTITY\ENTITYSTORAGEBASE->CREATE(ARRAY) (LINE: 370)
DRUPAL\CORE\ENTITY\ENTITYFORM->GETENTITYFROMROUTEMATCH(OBJECT, 'USER') (LINE: 73)
DRUPAL\CORE\ENTITY\HTMLENTITYFORMCONTROLLER->GETFORMOBJECT(OBJECT, 'USER.REGISTER') (LINE: 59)
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)
DRUPAL\CORE\EVENTSUBSCRIBER\EARLYRENDERINGCONTROLLERWRAPPERSUBSCRIBER->WRAPCONTROLLEREXECUTIONINRENDERCONTEXT(ARRAY, ARRAY) (LINE: 97)
DRUPAL\CORE\EVENTSUBSCRIBER\EARLYRENDERINGCONTROLLERWRAPPERSUBSCRIBER->DRUPAL\CORE\EVENTSUBSCRIBER\{CLOSURE}()
CALL_USER_FUNC_ARRAY(OBJECT, ARRAY) (LINE: 153)
SYMFONY\COMPONENT\HTTPKERNEL\HTTPKERNEL->HANDLERAW(OBJECT, 1) (LINE: 68)
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: 184)
DRUPAL\PAGE_CACHE\STACKMIDDLEWARE\PAGECACHE->FETCH(OBJECT, 1, 1) (LINE: 121)
DRUPAL\PAGE_CACHE\STACKMIDDLEWARE\PAGECACHE->LOOKUP(OBJECT, 1, 1) (LINE: 75)
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: 657)
DRUPAL\CORE\DRUPALKERNEL->HANDLE(OBJECT) (LINE: 19)

I hope that helps as I have been looking for a solution everywhere!

Cheers!

bas123’s picture

Status: Closed (works as designed) » Active
agentrickard’s picture

You need to run drush updb --entity-updates as documented and noted above.

JKHendrickson’s picture

Title: Error in user/register » Error in composer install
Version: 8.x-1.x-dev » 8.x-1.0-alpha8
Component: User interface » Code
Issue tags: +error composer install getDefaultValue

Hello,

Like bas123, I ran all of your suggested updates, and still when installing from composer...

"drupal/workbench": "^1.0",
"drupal/workbench_access": "^1.0-alpha8",
"drupal/workbench_moderation": "^1.2",

I get the error message...
"WorkbenchAccessManager does not have a method getDefaultValue" just like bas123.

I'm installing on Drupal 8.5, and I've tried this with both Drush 8, and 9.

Here is the call stack ...
backtrace ... WorkbenchAccessManager.php ln[176]
[559 - 1 - 1520856764.656] : [drush.php 12] drush_main()
--> [preflight.inc 66] Drush\Boot\BaseBoot->bootstrap_and_dispatch()
--> [BaseBoot.php 67] drush_dispatch()
--> [command.inc 199] drush_command()
--> [command.inc 231] _drush_invoke_hooks()
--> [command.inc 422] drush_default_content_deploy_import()
--> [default_content_deploy.drush.inc 212] Drupal\default_content_deploy\Importer->deployContent()
--> [Importer.php 258] Drupal\default_content_deploy\Importer->loadEntityFromJson()
--> [Importer.php 521] Symfony\Component\Serializer\Serializer->deserialize()
--> [Serializer.php 133] Symfony\Component\Serializer\Serializer->denormalize()
--> [Serializer.php 182] Drupal\hal\Normalizer\ContentEntityNormalizer->denormalize()
--> [ContentEntityNormalizer.php 148] Drupal\Core\Entity\EntityStorageBase->create()
--> [EntityStorageBase.php 184] Drupal\Core\Entity\ContentEntityStorageBase->doCreate()
--> [ContentEntityStorageBase.php 79] Drupal\Core\Entity\ContentEntityStorageBase->initFieldValues()
--> [ContentEntityStorageBase.php 137] Drupal\Core\Field\FieldItemList->applyDefaultValue()
--> [FieldItemList.php 169] Drupal\Core\Field\FieldConfigBase->getDefaultValue()
--> [FieldConfigBase.php 396] call_user_func()
--> Drupal\workbench_access\WorkbenchAccessManager::getDefaultValue()

Just for giggles, I put the function :
/**
* {@inheritdoc}
*/
public static function getDefaultValue() {
// JKH this is what was in this function in prev versions...
return array();
}
into the file WorkbenchAccessManager.php and the problem went away.

Is this problem going to be addressed?

agentrickard’s picture

Only if it can reliably be duplicated.

Have you run the entity updates as instructed _after_ installing from composer?

Putting that method back is a reliable shim for the issue.

agentrickard’s picture

Here's the output when I did this via composer following the instructions.

No errors.

> domain8: composer require drupal/workbench_access:1.0alpha6
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing drupal/workbench_access (1.0.0-alpha6): Downloading (100%)         
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess

> domain8: drush en workbench_access
The following extensions will be enabled: workbench_access
Do you really want to continue? (y/n): y
workbench_access was enabled successfully.                                               [ok]
workbench_access defines the following permissions: administer workbench access, use workbench access, assign workbench access, batch update workbench access, bypass workbench access, view workbench access information

> domain8: composer require drupal/workbench_access:1.0alpha8
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating drupal/workbench_access (1.0.0-alpha6 => 1.0.0-alpha8): Downloading (100%)         
> Drupal\Core\Composer\Composer::vendorTestCodeCleanup
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess

> domain8: drush updb --entity-updates
The following updates are pending:

access_scheme entity type : 
  The Access scheme entity type needs to be installed.
workbench_access module : 
  8002 -   Update to new access-scheme config entity. 
  8003 -   Create the new entity type. 

workbench_access module : 
  Convert role storage.
  Convert configuration into a scheme.
  Convert user storage.

Do you wish to run all pending updates? (y/n): y
Performing workbench_access_update_8002                                                  [ok]
Performing workbench_access_update_8003                                                  [ok]
Post updating workbench_access                                                           [ok]

Error: Call to a member function getConfiguration() on null in Drupal\Core\Config\Entity\ConfigEntityBase->preSave() (line 320 of /Applications/MAMP/htdocs/domain8/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).
Drush command terminated abnormally due to an unrecoverable error.                       [error]
Cache rebuild complete.                                                                  [ok]
Finished performing updates.                                                             [ok]

That one error is related to #2946766: Error in composer install and only appears when the module has not been configured.

agentrickard’s picture

OK, I was able to replicate this.

JKHendrickson’s picture

Thanks for the response.
Yes sir, all updates have been applied.
Composer install.
Then from our post installation script.
drush updb --entity-updates -y

I can reproduce this every single time.
getDefaultValue() WorkbenchAccessManager.php ln[166]
My trace from last run where I had put in the "shim" for this.
/**
* {@inheritdoc}
*/
public static function getDefaultValue() {
// JKH this is what was in this function in prev versions...
return array();
}

Are you saying that you will put this back in?

agentrickard’s picture

StatusFileSize
new567 bytes

This is a little bit tricky to handle, because DEV is now unstable with more major changes coming, including the removal of the field that is causing the error.

The attached patch will make this specific error go away.

My apologies for the confusion, we have tests for the upgrade path, but they don't cover this instance.

agentrickard’s picture

StatusFileSize
new654 bytes

And a patch which makes existing tests fail.

agentrickard’s picture

StatusFileSize
new1.19 KB

And combined for a passing test.

JKHendrickson’s picture

Thank you very much for the quick response!
We have a week or more before we deploy our solution, so we can wait until this patch is in a stable release.
In the meantime the "shim" will allow us to continue development.
Thanks again...

bas123’s picture

Well, it appears that there is more to this than I had expected and/or understand.

Ken, I guess I just need a specific PLAN of attack.

If it is spelled out here, I must admit that it is beyond my understanding.

If I am to apply a patch, I believe I have located the instructions on doing that in my terminal, but which one(s)?

Or, as discussed, I am happy to try and restore to version 8.x-1.0-alpha6 , and remove it as was suggested and then install alpha8...

And then start from scratch with the latest version however, I need some specific steps...
ie: I will do the following (Please confirm or modify):
1) Backups
2) Restore the ‘workbench access’ module to version alpha 6 manually
3) Run #drush updb –entity-updates
4) Clear caches etc.
5) Confirm that alpha 6 is running
6) Then I must ask, for your quick instruction for “removing alpha 6 entirely”
a. /admin/modules/uninstall ?
b. Or Drush?
7) Remove any User Account fields for ‘workbench access’ *
8) Install Alpha 8 (via browser, Drush, or Composer)

* And additionally,
I also realized that I now have a “sections” (Taxonomy for Workbench Access) dropdown field listing (what were “University Team” test samples that I converted to suit my needs ) in my posts and articles!
(Image attached)

Will these be affected? And how? (note: I only have one node assigned at this time)!

* Finally, if I simply decided not to reinstall Workbench Access at all, what would be the implications to using the remaining Workbench Modules?

Thoughts?

JKHendrickson’s picture

bas123, you don't need to go through any of those gyrations to apply the temporary fix.

If you have alpha8 installed, all you have to do is open the PHP file ...
web/modules/contrib/workbench_access/src/WorkbenchAccessManager.php
Scroll to the bottom of the file.
Insert this function into the class.

/**
* {@inheritdoc}
*/
public static function getDefaultValue() {
// JKH this is what was in this function in prev versions...
return array();
}

I think that the author is going to add this function back into his next alpha release.
Until it is released, this shim will work.

agentrickard’s picture

The instructions from @JKHenderson are correct. You can either patch workbench_access/src/WorkbenchAccessManager.php manually, or download and apply https://www.drupal.org/files/issues/2018-03-12/2946766-wa-field-test-pas... patch -p1 < 2946766-wa-field-test-passl.patch from the root directory of the workbench_access folder.

There is no need to downgrade to alpha6 with this patch.

If you choose to uninstall the module, it will have no effect on the rest of Workbench.

There probably won't be another alpha release. I spent yesterday testing the upgrade path and creating https://github.com/agentrickard/workbench_access/pull/110. The problem is that the current DEV branch contains major changes that mean that we cannot make another release without a major upgrade.

agentrickard’s picture

Category: Support request » Bug report
Priority: Normal » Major
Status: Active » Reviewed & tested by the community

The last submitted patch, 14: 2946766-wa-field.patch, failed testing. View results

The last submitted patch, 15: 2946766-wa-field-test-fail.patch, failed testing. View results

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: 2946766-wa-field-test-passl.patch, failed testing. View results

bas123’s picture

Thank you BOTH I/we have successfully removed the pecky error!

In as much as I had never used the "patch" process, I wanted to try that method.

Following a video at: https://drupalize.me/videos/applying-and-creating-patches-git?p=1173

Here is my result and a question:

indust10@az1-ls2 [~/dev/site/modules/workbench_access]# wget https://www.drupal.org/files/issues/2018-03-12/2946766-wa-field-test-passl.patch
--2018-03-13 11:05:08--  https://www.drupal.org/files/issues/2018-03-12/2946766-wa-field-test-passl.patch
Resolving www.drupal.org (www.drupal.org)... 151.101.197.175
Connecting to www.drupal.org (www.drupal.org)|151.101.197.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1221 (1.2K) [text/plain]
Saving to: '2946766-wa-field-test-passl.patch'

100%[==============================================================================================================>] 1,221       --.-K/s   in 0s

2018-03-13 11:05:08 (214 MB/s) - '2946766-wa-field-test-passl.patch' saved [1221/1221]

indust10@az1-ls2 [~/dev/site/modules/workbench_access]# git apply 2946766-wa-field-test-passl.patch
indust10@az1-ls2 [~/dev/site/modules/workbench_access]# git status
fatal: Not a git repository (or any of the parent directories): .git

Q1: I am sure there a reason I was not able to 'get' (pardon the pun) status?
ie: "Not a git repository"
Q2: Please point me to my next step toward researching, if you would!

Thanks again!!!

agentrickard’s picture

The error means that you are not working with a Git checkout of the code base. So you cannot apply the patch with git apply

Use the more generic command that I pasted above:

patch -p1 < 2946766-wa-field-test-passl.patch 
JKHendrickson’s picture

Here are the exact steps that I took to install the patch...
Open terminal window.
Change to the directory where you have workbench_access installed, in my case this was...
web/modules/contrib/workbench_access
Copy or download the file 2946766-wa-field-test-passl.patch to this directory.
Run the command...
patch -p1 < 2946766-wa-field-test-passl.patch

You can also just open the file...
WorkbenchAccessManager.php
and insert this function into the class WorkbenchAccessManager...

/**
* {@inheritdoc}
*/
public static function getDefaultValue() {
return [];
}

This is exactly what the patch does...
Thank you to the author for his support.

bas123’s picture

Once again, I am a bit confused, I have actually removed the error on my development (online) site using the drush and '# git apply' commands as I described above, however I did get that error. But again, the error on the /user/register page is gone!

Should I run the commands described in #16 and #27 over what I have done (in as much as the error has been resolved) to achieve the "Git checkout of the codebase" that you described ?

On my local version, my Aquia Dev Desktop's Drush version will not let me do much especially the 'git' commands, so I applied JKHendrickson's manual insert and that handled it locally!

Thanks again!

agentrickard’s picture

You do not want to be managing the workbench_access code with Git from inside the project git repository. That is a complex operation.

Inserting the code manually is fine. The YouTube instructions you found were not appropriate for this situation.

JKHendrickson’s picture

I agree with the author.
You should look into Composer.
Dependencies in your composer.json file will allow you to download and install contrib modules from their respective sites.
For example in my composer.json file I have the following dependencies that are workbench related...

"drupal/workbench": "^1.0",
"drupal/workbench_access": "^1.0-alpha8",
"drupal/workbench_moderation": "^1.2",

You could put the patch for this in your repo as well (as a temporary solution), and apply the patch as described above as part of your installation script. For example we import content as part of our installation script by executing all of the commands in a file that we call dc.txt.

Sample contents of that file...

drush updb --entity-updates -y
drush cim -y
drush dcdi -y

... your last commands would ...
... change to the directory where you have workbench_access installed.
cd web/modules/contrib/workbench_access
... copy the file 2946766-wa-field-test-passl.patch from where you put it from your git pull.
cp /my/gitplace/2946766-wa-field-test-passl.patch .
... then run the command...
patch -p1 < 2946766-wa-field-test-passl.patch

This is probably outside the scope of this discussion, apologies.

bas123’s picture

You are both quite helpful and I appreciate your having taken the time to help me with this, however apparently I have taken on a bit more that I should have as I am a bit overwhelmed by your explanations..

I do wish to do things correctly however it appears, from all that I can see, that my goal of removing the glaring RED error message has been achieved.

The code:

/**
* {@inheritdoc}
*/
public static function getDefaultValue() {
return [];
}

was inserted into the "WorkbenchAccessManager.php" and the error is gone...

What confuses me is (according to agentrickard), something in the method I used (via the video) was incorrect.

If this will result in problems down the line, I do wish to correct the problem.

So for JKHendrickson, the contents of my composer.json in the '/site/modules/workbench_access/' folder reads:

{
    "name": "drupal/workbench_access",
    "description": "Hierarchical access control for content.",
    "type": "drupal-module",
    "license": "GPL-2.0+",
    "homepage": "https://www.drupal.org/project/workbench_access"
}

should be adding:

"drupal/workbench": "^1.0",
"drupal/workbench_access": "^1.0-alpha8",
"drupal/workbench_moderation": "^1.2",

to that file? By what method would I do that?

Clearly I do not understand the meaning of these codes and/or what they accomplish... I am open to 1) resolving the issue at hand while at the same time 2) learning and understanding how to do this for other modules etc.

Thanks again to you both!

agentrickard’s picture

It is asking too much for us to answer your questions about Composer.

See the documentation here for starters -- https://www.drupal.org/docs/develop/using-composer/using-composer-with-d....

This discussion will be irrelevant within a week, however, when beta1 is released and the patch is no longer required.

bas123’s picture

Ok, fair enough and I have now perused that documentation and do appreciate the value and use of Composer particularly going forward.

Please do answer one question that I am unclear about regarding Composer and Drupal.

When I get messages in my admin reports that Modules etc. are outdated, and then update them and follow through with the database updates via the browser (Command Line), based upon what I have read, am I not using a built in version of Composer to follow all of updates including the dependencies in the json files? Or am I being told that ALL of this needs to be done in a terminal environment?

Further, and to finally clear up the discussion about the workbench access update and patch application, again I still do not know if the procedure I followed (which succeeded in removing the error & applying the patch code) has messed something up elsewhere.

I ask, because I have had some problems with the deployment of some of my backups via Acquia Dev Desktop when I run them locally and am trying to troubleshoot the causes!

These issues began around the time frame of 1) patching the WA Module and 2) Updating Core from 8.3.x to 8.5.0 and don't know if one or both are playing a role in the problems locally!

Thanks!

agentrickard’s picture

Status: Needs work » Fixed

I don't know enough about Composer to answer that question.

As for the update process, that is all a moot point now, as I am about to tag beta1, which eliminates the need for this patch.

It will require another database update, however.

drush updb --entity-updates or via update.php.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nickgee’s picture

Hello,

The getDefaultValue() method is still missing from WorkbenchAccessManager, 8.x-1.0-beta2.

2946766-wa-field-test-passl.patch does not apply cleanly but adding this to the class fixes the issue. (The test part of the patch is already in the code base.)

public static function getDefaultValue() {
    return [];
  }

Thanks!

nor4a’s picture

Problem still exists. In my case it rises when I try to add a new user in /admin/people/create
So I created the patch to fix this issue for version 2.0.0 also