dolibarr 25.0.0-alpha
filecheck_diff.php File Reference

Ajax fragment to show the diff of a modified file against its original version. More...

Go to the source code of this file.

Functions

if(!in_array( $algo, array( 'md5', 'sha256'), true)) filecheckLineDiff ($a, $b)
 Compute a line based diff between two arrays of lines, restricted to the changed region (common prefix and suffix are trimmed first to keep it cheap and memory safe).
 
 filecheckMiddleDiff ($a, $b)
 Diff of the changed region.
 
 filecheckFindAnchor ($a, $b)
 Find a line that appears exactly once in both arrays (a unique common "anchor"), choosing the candidate closest to the middle of $a to balance the recursion.
 
 filecheckLcs ($a, $b)
 Diff of two small arrays of lines using a classic LCS dynamic programming matrix.
 
 filecheckCollapseContext ($diff, $context=3)
 Collapse long runs of unchanged context lines, keeping a few lines around each change.
 
 llxFooterFragment ()
 Close the fragment output and stop the script.
 

Detailed Description

Ajax fragment to show the diff of a modified file against its original version.

Definition in file filecheck_diff.php.

Function Documentation

◆ filecheckCollapseContext()

filecheckCollapseContext ( $diff,
$context = 3 )

Collapse long runs of unchanged context lines, keeping a few lines around each change.

Parameters
array<array{0:string,1:string}>$diff Full diff as returned by filecheckLineDiff()
int$contextNumber of context lines to keep around changes
Returns
array<array{0:string,1:string}> Diff with collapsed context (type '@' marks a collapsed gap)

Definition at line 261 of file filecheck_diff.php.

References $context.

◆ filecheckFindAnchor()

filecheckFindAnchor ( $a,
$b )

Find a line that appears exactly once in both arrays (a unique common "anchor"), choosing the candidate closest to the middle of $a to balance the recursion.

Parameters
string[]$aLines
string[]$bLines
Returns
?array{0:int,1:int} [index in $a, index in $b] of the anchor, or null if none found

Definition at line 169 of file filecheck_diff.php.

Referenced by filecheckMiddleDiff().

◆ filecheckLcs()

filecheckLcs ( $a,
$b )

Diff of two small arrays of lines using a classic LCS dynamic programming matrix.

Parameters
string[]$aLines of the original file
string[]$bLines of the local file
Returns
array<array{0:string,1:string}> List of [type, line]

Definition at line 205 of file filecheck_diff.php.

Referenced by filecheckMiddleDiff().

◆ filecheckLineDiff()

if(!in_array($algo, array('md5', 'sha256'), true)) filecheckLineDiff ( $a,
$b )

Compute a line based diff between two arrays of lines, restricted to the changed region (common prefix and suffix are trimmed first to keep it cheap and memory safe).

Parameters
string[]$aLines of the original file
string[]$bLines of the local file
Returns
array<array{0:string,1:string}> List of [type, line] where type is ' ' (context), '-' (removed) or '+' (added)

Definition at line 71 of file filecheck_diff.php.

References filecheckMiddleDiff().

◆ filecheckMiddleDiff()

filecheckMiddleDiff ( $a,
$b )

Diff of the changed region.

For large regions, the region is recursively split on unique common lines (anchors, patience-diff style) so the expensive LCS only runs on small segments. This keeps small changes detected instead of one big block.

Parameters
string[]$aChanged lines of the original file
string[]$bChanged lines of the local file
Returns
array<array{0:string,1:string}> List of [type, line]

Definition at line 117 of file filecheck_diff.php.

References filecheckFindAnchor(), filecheckLcs(), and filecheckMiddleDiff().

Referenced by filecheckLineDiff(), and filecheckMiddleDiff().

◆ llxFooterFragment()

llxFooterFragment ( )

Close the fragment output and stop the script.

Returns
never

Definition at line 391 of file filecheck_diff.php.

References $db.