Need some geeky input on an error in migrating audio module to file field

Joined: 02/09/2009
User offline. Last seen 2 years 18 weeks ago.

Hello,

I recently used MF's tutorial on migrating audio module to file field. Everything worked good except for an error box that contained the following issues:

* warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in C:\wamp\www\olivebranchonline\sites\all\modules\date\date\date_elements.inc on line 48.
* warning: Invalid argument supplied for foreach() in C:\wamp\www\olivebranchonline\sites\all\modules\filefield\filefield_field.inc on line 127.
* warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in C:\wamp\www\olivebranchonline\sites\all\modules\date\date\date_elements.inc on line 48.
* warning: Invalid argument supplied for foreach() in C:\wamp\www\olivebranchonline\sites\all\modules\filefield\filefield_field.inc on line 127.
* warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in C:\wamp\www\olivebranchonline\sites\all\modules\date\date\date_elements.inc on line 48.
* warning: Invalid argument supplied for foreach() in C:\wamp\www\olivebranchonline\sites\all\modules\filefield\filefield_field.inc on line 127.

Not being a coder, I am totally in the dark as to what this means. I have not had any continuing problems that I can see and have not seen the error box again. MF asked to see the script, but I am unsure where to find that.

I am also seeing another issue in the new file field set up. When I attempt to publish a new podcast, I browse for the mp3 file and then hit the upload button. Upon reload of that section the entire field input area is gone. I checked the file in the root to see if drupal actually uploaded it correctly, but is was not there. Additionally, if I browse for the file and then fill out the rest of the fields and hit preview, the entire content form reloads completely empty with no preview. Not sure if the two are linked, but would love to hear any comments. Thanks

Oh, by the way I am running 6.9 and all the modules are updated. Also, this is a localhost attempt at migration for a future attempt on my remote server. That came to mind, don't know if that is actual issue or not.

pk

G&G Podcast Host
Matt Farina's picture
Joined: 06/01/2006
User offline. Last seen 21 weeks 6 days ago.
This will be hard

I think this will be hard for you. The migration script will most likely need to be customized or depend on your setup to work. In this case it looks like you have a date field you are migrating and there's missing information.

Did you just copy directly what I had or did you modify it? What fields do you have on your nodes?

Matt Farina
Geeks and God Former Co-Host
www.mattfarina.com

Joined: 02/09/2009
User offline. Last seen 2 years 18 weeks ago.
Sorry about the delay

Hey there, Sorry about the delay. I am a full time woodworker and a full time assistant pastor in a discipleship ministry and it has been very difficult to make time for the web lately. Um, let's see...Fields? Date, Speaker, Podcast Title, Podcast Description, Taxonomy, Key Words, Audio File. I got this list from the manage fields form under content types. Additionally, I did copy your code straight without any adjus...wait a minute. Now that I think about I had to make some adjustments to match my files. How about if I just post it like this....

<?php
// Bootstrap Drupal
require 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
// Query all the audio nodes.
$result = db_query("SELECT nid FROM {node} WHERE type = 'audio'");
 
// Loop through all the audio nodes.
while ($nid = db_fetch_object($result)) {
  // Load the node.
  $node = node_load($nid->nid);
 
  // Change the node type
  $node->type = '<strong>message_podcast</strong>';
 
  // Migrate the audio file to filefield
  $node->field_message_mp3_file[] = array(
	'fid' => $node->audio['file']->fid,
	'list' => 1, // Set to 1 to display on the node or 0 to hide.
	'uid' => $node->audio['file']->uid,
	'filename' => $node->audio['file']->filename,
	'filepath' => $node->audio['file']->filepath,
	'filemime' => $node->audio['file']->filemime,
	'filesize' => $node->audio['file']->filesize,
	'status' => $node->audio['file']->status,
	'timestamp' => $node->audio['file']->timestamp,
  );
  // Remove the audio module informaion.
  unset($node->audio);
 
  // Save the changes
  node_save($node);
}

G&G Moderator
G&G Podcast Host
micah's picture
Joined: 06/21/2007
User offline. Last seen 2 weeks 3 days ago.
Troubleshooting

Rats! Accidentally closed the tab I was writing this comment. (Stupid eraser mouse.) Hope I can reconstruct most of it.

I edited your comment and wrapped your script in code tags for easier reading.

Everything looks okay except for the <strong> tags on the line that sets $node->type, but you might have done that for emphasis when posting your comment.

Your problem might not be in the script. Try creating a node using the normal UI. Does it work, or do you get similar errors?

Does your content type have any required fields that are not being given values here? That could cause problems when you try to node_save.

Line 48 of date_elements.inc deals with timezone. Make sure date module is fully set up on your site. Some builds of Date module have quirks. Maybe try a different build. Same with Filefield. I got this working with Date 6.x-2.0-rc6 and Filefield 6.x-3.0-alpha6. Neither of those are current. Again, creating a node manually would test some of those issues.

Again, the script itself looks okay to me. I think the problem lies elsewhere in your setup.

Micah

Joined: 02/09/2009
User offline. Last seen 2 years 18 weeks ago.
EGADS

Hey Micah,

It would seem that when I checked the box to get an email about replies to this post that I must have "not" done that because I never got wind that you had posted a reply. Sorry it has taken so long to get back here and comment.

I did add the strong tag for display.

Your idea about creating a new node was exactly what I had considered initially but that is where I ran into the save node problems. I have yet to get back in and have a go at it. I am having localhost problems and a shortage of time. I think though that you are correct that it is a set up issue and not a script issue. I will have to do more testing when I get back up and running.

thanks for your help by the way.

God bless

Joined: 02/09/2009
User offline. Last seen 2 years 18 weeks ago.
more questions

I am back for more audio module migration help. My localhost crashed on me so I have had to spend the last couple of weeks trying to rebuild. I am now ready to trouble shoot this problem. One thing that I am attempting to do is make sure that I can get file field to work on my localhost environment. One issue that has come up that I tried to ask about on Bob's Musterseed media site is concerning the size limiting for audio files. With Audio module I can ftp our file into the audio folder and Audio Module finds it and off you go. Am I limited to using the Audio file upload in the Add Content area or is there another way. I could almost swear that I saw someone say that there is a way to change the upload size, but I can't seem to remember where I saw that. Thanks for the help again.

G&G Moderator
G&G Podcast Host
micah's picture
Joined: 06/21/2007
User offline. Last seen 2 weeks 3 days ago.
Maximum Upload Size

Here's that discussion you were looking for:

http://geeksandgod.com/forums/random-discussion/ge...

Yes, I used to use the audio import module, too. Once everything is set up with FileField, it's actually easier, since it's no longer a two-step process, although you can't import a batch of files at once, which was (sometimes) handy.

Micah