Closed (fixed)
Project:
Automatic Entity Label
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 May 2012 at 22:36 UTC
Updated:
10 Oct 2012 at 09:31 UTC
Jump to comment: Most recent file
Comments
Comment #1
bluenose37 commentedI applied a temporary fix to resolve the problem.
In the auto_entitylabel.module file I changed the code in the following function:
function _auto_entitylabel_patternprocessor($pattern, $entity, $entity_type, $language = LANGUAGE_NONE) {
...
from
return $output;
to
return substr($output, 0, 60); // !important - added to prevent an error for comment subject > 64 characters.
Comment #2
bforchhammer commentedRight, that's probably the line which needs to be changed...
Unfortunately setting it to 60 will unnecessarily limit other entities, e.g. node titles can in theory be full 255 characters long as far as I know. I'm afraid we need a more generic solution...
Comment #3
bluenose37 commentedAnother stab at it then...
if ($entity_type == 'comment') {
return substr($output, 0, 64);
}
else if($entity_type != 'comment') {
return substr($output, 0, 255);
}
Is that any closer?
Comment #4
bforchhammer commentedYes, that's a bit better but I'm not a huge fan of storing exceptions for some modules... there may be other entity types which have the same problem.
I'm wondering if we could extract the maximum length from the respective entity schema somehow... possibly via the entity properties api (i.e. use an entity metadata wrapper to get the label property; then see if the respective "schema field" has a length key).
Comment #5
bforchhammer commentedHere's a patch... would you mind testing out it in your use case?
Comment #6
bforchhammer commentedOh and I forgot to add: you have to download and enable the entity api module, if you don't already have it installed for this patch to work.
Attached is a new patch which adds that dependency.
Comment #7
bforchhammer commentedCommitted #6.
Comment #8
ohthehugemanatee commentedUpdated to dev to get this fix, and there's a typo in the patch which breaks it. It updates $title['k'] with the shortened title, rather than $titles['k']. Attached a fixed version of the patch, dev should be updated accordingly.
Comment #9
bforchhammer commentedHm, that's why I shouldn't commit things without getting a proper review... ;-)
Thanks! I've updated dev accordingly.
Comment #11
bforchhammer commentedFollow-up issue: #1802170: Automatic Entity Label for file types doesn't work