I had set the Comment Auto Label to add 'Re: ' to the front of the topic subject on a forum node. If the forum subject field + what Comment Auto Label add is greater that 64 character an error results.

The code should trim the comment subject to 64 characters.

Drupal 7.14
Advanced Forum 7.x-2.0
Automatic Entity Labels 7.x-1.0

Comments

bluenose37’s picture

I 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.

bforchhammer’s picture

Right, 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...

bluenose37’s picture

Another 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?

bforchhammer’s picture

Yes, 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).

bforchhammer’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.39 KB

Here's a patch... would you mind testing out it in your use case?

bforchhammer’s picture

StatusFileSize
new1.74 KB

Oh 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.

bforchhammer’s picture

Status: Needs review » Fixed

Committed #6.

ohthehugemanatee’s picture

Status: Fixed » Reviewed & tested by the community
StatusFileSize
new1.74 KB

Updated 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.

bforchhammer’s picture

Status: Reviewed & tested by the community » Fixed

Hm, that's why I shouldn't commit things without getting a proper review... ;-)

Thanks! I've updated dev accordingly.

Status: Fixed » Closed (fixed)

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

bforchhammer’s picture