Skip to main content
answered about the specific case
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

A custom module can call any function defined from another module, if these conditions are met.

  1. If the function is defined in the module file, that module must be installed, enabled, and loaded
  2. If the function is defined in a .inc file, the module must be installed, and the file containing the function must be first loaded with module_load_include()

To expand the first point, if you are calling that function in hook_boot(), it could be too early for that, since the other module could not be loaded, yet.

In your case, commerce_entity_reference_delete() is defined in the commerce.module file, so the only reason I can think for that error is that the other module is calling commerce_entity_reference_delete() too early, when the module is not yet loaded, or Drupal didn't even complete its bootstrap, which happens with external script trying to call Drupal functions.
It could also be that the line calling commerce_entity_reference_delete() is not put inside a function call, and in this case we are back to commerce_entity_reference_delete() being called before the module file containing it is loaded.

A custom module can call any function defined from another module, if these conditions are met.

  1. If the function is defined in the module file, that module must be installed, enabled, and loaded
  2. If the function is defined in a .inc file, the module must be installed, and the file containing the function must be first loaded with module_load_include()

To expand the first point, if you are calling that function in hook_boot(), it could be too early for that, since the other module could not be loaded, yet.

A custom module can call any function defined from another module, if these conditions are met.

  1. If the function is defined in the module file, that module must be installed, enabled, and loaded
  2. If the function is defined in a .inc file, the module must be installed, and the file containing the function must be first loaded with module_load_include()

To expand the first point, if you are calling that function in hook_boot(), it could be too early for that, since the other module could not be loaded, yet.

In your case, commerce_entity_reference_delete() is defined in the commerce.module file, so the only reason I can think for that error is that the other module is calling commerce_entity_reference_delete() too early, when the module is not yet loaded, or Drupal didn't even complete its bootstrap, which happens with external script trying to call Drupal functions.
It could also be that the line calling commerce_entity_reference_delete() is not put inside a function call, and in this case we are back to commerce_entity_reference_delete() being called before the module file containing it is loaded.

Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

A custom module can call any function defined from another module, if these conditions are met.

  1. If the function is defined in the module file, that module must be installed, enabled, and loaded
  2. If the function is defined in a .inc file, the module must be installed, and the file containing the function must be first loaded with module_load_include()

To expand the first point, if you are calling that function in hook_boot(), it could be too early for that, since the other module could not be loaded, yet.