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
10d77d42
Commit
10d77d42
authored
Feb 21, 2019
by
Carsten Rose
Browse files
Merge branch 'CwdLoggerProblem' into F7919RestAPIExportPrimaryTableIndex
# Conflicts: # extension/Source/core/Save.php
parents
cf88c24a
ee8d8e97
Changes
8
Show whitespace changes
Inline
Side-by-side
extension/Documentation/Manual.rst
View file @
10d77d42
extension/Source/core/Save.php
View file @
10d77d42
...
@@ -386,6 +386,8 @@ class Save {
...
@@ -386,6 +386,8 @@ class Save {
// No new upload and no existing: take care to remove previous upload file statistics.
// No new upload and no existing: take care to remove previous upload file statistics.
$this
->
store
->
unsetVar
(
VAR_FILE_MIME_TYPE
,
STORE_VAR
);
$this
->
store
->
unsetVar
(
VAR_FILE_MIME_TYPE
,
STORE_VAR
);
$this
->
store
->
unsetVar
(
VAR_FILE_SIZE
,
STORE_VAR
);
$this
->
store
->
unsetVar
(
VAR_FILE_SIZE
,
STORE_VAR
);
$vars
[
VAR_FILE_SIZE
]
=
0
;
$vars
[
VAR_FILE_MIME_TYPE
]
=
''
;
}
else
{
}
else
{
$vars
=
HelperFile
::
getFileStat
(
$pathFileNameTmp
);
$vars
=
HelperFile
::
getFileStat
(
$pathFileNameTmp
);
$this
->
store
->
appendToStore
(
$vars
,
STORE_VAR
);
$this
->
store
->
appendToStore
(
$vars
,
STORE_VAR
);
...
@@ -823,8 +825,7 @@ class Save {
...
@@ -823,8 +825,7 @@ class Save {
* @throws UserFormException
* @throws UserFormException
* @throws UserReportException
* @throws UserReportException
*/
*/
private
private
function
copyUploadFile
(
array
$formElement
,
array
$statusUpload
)
{
function
copyUploadFile
(
array
$formElement
,
array
$statusUpload
)
{
$pathFileName
=
''
;
$pathFileName
=
''
;
if
(
!
isset
(
$statusUpload
[
FILES_TMP_NAME
])
||
$statusUpload
[
FILES_TMP_NAME
]
===
''
)
{
if
(
!
isset
(
$statusUpload
[
FILES_TMP_NAME
])
||
$statusUpload
[
FILES_TMP_NAME
]
===
''
)
{
...
@@ -887,8 +888,7 @@ class Save {
...
@@ -887,8 +888,7 @@ class Save {
* @throws UserFormException
* @throws UserFormException
* @throws UserReportException
* @throws UserReportException
*/
*/
private
private
function
autoOrient
(
array
$formElement
,
$pathFileName
)
{
function
autoOrient
(
array
$formElement
,
$pathFileName
)
{
// 'autoOrient' wished?
// 'autoOrient' wished?
if
(
!
isset
(
$formElement
[
FE_FILE_AUTO_ORIENT
])
||
$formElement
[
FE_FILE_AUTO_ORIENT
]
==
'0'
)
{
if
(
!
isset
(
$formElement
[
FE_FILE_AUTO_ORIENT
])
||
$formElement
[
FE_FILE_AUTO_ORIENT
]
==
'0'
)
{
...
@@ -929,17 +929,16 @@ class Save {
...
@@ -929,17 +929,16 @@ class Save {
* @throws UserFormException
* @throws UserFormException
* @throws UserReportException
* @throws UserReportException
*/
*/
private
private
function
splitUpload
(
array
$formElement
,
$pathFileName
,
$chmod
,
array
$statusUpload
)
{
function
splitUpload
(
array
$formElement
,
$pathFileName
,
$chmod
,
array
$statusUpload
)
{
if
(
empty
(
$formElement
[
FE_FILE_SPLIT
])
||
$statusUpload
[
FILES_TYPE
]
!=
MIME_TYPE_SPLIT_CAPABLE
)
{
if
(
empty
(
$formElement
[
FE_FILE_SPLIT
])
||
$statusUpload
[
FILES_TYPE
]
!=
MIME_TYPE_SPLIT_CAPABLE
)
{
return
;
return
;
}
}
$fileDestinationSplit
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_DESTINATION_SPLIT
]
??
''
);
$fileDestinationSplit
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_DESTINATION_SPLIT
]
??
''
);
$fileSplitType
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_SPLIT
]
??
''
);
$fileSplitType
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_SPLIT
]
??
''
);
$fileSplitTypeOptions
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_SPLIT_OPTIONS
]
??
''
);
$fileSplitTypeOptions
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_SPLIT_OPTIONS
]
??
''
);
$fileSplitTableName
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_SPLIT_TABLE_NAME
]
??
''
);
$fileSplitTableName
=
$this
->
evaluate
->
parse
(
$formElement
[
FE_FILE_SPLIT_TABLE_NAME
]
??
''
);
if
(
empty
(
$fileSplitTableName
))
{
if
(
empty
(
$fileSplitTableName
))
{
$fileSplitTableName
=
$this
->
formSpec
[
F_TABLE_NAME
];
$fileSplitTableName
=
$this
->
formSpec
[
F_TABLE_NAME
];
...
@@ -956,12 +955,10 @@ class Save {
...
@@ -956,12 +955,10 @@ class Save {
$cwd
=
getcwd
();
$cwd
=
getcwd
();
// Create temporary directory
// Create temporary directory
$tempDir
=
Support
::
createT
emp
D
ir
();
$tempDir
=
HelperFile
::
mkt
emp
d
ir
();
$newSrc
=
$tempDir
.
DIRECTORY_SEPARATOR
.
QFQ_TEMP_SOURCE
;
$newSrc
=
$tempDir
.
DIRECTORY_SEPARATOR
.
QFQ_TEMP_SOURCE
;
HelperFile
::
copy
(
$pathFileName
,
$newSrc
);
HelperFile
::
copy
(
$pathFileName
,
$newSrc
);
HelperFile
::
chdir
(
$tempDir
);
// Split destination.
// Split destination.
$pathParts
=
pathinfo
(
$fileDestinationSplit
);
$pathParts
=
pathinfo
(
$fileDestinationSplit
);
if
(
empty
(
$pathParts
[
'filename'
])
||
empty
(
$pathParts
[
'basename'
]))
{
if
(
empty
(
$pathParts
[
'filename'
])
||
empty
(
$pathParts
[
'basename'
]))
{
...
@@ -986,7 +983,10 @@ class Save {
...
@@ -986,7 +983,10 @@ class Save {
}
}
// Split PDF
// Split PDF
HelperFile
::
chdir
(
$tempDir
);
$output
=
Support
::
qfqExec
(
$cmd
,
$rc
);
$output
=
Support
::
qfqExec
(
$cmd
,
$rc
);
HelperFile
::
chdir
(
$cwd
);
if
(
$rc
!=
0
)
{
if
(
$rc
!=
0
)
{
throw
new
UserFormException
(
throw
new
UserFormException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'pdf2svg failed'
,
ERROR_MESSAGE_SUPPORT
=>
"[
$cwd
][cmd=
$cmd
]
$output
"
]),
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'pdf2svg failed'
,
ERROR_MESSAGE_SUPPORT
=>
"[
$cwd
][cmd=
$cmd
]
$output
"
]),
...
@@ -994,7 +994,7 @@ class Save {
...
@@ -994,7 +994,7 @@ class Save {
}
}
// Array of created file names.
// Array of created file names.
if
(
false
===
(
$files
=
scandir
(
'.'
)))
{
if
(
false
===
(
$files
=
scandir
(
$tempDir
)))
{
throw
new
UserFormException
(
throw
new
UserFormException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Splitted files not found'
,
ERROR_MESSAGE_SUPPORT
=>
"[cwd=
$cwd
] scandir(.)"
.
HelperFile
::
errorGetLastAsString
()]),
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Splitted files not found'
,
ERROR_MESSAGE_SUPPORT
=>
"[cwd=
$cwd
] scandir(.)"
.
HelperFile
::
errorGetLastAsString
()]),
ERROR_PDF2JPEG
);
ERROR_PDF2JPEG
);
...
@@ -1025,16 +1025,13 @@ class Save {
...
@@ -1025,16 +1025,13 @@ class Save {
$fileDestination
=
$file
;
$fileDestination
=
$file
;
}
}
Support
::
moveFile
(
$file
,
Support
::
joinPath
(
$cwd
,
$fileDestination
),
true
);
Support
::
moveFile
(
$tempDir
.
DIRECTORY_SEPARATOR
.
$file
,
Support
::
joinPath
(
$cwd
,
$fileDestination
),
true
);
HelperFile
::
chmod
(
$fileDestination
,
$chmod
);
HelperFile
::
chmod
(
$fileDestination
,
$chmod
);
// Insert records.
// Insert records.
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
$fileSplitTableName
,
$xId
,
$fileDestination
]);
$this
->
db
->
sql
(
$sql
,
ROW_REGULAR
,
[
$fileSplitTableName
,
$xId
,
$fileDestination
]);
}
}
// Pop directory
HelperFile
::
chdir
(
$cwd
);
// Remove duplicated source
// Remove duplicated source
HelperFile
::
unlink
(
$newSrc
);
HelperFile
::
unlink
(
$newSrc
);
...
@@ -1053,8 +1050,7 @@ class Save {
...
@@ -1053,8 +1050,7 @@ class Save {
* @throws UserFormException
* @throws UserFormException
* @throws UserReportException
* @throws UserReportException
*/
*/
private
private
function
doUploadSlave
(
array
$fe
,
$modeUpload
)
{
function
doUploadSlave
(
array
$fe
,
$modeUpload
)
{
$sql
=
''
;
$sql
=
''
;
$flagUpdateSlaveId
=
false
;
$flagUpdateSlaveId
=
false
;
$flagSlaveDeleted
=
false
;
$flagSlaveDeleted
=
false
;
...
...
extension/Source/core/helper/HelperFile.php
View file @
10d77d42
...
@@ -61,6 +61,8 @@ class HelperFile {
...
@@ -61,6 +61,8 @@ class HelperFile {
/**
/**
* Creates a temporary directory.
* Creates a temporary directory.
* Be aware: '/tmp' is under systemd/apache2 (Ubuntu 18...) remapped to something like: '/tmp/systemd-private-...-apache2.service-.../tmp'
*
* @throws UserFormException
* @throws UserFormException
*/
*/
public
static
function
mktempdir
()
{
public
static
function
mktempdir
()
{
...
@@ -375,10 +377,18 @@ class HelperFile {
...
@@ -375,10 +377,18 @@ class HelperFile {
*/
*/
public
static
function
mkDirParent
(
$pathFileName
,
$chmodDir
=
false
)
{
public
static
function
mkDirParent
(
$pathFileName
,
$chmodDir
=
false
)
{
$path
=
""
;
$path
=
""
;
$cwd
=
''
;
// Leading '/' will be removed - chdir to / to still use correct path
if
(
$pathFileName
[
0
]
==
'/'
)
{
$cwd
=
getcwd
();
self
::
chdir
(
'/'
);
}
// Teile "Directory/File.Extension" auf
// Teile "Directory/File.Extension" auf
$pathParts
=
pathinfo
(
$pathFileName
);
$pathParts
=
pathinfo
(
$pathFileName
);
// Zerlege Pfad in einzelne Directories
// Zerlege Pfad in einzelne Directories
$arr
=
explode
(
"/"
,
$pathParts
[
"dirname"
]);
$arr
=
explode
(
"/"
,
$pathParts
[
"dirname"
]);
...
@@ -409,6 +419,10 @@ class HelperFile {
...
@@ -409,6 +419,10 @@ class HelperFile {
}
}
$path
.
=
"/"
;
$path
.
=
"/"
;
}
}
if
(
$cwd
!=
''
)
{
self
::
chdir
(
$cwd
);
}
}
}
/**
/**
...
...
extension/Source/core/helper/Logger.php
View file @
10d77d42
...
@@ -20,6 +20,18 @@ require_once(__DIR__ . '/../helper/Support.php');
...
@@ -20,6 +20,18 @@ require_once(__DIR__ . '/../helper/Support.php');
*/
*/
class
Logger
{
class
Logger
{
/**
* @var String
*/
private
static
$systemSitePath
=
''
;
/**
* @param $path
*/
public
static
function
setSystemSitePath
(
$path
)
{
self
::
$systemSitePath
=
$path
;
}
/**
/**
* Append $msg to $filename.
* Append $msg to $filename.
*
*
...
@@ -38,17 +50,19 @@ class Logger {
...
@@ -38,17 +50,19 @@ class Logger {
return
;
return
;
}
}
$filename
=
self
::
relativeToT3Dir
(
$filename
);
$filename
=
self
::
makePathAbsolute
(
$filename
);
try
{
try
{
$handle
=
fopen
(
$filename
,
$mode
);
$handle
=
fopen
(
$filename
,
$mode
);
}
catch
(
\
Exception
$e
)
{
}
catch
(
\
Exception
$e
)
{
$dummy
=
1
;
$dummy
=
1
;
}
}
if
(
$handle
===
false
)
{
$cwd1
=
getcwd
();
if
(
$handle
===
false
)
{
if
(
$recursion
){
if
(
$recursion
)
{
throw
new
UserFormException
(
throw
new
UserFormException
(
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Error: cannot open file'
,
json_encode
([
ERROR_MESSAGE_TO_USER
=>
'Error: cannot open file'
,
ERROR_MESSAGE_SUPPORT
=>
"Error - cannot open. File: "
.
$filename
.
ERROR_MESSAGE_SUPPORT
=>
"Error - cannot open. File: "
.
$filename
.
...
@@ -87,13 +101,25 @@ class Logger {
...
@@ -87,13 +101,25 @@ class Logger {
*
*
* @param $filename
* @param $filename
* @return string
* @return string
* @throws CodeException
*/
*/
private
static
function
relativeToT3Dir
(
$filename
)
{
private
static
function
makePathAbsolute
(
$filename
)
{
if
(
isset
(
$filename
[
0
])
&&
$filename
[
0
]
!=
'/'
)
{
if
(
isset
(
$filename
[
0
])
&&
$filename
[
0
]
!=
'/'
)
{
if
(
self
::
$systemSitePath
==
''
)
{
if
(
defined
(
'PHPUNIT_QFQ'
))
{
if
(
strpos
(
getcwd
(),
'qfq/'
.
API_DIR_EXT
)
!==
false
)
{
if
(
strpos
(
getcwd
(),
'qfq/'
.
API_DIR_EXT
)
!==
false
)
{
return
(
'../../../../../'
.
$filename
);
return
(
'../../../../../'
.
$filename
);
}
}
return
$filename
;
}
throw
new
CodeException
(
'SystemSitePath is not set and the given logfile should be made absolute.'
,
ERROR_MISSING_VALUE
);
}
return
self
::
$systemSitePath
.
DIRECTORY_SEPARATOR
.
$filename
;
}
}
return
$filename
;
return
$filename
;
...
...
extension/Source/core/helper/Support.php
View file @
10d77d42
...
@@ -990,7 +990,7 @@ class Support {
...
@@ -990,7 +990,7 @@ class Support {
}
}
// If min or max is set and if there is the standard error text given, define a more detailed error text.
// If min or max is set and if there is the standard error text given, define a more detailed error text.
if
((
$formElement
[
FE_MIN
]
!=
''
||
$formElement
[
FE_MAX
]
!=
''
)
&&
(
$formElement
[
F_FE_DATA_ERROR
]
??
''
)
==
F_FE_DATA_ERROR_DEFAULT
)
{
if
((
$formElement
[
FE_MIN
]
!=
''
||
$formElement
[
FE_MAX
]
!=
''
)
&&
(
$formElement
[
F_FE_DATA_ERROR
]
??
''
)
==
F_FE_DATA_ERROR_DEFAULT
)
{
$formElement
[
F_FE_DATA_ERROR
]
=
F_FE_DATA_ERROR_DEFAULT
.
' - allowed values: '
.
$formElement
[
FE_MIN
]
.
'...'
.
$formElement
[
FE_MAX
];
$formElement
[
F_FE_DATA_ERROR
]
=
F_FE_DATA_ERROR_DEFAULT
.
' - allowed values: '
.
$formElement
[
FE_MIN
]
.
'...'
.
$formElement
[
FE_MAX
];
}
}
}
}
...
@@ -1281,15 +1281,6 @@ class Support {
...
@@ -1281,15 +1281,6 @@ class Support {
HelperFile
::
unlink
(
$srcFile
);
HelperFile
::
unlink
(
$srcFile
);
}
}
/**
*
*/
public
static
function
createTempDir
()
{
return
exec
(
"mktemp -d --tmpdir "
.
QFQ_TEMP_FILE_PATTERN
);
}
/**
/**
* Convert 'false' and '<empty string>' to '0'.
* Convert 'false' and '<empty string>' to '0'.
*
*
...
...
extension/Source/core/store/Store.php
View file @
10d77d42
...
@@ -282,6 +282,8 @@ class Store {
...
@@ -282,6 +282,8 @@ class Store {
}
}
}
}
Logger
::
setSystemSitePath
(
$config
[
SYSTEM_SITE_PATH
]);
return
$config
;
return
$config
;
}
}
...
...
extension/Tests/unit/core/BuildFormPlainTest.php
View file @
10d77d42
...
@@ -544,6 +544,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
...
@@ -544,6 +544,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
$result
=
$build
->
buildSubrecord
(
$formElement
,
'name:1'
,
''
,
$json
);
$result
=
$build
->
buildSubrecord
(
$formElement
,
'name:1'
,
''
,
$json
);
$this
->
assertEquals
(
'<table class="table table-hover qfq-subrecord-table" ><thead><tr><th>id</th><th>name</th><th>firstName</th></tr></thead><tbody ><tr class="record" ><td><span class="text-muted">1</span></td><td>Doe</td><td>John</td></tr><tr class="record" ><td><span class="text-muted">2</span></td><td>Smith</td><td>Jane</td></tr></tbody></table>'
,
$result
);
$this
->
assertEquals
(
'<table class="table table-hover qfq-subrecord-table" ><thead><tr><th>id</th><th>name</th><th>firstName</th></tr></thead><tbody ><tr class="record" ><td><span class="text-muted">1</span></td><td>Doe</td><td>John</td></tr><tr class="record" ><td><span class="text-muted">2</span></td><td>Smith</td><td>Jane</td></tr></tbody></table>'
,
$result
);
// $this->assertEquals('Please save this record first.', $result);
$this
->
store
->
setStore
([
'id'
=>
1
],
STORE_RECORD
,
true
);
$this
->
store
->
setStore
([
'id'
=>
1
],
STORE_RECORD
,
true
);
$result
=
$build
->
buildSubrecord
(
$formElement
,
'name:1'
,
''
,
$json
);
$result
=
$build
->
buildSubrecord
(
$formElement
,
'name:1'
,
''
,
$json
);
...
...
extension/Tests/unit/core/database/AbstractDatabaseTest.php
View file @
10d77d42
...
@@ -19,7 +19,7 @@ abstract class AbstractDatabaseTest extends TestCase {
...
@@ -19,7 +19,7 @@ abstract class AbstractDatabaseTest extends TestCase {
static
protected
$mysqli
=
null
;
static
protected
$mysqli
=
null
;
/**
/**
* @var
Database
* @var
array
*/
*/
protected
$dbArray
=
array
();
protected
$dbArray
=
array
();
...
...
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