Skip to main content
added 80 characters in body
Source Link
mbomb007
  • 536
  • 5
  • 21

If two modules implementing two separate hooks ended up with functions with the same name, could that cause a conflict or problem?

a.module

/**
 * Implements hook_a_b().
 */
function a_a_b() {}

b.module

/**
 * Implements hook_b().
 */
function b_b() {}

c.module

/**
 * Implements hook_a_b().
 */
function c_a_b() {}

c_a.module

/**
 * Implements hook_b().
 */
function c_a_b() {}

Does the scoping prevent that from causing a problem, even though the functions have the same names?

What happens if two modules declare the same hooks, even though they follow the naming scheme and the hook names contain the module names?

a.module

/**
 * Implements hook_a_b_c().
 */
function a_a_b_c() {}

a_b.module

/**
 * Implements hook_a_b_c().
 */
function a_b_a_b_c() {}

x.module

/**
 * Implements hook_a_b_c().
 *
 * It's not clear which of the two hooks this actually implements.
 */
function x_a_b_c() {}

If two modules implementing two separate hooks ended up with functions with the same name, could that cause a conflict or problem?

a.module

/**
 * Implements hook_a_b().
 */
function a_a_b() {}

b.module

/**
 * Implements hook_b().
 */
function b_b() {}

c.module

/**
 * Implements hook_a_b().
 */
function c_a_b() {}

c_a.module

/**
 * Implements hook_b().
 */
function c_a_b() {}

Does the scoping prevent that from causing a problem, even though the functions have the same names?

What happens if two modules declare the same hooks, even though they follow the naming scheme and the hook names contain the module names?

a.module

/**
 * Implements hook_a_b_c().
 */
function a_a_b_c() {}

a_b.module

/**
 * Implements hook_a_b_c().
 */
function a_b_a_b_c() {}

x.module

/**
 * Implements hook_a_b_c().
 */
function x_a_b_c() {}

If two modules implementing two separate hooks ended up with functions with the same name, could that cause a conflict or problem?

a.module

/**
 * Implements hook_a_b().
 */
function a_a_b() {}

b.module

/**
 * Implements hook_b().
 */
function b_b() {}

c.module

/**
 * Implements hook_a_b().
 */
function c_a_b() {}

c_a.module

/**
 * Implements hook_b().
 */
function c_a_b() {}

Does the scoping prevent that from causing a problem, even though the functions have the same names?

What happens if two modules declare the same hooks, even though they follow the naming scheme and the hook names contain the module names?

a.module

/**
 * Implements hook_a_b_c().
 */
function a_a_b_c() {}

a_b.module

/**
 * Implements hook_a_b_c().
 */
function a_b_a_b_c() {}

x.module

/**
 * Implements hook_a_b_c().
 *
 * It's not clear which of the two hooks this actually implements.
 */
function x_a_b_c() {}
changed the examples to be closer to PHP code
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

This is a theoretical question. If some modules define hooks, and two modules implementing two separate hooks ended up with functions with the same name, could that cause a conflict or problem?

A.module

a.module

hook_A_B/**
 * Implements hook_a_b().
 */
function a_a_b() {}

B.module

b.module

hook_B/**
 * Implements hook_b().
 */
function b_b() {}

C.module

c.module

//**
 * Implements hook_A_Bhook_a_b().
 */
function C_A_Bc_a_b() {}    // SAME NAME

C_A.module

c_a.module

//**
 * Implements hook_Bhook_b().
 */
function C_A_Bc_a_b() {}    // SAME NAME

Or doesDoes the scoping prevent that from causing a problem, even though the functions have the same names?


 

And a related question, whatWhat happens if two modules declare the same hooks, even though they follow the naming scheme and the hook names contain the module names?

A.module

a.module

hook_A_B_C/**
 * Implements hook_a_b_c().
 */
function a_a_b_c() {}

A_B.module

a_b.module

hook_A_B_C/**
 * Implements hook_a_b_c().
 */
function a_b_a_b_c() {}

X.module

x.module

//**
 * Implements hook_A_B_Chook_a_b_c() -- WHICH.
 ONE?*/
function X_A_B_Cx_a_b_c() {}

This is a theoretical question. If some modules define hooks, and two modules implementing two separate hooks ended up with functions with the same name, could that cause a conflict or problem?

A.module

hook_A_B() {}

B.module

hook_B() {}

C.module

// Implements hook_A_B()
function C_A_B() {}    // SAME NAME

C_A.module

// Implements hook_B()
function C_A_B() {}    // SAME NAME

Or does the scoping prevent that from causing a problem, even though the functions have the same names?


 

And a related question, what happens if two modules declare the same hooks, even though they follow the naming scheme and the hook names contain the module names?

A.module

hook_A_B_C() {}

A_B.module

hook_A_B_C() {}

X.module

// Implements hook_A_B_C() -- WHICH ONE?
function X_A_B_C() {}

If two modules implementing two separate hooks ended up with functions with the same name, could that cause a conflict or problem?

a.module

/**
 * Implements hook_a_b().
 */
function a_a_b() {}

b.module

/**
 * Implements hook_b().
 */
function b_b() {}

c.module

/**
 * Implements hook_a_b().
 */
function c_a_b() {}

c_a.module

/**
 * Implements hook_b().
 */
function c_a_b() {}

Does the scoping prevent that from causing a problem, even though the functions have the same names?

What happens if two modules declare the same hooks, even though they follow the naming scheme and the hook names contain the module names?

a.module

/**
 * Implements hook_a_b_c().
 */
function a_a_b_c() {}

a_b.module

/**
 * Implements hook_a_b_c().
 */
function a_b_a_b_c() {}

x.module

/**
 * Implements hook_a_b_c().
 */
function x_a_b_c() {}
Source Link
mbomb007
  • 536
  • 5
  • 21

Hook naming conflicts: what happens?

This is a theoretical question. If some modules define hooks, and two modules implementing two separate hooks ended up with functions with the same name, could that cause a conflict or problem?

A.module

hook_A_B() {}

B.module

hook_B() {}

C.module

// Implements hook_A_B()
function C_A_B() {}    // SAME NAME

C_A.module

// Implements hook_B()
function C_A_B() {}    // SAME NAME

Or does the scoping prevent that from causing a problem, even though the functions have the same names?


And a related question, what happens if two modules declare the same hooks, even though they follow the naming scheme and the hook names contain the module names?

A.module

hook_A_B_C() {}

A_B.module

hook_A_B_C() {}

X.module

// Implements hook_A_B_C() -- WHICH ONE?
function X_A_B_C() {}