Problems I faced some Problems when I install audio module

when i add audio node I got this message


warning: Invalid argument supplied for foreach() in /home/xxxx/public_html/sites/all/modules/audio/audio.module on line 558.

function make the problem

function _audio_save(&$node) {
  // Save the file
  $node->audio['file']->timestamp = time();
  $node->audio['file']->filesize = filesize($node->audio['file']->filepath);
  $node->audio['file']->status |= FILE_STATUS_PERMANENT;
  // If there's an fid update, otherwise insert.
  $file_update = empty($node->audio['file']->fid) ? array() : array('fid');
  drupal_write_record('files', $node->audio['file'], empty($node->audio['file']->fid) ? array() : array('fid'));

  // Save the audio row.
  $audio = array_merge($node->audio, array('nid' => $node->nid, 'vid' => $node->vid, 'title_format' => $node->title_format, 'fid' => $node->audio['file']->fid));
  $audio_update = ($node->is_new || $node->revision) ? array() : array('vid');
  drupal_write_record('audio', $audio, $audio_update);

  // Remove any existing metadata.
  db_query("DELETE FROM {audio_metadata} WHERE vid=%d", $node->vid);

  // Save the new tags.
  $allowed_tags = audio_get_tags_allowed();
  foreach ($node->audio_tags as $tag => $value) {
    if (in_array($tag, $allowed_tags) && $value) {
      $metadata = array('vid' => $node->vid, 'tag' => $tag, 'value' => $value, 'clean' => audio_clean_tag($value));
      drupal_write_record('audio_metadata', $metadata);
    }
  }
}

also when I view the audio node I got this message :

# warning: Illegal offset type in isset or empty in /home/xxxx/public_html/includes/bootstrap.inc on line 873.
# warning: Illegal offset type in /home/xxxx/public_html/includes/bootstrap.inc on line 874.
# warning: Illegal offset type in /home/xxxx/public_html/includes/bootstrap.inc on line 878

CommentFileSizeAuthor
#2 audio.module.patch2.12 KByarrait
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yarrait’s picture

Hi

I have reproduced same bug "warning: Invalid argument supplied for foreach() in audio.module on line 558.".

In my case I havent enabled the "Audio getID3" sub module provided in the audio module pack. But after enabling and configuring "Audio getID3" module and its dependency "getid3" module above problem is solved"

After looking at the code on line number 558 of audio.module it can be seen that while saving new nodes audio modules does not check that "Audio getID3" module is enabled or not. And it calls "$allowed_tags = audio_get_tags_allowed();" which returns null array. While saving audio nodes in hook_save of audio module its needed to insure that underlying submodule "Audio getID3" is enabled and configured properly.

This also produces another bug of node title of audio module, if "Audio getID3" module is not enabled while saving node it does not converts given tokens to its value and saves node titles as given tokens. This problem can also be solved by enabling and configuring "Audio getID3" module.

While creating new audio node the node creation form of audio nodes gives pre-filled Title with applied token, here it is also needed to ensure that "Audio getID3" module is enabled or not. Depending on it the title field either can be blank(default drupal behavior) while creating new nodes or can be filled with the node Tokens.

yarrait’s picture

Status: Active » Patch (to be ported)
FileSize
2.12 KB

Hi,
I have created patch for this problem and its solved problem at my end. Please review it.

ayalsule’s picture

fixed
Thanks for patch

KMethe1087’s picture

sorry for asking a possibly obvious question, but how would i implement this patch?

ayalsule’s picture