Hello.

Today I've got an exception due to the fact that the name of the module of one of my features is too long.

Please take a look on the screenshot
scr

I had no any warnings but this name is too long. I propose to add some validation on JS or backend side to prevent this problem.

CommentFileSizeAuthor
screenshot_191.png58.34 KBeugene.ilyin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eugene.ilyin created an issue. See original summary.

dawehner’s picture

Nice catch! I think we should totally add some validation in the UI for that.

eugene.ilyin’s picture

Issue summary: View changes
nedjo’s picture

Good point. Where all should we be validating?

As noted in the screenshot, we generate the module name by concatenating the bundle machine name and the package machine name in the form bundle_package where bundle is the bundle machine name and package is the package machine name. So there are three points we should probably validate: the features bundle machine name; the package machine name; and the concatenated result.

Since it's the concatenated combination of the bundle and package machine names that can't exceed 50 characters, on their own, each could be a maximum of 48 characters leaving one character for the underscore and one for the other component's machine name. Of course, they couldn't both be 48 characters.

Some package assigners automatically generate package machine names based on existing strings like the machine name of an entity bundle, so to address we'll need to do more than validate forms.

Possible approaches:

  • Add validation to the bundle machine name form element.
  • In FeaturesManager::getPackageArray(), or a method introduced by #2595263: Remodel packages as objects, throw an exception if the $machine_name argument exceeds 48 characters or if the string returned by FeaturesBundleInterface::getFullName() exceeds 50 characters.
nedjo’s picture

The relevant value is in the constant DRUPAL_EXTENSION_NAME_MAX_LENGTH.