[Mapbender-commits] r9663 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun Jan 22 08:24:46 PST 2017


Author: armin11
Date: 2017-01-22 08:24:46 -0800 (Sun, 22 Jan 2017)
New Revision: 9663

Modified:
   trunk/mapbender/http/classes/class_syncCkan.php
Log:
Bugfix

Modified: trunk/mapbender/http/classes/class_syncCkan.php
===================================================================
--- trunk/mapbender/http/classes/class_syncCkan.php	2017-01-18 16:24:01 UTC (rev 9662)
+++ trunk/mapbender/http/classes/class_syncCkan.php	2017-01-22 16:24:46 UTC (rev 9663)
@@ -58,31 +58,31 @@
 	$this->compareTimestamps = false; //default to update each dataset, because the ckan index for metadata_modified may not be up to date !!!
     }
 
-   //TODO: Following function is only needed til php 5.5 - after upgrade to debian 8 it is obsolet - see also class_iso19139.php!
-   public function array_column(array $input, $columnKey, $indexKey = null) {
-        $array = array();
-        foreach ($input as $value) {
-            if ( !array_key_exists($columnKey, $value)) {
-                trigger_error("Key \"$columnKey\" does not exist in array");
-                return false;
-            }
-            if (is_null($indexKey)) {
-                $array[] = $value[$columnKey];
-            }
-            else {
-                if ( !array_key_exists($indexKey, $value)) {
-                    trigger_error("Key \"$indexKey\" does not exist in array");
-                    return false;
-                }
-                if ( ! is_scalar($value[$indexKey])) {
-                    trigger_error("Key \"$indexKey\" does not contain scalar value");
-                    return false;
-                }
-                $array[$value[$indexKey]] = $value[$columnKey];
-            }
-        }
-        return $array;
-    }
+    //TODO: Following function is only needed til php 5.5 - after upgrade to debian 8 it is obsolet - see also class_iso19139.php!
+    public function array_column(array $input, $columnKey, $indexKey = null) {
+         $array = array();
+         foreach ($input as $value) {
+             if ( !array_key_exists($columnKey, $value)) {
+                 trigger_error("Key \"$columnKey\" does not exist in array");
+                 return false;
+             }
+             if (is_null($indexKey)) {
+                 $array[] = $value[$columnKey];
+             }
+             else {
+                 if ( !array_key_exists($indexKey, $value)) {
+                     trigger_error("Key \"$indexKey\" does not exist in array");
+                     return false;
+                 }
+                 if ( ! is_scalar($value[$indexKey])) {
+                     trigger_error("Key \"$indexKey\" does not contain scalar value");
+                     return false;
+                 }
+                 $array[$value[$indexKey]] = $value[$columnKey];
+             }
+         }
+         return $array;
+     }
 
     public function getMapbenderOrganizations() {
         if (isset($this->mapbenderUserId) && (integer)$this->mapbenderUserId > 0) {
@@ -246,11 +246,12 @@
                             //build diffs for ckan and geoportal
                             //Arrays: ckanPackageNames / geoportalUuids
                             //Those which are only in ckan: delete them
-                            $onlyInCkan = array_diff($ckanPackageNames, $geoportalUuids);
+                            $onlyInCkan = array_values(array_diff($ckanPackageNames, $geoportalUuids));
                             //Those which are only in geoportal: create them
-                            $onlyInGeoportal = array_diff($geoportalUuids, $ckanPackageNames);
+                            $onlyInGeoportal = array_values(array_diff($geoportalUuids, $ckanPackageNames));
                             //Those which are in both - update them if geoportal metadata is newer than the package in ckan
-                            $inBoth = array_intersect($ckanPackageNames, $geoportalUuids);
+				
+                            $inBoth = array_values(array_intersect($ckanPackageNames, $geoportalUuids));
                             //if the timestamps should be compared before
                             if ($this->compareTimestamps == true) { 
                                 foreach ($inBoth as $uuid) {
@@ -260,13 +261,16 @@
                                     if ($dateTimeCkan > $dateTimeGeoportal) {
                                         //delete from $inBoth!
                                         $e = new mb_notice("classes/class_syncCkan.php: Ckans package newer than geoportals metadata!");
-                                        $inBoth = array_diff($inBoth, [$uuid]);
+                                        $inBoth = array_values(array_diff($inBoth, [$uuid]));
                                     } else {
                                         $e = new mb_notice("classes/class_syncCkan.php: Ckans package older than geoportals metadata!");
                                     }
                                 }
                             }
                             //$e = new mb_exception("Number of packages which are only in ckan: ".count($onlyInCkan)." - number of packages which are only in geoportal: ".count($onlyInGeoportal)." - number of packages which are in both catalogues: ".count($inBoth));
+			    //$e = new mb_exception("both: ".gettype($inBoth)." number: ".count($inBoth)." json: ".json_encode($inBoth));
+		            //$e = new mb_exception("only ckan: ".gettype($onlyInCkan)." number: ".count($onlyInCkan)." json: ".json_encode($onlyInCkan));
+                            //$e = new mb_exception("only geoportal: ".gettype($onlyInGeoportal)." number: ".count($onlyInGeoportal)." json: ".json_encode($onlyInGeoportal));
                             $syncListResult->geoportal_organization[$numberGeoportalOrga]->update = $inBoth;
                             $syncListResult->geoportal_organization[$numberGeoportalOrga]->delete = $onlyInCkan;
                             $syncListResult->geoportal_organization[$numberGeoportalOrga]->create = $onlyInGeoportal;



More information about the Mapbender_commits mailing list