Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I think this code inside of cck_private_fields_nodeapi() is broken. If you enable private fields, set a field to "Hidden by default", and then later go and change the field to "Private by default" the information never gets updated in the {cck_private_fields} table.
The problem is hook_nodeapi('load') loads information from {cck_private_fields} in to the node object, then hook_nodeapi('update') deletes the information from the table and cascades in to 'insert' which then just saves the same information that was just deleted back to the table.
case 'update':
if (!empty($node->cck_private_fields) && is_array($node->cck_private_fields)) {
db_query("DELETE FROM {cck_private_fields} WHERE vid = %d", $node->vid);
}
// Fallback to 'insert' case is intentional.
case 'insert':
if (!empty($node->cck_private_fields) && is_array($node->cck_private_fields)) {
module_load_include('inc', 'cck_private_fields', 'includes/common');
$private_fields = cck_private_fields_get_content_private_fields($node->type);
foreach ($private_fields as $field_name => $privacy_status) {
if ($private_fields[$field_name] !== FALSE) {
db_query("INSERT INTO {cck_private_fields} (nid, vid, content_type, field_name, privacy_status) VALUES (%d, %d, '%s', '%s', %d)", array(
$node->nid, $node->vid, $node->type, $field_name, $privacy_status
));
}
}
}
break;
Path to follow shortly.
Comment | File | Size | Author |
---|---|---|---|
#1 | cck_private_fields-eojthebrave-904864-2-privacy_status_not_saved_on_update.patch | 853 bytes | eojthebrave |
Comments
Comment #1
eojthebraveThis fixes the problem for me.
Comment #2
memoo CreditAttribution: memoo commentedThe patch did not work for me. I can change the privacy options, but they are no stored when saved; it jumps back to the initial option.
Is there another way to get this working?