We are having an issue where the Drupal devel module's generate feature does not adhere to cck custom fields max length settings. Is this normal, is there a workaround for this?
Using the latest Drupal Devel module and Drupal 6.

CommentFileSizeAuthor
#2 generate_ignores_cck_limits-534166-2.patch473 bytesandyf

Comments

moshe weitzman’s picture

Project: Devel » Content Construction Kit (CCK)
Component: devel_generate » General
andyf’s picture

Title: Generate does not adhere to cck limits » Generate does not adhere to cck limits (patch)
Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new473 bytes

I can't believe this bug's been around this long without someone spotting it, but I have exactly this issue, and it seems to be down to the logic in content.devel.inc. If $max is 0 (one value) it works fine, if $max is 1 (unlimited) it works fine, if it's another fixed number however it'll iterate once too many times.

if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
  $max = 0;
}
else {
  switch ($field['multiple']) {
    case 0:
      $max = 0;
      break;
    case 1:
      $max = rand(0, 3); //just an arbitrary number for 'unlimited'
      break;
    default:
      $max = $field['multiple'];
      break;
  }
}
for ($i = 0; $i <= $max; $i++) {

Patch attached. As I say, I'm very confused as to how this could've escaped the gazillions of other developers using this, so I might've missed something :)

Thanks,

Andy

moshe weitzman’s picture

Status: Needs review » Postponed (maintainer needs more info)

Does D7 need similar fix?

andyf’s picture

Status: Postponed (maintainer needs more info) » Active

Just gave it a quick go, and it appears that D7's fine. Btw, I realise now that I hijacked/misread this unrelated issue. The OP was on about a field's max length, and I'm referring to the number of fields generated.

andyf’s picture

Status: Active » Needs review

Patch isn't committed.