[mapguide-commits] r10248 - branches/4.0/MgDev/Bindings/src/Test/Php
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon Nov 2 17:57:19 PST 2026
Author: jng
Date: 2026-11-02 17:57:18 -0800 (Mon, 02 Nov 2026)
New Revision: 10248
Modified:
branches/4.0/MgDev/Bindings/src/Test/Php/Validate.php
branches/4.0/MgDev/Bindings/src/Test/Php/ValidateUtils.php
Log:
#2494: Fix DWF content comparison on Linux
Modified: branches/4.0/MgDev/Bindings/src/Test/Php/Validate.php
===================================================================
--- branches/4.0/MgDev/Bindings/src/Test/Php/Validate.php 2026-11-03 01:40:22 UTC (rev 10247)
+++ branches/4.0/MgDev/Bindings/src/Test/Php/Validate.php 2026-11-03 01:57:18 UTC (rev 10248)
@@ -140,6 +140,9 @@
if ($_POST['testExecutionMode'] == "validate")
{
+ //A stored drawing baseline may predate the current DWF normalization, so apply it here too
+ $expectedResult = ValidateUtils::NormalizeDwfResult($operation, $expectedResult);
+
//Normalize line endings so comparisons don't fall over due to incorrect line endings when expected results were entered in SQLite GUI
$normResultData = str_replace("\r\n", "\n", $resultData);
$normExpectedResult = str_replace("\r\n", "\n", $expectedResult);
@@ -343,6 +346,9 @@
if ($_POST['testExecutionMode'] == "validate")
{
+ //A stored drawing baseline may predate the current DWF normalization, so apply it here too
+ $expectedResult = ValidateUtils::NormalizeDwfResult($operation, $expectedResult);
+
//Normalize line endings. Don't want stray CRLFs derailing verification
$resultData = str_replace("\r\n", "\n", $resultData);
$expectedResult = str_replace("\r\n", "\n", $expectedResult);
Modified: branches/4.0/MgDev/Bindings/src/Test/Php/ValidateUtils.php
===================================================================
--- branches/4.0/MgDev/Bindings/src/Test/Php/ValidateUtils.php 2026-11-03 01:40:22 UTC (rev 10247)
+++ branches/4.0/MgDev/Bindings/src/Test/Php/ValidateUtils.php 2026-11-03 01:57:18 UTC (rev 10248)
@@ -134,7 +134,34 @@
public static function RemoveDwfSectionName($actualResult)
{
- $newResult = substr($actualResult, strpos($actualResult, ".w2d"));
+ //A drawing operation returns a DWF package, which is a zip: the section entry's name ends in
+ //".w2d" and what follows is that entry's raw deflate data. When the data was written as a
+ //single stored block its header carries the uncompressed size and the one's complement of
+ //that size, so the packaging rather than the section would be compared. The W2D end marker
+ //is written with WD_NEWLINE, which is "\r\n" only when built with MSVC, so the same section
+ //is one byte shorter on Linux and the size fields of every stored block differ. Keep the
+ //stream payload only; the result is already in this form when it comes back from a baseline.
+ $start = strpos($actualResult, ".w2d");
+ if (false === $start)
+ {
+ return $actualResult;
+ }
+
+ $newResult = substr($actualResult, $start + strlen(".w2d"));
+ if (strlen($newResult) >= 5)
+ {
+ $blockHeader = ord($newResult[0]);
+ $blockLength = ord($newResult[1]) | (ord($newResult[2]) << 8);
+ $blockNotLength = ord($newResult[3]) | (ord($newResult[4]) << 8);
+
+ //BFINAL set and BTYPE == 00 (stored) with LEN and NLEN consistent: the header is 1 byte
+ //plus the two sizes, so decode the block by dropping it
+ if ((0x01 == ($blockHeader & 0x07)) && (0xFFFF == (($blockLength ^ $blockNotLength) & 0xFFFF)))
+ {
+ $newResult = substr($newResult, 5);
+ }
+ }
+
if (0!=strpos($newResult, "EndOfDWF"))
{
$newResult = substr($newResult, 0, strpos($newResult, "EndOfDWF"));
@@ -142,6 +169,18 @@
return $newResult;
}
+ //A drawing result is normalized before a baseline is stored, but a baseline written by an older
+ //version of this script still carries the DWF zip framing, so the normalization is applied to a
+ //stored result as well. It is idempotent: an already normalized result has no ".w2d" to find.
+ public static function NormalizeDwfResult($operation, $resultData)
+ {
+ if (("GETDRAWINGLAYER" == $operation) || ("GETDRAWINGSECTION" == $operation))
+ {
+ return self::RemoveDwfSectionName($resultData);
+ }
+ return $resultData;
+ }
+
public static function StripFdoVersionFromProvider($actualResult)
{
$start = strpos($actualResult, "<ProviderName>");
More information about the mapguide-commits
mailing list