From a0a20f293b373e7ae179ae85e349bc67ef24aa5a Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Fri, 6 Dec 2024 20:37:05 +0100
Subject: [PATCH 01/12] style: clean up code

---
 core/base/upgrade/class.transform_data.php    | 20 ++++++++-----------
 .../js/component_text_area.js                 | 14 +++++++++----
 .../js/render_edit_component_text_area.js     |  2 +-
 .../service_ckeditor/js/service_ckeditor.js   |  1 -
 core/unit_test/js/list.js                     |  1 +
 5 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/core/base/upgrade/class.transform_data.php b/core/base/upgrade/class.transform_data.php
index ce8039427c..172eb02d9a 100644
--- a/core/base/upgrade/class.transform_data.php
+++ b/core/base/upgrade/class.transform_data.php
@@ -709,9 +709,8 @@ public static function add_view_in_thesaurus(?object $datos) {
 						$datos->section_tipo
 					);
 
-					$compnent_data = $component_view_in_ts->get_dato();
-
-					if(!empty($compnent_data)){
+					$component_data = $component_view_in_ts->get_dato();
+					if(!empty($component_data)){
 						return null;
 					}
 
@@ -891,7 +890,6 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo, $skip_
 						return;
 					}
 
-
 					// datos properties
 					foreach ($datos as $datos_key => $datos_value) {
 
@@ -1500,11 +1498,11 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 						$options->ar_transform_map	= $ar_transform_map;
 						$options->datos				= $dato;
 
-					$procesed_data = ( !empty($dato) )
+					$processed_data = ( !empty($dato) )
 						? transform_data::process_locators_in_section_data( $options )
 						: null;
 
-					$section_data_encoded = json_encode($procesed_data);
+					$section_data_encoded = json_encode($processed_data);
 
 					$new_tipo = $ar_transform_map[$tipo]->new;
 
@@ -1627,11 +1625,11 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 						$options->ar_transform_map	= $ar_transform_map;
 						$options->datos				= $datos;
 
-					$procesed_data = ( !empty($datos) )
+					$processed_data = ( !empty($datos) )
 						? transform_data::process_locators_in_section_data( $options )
 						: null;
 
-					$section_data_encoded = json_encode($procesed_data);
+					$section_data_encoded = json_encode($processed_data);
 
 					$strQuery	= "UPDATE $table SET datos = $1 WHERE id = $2 ";
 					$result		= pg_query_params(DBi::_getConnection(), $strQuery, array( $section_data_encoded, $id ));
@@ -1808,7 +1806,6 @@ public static function process_locators_in_section_data( object $options ) : obj
 							$datos->section_id	= (int)$new_section_id;
 						}
 					}
-
 					break;
 			}
 		}//end foreach ($datos as $datos_key => $datos_value)
@@ -1957,7 +1954,7 @@ public static function set_move_identification_value( object $options ) : object
 		switch ($action) {
 			case 'new_only_once':
 				// used to create new section as 'Typology' or other portal
-				// and set a component data inside new section with the specifyed values
+				// and set a component data inside new section with the specified values
 				// values could be a literal with translations or a related data.
 
 				// set a cache with the locator created
@@ -2019,11 +2016,10 @@ public static function set_move_identification_value( object $options ) : object
 
 				// add new locator to datos
 				$datos->relations[] = $locator;
-
 				break;
 
 			default:
-				// doesn't used rigth now.
+				// doesn't used right now.
 				break;
 		}
 
diff --git a/core/component_text_area/js/component_text_area.js b/core/component_text_area/js/component_text_area.js
index e53cb6e88a..b166a8b01f 100644
--- a/core/component_text_area/js/component_text_area.js
+++ b/core/component_text_area/js/component_text_area.js
@@ -1293,14 +1293,20 @@ component_text_area.prototype.add_component_history_note = async function(option
 /**
 * BUILD_TAG
 * Build a new annotation when user clicks on text editor button
-*
+* @param object options
+* {
+* 	caller: object (component_text_area_instance),
+* 	text_editor: object (service_ckedito instance)
+* }
 * @return
 */
 component_text_area.prototype.build_tag = function(options) {
 
-	const self = options.caller
-	// get the text_editor sent by the event (button_note event)
-	const text_editor = options.text_editor
+	// options
+		// component_text_area instance
+		const self = options.caller
+		// get the text_editor sent by the event (button_note event)
+		const text_editor = options.text_editor
 
 	const susbscriptors_responses			= event_manager.publish('key_up_f2' +'_'+ self.id_base, 'F2')
 	const susbscriptors_responses_length	= susbscriptors_responses.length
diff --git a/core/component_text_area/js/render_edit_component_text_area.js b/core/component_text_area/js/render_edit_component_text_area.js
index 8c5b6f78eb..6972f442e4 100644
--- a/core/component_text_area/js/render_edit_component_text_area.js
+++ b/core/component_text_area/js/render_edit_component_text_area.js
@@ -13,7 +13,7 @@
 
 
 /**
-* RENDER_EDIT_COMPONENT_text_area
+* RENDER_EDIT_COMPONENT_TEXT_AREA
 * Manage the components logic and appearance in client side
 */
 export const render_edit_component_text_area = function() {
diff --git a/core/services/service_ckeditor/js/service_ckeditor.js b/core/services/service_ckeditor/js/service_ckeditor.js
index f840903521..b1e8a5fbd2 100644
--- a/core/services/service_ckeditor/js/service_ckeditor.js
+++ b/core/services/service_ckeditor/js/service_ckeditor.js
@@ -678,7 +678,6 @@ export const service_ckeditor = function() {
 
 		// keyup event
 			editor.editing.view.document.on('keydown', function(evt, data ) {
-
 				if (custom_events.KeyUp) {
 					custom_events.KeyUp(data.domEvent, {})
 				}
diff --git a/core/unit_test/js/list.js b/core/unit_test/js/list.js
index 70edbb6b4d..a26ca67bbd 100644
--- a/core/unit_test/js/list.js
+++ b/core/unit_test/js/list.js
@@ -17,6 +17,7 @@ import {elements} from './elements.js'
 		'test_components_data_changes',
 		'test_components_activate',
 		'test_components_render',
+		'test_component_text_area',
 		'test_no_logged_error',
 		'test_unknown_error',
 		'test_page',

From 205d0af97ca69866bf135108270d93e850b50584 Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Sun, 8 Dec 2024 19:20:12 +0100
Subject: [PATCH 02/12] style: clean up code

---
 core/api/v1/common/class.dd_utils_api.php     |  2 +-
 core/area/class.area.php                      | 22 ++++++-------
 core/area_graph/area_graph_json.php           |  6 ++--
 core/area_graph/class.area_graph.php          |  2 +-
 .../class.area_maintenance.php                |  8 ++---
 core/base/upgrade/class.transform_data.php    | 31 ++++++++++---------
 6 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/core/api/v1/common/class.dd_utils_api.php b/core/api/v1/common/class.dd_utils_api.php
index 543443f0f3..a3949a4d3b 100644
--- a/core/api/v1/common/class.dd_utils_api.php
+++ b/core/api/v1/common/class.dd_utils_api.php
@@ -1376,7 +1376,7 @@ public static function get_process_status(object $rqo) {
 			header("Cache-Control: no-cache, must-revalidate");
 			header('Connection: keep-alive');
 			header("Access-Control-Allow-Origin: *");
-			header('X-Accel-Buffering: no'); // nginex buffer control
+			header('X-Accel-Buffering: no'); // nginx buffer control
 
 		// mandatory vars
 			if (empty($pfile) || empty($pid)) {
diff --git a/core/area/class.area.php b/core/area/class.area.php
index c845ea2922..1e4da27c47 100644
--- a/core/area/class.area.php
+++ b/core/area/class.area.php
@@ -169,15 +169,15 @@ protected static function get_ar_children_areas_recursive(string $terminoID) : a
 
 		// short vars
 		$RecordObj_dd			= new RecordObj_dd($terminoID);
-		$ar_ts_childrens		= $RecordObj_dd->get_ar_childrens_of_this();
-		$ar_ts_childrens_size	= sizeof($ar_ts_childrens);
+		$ar_ts_children			= $RecordObj_dd->get_ar_childrens_of_this();
+		$ar_ts_children_size	= sizeof($ar_ts_children);
 
-		if ($ar_ts_childrens_size>0) {
+		if ($ar_ts_children_size>0) {
 
-			// foreach ($ar_ts_childrens as $children_terminoID) {
-			for ($i=0; $i < $ar_ts_childrens_size; $i++) {
+			// foreach ($ar_ts_children as $children_terminoID) {
+			for ($i=0; $i < $ar_ts_children_size; $i++) {
 
-				$children_terminoID = $ar_ts_childrens[$i];
+				$children_terminoID = $ar_ts_children[$i];
 
 				$RecordObj_dd	= new RecordObj_dd($children_terminoID);
 				$model			= RecordObj_dd::get_modelo_name_by_tipo($children_terminoID,true);
@@ -196,7 +196,7 @@ protected static function get_ar_children_areas_recursive(string $terminoID) : a
 					$ar_temp = self::get_ar_children_areas_recursive($children_terminoID);
 					$ar_children_areas_recursive = array_merge($ar_children_areas_recursive, $ar_temp);
 				}
-			}//end for ($i=0; $i < $ar_ts_childrens_size; $i++)
+			}//end for ($i=0; $i < $ar_ts_children_size; $i++)
 		}
 
 
@@ -214,7 +214,7 @@ protected static function get_ar_children_areas_recursive(string $terminoID) : a
 	public static function get_config_areas() : object {
 
 		// non existing config_areas.php file case
-			if( !include(DEDALO_CONFIG_PATH . '/config_areas.php') ) {
+			if( !include DEDALO_CONFIG_PATH . '/config_areas.php' ) {
 
 				debug_log(__METHOD__
 					." ERROR ON LOAD FILE config4_areas . Using empty values as default "
@@ -222,11 +222,11 @@ public static function get_config_areas() : object {
 				);
 
 				if(SHOW_DEBUG===true) {
-					throw new Exception("Error Processing Request. config4_areas file not found", 1);;
+					throw new Exception("Error Processing Request. config4_areas file not found", 1);
 				}
 
-				$areas_deny		= array();
-				$areas_allow	= array();
+				$areas_deny		= [];
+				$areas_allow	= [];
 			}
 
 		// config_areas object
diff --git a/core/area_graph/area_graph_json.php b/core/area_graph/area_graph_json.php
index ce0e375507..d11626c2f9 100644
--- a/core/area_graph/area_graph_json.php
+++ b/core/area_graph/area_graph_json.php
@@ -55,11 +55,11 @@
 			); // $this->get_data_items();
 
 		// typologies
-			$ar_tipologies_section_id	= [];
+			$ar_typologies_section_id	= [];
 			$ar_typologies				= [];
 			foreach ($hierarchy_sections as $hierarchy_data) {
-				if (!in_array($hierarchy_data->typology_section_id, $ar_tipologies_section_id)) {
-					$ar_tipologies_section_id[] = $hierarchy_data->typology_section_id;
+				if (!in_array($hierarchy_data->typology_section_id, $ar_typologies_section_id)) {
+					$ar_typologies_section_id[] = $hierarchy_data->typology_section_id;
 					$typology = new stdClass();
 						$typology->section_id	= $hierarchy_data->typology_section_id;
 						$typology->type			= 'typology';
diff --git a/core/area_graph/class.area_graph.php b/core/area_graph/class.area_graph.php
index 8567e17fa2..68b644b532 100644
--- a/core/area_graph/class.area_graph.php
+++ b/core/area_graph/class.area_graph.php
@@ -492,7 +492,7 @@ public function search_thesaurus(object $search_query_object) : object {
 		// debug
 			if(SHOW_DEBUG===true) {
 				$response->strQuery = $search_result->strQuery;
-				$response->debug[] = exec_time_unit($start_time);
+				$response->debug = [exec_time_unit($start_time)];
 			}
 
 
diff --git a/core/area_maintenance/class.area_maintenance.php b/core/area_maintenance/class.area_maintenance.php
index a48687df86..93e5d3f899 100644
--- a/core/area_maintenance/class.area_maintenance.php
+++ b/core/area_maintenance/class.area_maintenance.php
@@ -41,7 +41,7 @@ class area_maintenance extends area_common {
 	public function item_make_backup() : object {
 
 		// short vars
-			$mysql_db = (defined('API_WEB_USER_CODE_MULTIPLE') ? API_WEB_USER_CODE_MULTIPLE : null);
+			$mysql_db = defined('API_WEB_USER_CODE_MULTIPLE') ? API_WEB_USER_CODE_MULTIPLE : null;
 
 		// item
 			$item = new stdClass();
@@ -737,7 +737,6 @@ public static function regenerate_relations(object $options) : object {
 		// response
 			$response->result	= true;
 			$response->msg[0]	= 'OK. All data is propagated successfully'; // Override first message
-			$response->msg		= $response->msg; // array
 
 
 		return $response;
@@ -1327,8 +1326,8 @@ public static function update_code(object $options) : object {
 					: DEDALO_SOURCE_VERSION_LOCAL_DIR .'/'. pathinfo($file_name)['filename']; // like 'dedalo6_code' from 'dedalo6_code.zip'
 				$target		= DEDALO_ROOT_PATH;
 				$exclude	= ' --exclude="*/config*" --exclude="media" ';
-				$aditional 	= ''; // $is_preview===true ? ' --dry-run ' : '';
-				$command	= 'rsync -avui --no-owner --no-group --no-perms --progress '. $exclude . $aditional . $source.'/ ' . $target.'/';
+				$additional = ''; // $is_preview===true ? ' --dry-run ' : '';
+				$command	= 'rsync -avui --no-owner --no-group --no-perms --progress '. $exclude . $additional . $source.'/ ' . $target.'/';
 				$output		= shell_exec($command);
 				if ($output===null) {
 					$response->msg = 'Error. Request failed ['.__FUNCTION__.']. Error executing rsync command. source: '.$source;
@@ -1572,7 +1571,6 @@ private static function set_congif_auto(object $options) {
 				default:
 					$response->msg = 'Error. Invalid name';
 					return $response;
-					break;
 			}
 
 		// write_value check
diff --git a/core/base/upgrade/class.transform_data.php b/core/base/upgrade/class.transform_data.php
index 172eb02d9a..f4f628d141 100644
--- a/core/base/upgrade/class.transform_data.php
+++ b/core/base/upgrade/class.transform_data.php
@@ -1817,24 +1817,26 @@ public static function process_locators_in_section_data( object $options ) : obj
 
 	/**
 	* REPLACE_LOCATOR_IN_TM_DATA
-	* This function only accept locator data in tm machine.
+	* This function only accepts locator data in tm machine.
 	* Filter previously the tm_data to send only locator data.
-	*
-	* @param $options->ar_transform_map
+	* @param object $options-
 	* {
-	*	"rsc194": {
-	*		"old": "rsc194",
-	*		"new": "rsc197",
-	*		"type": "section",
-	*		"perform": [
-	*			"move_tld"
-	*		],
-	* 		"base_counter": 76
-	*		"info": "Old People section => New People under Study section"
+	* 	ar_transform_map: {
+	*		"rsc194": {
+	*			"old": "rsc194",
+	*			"new": "rsc197",
+	*			"type": "section",
+	*			"perform": [
+	*				"move_tld"
+	*			],
+	* 			"base_counter": 76
+	*			"info": "Old People section => New People under Study section"
 	*	}
-	* @return
+	* 	tm_value: array
+	* }
+	* @return array $tm_value
 	*/
-	public static function replace_locator_in_tm_data( object $options ) {
+	public static function replace_locator_in_tm_data( object $options ) : array {
 
 		$ar_transform_map	= $options->ar_transform_map;
 		$tm_value			= $options->tm_value;
@@ -1906,6 +1908,7 @@ public static function replace_locator_in_string( object $options ) : string {
 					);
 					continue;
 				}
+
 				// check if the locator has the old section_tipo reference
 				if( isset($ar_transform_map[$loc_value]) ){
 					// replace old tipo with the new one in any locator property

From 8519be9621931211b3fd5591758964cd56f1b5db Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Sun, 8 Dec 2024 19:21:21 +0100
Subject: [PATCH 03/12] change: add `max_execution_time` control to
 `dd_utils_api::get_process_status` to prevent stop the update of process
 status

---
 core/api/v1/common/class.dd_utils_api.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/api/v1/common/class.dd_utils_api.php b/core/api/v1/common/class.dd_utils_api.php
index a3949a4d3b..4598b3b470 100644
--- a/core/api/v1/common/class.dd_utils_api.php
+++ b/core/api/v1/common/class.dd_utils_api.php
@@ -1359,6 +1359,9 @@ public static function get_dedalo_files(object $rqo) : object {
 	public static function get_process_status(object $rqo) {
 		$start_time=start_time();
 
+		// max_execution_time
+			ini_set('max_execution_time', 36000); // seconds ( 3600 * 10 ) = 10 hours
+
 		// session unlock
 			session_write_close();
 

From be06b3872971f8e1a86456ab3b4e1c3d18b02fcc Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Sun, 8 Dec 2024 19:29:38 +0100
Subject: [PATCH 04/12] change: add control to locator key in
 `replace_locator_in_tm_data`

---
 core/base/upgrade/class.transform_data.php | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/core/base/upgrade/class.transform_data.php b/core/base/upgrade/class.transform_data.php
index f4f628d141..203139751e 100644
--- a/core/base/upgrade/class.transform_data.php
+++ b/core/base/upgrade/class.transform_data.php
@@ -1849,6 +1849,18 @@ public static function replace_locator_in_tm_data( object $options ) : array {
 
 			foreach ($current_locator as $loc_key => $current_value) {
 
+				if (!is_string($current_value) && !is_int($current_value)) {
+					debug_log(__METHOD__
+						. " Ignored non acceptable  " . PHP_EOL
+						. ' loc_key: ' . to_string($loc_key) . PHP_EOL
+						. ' current_value: ' . to_string($current_value) . PHP_EOL
+						. ' current_value type: ' . gettype($current_value) . PHP_EOL
+						. ' current_locator: ' . to_string($current_locator)
+						, logger::ERROR
+					);
+					continue;
+				}
+
 				if( isset($ar_transform_map[$current_value]) && $current_value === $ar_transform_map[$current_value]->old ){
 
 					$current_locator->$loc_key	= $ar_transform_map[$current_value]->new;

From 60d2ddab376eda2526136da74d9825963be00bef Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 10:02:22 +0100
Subject: [PATCH 05/12] fix: fix wrong class name from `area_maintenance` to
 `counter`

---
 core/base/update/updates.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/base/update/updates.php b/core/base/update/updates.php
index 7d2257ea78..decb84c769 100644
--- a/core/base/update/updates.php
+++ b/core/base/update/updates.php
@@ -106,7 +106,7 @@
 		// fix rsc197 counter
 			$script_obj = new stdClass();
 				$script_obj->info			= "Consolidate counter for People under study rsc197";
-				$script_obj->script_class	= "area_maintenance";
+				$script_obj->script_class	= "counter";
 				$script_obj->script_method	= "modify_counter";
 				$script_obj->script_vars	= [
 					'rsc197',
@@ -115,6 +115,7 @@
 			$updates->$v->run_scripts[] = $script_obj;
 
 
+
 $v=629; #####################################################################################
 $updates->$v = new stdClass();
 

From 74c170220229b97b5954656fb9a3e1f4d7a69cbc Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 10:04:59 +0100
Subject: [PATCH 06/12] change: disable `logger_backend_activity` temporally in
 `transform_data::changes_in_locators` (it's not necessary to log millions of
 changes in time machine and activity tables)

---
 core/base/upgrade/class.transform_data.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/core/base/upgrade/class.transform_data.php b/core/base/upgrade/class.transform_data.php
index 203139751e..64f2b8eec2 100644
--- a/core/base/upgrade/class.transform_data.php
+++ b/core/base/upgrade/class.transform_data.php
@@ -1349,6 +1349,9 @@ public static function copy_descriptors_to_jer_dd() : bool {
 	*/
 	public static function changes_in_locators(array $ar_tables, array $json_files) : bool {
 
+		// disable activity log
+			logger_backend_activity::$enable_log = false;
+
 		debug_log(__METHOD__ . PHP_EOL
 			. " ))))))))))))))))))))))))))))))))))))))))))))))))))))))) " . PHP_EOL
 			. " CONVERTING ... " . PHP_EOL
@@ -1710,6 +1713,9 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 			}//end anonymous function
 		);
 
+		// re-enable activity log
+			logger_backend_activity::$enable_log = true;
+
 
 		return true;
 	}//end changes_in_locators

From 0d72817569e31f507b0ecd8a705ba3a22fd445de Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 10:06:28 +0100
Subject: [PATCH 07/12] style: clean up code

---
 core/base/upgrade/class.transform_data.php | 35 ++++++++++++----------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/core/base/upgrade/class.transform_data.php b/core/base/upgrade/class.transform_data.php
index 64f2b8eec2..496451b01c 100644
--- a/core/base/upgrade/class.transform_data.php
+++ b/core/base/upgrade/class.transform_data.php
@@ -1344,7 +1344,16 @@ public static function copy_descriptors_to_jer_dd() : bool {
 	* counter for the new section: 87
 	* new section_id : 92
 	* @param array $ar_tables
+	* [
+	* 	'matrix_users',
+	*	'matrix_projects',
+	*	'matrix',
+	*	'matrix_list'...
+	* ]
 	* @param array $json_files
+	* [
+	*	"people_rsc194_to_rsc197.json", ..
+	* ]
 	* @return bool
 	*/
 	public static function changes_in_locators(array $ar_tables, array $json_files) : bool {
@@ -1352,6 +1361,7 @@ public static function changes_in_locators(array $ar_tables, array $json_files)
 		// disable activity log
 			logger_backend_activity::$enable_log = false;
 
+
 		debug_log(__METHOD__ . PHP_EOL
 			. " ))))))))))))))))))))))))))))))))))))))))))))))))))))))) " . PHP_EOL
 			. " CONVERTING ... " . PHP_EOL
@@ -1392,11 +1402,6 @@ public static function changes_in_locators(array $ar_tables, array $json_files)
 				return $el->old;
 			}, $ar_section_elements, []);
 
-			// ar_new_section_tipo without keys like ["rsc194"]
-			$ar_new_section_tipo = array_map(function($el){
-				return $el->new;
-			}, $ar_section_elements, []);
-
 		// counter of the new sections.
 			// counter will use as base section_id to add new section_id into the old section as:
 			// rsc197 counter = 8500
@@ -1447,15 +1452,15 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 						print_cli(common::$pdata);
 					}
 
-
 				// section_tipo. All tables has section_tipo
 				if( isset($section_tipo) && isset($ar_transform_map[$section_tipo]) ){
 
 					// new section_id
-						$base_section_id 	= $ar_transform_map[$section_tipo]->base_counter;
+						$base_section_id	= $ar_transform_map[$section_tipo]->base_counter;
 						$new_section_id		= (int)$section_id + (int)$base_section_id;
 
-					$new_section_tipo	= $ar_transform_map[$section_tipo]->new;
+					// new section tipo
+						$new_section_tipo = $ar_transform_map[$section_tipo]->new;
 
 					// add data to new section
 					// create data to identify the moved from previous records
@@ -1464,8 +1469,8 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 							$process = $ar_transform_map[$section_tipo]->add_data_to_new_section;
 							foreach ($process as $fn_object) {
 								$fn 		= $fn_object->fn;
-								$fn_class 	= explode("::", $fn)[0];
-								$fn_method 	= explode("::", $fn)[1];
+								$fn_class 	= explode('::', $fn)[0];
+								$fn_method 	= explode('::', $fn)[1];
 								// check method already exists
 									if(!method_exists($fn_class, $fn_method)) {
 										debug_log(__METHOD__
@@ -1528,8 +1533,8 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 					// in those case the change only is applied to this component
 					if ($table==='matrix_activity') {
 
-						$activity_data = $datos;
-						$old_activity_data = json_encode($activity_data);
+						$activity_data		= $datos;
+						$old_activity_data	= json_encode($activity_data);
 
 						//activity data is set into the dd551 component
 						$dd551_value = $datos->components->dd551->dato->{DEDALO_DATA_NOLAN} ?? null;
@@ -1607,7 +1612,6 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 
 							$strQuery	= "UPDATE $table SET datos = $1 WHERE id = $2 ";
 							$result		= pg_query_params(DBi::_getConnection(), $strQuery, array( $new_activity_data, $id ));
-
 							if($result===false) {
 								$msg = "Failed Update section_data ($table) $id";
 								debug_log(__METHOD__
@@ -1671,7 +1675,7 @@ function($row, $table, $max) use($ar_transform_map, $ar_old_section_tipo) { // c
 						$new_dato_encoded = json_encode( $new_tm_value );
 
 						//check if the data has been changed, if yes, save it.
-						if($old_dato_encoded !== $new_dato_encoded ){
+						if($old_dato_encoded !== $new_dato_encoded){
 							$strQuery	= "UPDATE $table SET dato = $1 WHERE id = $2 ";
 							$result		= pg_query_params(DBi::_getConnection(), $strQuery, array( $new_dato_encoded, $id ));
 							if($result===false) {
@@ -1897,7 +1901,7 @@ public static function replace_locator_in_string( object $options ) : string {
 
 		$string				= $options->string;
 		$ar_transform_map	= $options->ar_transform_map;
-		//get all locator in the middle of the string
+		// get all locator in the middle of the string
 		// locator is identified as:
 		// text	'data:{'section_tipo':'rsc194','section_id':'1'}:data' text
 		$regex = '/data:({.*?}):data/m';
@@ -1948,7 +1952,6 @@ public static function replace_locator_in_string( object $options ) : string {
 
 
 
-
 	/**
 	* SET_MOVE_IDENTIFICATION_VALUE
 	* Used to add a value to moved records

From 7f19df77f35a7b68977059456725cc0b884f5988 Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 10:08:07 +0100
Subject: [PATCH 08/12] change: add search previous saved typology for `People`
 to prevent duplicates when user apply this update more than once

---
 core/base/upgrade/class.transform_data.php | 110 +++++++++++++++------
 1 file changed, 78 insertions(+), 32 deletions(-)

diff --git a/core/base/upgrade/class.transform_data.php b/core/base/upgrade/class.transform_data.php
index 496451b01c..f98d943afe 100644
--- a/core/base/upgrade/class.transform_data.php
+++ b/core/base/upgrade/class.transform_data.php
@@ -1990,42 +1990,88 @@ public static function set_move_identification_value( object $options ) : object
 					$locator = $cache_set_move_identification_value[$cache_key];
 
 				}else{
-					// create new section to save new data
-					// new section will be the locator to add into the records
-					$new_section = section::get_instance(
-						null, // string|null section_id
-						$section_tipo // string section_tipo
-					);
-					$new_section_id = $new_section->Save();
-
-					// create new component with the specification
-					$component_model		= RecordObj_dd::get_modelo_name_by_tipo( $component_tipo );
-					// check if the component is a related to be save as block, else create comonent for every lang.
-					$relation_components	= component_relation_common::get_components_with_relations();
-					$is_related				= in_array( $component_model, $relation_components );
-					// set the main lang of the component as translatable or not (for literals the lang will be change)
-					$translatable			= RecordObj_dd::get_translatable( $component_tipo );
-					$lang					= $translatable === true ? DEDALO_DATA_LANG : DEDALO_DATA_NOLAN;
-					$component				= component_common::get_instance(
-						$component_model, // string model
-						$component_tipo, // string tipo
-						$new_section_id, // string section_id
-						'list', // string mode
-						$lang, // string lang
-						$section_tipo // string section_tipo
+
+					// search in database (this prevents duplicates when user apply this update more than once)
+					$sqo = json_decode('
+						{
+							"section_tipo": [
+								"rsc450"
+							],
+							"limit": 10,
+							"offset": 0,
+							"filter": {
+								"$and": [
+									{
+										"q": [
+											"Moved from People"
+										],
+										"q_operator": null,
+										"path": [
+											{
+												"section_tipo": "rsc450",
+												"component_tipo": "rsc452",
+												"model": "component_input_text",
+												"name": "Typology"
+											}
+										],
+										"q_split": true,
+										"type": "jsonb"
+									}
+								]
+							}
+						}
+					');
+					$search = search::get_instance(
+						$sqo // object sqo
 					);
-					// related component can save his data as block
-					if( $is_related	=== true ){
-						$component->set_dato( $value );
-						$component->Save();
+					$check_search		= $search->search();
+					$check_ar_records	= $check_search->ar_records;
+					if(count($check_ar_records)>0) {
+
+						$record = $check_ar_records[0];
+
+						$new_section_id = $record['section_id'];
+
 					}else{
-						// literal comonents needs to save his data by language
-						foreach ($value as $current_lang => $current_value) {
-							$component->set_lang( $current_lang );
-							$component->set_dato( $current_value );
+
+						// create new section to save new data
+						// new section will be the locator to add into the records
+						$new_section = section::get_instance(
+							null, // string|null section_id
+							$section_tipo // string section_tipo
+						);
+						$new_section_id = $new_section->Save();
+
+						// create new component with the specification
+						$component_model		= RecordObj_dd::get_modelo_name_by_tipo( $component_tipo );
+						// check if the component is a related to be save as block, else create component for every lang.
+						$relation_components	= component_relation_common::get_components_with_relations();
+						$is_related				= in_array( $component_model, $relation_components );
+						// set the main lang of the component as translatable or not (for literals the lang will be change)
+						$translatable			= RecordObj_dd::get_translatable( $component_tipo );
+						$lang					= $translatable === true ? DEDALO_DATA_LANG : DEDALO_DATA_NOLAN;
+						$component				= component_common::get_instance(
+							$component_model, // string model
+							$component_tipo, // string tipo
+							$new_section_id, // string section_id
+							'list', // string mode
+							$lang, // string lang
+							$section_tipo // string section_tipo
+						);
+						// related component can save his data as block
+						if( $is_related	=== true ){
+							$component->set_dato( $value );
 							$component->Save();
+						}else{
+							// literal components needs to save his data by language
+							foreach ($value as $current_lang => $current_value) {
+								$component->set_lang( $current_lang );
+								$component->set_dato( $current_value );
+								$component->Save();
+							}
 						}
 					}
+
 					// fix new locator with the new section created
 					// take account that the value is not the component value because this action use a related component to set the value
 					$locator = new locator();
@@ -2034,7 +2080,7 @@ public static function set_move_identification_value( object $options ) : object
 						$locator->set_from_component_tipo( $from_component_tipo );
 						$locator->set_type( $type );
 
-					// set new locator into the cache to be used nex time
+					// set new locator into the cache to be used next time
 					$cache_set_move_identification_value[$cache_key] = $locator;
 				}
 

From 987bf747163d69a8a368abbc08d1c7087c6b14df Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 10:18:01 +0100
Subject: [PATCH 09/12] change: change process status update rate from 41 to
 1000 to reduce the process log file in large process (`area_maintenence` =>
 `update_data_version`)

---
 .../widgets/update_data_version/render_update_data_version.js   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/area_maintenance/js/widgets/update_data_version/render_update_data_version.js b/core/area_maintenance/js/widgets/update_data_version/render_update_data_version.js
index 7580baac41..cb758cd704 100644
--- a/core/area_maintenance/js/widgets/update_data_version/render_update_data_version.js
+++ b/core/area_maintenance/js/widgets/update_data_version/render_update_data_version.js
@@ -307,7 +307,7 @@ const get_content_data = async function(self) {
 					body : {
 						dd_api		: 'dd_utils_api',
 						action		: 'get_process_status',
-						update_rate	: 41, // int milliseconds
+						update_rate	: 1000, // int milliseconds
 						options		: {
 							pid		: pid,
 							pfile	: pfile

From f5ea55f7b95d382ce8ec1e7b2a114843036a5797 Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 13:56:26 +0100
Subject: [PATCH 10/12] change!: improve locator check safe tipo and section
 tipo to prevent importing bad locators like UCA case

---
 core/common/class.locator.php                 | 40 ++++++++++++-
 .../class.component_relation_common.php       | 58 ++++++++++++++++++-
 shared/core_functions.php                     |  5 ++
 3 files changed, 99 insertions(+), 4 deletions(-)

diff --git a/core/common/class.locator.php b/core/common/class.locator.php
index 7c546d8306..1df8c4229f 100644
--- a/core/common/class.locator.php
+++ b/core/common/class.locator.php
@@ -498,8 +498,27 @@ public function check_locator() : object {
 				return $response;
 			}
 
+		// safe section_tipo
+			if (!safe_tipo($this->section_tipo)) {
+
+				$response->result	= false;
+				$response->errors[] = 'Invalid section_tipo';
+				$response->msg		= 'Invalid locator: locator section_tipo is invalid';
+
+				if(SHOW_DEBUG===true) {
+					$bt = debug_backtrace()[1];
+					debug_log(__METHOD__
+						. " $response->msg " . PHP_EOL
+						. ' backtrace 1: ' . to_string($bt)
+						, logger::ERROR
+					);
+				}
+
+				return $response;
+			}
+
 		// section_id mandatory
-			if (!isset($this->section_id)) {
+			if (!isset($this->section_id) || empty($this->section_id)) {
 
 				$response->result	= false;
 				$response->errors[] = 'Empty section_id';
@@ -517,6 +536,25 @@ public function check_locator() : object {
 				return $response;
 			}
 
+		// safe section_id
+			if (!safe_section_id($this->section_id)) {
+
+				$response->result	= false;
+				$response->errors[] = 'Invalid section_id';
+				$response->msg		= 'Invalid locator: locator section_id is invalid';
+
+				if(SHOW_DEBUG===true) {
+					$bt = debug_backtrace()[1];
+					debug_log(__METHOD__
+						. " $response->msg " . PHP_EOL
+						. ' backtrace 1: ' . to_string($bt)
+						, logger::ERROR
+					);
+				}
+
+				return $response;
+			}
+
 		// OK message
 			$response->result	= true;
 			$response->msg		= 'OK. Locator is valid';
diff --git a/core/component_relation_common/class.component_relation_common.php b/core/component_relation_common/class.component_relation_common.php
index 9d7a7daed9..ad65c61e4c 100755
--- a/core/component_relation_common/class.component_relation_common.php
+++ b/core/component_relation_common/class.component_relation_common.php
@@ -2969,16 +2969,53 @@ public function conform_import_data( string $import_value, string $column_name )
 								$failed->section_id		= $this->section_id;
 								$failed->data			= stripslashes( $import_value );
 								$failed->component_tipo	= $this->get_tipo();
-								$failed->msg			= 'IGNORED: mTry to import multiple section_tipo without clear target ';
+								$failed->msg			= 'IGNORED: Try to import multiple section_tipo without clear target ';
 							$response->errors[] = $failed;
 
 							return $response;
 						}
 						$target_section_tipo = $ar_target_section_tipo[0] ?? null;
+
+						// check valid target_section_tipo
+						if (!safe_tipo($target_section_tipo)) {
+							debug_log(__METHOD__
+								." Trying to import invalid target_section_tipo" .PHP_EOL
+								.' section_id: '. to_string($target_section_tipo)
+								, logger::ERROR
+							);
+
+							$failed = new stdClass();
+								$failed->section_id		= $this->section_id;
+								$failed->data			= to_string( $import_value );
+								$failed->component_tipo	= $this->get_tipo();
+								$failed->msg			= 'IGNORED: Try to import invalid target_section_tipo';
+							$response->errors[] = $failed;
+
+							return $response;
+						}
 					}
 
 				$ar_values = explode(',', (string)$value);
 				foreach ($ar_values as $section_id) {
+
+					// section_id. Check if section_id value is valid
+					if (!safe_section_id($section_id)) {
+						debug_log(__METHOD__
+							." Trying to import invalid section_id" .PHP_EOL
+							.' section_id: '. to_string($section_id)
+							, logger::ERROR
+						);
+
+						$failed = new stdClass();
+							$failed->section_id		= $this->section_id;
+							$failed->data			= to_string( $import_value );
+							$failed->component_tipo	= $this->get_tipo();
+							$failed->msg			= 'IGNORED: Try to import invalid section_id';
+						$response->errors[] = $failed;
+
+						return $response;
+					}
+
 					// old format (section_id)
 					// is int. Builds complete locator and set section_id from value
 					$locator = new locator();
@@ -3003,8 +3040,23 @@ public function conform_import_data( string $import_value, string $column_name )
 
 						$check_response = $locator->check_locator();
 						if ($check_response->result!==true) {
-							$msg = $check_response->msg . ' record section_id: ' . $this->section_id;
-							throw new Exception("Error Processing Request. ".$msg, 1);
+
+							debug_log(__METHOD__
+								." Trying to import invalid locator" . PHP_EOL
+								.' check_response->msg: ' . $check_response->msg . PHP_EOL
+								.' section_id: '. to_string($this->section_id) . PHP_EOL
+								.' locator: '. json_encode($locator, JSON_PRETTY_PRINT)
+								, logger::ERROR
+							);
+
+							$failed = new stdClass();
+								$failed->section_id		= $this->section_id;
+								$failed->data			= to_string( $import_value );
+								$failed->component_tipo	= $this->get_tipo();
+								$failed->msg			= 'IGNORED: Try to import invalid locator';
+							$response->errors[] = $failed;
+
+							return $response;
 						}
 
 						// ! type could be false (component_relation_parent)
diff --git a/shared/core_functions.php b/shared/core_functions.php
index 7775e31f80..303a380b2c 100644
--- a/shared/core_functions.php
+++ b/shared/core_functions.php
@@ -1801,6 +1801,11 @@ function safe_tipo(string $tipo) : string|bool {
 */
 function safe_section_id( string|int $section_id ) : string|int|bool {
 
+	// temp case. Allow temp name for temporal sections
+	if ($section_id===DEDALO_SECTION_ID_TEMP) {
+		return $section_id;
+	}
+
 	preg_match("/^[0-9]+$/", (string)$section_id, $output_array);
 	if (empty($output_array[0])) {
 		return false;

From b02513be10751b66933cc365b73d06e03a9d5ef8 Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 13:56:39 +0100
Subject: [PATCH 11/12] style: clean up code

---
 .../class.component_relation_common.php              | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/core/component_relation_common/class.component_relation_common.php b/core/component_relation_common/class.component_relation_common.php
index ad65c61e4c..e386e82ddb 100755
--- a/core/component_relation_common/class.component_relation_common.php
+++ b/core/component_relation_common/class.component_relation_common.php
@@ -2953,7 +2953,7 @@ public function conform_import_data( string $import_value, string $column_name )
 		// but not the locator [{"section_tipo":"oh1","section_id":"1"}] it's valid JSON
 			if (is_string($value) || is_int($value)) {
 
-				// $target_section_tipo
+				// target_section_tipo
 					if( empty($target_section_tipo) ) {
 
 						$ar_target_section_tipo = $this->get_ar_target_section_tipo();
@@ -2969,7 +2969,7 @@ public function conform_import_data( string $import_value, string $column_name )
 								$failed->section_id		= $this->section_id;
 								$failed->data			= stripslashes( $import_value );
 								$failed->component_tipo	= $this->get_tipo();
-								$failed->msg			= 'IGNORED: Try to import multiple section_tipo without clear target ';
+								$failed->msg			= 'IGNORED: Trying to import multiple section_tipo without clear target ';
 							$response->errors[] = $failed;
 
 							return $response;
@@ -2978,6 +2978,7 @@ public function conform_import_data( string $import_value, string $column_name )
 
 						// check valid target_section_tipo
 						if (!safe_tipo($target_section_tipo)) {
+
 							debug_log(__METHOD__
 								." Trying to import invalid target_section_tipo" .PHP_EOL
 								.' section_id: '. to_string($target_section_tipo)
@@ -2988,7 +2989,7 @@ public function conform_import_data( string $import_value, string $column_name )
 								$failed->section_id		= $this->section_id;
 								$failed->data			= to_string( $import_value );
 								$failed->component_tipo	= $this->get_tipo();
-								$failed->msg			= 'IGNORED: Try to import invalid target_section_tipo';
+								$failed->msg			= 'IGNORED: Trying to import invalid target_section_tipo';
 							$response->errors[] = $failed;
 
 							return $response;
@@ -3000,6 +3001,7 @@ public function conform_import_data( string $import_value, string $column_name )
 
 					// section_id. Check if section_id value is valid
 					if (!safe_section_id($section_id)) {
+
 						debug_log(__METHOD__
 							." Trying to import invalid section_id" .PHP_EOL
 							.' section_id: '. to_string($section_id)
@@ -3010,7 +3012,7 @@ public function conform_import_data( string $import_value, string $column_name )
 							$failed->section_id		= $this->section_id;
 							$failed->data			= to_string( $import_value );
 							$failed->component_tipo	= $this->get_tipo();
-							$failed->msg			= 'IGNORED: Try to import invalid section_id';
+							$failed->msg			= 'IGNORED: Trying to import invalid section_id';
 						$response->errors[] = $failed;
 
 						return $response;
@@ -3053,7 +3055,7 @@ public function conform_import_data( string $import_value, string $column_name )
 								$failed->section_id		= $this->section_id;
 								$failed->data			= to_string( $import_value );
 								$failed->component_tipo	= $this->get_tipo();
-								$failed->msg			= 'IGNORED: Try to import invalid locator';
+								$failed->msg			= 'IGNORED: Trying to import invalid locator';
 							$response->errors[] = $failed;
 
 							return $response;

From 33d5f1f32abd2c71b3154d9d824f998848f2f11a Mon Sep 17 00:00:00 2001
From: Paco <paco@render.es>
Date: Mon, 9 Dec 2024 14:00:07 +0100
Subject: [PATCH 12/12] ci: update version info

---
 core/base/version.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/base/version.inc b/core/base/version.inc
index b84243c4bc..90e18a182d 100644
--- a/core/base/version.inc
+++ b/core/base/version.inc
@@ -6,5 +6,5 @@
 		$DEDALO_VERSION .= '.dev';
 	}
 	define('DEDALO_VERSION'	, $DEDALO_VERSION);
-	define('DEDALO_BUILD'	, '2024-12-05T11:15:25+01:00');
+	define('DEDALO_BUILD'	, '2024-12-09T13:59:42+01:00');
 	define('DEDALO_MAJOR_VERSION', '6');