Fix for backward compatibility of IndexDocumentBundle::isType() with old letter code format
Fix for backward compatibility of IndexDocumentBundle::isType() with old letter code format
Signed-off-by: Chris Pollett <chris@pollett.org>
diff --git a/src/library/IndexDocumentBundle.php b/src/library/IndexDocumentBundle.php
index 21668fa12..42661a6b6 100644
--- a/src/library/IndexDocumentBundle.php
+++ b/src/library/IndexDocumentBundle.php
@@ -1214,6 +1214,21 @@ class IndexDocumentBundle implements CrawlConstants
56 => "text",
64 => "video",
];
+ /**
+ * This map is maintained for backward compatibility, i.e., for the $key values
+ * using the previous letter code format.
+ */
+ $old_type_map = [
+ "b" => "binary",
+ "d" => "old_doc",
+ "e" => "external_link",
+ "f" => "feed",
+ "i" => "internal_link",
+ "l" => "old_link",
+ "p" => "image",
+ "t" => "text",
+ "v" => "video",
+ ];
if (is_string($types)) {
$types = [$types];
}
@@ -1224,8 +1239,14 @@ class IndexDocumentBundle implements CrawlConstants
$types = array_merge($types, ["binary", "feed", "image",
"old_doc", "text", "video"]);
}
- $key_type = ord($key[self::DOCID_PART_LEN << 1] ?? 0) & 120;
- return in_array($type_map[$key_type] ?? "old_link", $types);
+ $doc_id_format = ord($key[self::DOCID_PART_LEN << 1] ?? 0) & 96;
+ if ($doc_id_format != 96) {
+ $key_type = ord($key[self::DOCID_PART_LEN << 1] ?? 0) & 120;
+ return in_array($type_map[$key_type] ?? "old_link", $types);
+ }
+ // $key uses the old letter code format
+ $key_type = chr(ord($key[self::DOCID_PART_LEN << 1] ?? 0) & 127);
+ return in_array($old_type_map[$key_type] ?? "old_link", $types);
}
/**
* As pre-step to calculating the inverted index information for a partition