3

What are the consequences of two modules sharing the same machine name?

For instance, if I write a custom module named 'views' and do not have the contrib module 'views' enabled, will the update manager attempt to update my custom module according to the contrib project status?

  • Why would you name it Views? – Kevin Mar 31 '17 at 17:13
6

I write a custom module named 'views' and do not have the contrib module 'views' enabled, will the update manager attempt to update my custom module according to the contrib project status?

No it won't. The update manager looks at the packaging information added to the .info file for released modules, as long as your module doesn't have that data in the .info file (no reason why it would), then you won't have any problems.

The other answers are of course correct insofar as you can't have both modules enabled at the same time. You'd never even get to the point of seeing the fatal errors though, Drupal simply wouldn't let you install a module that has the same machine name as another module that's already installed.

You should aim to name your modules differently than the most popular module in existence, though, if only to save the sanity of the poor developer who eventually takes over the project from you.

5

It will most likely end up in fatal PHP errors. If you implement a hook that the contrib module also implements you will get a

: Cannot redeclare hook() (previously declared in contrib_module.module) 

Also, your Drupal website will only pick up one of the two modules.

So in short: you have to avoid using the same modules (or theme) names. It will totally mess up your Drupal installation

  • 2
    Drupal wouldn't even let you get that far (two modules with the same machine name enabled), you'd have to mess with the system table manually to make that happen – Clive Mar 31 '17 at 19:15
1

The second one will not work. You can't have two modules with the same name enabled at the same time.

  • I agree with this. That's why there is a namespace. Just like you can't have two files with the same name. – Jason Glisson Mar 31 '17 at 18:20
  • The OP is not asking about two enabled modules with the same machine name, or even two modules with the same machine name copied in the module directory. – kiamlaluno Apr 1 '17 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.