Problem/Motivation
The locale module tries to add extra info to the node entity in locale_entity_info_alter(), even when the node entity is not there yet.
Install for example https://www.drupal.org/project/paddle, enable the Simpletest Drupal module and try to run a test which installs the paddle profile.
You can also achieve the failure by adding a bunch of modules to a custom profile which have locale as dependency. The locale module will be installed before the node module and the exceptions will happen.
You will get the following:
Exception Notice field.crud.inc 92 field_create_field()
Undefined index: entity keys
Exception Warning field.crud.inc 92 field_create_field()
in_array() expects parameter 2 to be array, null given
Exception Notice field.crud.inc 92 field_create_field()
Undefined index: entity keys
Exception Warning field.crud.inc 92 field_create_field()
in_array() expects parameter 2 to be array, null given
Exception Notice field.crud.inc 92 field_create_field()
Undefined index: entity keys
Exception Warning field.crud.inc 92 field_create_field()
in_array() expects parameter 2 to be array, null given
Exception Notice field.crud.inc 92 field_create_field()
Undefined index: entity keys
Exception Warning field.crud.inc 92 field_create_field()
in_array() expects parameter 2 to be array, null given
Exception Notice module.inc 449 module_enable()
Trying to get property of non-object
Proposed resolution
Wrap the alteration in an if-statement which checks if the node entity exists.
User interface changes
None
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#3 | locale_entity_info_alter_causes_notices-2869038-1.patch | 641 bytes | iSoLate |
Comments
Comment #2
iSoLate CreditAttribution: iSoLate at Randstad Digital for Government of Flanders commentedComment #3
iSoLate CreditAttribution: iSoLate at Randstad Digital for Government of Flanders commentedPatch added
Comment #4
iSoLate CreditAttribution: iSoLate at Randstad Digital for Government of Flanders commentedComment #5
iSoLate CreditAttribution: iSoLate at Randstad Digital for Government of Flanders commentedComment #6
michel.g CreditAttribution: michel.g at Randstad Digital for Government of Flanders commentedI have tested the patch locally with the paddle profile which you linked and it does indeed fix the issue.
Also kudos for using the same method which has been used to solve that issue with the comment module.
Comment #7
iSoLate CreditAttribution: iSoLate at Randstad Digital for Government of Flanders commentedComment #8
David_Rothstein CreditAttribution: David_Rothstein commentedThe Node module is a required module, so the Locale module should be able to depend on it. I think we need to get to the root cause of this bug.
I couldn't get very far with the Paddle profile because the latest version has other errors when you try to install it (e.g. it seems to be trying to enable modules that don't exist in the codebase). But when I looked at the order in which Drupal was trying to install that profile's modules, as well as trying it with a separate profile as described above, I couldn't see any problem. Since the Node module is a required module and https://api.drupal.org/api/drupal/includes!install.core.inc/function/ins... always tries to install required modules first, it always installs Node before Locale.
Any more details on how to reproduce this?
Comment #9
David_Rothstein CreditAttribution: David_Rothstein commentedThis issue summary here does specifically say that the problem happens when running tests, so I guess it's worth mentioning that I couldn't figure out how to reproduce it there either. When a profile is installed in a test, it does use a code path that's different from the above, but it does it via https://api.drupal.org/api/drupal/modules%21simpletest%21drupal_web_test... which calls https://api.drupal.org/api/drupal/includes%21install.inc/function/instal... which looks like it always installs required modules before non-required ones also, so again, the result is the same and I couldn't figure out how to get the Locale module installed before the Node module.