First let me say that Content Distribution is a great module and exactly what I was looking for.

Content Distribution works great with all CCK-fields EXCEPT Imagefield-fields. If I try to send a node with a image (in a imagefield), the newly created node on the receiving drupal portal has no image (but all the other data). The send image can also not be found in the file-directory of the receiving drupal portal.

I looked in the code of the content_retriever_module and found a problem:

function _content_retriever_save_file
...
case 'cck':
...
The data of $content_table is wrong for imagefields. Imagefields are not stored in 'content_type_'.$node_type but 'content_'.$field

But it does not work even if I change that line.

With the original code I get an error on the receiving side, that a column does not exist.
With the changes above, this error is gone. But with both ways, I see no image in the nodes of the receiving side :(

Perhaps someone can give me a tip where I must search for the problem.

Comments

vaafri2’s picture

OK solved the problem:
1. content_retriever.module
I had to change $content_table = 'content_type_'.$node_type; to $content_table = 'content_'.$field in line 447 (V 6.x-1.2).

2. To get images, I had to change the permissions on the distributor site. I had to give "anonymous user" the right to "get any binary files".

Now, I am able to distribute nodes with imagefields.

joachim’s picture

> I had to change $content_table = 'content_type_'.$node_type; to $content_table = 'content_'.$field in line 447 (V 6.x-1.2).

That looks like a difference between a single-valued field (where it's stored as extra columns on a table for the node type) and a multi-valued field (which gets its own table).

If the module doesn't take that into account, that's a serious problem.

joachim’s picture

Title: Not working with imagefield » fails with multivalues/multitype filefield and imagefield
Version: 6.x-1.2 » 6.x-2.x-dev
Priority: Normal » Critical

Indeed, it does not. The code assumes that it's a single-value, single type field:

      //set content type db table, and field to search on.
      $content_table = 'content_type_'.$node_type;
      $fid_field = $field['field_name'] . '_fid';

We need to either use the CCK API to get this information, or just check the db_storage key on the field array:

define('CONTENT_DB_STORAGE_PER_FIELD', 0);
define('CONTENT_DB_STORAGE_PER_CONTENT_TYPE', 1);

Bumping the version to 6--2, as it'll get fixed here first.

agileware’s picture

Status: Active » Needs review
StatusFileSize
new1.27 KB

Here is a patch for the second solution in #3.

The CCK API could also be used but would be more overhead.
The second solution seems better seeing as we already have the required information available.

Fixed the errors I was getting. Which for the record were unknown column sql errors.

joachim’s picture

Status: Needs review » Needs work

Since this issue was filed I came across this problem working on another module.

The CCK API for this is actually quite simple:

// Get CCK's database info for this field and hence table and field names.
$db_info = content_database_info($field);
$table = $db_info['table'];
$column = $db_info['columns']['uid']['column']; // but not uid in our case.

I think we should use that as it's easier to read and more robust in the event anything changes in CCK's internals.

luketsimmons’s picture

Status: Needs work » Needs review
StatusFileSize
new1.98 KB

Hi,

Thanks to joachim's idea, I've created a patch that appears to work with the use of content_database_info().

I've tested it with a content type that has both a single use imagefield and a shared imagefield and it works.

Let me know if there are any problems.

Thanks,

Luke

joachim’s picture

Status: Needs review » Fixed

Great work, thanks!

I've not tested this with a multivalued field, just a single, but it all looks fine.

Do remember to roll your patches from the base directory of the project another time though -- ie from /modules/foobar, not any deeper.

Committed: #683480 by luketsimmons, Agileware: Fixed filefield processing to work with multivalued fields.

luketsimmons’s picture

Hi joachim,

OK cool, no worries about the patching paths, I'm used to doing them more locally but it makes sense to roll them from base.

Thanks again,

Luke

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.