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.

CommentFileSizeAuthor
#55 call_to_a_member-2608408-54.patch4.15 KBneclimdul
#55 call_to_a_member-2608408-54.interdiff.txt1.45 KBneclimdul
#47 missing_dependencies.png3.6 MBnlisgo
#45 interdiff-2608408-41-45.txt2.83 KBBR0kEN
#45 core-profile_unknown_module-2608408-45.patch4.29 KBBR0kEN
#41 interdiff-2608408-39-41.txt773 bytesdagmar
#41 call_to_a_member-2608408-41.patch3.5 KBdagmar
#39 interdiff-2608408-34-39.txt2.46 KBdagmar
#39 call_to_a_member-2608408-39.patch3.37 KBdagmar
#37 interdiff-2608408-34-37.txt2.28 KBgaydabura
#37 call_to_a_member-2608408-37.patch3.41 KBgaydabura
#34 2608408-missing_dependences.png390.48 KBaleevas
#34 call_to_a_member-2608408-34.patch3.31 KBaleevas
#34 interdiff-2608408-28-34.txt2.48 KBaleevas
#28 missing_dependency.png199.58 KBnlisgo
#28 interdiff-2608408-21-28.txt3.59 KBnlisgo
#28 call_to_a_member-2608408-28.patch3.83 KBnlisgo
#21 call_to_a_member-2608408-21.patch2.91 KBnlisgo
#21 call_to_a_member-test-only-2608408-21.patch1.99 KBnlisgo
#18 call_to_a_member-2608408-18.patch2.88 KBnlisgo
#18 call_to_a_member-test-only-2608408-18.patch1.96 KBnlisgo
#11 2608408-11.patch697 bytespfrenssen
#5 error.zip1.92 KBnils.destoop
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Saphyel created an issue. See original summary.

nils.destoop’s picture

I 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.

no_angel’s picture

Assigned: Unassigned » no_angel

Can you please provide the steps to reproduce the issue.

nils.destoop’s picture

