Try to resolve an issue where IndexDocumentBundles were sotring cound in duplicate locations that would get out of sync 3, a=chris

Chris Pollett [2022-08-14 03:Aug:th]
Try to resolve an issue where IndexDocumentBundles were sotring cound in duplicate locations that would get out of sync 3, a=chris
Filename
src/library/IndexDocumentBundle.php
diff --git a/src/library/IndexDocumentBundle.php b/src/library/IndexDocumentBundle.php
index 6a093ce13..875bf8277 100644
--- a/src/library/IndexDocumentBundle.php
+++ b/src/library/IndexDocumentBundle.php
@@ -1538,24 +1538,39 @@ class IndexDocumentBundle implements CrawlConstants
             $info = [];
         }
         $pdb_info = [];
+        $got_pdb_info = false;
         if (!empty($info)) {
             $doc_folder =  $dir_name. "/" . self::DOCUMENTS_FOLDER;
             if (file_exists($doc_folder)) {
                 $pdb_info = PartitionDocumentBundle::getParameterInfo(
                     $doc_folder);
+                if (!empty($pdb_info)) {
+                    $got_pdb_info = true;
+                }
                 // avoid getting same data (_COUNTS) stored in two locations
                 if (!empty($info) && !empty($pdb_info)) {
                     $info = array_diff_key($info, $pdb_info);
                 }
             }
         }
+        $pdb_change = false;
         foreach ($update_info as $field => $value) {
+            if (isset($pdb_info[$field])) {
+                $pdb_info[$field] = $value;
+                $pdb_change = true;
+            }
             $info[$field] = $value;
         }
         if (empty($info["VERSION"])) {
             $info["VERSION"] = self::DEFAULT_VERSION;
         }
         file_put_contents($archive_info_path, serialize($info));
+        if ($got_pdb_info && $pdb_change) {
+            $parameter_path = $doc_folder . "/" .
+                PartitionDocumentBundle::PARAMETERS_FILE;
+            file_put_contents($parameter_path, serialize($pdb_info),
+                LOCK_EX);
+        }
     }
     /**
      * Returns the last time the archive info of the bundle was modified.
ViewGit