Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_jobs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_jobs
Commits
74b5bf5a
Commit
74b5bf5a
authored
1 year ago
by
Stefan Galinski
Browse files
Options
Downloads
Patches
Plain Diff
[BUGFIX] Crash if the same is uploaded in the application, Tmp folder not removed on error
parent
d7c764f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/Controller/JoblistController.php
+22
-12
22 additions, 12 deletions
Classes/Controller/JoblistController.php
with
22 additions
and
12 deletions
Classes/Controller/JoblistController.php
+
22
−
12
View file @
74b5bf5a
...
...
@@ -46,6 +46,7 @@ use TYPO3\CMS\Core\Core\Environment;
use
TYPO3\CMS\Core\Error\Http\PageNotFoundException
;
use
TYPO3\CMS\Core\Exception\SiteNotFoundException
;
use
TYPO3\CMS\Core\Http\ImmediateResponseException
;
use
TYPO3\CMS\Core\Resource\Exception\AbstractFileOperationException
;
use
TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
;
use
TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException
;
use
TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
;
...
...
@@ -704,12 +705,13 @@ class JoblistController extends ActionController {
*
* @param string $folderName
* @param JobApplication $applicationData
* @throws TypeConverterException
* @throws ExistingTargetFileNameException
* @throws ExistingTargetFolderException
* @throws InsufficientFolderAccessPermissionsException
* @throws InsufficientFolderReadPermissionsException
* @throws InsufficientFolderWritePermissionsException
* @throws TypeConverterException
* @throws AbstractFileOperationException
*/
protected
function
moveTmpFolder
(
string
$folderName
,
JobApplication
$applicationData
):
void
{
$allowedFileExtensions
=
$this
->
getAllowedFileExtensions
();
...
...
@@ -726,6 +728,7 @@ class JoblistController extends ActionController {
}
// Move uploaded files & csv fo real folder and delete the tmp folder
$uploadedFiles
=
[];
foreach
(
self
::
UPLOADED_FILES
as
$singleFilePostKey
)
{
if
(
!
array_key_exists
(
$singleFilePostKey
,
$_POST
))
{
throw
new
TypeConverterException
(
...
...
@@ -739,7 +742,6 @@ class JoblistController extends ActionController {
// get the first uploaded document, should be prevented in the frontend to upload more than one
$singleUploadedFile
=
current
(
$_POST
[
$singleFilePostKey
])[
'path'
];
$filePathInfo
=
PathUtility
::
pathinfo
(
$singleUploadedFile
);
if
(
!
GeneralUtility
::
inList
(
$allowedFileExtensions
,
strtolower
(
$filePathInfo
[
'extension'
])))
{
throw
new
TypeConverterException
(
...
...
@@ -749,19 +751,25 @@ class JoblistController extends ActionController {
}
$basename
=
$filePathInfo
[
'basename'
];
if
(
!
$newFolder
->
hasFile
(
$basename
))
{
/** @noinspection PhpUnreachableStatementInspection */
$singleFileToMove
=
$storage
->
getFileInFolder
(
$basename
,
$tempFolder
);
$newFilename
=
strtolower
(
$singleFilePostKey
)
.
'.'
.
strtolower
(
$filePathInfo
[
'extension'
]);
if
(
array_key_exists
(
$singleUploadedFile
,
$uploadedFiles
))
{
// the same file was uploaded for different sources
$usableFile
=
$newFolder
->
getFile
(
$uploadedFiles
[
$singleUploadedFile
]
.
'.'
.
strtolower
(
$filePathInfo
[
'extension'
])
);
if
(
!
$usableFile
)
{
throw
new
\RuntimeException
(
'File not found ('
.
$singleFilePostKey
.
')!'
);
}
$usableFile
=
$storage
->
copyFile
(
$usableFile
,
$newFolder
,
$newFilename
);
}
elseif
(
!
$newFolder
->
hasFile
(
$newFilename
))
{
// when we reload etc. this image might already be moved.
$usableFile
=
$storage
->
moveFile
(
$singleFileToMove
,
$newFolder
,
$singleFilePostKey
.
'.'
.
$filePathInfo
[
'extension'
]
);
/** @noinspection PhpUnreachableStatementInspection */
$singleFileToMove
=
$storage
->
getFileInFolder
(
$basename
,
$tempFolder
);
$usableFile
=
$storage
->
moveFile
(
$singleFileToMove
,
$newFolder
,
$newFilename
);
}
else
{
/** @noinspection PhpUnreachableStatementInspection */
$usableFile
=
$newFolder
->
getFile
(
$
bas
ename
);
$usableFile
=
$newFolder
->
getFile
(
$
newFil
ename
);
}
$fileReference
=
$this
->
fileAndFolderService
->
createFileReferenceFromFalFileObject
(
$usableFile
);
...
...
@@ -776,6 +784,8 @@ class JoblistController extends ActionController {
if
(
$singleFilePostKey
===
'certificate'
)
{
$applicationData
->
setCertificate
(
$fileReference
);
}
$uploadedFiles
[
$singleUploadedFile
]
=
strtolower
(
$singleFilePostKey
);
}
}
...
...
@@ -798,7 +808,7 @@ class JoblistController extends ActionController {
$resourceFactory
=
$this
->
objectManager
->
get
(
ResourceFactory
::
class
);
$storage
=
$resourceFactory
->
getStorageObject
(
1
);
try
{
$tempFolder
=
$storage
->
getFolder
(
'/JobApplication/
temp/
'
.
$folderName
);
$tempFolder
=
$storage
->
getFolder
(
'/JobApplication/'
.
$folderName
);
$storage
->
deleteFolder
(
$tempFolder
,
TRUE
);
}
catch
(
\Exception
$exception
)
{
// folder is already deleted for some reason
...
...
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