Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
a1cc0200
Commit
a1cc0200
authored
Jun 02, 2016
by
Carsten Rose
Browse files
Delete: fixed that files not automatically deleted.
Delete.php: chdir to the correct directory before starting to delete files
parent
9efd27f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/Delete.php
View file @
a1cc0200
...
...
@@ -10,6 +10,7 @@ namespace qfq;
require_once
(
__DIR__
.
'/Constants.php'
);
require_once
(
__DIR__
.
'/Database.php'
);
require_once
(
__DIR__
.
'/store/Store.php'
);
class
Delete
{
...
...
@@ -18,11 +19,17 @@ class Delete {
*/
private
$db
=
null
;
/**
* @var Store
*/
private
$store
=
null
;
/**
*
*/
public
function
__construct
()
{
public
function
__construct
(
$phpUnit
=
false
)
{
$this
->
db
=
new
Database
();
$this
->
store
=
Store
::
getInstance
(
''
,
$phpUnit
);
}
/**
...
...
@@ -36,6 +43,7 @@ class Delete {
* @return bool
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
public
function
process
(
array
$form
,
$recordId
,
array
&
$msg
)
{
$rc
=
false
;
...
...
@@ -49,6 +57,13 @@ class Delete {
throw
new
CodeException
(
'Invalid record id'
,
ERROR_MISSING_RECORD_ID
);
}
// Take care the necessary target directories exist.
$cwd
=
getcwd
();
$sitePath
=
$this
->
store
->
getVar
(
SYSTEM_SITE_PATH
,
STORE_SYSTEM
);
if
(
$cwd
===
false
||
$sitePath
===
false
||
!
chdir
(
$sitePath
))
{
throw
new
UserFormException
(
"getcwd() failed or SITE_PATH undefined or chdir('
$sitePath
') failed."
,
ERROR_IO_CHDIR
);
}
// Read record first.
$row
=
$this
->
db
->
sql
(
"SELECT * FROM "
.
$form
[
F_TABLE_NAME
]
.
" WHERE id=?"
,
ROW_EXPECT_0_1
,
[
$recordId
]);
if
(
count
(
$row
)
>
0
)
{
...
...
@@ -83,6 +98,8 @@ class Delete {
$msg
[
MSG_ERROR_CODE
]
=
ERROR_RECORD_NOT_FOUND
;
}
chdir
(
$cwd
);
return
$rc
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment