After adding a new player I get the following warning message:

Warning: Illegal string offset '#value' in brightcove_player_form_validate_field() (line 414 of my_drupal_root\sites\all\modules\contrib\brightcove\brightcove.admin.inc).

The message doesn't seem to cause problems (that I've noticed) and everything seems to work fine. Even if I edit the Player I don't see the message again. It only seems to happen when adding a new player.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ladybug_3777’s picture

Issue summary: View changes
ladybug_3777’s picture

It looks like the issue in brightcove.admin.inc is in this function:

function brightcove_player_form_validate_field($element, &$form_state) {
  if (!preg_match('!^[a-z0-9_]+$!', $element['#value'])) {
    form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
  }
}

Maybe I'm wrong but aren't the parameters of that function wrong? Shouldn't that read:

function brightcove_player_form_validate_field($name) {
  if (!preg_match('!^[a-z0-9_]+$!', $name)) {
    form_error($name, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
  }
}

The only problem is I can't figure out how to test this properly because it seems like Drupal 7 is already sanitizing the machine name, as I type, on the add player form. So I can't get this function to fire with incorrectly entered values. I'm almost wondering if this function isn't needed. I'm trying to learn more about how 'exits' => is supposed to work though. So maybe the entire function isn't doing quite the right thing. Is this function instead supposed to prevent me from entering a machine name that already exists? I can get an error to occur if I reuse a player name (causing the same machine name).

ladybug_3777’s picture

I *think* I've fixed this issue. I believe the function was supposed to check the machine name of the Player to make sure it is unique, however it was written in a way that makes it look like it was trying to validate the format. I think that is incorrect. I will need help from more experienced in Drupal to be sure I made the proper change here, but this patch removes the error I reported initially, and it also prevents the error that occurs if you try and enter an existing player machine name.

Patch is attached. Please validate that what I did is correct since I am still somewhat new to the Drupal world.

ladybug_3777’s picture

Status: Active » Needs review
k.dani’s picture

Status: Needs review » Closed (fixed)

Thank you for the patch, it has been added to the latest dev version (Commit 5abd4c8 on 7.x-5.x).