I have a configuration that converts files. The file gets harvested from cck field, processed with ffmpeg to flv and stored the file back on the node. Everything work just fine. Great!
But...
I deleted my configuration because I wanted to have the node published. Since you cant update the configuration which I would recommend as a feature I deleted my configuration and added a new one where the node got published.
I also have auto process on so when creating a node everything should work like it did with the first configuration? Well it didnt. The problem, the files in in het media_mover_files do not have the correct cid. The cid is allways 1. And when the processing gets executed it querries for cid 2 (the id )
I looked where the cid is stored in the db and it receives an object on $cid
function media_mover_api_file_db_add($file, $cid, $status = MMA_FILE_STATUS_HARVESTED) {
// add to db
db_query("INSERT INTO {media_mover_files} (nid, fid, cid, harvest_file, status, date, data) VALUES (%d, %d, %d, '%s', %d, %d, '%s')",
$file['nid'], $file['fid'], $cid, $file['harvest_file'], $status, time(), serialize($file['data'])
);
// return the mmfid
return db_last_insert_id("media_mover_files", 'mmfid');
}
This solution is simple $cid should be $cid->cid in the query. So you end up with.
function media_mover_api_file_db_add($file, $cid, $status = MMA_FILE_STATUS_HARVESTED) {
// add to db
db_query("INSERT INTO {media_mover_files} (nid, fid, cid, harvest_file, status, date, data) VALUES (%d, %d, %d, '%s', %d, %d, '%s')",
$file['nid'], $file['fid'], $cid->cid, $file['harvest_file'], $status, time(), serialize($file['data'])
);
// return the mmfid
return db_last_insert_id("media_mover_files", 'mmfid');
}
This code is tested and is everything working fine now. After you guys reviewed it and tested it you should include this bug fix into the next release.
Comments
Comment #1
arthurf commentedI did a refactor on this to fix something else and I missed this. I actually modified the calling function (media_mover_api_run_config_harvest()) to pass the $cid rather than the configuration. Thanks for the catch!