Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
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.
Comment | File | Size | Author |
---|---|---|---|
screenshot_191.png | 58.34 KB | eugene.ilyin |
Comments
Comment #2
dawehnerNice catch! I think we should totally add some validation in the UI for that.
Comment #3
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedComment #4
nedjoGood 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:
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 byFeaturesBundleInterface::getFullName()
exceeds 50 characters.Comment #5
nedjoThe relevant value is in the constant
DRUPAL_EXTENSION_NAME_MAX_LENGTH
.