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.
Problem/Motivation
When I try to install a custom profile (or distro) via drush I get this error:
Error: Call to a member function getPath() on null in core/includes/install.inc, line 942
Affect any kind of custom profile even if is similar to minimal or standard...
I'm using
- Drush Version : 8.0-dev
- Drupal Version: 8.0-dev
Proposed resolution
Provide a more helpful error message.
Remaining tasks
Decide on the error message. Write a test.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#55 | call_to_a_member-2608408-54.patch | 4.15 KB | neclimdul |
#55 | call_to_a_member-2608408-54.interdiff.txt | 1.45 KB | neclimdul |
Comments
Comment #2
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedI can confirm this issue. It's occurring when you have a module set in dependencies, and the module doesn't exist.
When a module is not existing. This should be added to the requirements array that is returned in drupal_check_profile.
Comment #3
no_angel CreditAttribution: no_angel as a volunteer commentedCan you please provide the steps to reproduce the issue.
Comment #4
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedUse profile in attachment. This will trigger an error (the menu module doesn't exist)
Comment #5
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedComment #6
cilefen CreditAttribution: cilefen commentedThis seems like a drush issue.
Comment #7
no_angel CreditAttribution: no_angel as a volunteer commentedMaybe similar to: https://www.drupal.org/node/1971072?https://www.drupal.org/node/1971072#comment-10687236 thanks @zuuperman
Comment #8
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedIt's not a drush issue. I also had this error when installing via the browser.
Comment #9
cilefen CreditAttribution: cilefen commented@zuuperman The issue summary reads "via drush". Can you update it please?
Comment #10
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedNever noticed the drush in description. Seems like another issue then, because he is also having it with copies of minimal / standard.
Comment #11
pfrenssenIt would be better to throw an exception with a helpful message, something like this.
Comment #12
pfrenssenComment #14
sandervd CreditAttribution: sandervd commentedThe path in #11 does indeed makes it a lot more obvious what the problem is...
Comment #15
sqndr CreditAttribution: sqndr at Randstad Digital commented+1 for the error message!
Comment #16
nlisgo CreditAttribution: nlisgo commentedComment #17
nlisgo CreditAttribution: nlisgo commentedGoing to see if I can recreate the issue in a test and I will expect an error message.
Comment #18
nlisgo CreditAttribution: nlisgo commentedI have a test only patch and a patch which incorporates the code from #11 with the minor adjustment of using the InstallerException.
Comment #19
nlisgo CreditAttribution: nlisgo commentedComment #20
nlisgo CreditAttribution: nlisgo commentedI have placed the tests in the wrong location. I will prepare the patches again
Comment #21
nlisgo CreditAttribution: nlisgo commentedComment #22
nlisgo CreditAttribution: nlisgo commentedComment #26
nlisgo CreditAttribution: nlisgo commentedGood news that the test only failed and the test+fix passed testing. I will do more work on this to improve the Exception and perhaps create a new Exception for this which extends InstallerException.
Comment #27
neclimdulNice work! I'm quite a fan of clear exceptions and like your idea.
Since this is the only thing you are testing, the @expectedException and @expectedExceptionMessage annotations in the docblock make more sense. https://phpunit.de/manual/current/en/appendixes.annotations.html#appendi...
Comment #28
nlisgo CreditAttribution: nlisgo commentedThanks for the feedback @neclimdul, I wasn't even aware of the annotations. It works perfectly.
I am attaching a screenshot of the message that is display to the end user when they encounter this issue as well as the new patch for review.
Credit due to @mariancalinro who helped review my patch in person at Dev Days.
Comment #29
nlisgo CreditAttribution: nlisgo commentedComment #30
nlisgo CreditAttribution: nlisgo commentedComment #31
malcomio CreditAttribution: malcomio at Capgemini commentedWith the patch applied, the installer UI will only list a single missing dependency at a time, even if there are many dependencies.
It would be better to list all the missing dependencies, the way that Drupal 7 did.
Comment #32
jhedstromThis would be possible by first verifying all dependencies (similar to how config finds missing dependencies), and then throwing an exception (or using an assertion) listing all of them.
Comment #34
aleevasI'm attaching a screenshot of the message that is display to the end user when they encounter this issue as well as the new patch for review.
Comment #36
andypostI think the idea is to have more then one dependent module so exception will list them all
Comment #37
gaydabura CreditAttribution: gaydabura as a volunteer and at Skilld commentedComment #39
dagmarIt seems interdiff from #37 is not quite real. I applied the changes from interdiff #37 in patch #34.
Comment #41
dagmarThis should fix the remaining test.
Comment #42
andypostLooks good to go
Comment #45
BR0kENComment #46
nlisgo CreditAttribution: nlisgo commentedI'm going to review this patch.
Comment #47
nlisgo CreditAttribution: nlisgo commentedThis looks good to me. I've read through the code and cannot spot anything that would raise concern.
This is a major improvement on the approach initially proposed which throws an Exception when the first missing dependency is detected. It now displays all missing dependencies along side all other requirement problems.
Comment #48
ifrikJust changing the issue tag for consistency. Don't credit me for that.
Comment #49
alimac CreditAttribution: alimac commentedComment #50
alimac CreditAttribution: alimac commentedComment #51
neclimdulwhy?
Enough for what? There's an @see where I can probably figure it out but the comment should tell us what does the keys existence actually tell us?
Is there a reason to use array_key_exists instead of
isset($module_list[$module])
? i.e. does the code care about a set null value for some reason?Comment #52
BR0kEN$module_list
will definitely contain...". And@see
annotation available as well.Comment #53
neclimdul1) No, why did you change the spacing on the documentation but not change the documentation.
2) I did. that doesn't tell me that "enough" is. what does its existence mean?
3) then use isset instead of array_key_exists and don't be rude.
Comment #54
BR0kEN@see
reference there. Execution of(new ExtensionDiscovery())->scan()
will return an array of\Drupal\Core\Extension\Extension
.array_key_exists
and not going to do this now.Bringing it back to RTBC since no blockers here.
P.S. I'm sorry.
Comment #55
neclimdulI don't agree that this is RTBC and that's generally the reviewers role in core issues.
1) That's what I figured. Border is not a documentation problem though. It'd be fine to use that in new docs but lets leave the old one's alone. Smaller patch for committer to review and more likely to go in quickly and keeps the blame history more concise.
2) Right, I could follow it. But why would we rely on that when we could just tell people the existence of the key tells us the module doesn't exist and we don't want to run the registration code when that's the case. That's will be a lot more useful to future developers looking at this. Also, I missed it in my first review but we require FQDN on @see annotations.
3) Cool, it is being added in this patch which is why I reviewed it. The actual fix for the issue even ;). Drupal avoids array_key_exists unless its absolutely necessary for various reasons and will be a red flag for most maintainers so lets not use it here.
Comment #56
andypostRTBC++
I worried only about
there was array_key_exists() for reason
Last time I debugged this key was in array but value was NULL
Comment #57
neclimdulCool! NULL is not a valid extension so if there where NULL values in the array isset is actually fixing an additional bug.
Comment #58
nlisgo CreditAttribution: nlisgo commentedI support the changes too. Thanks for weighing in @neclimdul.
Comment #59
BR0kEN@andypost, @neclimdul
NULL
is impossible there sincescan()
method of\Drupal\Core\Extension\ExtensionDiscovery
has only one return from it -return $this->process($files);
. So, if you follow to theprocess()
method, you'll see that there is triggering thegetName()
method for each extension... So, fatal error will be earlier than you'll seeNULL
.Let's finish with this. RTBC+
Comment #61
catchCommitted/pushed to 8.3.x, thanks!
This looks fine for a patch release, so setting 'to be ported' against 8.2.x for cherry-pick once 8.2.0 is out.
Comment #63
catchCherry-picked to 8.2.x