This arises from #1061654: Machine-readable name cannot be longer than 21 characters but is currently 30 characters long.. The migrate module's migrate_example sub-module creates some vocabularies with long machine names at install time, and deletes them at uninstall, and everything works fine, but attempting to delete them through the UI fails with (e.g.) "Machine-readable name cannot be longer than 21 characters but is currently 27 characters long." I was going to ask why the 21-character limit, but managed to track it down to the patch at comment #81 of #902644: Machine names are too hard to implement. Date types and menu names are not validated - the removed code in there had a comment "Restrict machine names to 21 characters to avoid exceeding the limit for field names". The math seems off here, since the field name limit is 32 and (32-strlen('field_')) == 26, not 21...

I presume the thinking is that the machine_name long_example_vocabulary leads to field name field_long_example_vocabulary, which leads to table name field_data_field_long_example_vocabulary. But, the field name of a taxonomy term reference has no formal connection to the vocabulary machine_name, and the field name length itself is enforced, so I don't see why a limit on the vocabulary machine_name is necessary (short of the 255-character size in taxonomy_vocabulary, of course).

So,

  1. Can't we just change the #maxlength of machine_name to 255?
  2. If not, then I think the API should also enforce the limit (21? 26?).
  3. If neither of those approaches are acceptable, we should at least have a comment to explain the magic number 21. Please include the math to support it:-).

Thanks.

CommentFileSizeAuthor
#1 1062370-machine-name-length-1.patch711 bytesmikeryan

Comments

mikeryan’s picture

Status: Active » Needs review
StatusFileSize
new711 bytes

Patch for option 1.

marcingy’s picture

Status: Needs review » Reviewed & tested by the community

Looks like a sensible patch to me.

dawehner’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7
dries’s picture

Status: Reviewed & tested by the community » Fixed

I think this approach works. The 21 was a left-over -- it should have been fixed as part of the previous clean-up in #902644: Machine names are too hard to implement. Date types and menu names are not validated. Committed to 7.x and 8.x.

bfroehle’s picture

Issue tags: -Needs backport to D7

Untagging since it's been committed to 7.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.