Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qfq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
typo3
qfq
Commits
c17824b9
Commit
c17824b9
authored
4 years ago
by
Marc Egger
Browse files
Options
Downloads
Patches
Plain Diff
FormAsFile.php: keep old form during import and delete only at the end
parent
bf85b689
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!302
Develop
,
!296
Marc: Form/Report As File, Path class, Config class, Typo3 v9 compatability
Pipeline
#3978
failed
4 years ago
Stage: before
Stage: build
Stage: selenium
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extension/Classes/Core/Form/FormAsFile.php
+15
-10
15 additions, 10 deletions
extension/Classes/Core/Form/FormAsFile.php
with
15 additions
and
10 deletions
extension/Classes/Core/Form/FormAsFile.php
+
15
−
10
View file @
c17824b9
...
...
@@ -85,10 +85,9 @@ class FormAsFile
}
}
// Delete old form with that name from DB if it exists.
if
(
array_key_exists
(
F_ID
,
$formFromDb
))
{
self
::
deleteFormDBWithId
(
$formFromDb
[
F_ID
],
$database
);
}
// keep old form ID for deletion later & define temporary name for new form
$formIdOld
=
$formFromDb
[
F_ID
]
??
null
;
$newFormTempName
=
$formName
.
'_FAILED_IMPORT'
;
// will be renamed at the end
// Insert new Form to DB (after filtering allowed columns and adding column 'name')
$formSchema
=
$database
->
getTableDefinition
(
TABLE_NAME_FORM
);
...
...
@@ -96,17 +95,18 @@ class FormAsFile
$insertValues
=
array_filter
(
$formFromFile
,
function
(
$columnName
)
use
(
$formColumns
)
{
return
$columnName
!==
F_ID
&&
in_array
(
$columnName
,
$formColumns
);
},
ARRAY_FILTER_USE_KEY
);
// array(column => value)
$insertValues
[
F_NAME
]
=
$formName
;
$insertValues
[
F_NAME
]
=
$newFormTempName
;
$insertValues
[
F_FILE_STATS
]
=
$fileStatsNew
;
list
(
$sqlFormInsert
,
$parameterArrayFormInsert
)
=
SqlQuery
::
insertRecord
(
TABLE_NAME_FORM
,
$insertValues
);
$formId
=
$database
->
sql
(
$sqlFormInsert
,
ROW_REGULAR
,
$parameterArrayFormInsert
);
$formId
New
=
$database
->
sql
(
$sqlFormInsert
,
ROW_REGULAR
,
$parameterArrayFormInsert
);
// Delete stale formElements with the new form id (these should not exist, but better make sure)
self
::
deleteFormElementsDBWithFormId
(
$formId
,
$database
);
self
::
deleteFormElementsDBWithFormId
(
$formId
New
,
$database
);
// Insert FormElements to DB and collect container ids
$containerIds
=
[];
// array(container_name => id)
foreach
(
$formFromFile
[
F_FILE_FORM_ELEMENT
]
as
&
$formElementFromFile
)
{
$feId
=
self
::
insertFormElement
(
$formElementFromFile
,
$formId
,
$database
);
$feId
=
self
::
insertFormElement
(
$formElementFromFile
,
$formId
New
,
$database
);
$formElementFromFile
[
FE_ID
]
=
$feId
;
if
(
$formElementFromFile
[
FE_CLASS
]
===
FE_CLASS_CONTAINER
)
{
$containerIds
[
$formElementFromFile
[
FE_NAME
]]
=
$feId
;
...
...
@@ -127,8 +127,13 @@ class FormAsFile
}
}
// Update column fileStats if everything went well
list
(
$sql
,
$parameterArray
)
=
SqlQuery
::
updateRecord
(
TABLE_NAME_FORM
,
[
F_FILE_STATS
=>
$fileStatsNew
],
$formId
);
// Delete old form if everything went well
if
(
$formIdOld
!==
null
)
{
self
::
deleteFormDBWithId
(
$formIdOld
,
$database
);
}
// Replace temporary name of new form
list
(
$sql
,
$parameterArray
)
=
SqlQuery
::
updateRecord
(
TABLE_NAME_FORM
,
[
F_NAME
=>
$formName
],
$formIdNew
);
$database
->
sql
(
$sql
,
ROW_REGULAR
,
$parameterArray
);
return
true
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment