From f7f8722e1f013afbb0332cd9d03999ef54c293fa Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 23 Aug 2022 02:39:53 +0100 Subject: Refactor insert edit (#17684) This is a major redesign of the code that handles these four actions: in-place edit(AJAX), edit of multiple rows, copying of rows, and insertion of new rows. The goal is to make the code easier to read and more understandable. I introduced a new DTO for better readability. Some of the methods were made private to the model The controller has access to two methods for getting the value for INSERT and for UPDATE Unfortunately, I have introduced method envy on EditField, but I do not want to move the functionality away from InsertEdit.php Unit tests have not improved in readability but I added helpful comments explaining what we are testing. There's probably a way to improve it too. I will probably merge all commits once I decide it's ready for review. Signed-off-by: Kamil Tekiela --- psalm-baseline.xml | 79 +++++++++++++----------------------------------------- 1 file changed, 19 insertions(+), 60 deletions(-) (limited to 'psalm-baseline.xml') diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5cf4c590a0..8840207287 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3651,29 +3651,20 @@ $insertErrors - + $_POST['db'] $_POST['rel_fields_list'] $_POST['table'] $_POST['transform_fields_list'] $column_name $column_name - $current_value - $current_value - $current_value + $column_name $errorMessages $extra_data $lastMessages - $multi_edit_auto_increment - $multi_edit_columns_name - $multi_edit_columns_null - $multi_edit_columns_null - $multi_edit_columns_null_prev - $multi_edit_columns_null_prev - $multi_edit_columns_prev - $multi_edit_columns_type - $multi_edit_funcs - $multi_edit_funcs[$key] + $multi_edit_columns_prev[$key] ?? null + $multi_edit_columns_type[$key] ?? '' + $multi_edit_funcs[$key] ?? '' $multi_edit_salt[$key] ?? null $one_where_clause $relation_field @@ -3682,19 +3673,14 @@ $totalAffectedRows $totalAffectedRows $warningMessages - $where_clause - - $current_value - $key - $key - $queryValues - $queryValues - - + $_POST['fields_name']['multi_edit'] $extra_data['relations'] $multi_edit_columns[$key] + $multi_edit_columns_prev[$key] + $multi_edit_columns_type[$key] + $multi_edit_funcs[$key] $multi_edit_salt[$key] @@ -3706,7 +3692,7 @@ $mimeMap[$column_name] - + $GLOBALS['active_page'] $GLOBALS['cfg']['InsertRows'] $GLOBALS['disp_message'] @@ -3722,11 +3708,11 @@ $column_name $column_name $curr_rel_field - $current_value $extra_data['row_count'] $insertRows $multi_edit_auto_increment $multi_edit_columns + $multi_edit_columns[$key] $multi_edit_columns_name $multi_edit_columns_null $multi_edit_columns_null_prev @@ -3738,32 +3724,17 @@ $one_where_clause $relation_field $relation_field_value - $where_clause new $classname() - + $relation_field_value - $where_clause - $where_clause - + $GLOBALS['urlParams'] $GLOBALS['urlParams'] - $current_value - $current_value - $current_value - $multi_edit_columns_null - $multi_edit_columns_null - $multi_edit_columns_null_prev - $multi_edit_columns_null_prev - $multi_edit_columns_prev - $multi_edit_funcs - - $multi_edit_salt[$key] - get @@ -7895,7 +7866,7 @@ - + $_POST['fields']['multi_edit'] $backupField $columnMime['input_transformation_options'] @@ -7952,10 +7923,6 @@ $foreigner['foreign_table'] $foreigner['foreign_table'] $foreigner['foreign_table'] - $multiEditColumnsName[$key] - $multiEditColumnsName[$key] - $multiEditColumnsName[$key] - $protectedRow[$multiEditColumnsName[$key]] $rows[$keyId] $singleQuery $singleQuery @@ -7983,7 +7950,7 @@ $urlParams $valueSets - + $_POST['fields']['multi_edit'] $_POST['where_clause'][0] $_SESSION['tmpval']['relational_display'] @@ -7991,13 +7958,12 @@ $enumValue['plain'] $enumValue['plain'] $enumValue['plain'] - $protectedRow[$multiEditColumnsName[$key]] $editedValues[$cellIndex][$columnName] $extraData['transformations'][$cellIndex] - + $commentsMap[$column['Field']] $commentsMap[$column['Field']] $currentRow[$column['Field']] @@ -8025,9 +7991,8 @@ $currentRow[$column['Field']] $mimeMap[$tableColumn['Field']] $mimeMap[$tableColumn['Field']] - $protectedRow[$multiEditColumnsName[$key]] - + $GLOBALS['cfg']['ShowFieldTypesInDataEditView'] $GLOBALS['cfg']['ShowFunctionFields'] $_SESSION['edit_next'] @@ -8056,7 +8021,6 @@ $tmp['Default'] $transformedHtml $trueType - $type $urlParams['sql_query'] $whereClause $whereClause @@ -8088,13 +8052,10 @@ - $multiEditSalt + $editField->salt $newValue $newValue - - $protectedRow - (int) $GLOBALS['cfg']['InsertRows'] @@ -15233,9 +15194,7 @@ $result['pma_type'] $result['wrap'] - - $_POST['fields']['multi_edit'] - $_POST['fields']['multi_edit'] + $_POST['fields']['multi_edit'] $_SESSION['tmpval']['relational_display'] $_SESSION['tmpval']['relational_display'] -- cgit v1.2.3