Capture description:
When we install Drupal 8 site with the entity browser module enabled.
Then we get the following error
PHP Fatal error: Call to a member function getConfigDependencyKey() on null in /var/www/html/test/drupal8/modules/contrib/entity_browser/src/Plugin/EntityBrowser/Widget/View.php on line 277
Environment: Development
Steps to reproduce:
Given that we do have a drupal 8 site at "/var/www/html/test/drupal 8/"
And we changed directory to "/var/www/html/test/drupal 8/"
When we run the following command :
"
drush site-install profile_with_entity_browser --yes --account-name=webmaster --account-pass=dD.123123ddd --account-mail=webmaster@example.com --db-url=mysql://mysqluser:mysqlpassword@localhost/test_drupal8 -vvv
"
Then we will get the following error:
"
PHP Fatal error: Call to a member function getConfigDependencyKey() on null
"
Expected results:
Install without any issues.
Comments
Comment #2
rajab natshahComment #3
rajab natshahComment #4
rajab natshahAttached the patch file.
Comment #5
rajab natshahComment #6
rajab natshahComment #7
samuel.mortensonRe-queuing failed test but the change is simple enough to RTBC after tests pass.
Comment #8
samuel.mortensonLooks like branch tests are failing https://www.drupal.org/node/1943336/qa, we need to wait for that to be fixed before committing this.
Comment #9
rajab natshahNoted :)
Comment #10
grimreaperHello,
Thanks for the patch.
I encountered the same issue.
I have updated entity browser from 8.x-1.0-beta2 to 8.x-1.0-beta4 and when I have rebuilded my website from scratch I got the error and the patch solved it.
I do not change the status to RTBC as I don't know if there is other things to do in the module to solve the issue.
Comment #11
killua99 commentedThis is a quite important issue. We can not install sites that are using this module.
The branch fail the test, but someone can point which test are failing? issue I mean.
To try to solve ASAP, we can not relay on a patch in our composer.
Comment #12
podarokCode from #4 looks good
Comment #14
schiavone commented@RajabNatshah Thanks for the patch. Applied successfully on 8.x-1.0-beta4
Comment #15
slashrsm commentedAdded parenthesis around the assignment.
Comment #16
slashrsm commentedCommitted. Thanks!
Comment #18
slashrsm commentedDiscussed this with @beridr. He pointed out that the fact that view is not loadable indicated some bigger problem and with this patch we just hide it.
I also noticed that this happens if one is using media module since it does not correctly declare its dependencies: #2849475: Entity browser configuration doesn't correctly declare all its dependencies. Did you get this error using that module?
Comment #20
rajab natshahYes
Comment #21
rajab natshahSorry, No I do have a custom feature module http://cgit.drupalcode.org/varbase/tree/modules/varbase_features/varbase...
Comment #22
slashrsm commentedCheck what was done in #2849475: Entity browser configuration doesn't correctly declare all its dependencies (which was just committed). You should do the same thing to fix the problem.
Comment #23
rajab natshahThank you :)
Comment #24
rajab natshahSeems that features will not add the config dependency. in the next write.
Should this be done manually every time?
Comment #25
samuel.mortensonIf I understand #2849475: Entity browser configuration doesn't correctly declare all its dependencies correctly, this means that every existing Entity Browser config (exported to a module/distribution's /config/install folder) will need to be updated to include the View dependency. This would effect Lightning, Demo Framework, and Thunder, right? I'm wondering how we can make this easier on people with existing config exports, not sure what the best path forward is if the patch from this issue isn't acceptable. Any ideas?
Comment #26
slashrsm commentedThe approach that this patch uses leaves the doors open for problems in the future and I would rather not use it.
One thing that we could do is to allow view to be non-loadable on the first run and enforce it after that. That would ensure that the install went file even for exported configurations that are missing dependencies with the expectation that all of there were imported. We could use a flag somewhere to track that. I am not sure though if the benefits that this would bring outweigh the additional complexity in the code. It is also worth mentioning that we're already in beta which kind of implies we'll maintain the BC. Not sure about that.
Another approach could be a script that would help people update their config exports. This would obviously still require manual work so it is questionable how much sense this makes.
Comment #27
stefan.r commentedWhen we include rc2 in our distribution, it's currently making the installation fail altogether. A fatal error during installation sounds critical :)
Comment #28
stefan.r commentedComment #29
rajab natshah- Removed 2845037_15.patch for the [Entity Browser] module.
#2870617: [8.4.x] Removed 2845037_15.patch for the [Entity Browser] module.
If we create an entity browser and we do use any other config we need to add them manually.
we need a schema or config handler to let CMI get the right dependencies
This will handled manually:
Thank you, Back to your way. which is the right way.
Comment #30
keesje commentedThanks Stefan for posting the conversation, that explains a lot.
I had to manually add the views dependency (views.view.yourview) to the entity_browser config (entity_browser.browser.yourbrowser.yml).
Comment #31
RaisinBranCrunch commentedSo as per the convo with Berdir, why don't we made the module explain which view is causing the problem? It should be a simple addition to src/Plugin/EntityBrowser/Widget/View.php.
Comment #32
adamclark-dev commentedAdded new patch, as having issue where getConfigDependencyKey method does not exist.
Comment #33
avpadernoComment #34
podarok#32 works for me for
"drupal/entity_browser": "^2",- Version: 8.x-2.5And we were able to install in within Open Y distribution + Drupal 9 by using both drush ( 10 ) and web Installer.
Comment #35
asak commentedThe patch in #32 is for version 8.x-1.x.
Attaching an updated patch for 8.x-2.x with the only changes being line numbering for the patch to apply cleanly.
Comment #36
podarok#35 looks good
Let's release it.
Thank you
Comment #37
avpadernoComment #38
dave reidWhat's the reason for adding the
method_exists($view, 'getConfigDependencyKey')check. Shouldn't this always be defined for every View config entity?Comment #39
avpadernoIs the following code a tentative to check that
ViewEntity::load($this->configuration['view']))effectively returns a View object?If that is the case, I would rather remove the part checking the value returned from
method_exists($view, 'getConfigDependencyKey'). The error reported from the IS is caused by code trying to callgetConfigDependencyKey()onNULL. To avoid that, the following code is sufficient.Comment #40
dave reidYup if $view is assigned NULL or FALSE the if statement will not pass. Moving to needs work for an update.
Comment #41
avpadernoI agree.
ViewEntity::load()won't return (for example) 1, which would make theif()fail and cause an exception.Comment #43
olegrymar commentedPlease, review the patch.
I think it would be better to add isset($this->configuration['view']) to avoid generating unnecessary warnings.
Comment #44
olegrymar commentedUploaded a new patch.
Comment #45
avpadernoSince patches are no longer tested, a merge request needs to be provided.
Comment #46
mrinalini9 commentedHi,
I have checked and found that the changes mentioned in #44 are already merged on 8.x-2.x branch. So, no work is needed here.
Thanks!
Comment #47
benstallings commented