When use non-english long labels I get PDO excetion.
I think it is good idea to use transliteration for labels (from transliteration module or custom translit function in bean module).
In attach module that implement hook_bean_submit to do it (transliteration module needed).

CommentFileSizeAuthor
#4 bean-1684250.patch600 bytesfoopang
bean_translit_label.zip938 bytesrimen

Comments

indytechcook’s picture

Status: Needs review » Reviewed & tested by the community

This is a nice idea. I moved the code to Bean:save(). We really don't need to do the duplicate check twice. It's passive also which is also nice :)

 /**
   * Override the save to add clearing of caches
   */
  public function save() {
    // Set the delta if it's not set already
    if (empty($this->delta)) {
      $max_length = 32;

      // Base it on the label and make sure it isn't too long for the database.
      if (module_exists('transliteration')) {
        $delta = drupal_clean_css_identifier(transliteration_get($this->label));
      }
      else {
        $delta = drupal_clean_css_identifier(strtolower($this->label));;
      }

      $this->delta = substr($delta, 0, $max_length);

      // Check if delta is unique.
      if (bean_load_delta($this->delta)) {
        $i = 0;
        $separator = '-';
        $original_delta = $this->delta;
        do {
          $unique_suffix = $separator . $i++;
          $this->delta = substr($original_delta, 0, $max_length - drupal_strlen($unique_suffix)) . $unique_suffix;
        } while (bean_load_delta($this->delta));
      }
    }

    $this->plugin->submit($this);

    $return = parent::save();
    block_flush_caches();
    cache_clear_all('bean:' . $this->delta . ':', 'cache_block', TRUE);
    return $return;
  }
indytechcook’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

foopang’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new600 bytes

transliteration_get() does not convert block delta into lowercase characters, so please add strtolower().

Status: Needs review » Needs work

The last submitted patch, bean-1684250.patch, failed testing.

foopang’s picture

Version: 7.x-1.0-rc5 » 7.x-1.x-dev
Status: Needs work » Needs review
foopang’s picture

#4: bean-1684250.patch queued for re-testing.

indytechcook’s picture

Status: Fixed » Closed (fixed)

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