Fix/140/t250062/extrafields multicompany data loss (#34022)

* insertExtrafields(): simplify by returning 0 early if array_options is empty

* insertExtrafields(): simplify by using local variables $newValue and $attributeType

* insertExtrafields(): refactor by grouping the empty value cases for geodatabase-type extrafields

* insertExtrafields(): refactor by using a static mapping of geodata types to their ST_* db function on ExtraField class

* FIX: when an object that is shared across multiple entities already has some extrafields from another entity that are not reachable from the current entity, their values are lost

* Compliance with
- phan ( Closure Closure($key) has no declared or inferred parameter type for $key)
- php-stan (Error: Property ExtraFields::$geoDataTypes has no type specified)
This commit is contained in:
Florian Mortgat
2025-05-04 18:42:01 +02:00
committed by GitHub
parent 8bec4db5e5
commit 9d0d8f7ec5
2 changed files with 290 additions and 301 deletions

View File

@@ -107,6 +107,26 @@ class ExtraFields
'stars' => 'ExtrafieldStars',
);
/** @var array<string,array<string,string>> $geoDataTypes */
public static $geoDataTypes = array(
'point' => array(
'ST_Function' => 'ST_PointFromText',
'shortname' => 'point'
),
'multipts' => array(
'ST_Function' => 'ST_MultiPointFromText',
'shortname' => 'multipoint'
),
'linestrg' => array(
'ST_Function' => 'ST_LineFromText',
'shortname' => 'line'
),
'polygon' => array(
'ST_Function' => 'ST_PolyFromText',
'shortname' => 'polygon'
)
);
/**
* Constructor
*