Use profile in attachment. This will trigger an error (the menu module doesn't exist)

nils.destoop’s picture

FileSize
1.92 KB
cilefen’s picture

Title: Error installing Profiles » Call to a member function getPath() installing Profiles or distros with drush

This seems like a drush issue.

no_angel’s picture

Assigned: no_angel » Unassigned
Issue summary: View changes
nils.destoop’s picture

Title: Call to a member function getPath() installing Profiles or distros with drush » Call to a member function getPath() when installing Profiles with unknown modules as requirement

It's not a drush issue. I also had this error when installing via the browser.

cilefen’s picture

@zuuperman The issue summary reads "via drush". Can you update it please?

nils.destoop’s picture

Never noticed the drush in description. Seems like another issue then, because he is also having it with copies of minimal / standard.

pfrenssen’s picture

It would be better to throw an exception with a helpful message, something like this.

pfrenssen’s picture

Issue summary: View changes

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sandervd’s picture

The path in #11 does indeed makes it a lot more obvious what the problem is...

sqndr’s picture

+1 for the error message!

nlisgo’s picture

Issue tags: +Needs tests
nlisgo’s picture

Assigned: Unassigned » nlisgo

Going to see if I can recreate the issue in a test and I will expect an error message.

nlisgo’s picture

I have a test only patch and a patch which incorporates the code from #11 with the minor adjustment of using the InstallerException.

nlisgo’s picture

Status: Active » Needs review
nlisgo’s picture

Status: Needs review » Needs work

I have placed the tests in the wrong location. I will prepare the patches again

nlisgo’s picture

nlisgo’s picture

Issue tags: +drupaldevdays

The last submitted patch, 21: call_to_a_member-test-only-2608408-21.patch, failed testing.

The last submitted patch, 11: 2608408-11.patch, failed testing.

The last submitted patch, 18: call_to_a_member-test-only-2608408-18.patch, failed testing.

nlisgo’s picture

Status: Needs review » Needs work

Good 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.

neclimdul’s picture

Nice work! I'm quite a fan of clear exceptions and like your idea.

+++ b/core/modules/system/tests/src/Kernel/Installer/InstallerMissingDependenciesTest.php
@@ -0,0 +1,35 @@
+    $this->setExpectedException('Drupal\Core\Installer\Exception\InstallerException', t('The Testing missing dependencies profile depends on the missing module missing_module.'));

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...

nlisgo’s picture

Status: Needs work » Needs review
FileSize
3.83 KB
3.59 KB
199.58 KB

Thanks 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.

nlisgo’s picture

Issue tags: +Novice
nlisgo’s picture

Assigned: nlisgo » Unassigned
malcomio’s picture

Status: Needs review » Needs work

With 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.

jhedstrom’s picture

It would be better to list all the missing dependencies, the way that Drupal 7 did.

This 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.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

aleevas’s picture

I'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.

Status: Needs review » Needs work

The last submitted patch, 34: call_to_a_member-2608408-34.patch, failed testing.

andypost’s picture

+++ b/core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml
@@ -0,0 +1,9 @@
+dependencies:
+  - missing_module

I think the idea is to have more then one dependent module so exception will list them all

Status: Needs review » Needs work

The last submitted patch, 37: call_to_a_member-2608408-37.patch, failed testing.

dagmar’s picture

It seems interdiff from #37 is not quite real. I applied the changes from interdiff #37 in patch #34.

Status: Needs review » Needs work

The last submitted patch, 39: call_to_a_member-2608408-39.patch, failed testing.

dagmar’s picture

Status: Needs work » Needs review
FileSize
3.5 KB
773 bytes

This should fix the remaining test.

andypost’s picture

Looks good to go

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 41: call_to_a_member-2608408-41.patch, failed testing.

The last submitted patch, 39: call_to_a_member-2608408-39.patch, failed testing.

BR0kEN’s picture

Status: Needs work » Needs review
FileSize
4.29 KB
2.83 KB
nlisgo’s picture

Assigned: Unassigned » nlisgo
Issue summary: View changes

I'm going to review this patch.

nlisgo’s picture

Assigned: nlisgo » Unassigned
Status: Needs review » Reviewed & tested by the community
Issue tags: +Dublin2016
FileSize
3.6 MB

This 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.

ifrik’s picture

Just changing the issue tag for consistency. Don't credit me for that.

alimac’s picture

Issue tags: -Dublin2016
alimac’s picture

Issue tags: +Dublin2016
neclimdul’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/includes/install.inc
    @@ -930,27 +930,35 @@ function drupal_requirements_url($severity) {
    -
    ...
    -
    -  // Performs an ExtensionDiscovery scan as the system module is unavailable and
    -  // we don't yet know where all the modules are located.
    +  // Performs an ExtensionDiscovery scan as the system module is unavailable
    +  // and we don't yet know where all the modules are located.
    

    why?

  2. +++ b/core/includes/install.inc
    @@ -930,27 +930,35 @@ function drupal_requirements_url($severity) {
    +    // Checking for key existence is enough because the "$module_list" will
    

    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?

  3. +++ b/core/includes/install.inc
    @@ -930,27 +930,35 @@ function drupal_requirements_url($severity) {
    +    if (array_key_exists($module, $module_list)) {
    

    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?

BR0kEN’s picture

Status: Needs work » Needs review
  1. Because we are on installation phase.
  2. Try to read after "because $module_list will definitely contain...". And @see annotation available as well.
  3. There will not be any null items. Please, try to spend more time for review and not do useless review.
neclimdul’s picture

Status: Needs review » Needs work

1) 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.

BR0kEN’s picture

Status: Needs work » Reviewed & tested by the community
  1. Yes. I've changed it because it was in contact with a border of 80 chars.
  2. Please, follow the @see reference there. Execution of (new ExtensionDiscovery())->scan() will return an array of \Drupal\Core\Extension\Extension.
  3. I have not changed previously used array_key_exists and not going to do this now.

Bringing it back to RTBC since no blockers here.

P.S. I'm sorry.

neclimdul’s picture

I 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.

andypost’s picture

RTBC++

I worried only about

+++ b/core/includes/install.inc
@@ -932,17 +932,17 @@ function drupal_check_profile($profile) {
-    if (array_key_exists($module, $module_list)) {
...
+    if (isset($module_list[$module])) {

there was array_key_exists() for reason
Last time I debugged this key was in array but value was NULL

neclimdul’s picture

Cool! NULL is not a valid extension so if there where NULL values in the array isset is actually fixing an additional bug.

nlisgo’s picture

Status: Needs review » Reviewed & tested by the community

I support the changes too. Thanks for weighing in @neclimdul.

BR0kEN’s picture

@andypost, @neclimdul NULL is impossible there since scan() method of \Drupal\Core\Extension\ExtensionDiscovery has only one return from it - return $this->process($files);. So, if you follow to the process() method, you'll see that there is triggering the getName() method for each extension... So, fatal error will be earlier than you'll see NULL.

Let's finish with this. RTBC+

  • catch committed c5c1cdf on 8.3.x
    Issue #2608408 by nlisgo, dagmar, aleevas, neclimdul, BR0kEN, gaydabura...
catch’s picture

Version: 8.3.x-dev » 8.2.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed/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.

  • catch committed 016a060 on 8.2.x
    Issue #2608408 by nlisgo, dagmar, aleevas, neclimdul, BR0kEN, gaydabura...
catch’s picture

Status: Patch (to be ported) » Fixed

Cherry-picked to 8.2.x

Status: Fixed » Closed (fixed)

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