Diff doesn't detect Geshi CCK field changes. I tested it with Geshi 6.x-1.3.

Comments

abaddon’s picture

Project: Diff » GeSHi Filter for syntax highlighting
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: Miscellaneous » Code
Category: feature » bug
Status: Active » Needs review
StatusFileSize
new1023 bytes

this should be in geshi's issue queue, cck provides a hook for cck fields to provide diff data
ive attached a patch to fix this, patch is against the current HEAD

also, for geshinode, im not using it now but i suspect diff is already working (picking up changes in the _node body_)

soxofaan’s picture

Category: bug » feature

Is there any documentation on this hook hook_content_diff_values?
I googled a bit, but didn't find a lot of info about it

(didn't try the patch yet)

abaddon’s picture

not sure, i got there by looking at some old cck archive i had which did things differently, and looking the the most recent stable version, and..
in cck/includes/content.diff.inc line 25:

      $function = $field_types[$field['type']]['module'] . '_content_diff_values';
      $function = function_exists($function) ? $function : 'content_content_diff_values';

see the changelog too
cck/CHANGELOG.txt:164:- Diff integration: refactored around a new hook_content_diff_values() to save contrib field modules the........

and theres some example implementations in that diff.inc, also filefield implements the "hook"

soxofaan’s picture

Status: Needs review » Needs work

(disclaimer: at the moment I don't have a development environment handy, so this is just from reading code)

In the patch of #1, you use the t() function, while I didn't found this in any other implementation of hook_content_diff_values. Also, you put all the source code in one array item, while node_diff (from diff/node.inc) and content_content_diff_values (from cck/includes/content.diff.inc) explode the bodies on newlines.

As a second iteration, I'd propose something like (again, I didn't test this code):

function geshifield_content_diff_values($node, $field, $items) {
  $result = array();
  foreach ($items as $item) {
    if (isset($item['sourcecode']) && isset($item['language']) {
      $result[] = t('[Language: !language]', array('!language' => $item['language']));
      foreach (explode("\n", $item['sourcecode']) as $i) {
        $result[] = $i;
      }
    }
  }
  return $result;
}
abaddon’s picture

StatusFileSize
new1.01 KB

Stefaan, thank you for taking your time and looking at this

you are right about #2, lines should be exploded on newlines, i didnt payed attention to the fact that all my diffed content was highlighted because the actual differences were in red and it looked ok overall

#1 - the use of t(), i think its good coding practice, and harmless, to provide the user the ability to translate the label, without t() it wont be translatable, i dont think it has any side effects

ive tested your patch and it works fine, ive re-rolled it unmodified (just fixed a typo) and attached

soxofaan’s picture

Title: Diff doesnt detect Geshi CCK field's changes » support for diff'ing revisions
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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