In mm_content.module

function mm_content_harvest($action, $configuration, $running_config, $nid)

should be: (I think!)

function mm_content_harvest($configuration, $running_config, $nid)

CommentFileSizeAuthor
#8 mm_cck.module.patch442 bytesjcmarco
#3 mm_cck.module.patch1.53 KBjcmarco

Comments

falk_g’s picture

Is this why I get the

"PHP Fatal error: Cannot use object of type stdClass as array in /home/32/fgprotoc/drupal/sites/all/modules/media_mover/mm_content/mm_content.module on line 144"

error in the beta 11?

I try it out without the $action as you suggested - will report back in a second...

update: removing $action is getting rid of the error above - but there seems also a problem in the sql query right below... when I run an MM config I get the following error:

Table 'falkdatabase.content_type_mmtest' doesn't exist query: SELECT f.filepath, n.nid FROM drupal_live_files f LEFT JOIN drupal_live_node n ON f.nid = n.nid LEFT JOIN content_type_mmtest c ON c.nid = n.nid LEFT JOIN drupal_live_media_mover_files m ON m.fid = f.fid AND m.cid = 2 WHERE c.field_mediamover_image_test_fid = f.fid AND m.mmfid IS NULL AND n.changed > 1226078578 ORDER BY n.nid DESC in /home/32/falkdatabase/drupal/includes/database.mysql.inc on line 172.

as you can see the actual table prefix was not added to the content_type_mmtest it should read drupal_live_content_type_mmtest instead.
Reading the corresponding code I see a that something was added to the SQL chain - possibly later because it doesn´t follow the drupal convention of using %s %f %d or similar for db_query()

'$db_info['table']' which is pulled from content_database_info($fields[$field_name])

this is where my knowledge ends but I will investigate further...

Update2:
ok the curly brackets where missing. Removing $action and changing the sql query doesn´t give me any more errors, it doesn´t harvest anything either so... :( anyone got it working?

line 144:

    $results = db_query('SELECT f.filepath, n.nid FROM {files} f LEFT JOIN {node} n ON f.nid = n.nid LEFT JOIN {'.$db_info['table'] .'} c ON c.nid = n.nid LEFT JOIN {media_mover_files} m ON m.fid = f.fid AND m.cid = %d WHERE c.'. $db_info['columns']['fid']['column'] .' = f.fid AND m.mmfid IS NULL '. $harvest_conditions .' ORDER BY n.nid DESC', $configuration['cid'], $running_config->last_start_time);
falk_g’s picture

Ok got it working with fusing some of d6 cvs in and adding the changes above.

here is the whole thing:
function: mm_content_harvest
line: 132
module: mm_content.module

function mm_content_harvest($configuration, $running_config, $nid) {
  $files = array();
  $fields = content_fields();
  
  // are we harvesting from a specific NID ?
  if ($nid) {
    $harvest_conditions = ' AND n.nid = '. $nid;
  }
  else {
    $harvest_conditions = ' AND n.changed > '. $running_config->last_start_time;
  }
  
  foreach ($configuration['mm_config_harvest_field'] as $field_name) {
    $db_info = content_database_info($fields[$field_name]);
    $results = db_query('SELECT f.filepath, n.nid, f.fid FROM {files} f 
      LEFT JOIN {'. $db_info['table'] .'} c ON c.'. $db_info['columns']['fid']['column'] .' = f.fid
      LEFT JOIN {node} n ON c.nid = n.nid 
      LEFT JOIN {media_mover_files} m ON m.fid = f.fid AND m.cid = %d 
      WHERE  m.mmfid IS NULL '. $harvest_conditions .'       
      ORDER BY n.nid DESC', $configuration['cid']);;
    while ($result = db_fetch_array($results)) {
      $files[] = array(
        'harvest_file' => $result['filepath'],
        'nid' => $result['nid'],
        'fid' => $result['fid'],

      );
    }
  }
  
  return $files;  
}

Update 1:
taking out the test drupal messages and adding a file ID to the $file object

jcmarco’s picture

Status: Active » Needs review
StatusFileSize
new1.53 KB

I have tested this patch, and without it there is no way to harvest any ckk_field.
I have updated the patch for the new mm_cck.module

arthurf’s picture

jcmarco- this is almost exactly what I did with the D6 branch, except that you got the argument order right and I did not. I'll apply this to the D5 branch and apply the argument fix to the D6 branch. Please feel free to test.

Note, the module has been renamed mm_cck which I think makes more sense.

aaron’s picture

Am going to try this against the d6 version as well, will roll a patch if I can get it working successfully. However, the module is still named mm_content from what I can tell.

arthurf’s picture

Sorry Aaron- the rename is in the D5 branch has not be applied to the D6 branch. Things to do.. things to do.

aaron’s picture

I tried simply changing the arguments to

function mm_content_harvest($configuration, $running_config, $nid) {

but now it results in

recoverable fatal error: Object of class stdClass could not be converted to string in /home/youdrup/domains/youdrup.com/public_html/sites/all/modules/media_mover/mm_content/mm_content.module on line 138.

jcmarco’s picture

StatusFileSize
new442 bytes

Running last 5.x-dev with the patch I got this with a WSOD:

warning: Missing argument 4 for mm_cck_harvest(), called in /home/webapps/devel/current/sites/all/modules/media_mover/mm_cck/mm_cck.module on line 52 and defined in /home/webapps/devel/current/sites/all/modules/media_mover/mm_cck/mm_cck.module on line 132.

Where the function is call on this way:
return mm_cck_harvest($configuration, $running_config, $nid);

But the new release is defined as:
function mm_cck_harvest($action, $configuration, $running_config, $nid) {

In the version 6 you are calling the mm_content_harvest function with $action although is not used into the mm_content_harvest function.

I send a new patch for v5.x removing the $action parameter in the mm_cck_harvest function.
Anyway it is up to you to decide if version 6 (and also v5) uses the $action parameter or not but this parameter is not used into the function and then use the right function call into the module. It seems a bug in the 6.x-dev version.

arthurf’s picture

Assigned: Unassigned » arthurf
Status: Needs review » Patch (to be ported)

@jcmarco - I've done a number of fixes in the D6 branch which clean this issue up. They need to be backported to D5, along with a large number of other changes that have gone into the D6 version