From c0b77dabe02c5108600f06ff0b15d7f8d481d541 Mon Sep 17 00:00:00 2001 From: bear Date: Sun, 8 Nov 2026 14:40:17 +0100 Subject: [PATCH] Remove incorrect assert() in _lcsPos() On PHP 8 assert() throws AssertionError in production, aborting diff rendering. The condition can legitimately be true when the text has repeated lines; the code right below already handles that case, so the assertion is simply wrong. The assert originates from the original Algorithm::Diff port; the Perl original has no such check. --- lib/Horde/Text/Diff/Engine/Native.php | 2 -- src/NativeEngine.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/Horde/Text/Diff/Engine/Native.php b/lib/Horde/Text/Diff/Engine/Native.php index bcfb326..304bbf7 100644 --- a/lib/Horde/Text/Diff/Engine/Native.php +++ b/lib/Horde/Text/Diff/Engine/Native.php @@ -288,8 +288,6 @@ protected function _lcsPos($ypos) } } - assert($ypos != $this->seq[$end]); - $this->in_seq[$this->seq[$end]] = false; $this->seq[$end] = $ypos; $this->in_seq[$ypos] = 1; diff --git a/src/NativeEngine.php b/src/NativeEngine.php index 4fa8241..f4b6af9 100644 --- a/src/NativeEngine.php +++ b/src/NativeEngine.php @@ -309,8 +309,6 @@ protected function _lcsPos($ypos) } } - assert($ypos != $this->seq[$end]); - $this->in_seq[$this->seq[$end]] = false; $this->seq[$end] = $ypos; $this->in_seq[$ypos] = 1;