Skip to content
GitLab
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
7891900a
Commit
7891900a
authored
Jul 07, 2018
by
Carsten Rose
Browse files
Recode exception catching in API PHP files.
parent
181a9c94
Pipeline
#662
passed with stage
in 1 minute and 35 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Documentation/Manual.rst
View file @
7891900a
...
...
@@ -6877,7 +6877,7 @@ Usage
^^^^^
The system `cron` service will call the `QFQ AutoCron` every minute. `QFQ AutoCron` checks if there is a pending job, by looking
for jobs with `nextRun`<=NOW(). All found jobs will be fired - depending on their type, such jobs will send mail(s) or
for jobs with `nextRun`
<=
`
NOW()
`
. All found jobs will be fired - depending on their type, such jobs will send mail(s) or
open a `webpage`. A `webpage` will mostly be a local T3 page with at least one QFQ record on it. Such a QFQ record might
do some manipulation on the database or any other task.
...
...
@@ -7057,7 +7057,7 @@ Search the given code in `typo3temp/logs/*`, in this example 20180612205917761fc
a more detailed message.
The error might occur if there are problematic characters in config.qfq.php, like single or double ticks inside strings,
wich are not enclosed (correctly).
wich are not enclosed (correctly).
.. _`sendEmailProblem`:
...
...
extension/qfq/api/delete.php
View file @
7891900a
...
...
@@ -73,70 +73,74 @@ $modeAnswer = false;
$flagSuccess
=
false
;
try
{
try
{
$qfq
=
new
\
qfq\QuickFormQuery
([
'bodytext'
=>
''
]);
$qfq
=
new
\
qfq\QuickFormQuery
([
'bodytext'
=>
''
]);
$answer
=
$qfq
->
delete
();
$answer
=
$qfq
->
delete
();
// in case everything is fine, an empty string is returned. Else an Array.
$flagSuccess
=
(
$answer
===
''
);
// in case everything is fine, an empty string is returned. Else an Array.
$flagSuccess
=
(
$answer
===
''
);
$targetUrl
=
Store
::
getVar
(
SIP_TARGET_URL
,
STORE_SIP
);
$modeAnswer
=
Store
::
getVar
(
SIP_MODE_ANSWER
,
STORE_SIP
);
$targetUrl
=
Store
::
getVar
(
SIP_TARGET_URL
,
STORE_SIP
);
$modeAnswer
=
Store
::
getVar
(
SIP_MODE_ANSWER
,
STORE_SIP
);
switch
(
$modeAnswer
)
{
case
MODE_JSON
:
$answer
=
array
();
if
(
$flagSuccess
)
{
$answer
[
API_MESSAGE
]
=
'Deleted'
;
$answer
[
API_REDIRECT
]
=
API_ANSWER_REDIRECT_AUTO
;
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_SUCCESS
;
}
else
{
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_ERROR
;
}
switch
(
$modeAnswer
)
{
case
MODE_JSON
:
$answer
=
array
();
if
(
$flagSuccess
)
{
$answer
[
API_MESSAGE
]
=
'Deleted'
;
$answer
[
API_REDIRECT
]
=
API_ANSWER_REDIRECT_AUTO
;
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_SUCCESS
;
}
else
{
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_ERROR
;
}
break
;
break
;
case
MODE_HTML
:
if
(
$targetUrl
===
false
||
$targetUrl
===
''
)
{
throw
new
CodeException
(
'Missing target URL'
,
ERROR_MISSING_VALUE
);
}
case
MODE_HTML
:
if
(
$targetUrl
===
false
||
$targetUrl
===
''
)
{
throw
new
CodeException
(
'Missing target URL'
,
ERROR_MISSING_VALUE
);
}
if
(
$flagSuccess
)
{
$result
[
MSG_HEADER
]
=
"Location:
$targetUrl
"
;
}
break
;
if
(
$flagSuccess
)
{
$result
[
MSG_HEADER
]
=
"Location:
$targetUrl
"
;
}
break
;
default
:
throw
new
CodeException
(
'Unknown mode: '
.
$modeAnswer
,
ERROR_UNKNOWN_MODE
);
break
;
}
default
:
throw
new
CodeException
(
'Unknown mode: '
.
$modeAnswer
,
ERROR_UNKNOWN_MODE
);
break
;
}
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT
,
STORE_SYSTEM
);
if
(
$val
!==
false
)
{
$answer
[
API_FIELD_NAME
]
=
$val
;
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT
,
STORE_SYSTEM
);
if
(
$val
!==
false
)
{
$answer
[
API_FIELD_NAME
]
=
$val
;
}
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT_MESSAGE
,
STORE_SYSTEM
);
if
(
$val
!==
false
)
{
$answer
[
API_FIELD_MESSAGE
]
=
$val
;
}
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT_MESSAGE
,
STORE_SYSTEM
);
if
(
$
val
!
==
false
)
{
$
answer
[
API_FIELD_MESSAGE
]
=
$val
;
// In case $modeAnswer is still missing: try to get it again - maybe the SIP store has been initialized before the exception has been thrown.
if
(
$
modeAnswer
=
==
false
)
{
$
modeAnswer
=
Store
::
getVar
(
SIP_MODE_ANSWER
,
STORE_SIP
)
;
}
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
\
Exception
$e
)
{
$answer
[
API_MESSAGE
]
=
"Generic Exception: "
.
$e
->
getMessage
();
}
// In case $modeAnswer is still missing: try to get it again - maybe the SIP store has been initialized before the exception has been thrown.
if
(
$modeAnswer
===
false
)
{
$modeAnswer
=
Store
::
getVar
(
SIP_MODE_ANSWER
,
STORE_SIP
);
}
if
(
$modeAnswer
===
MODE_JSON
)
{
// JSON
...
...
extension/qfq/api/dragAndDrop.php
View file @
7891900a
...
...
@@ -55,22 +55,24 @@ $answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
$answer
[
API_MESSAGE
]
=
''
;
try
{
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
''
]);
try
{
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
''
]);
$data
=
$qfq
->
dragAndDrop
();
$data
=
$qfq
->
dragAndDrop
();
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_SUCCESS
;
$answer
[
API_MESSAGE
]
=
'reorder: success'
;
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_SUCCESS
;
$answer
[
API_MESSAGE
]
=
'reorder: success'
;
// $answer[API_FORM_UPDATE] = $data[API_FORM_UPDATE];
// $answer[API_ELEMENT_UPDATE] = $data[API_ELEMENT_UPDATE];
// unset($answer[API_FORM_UPDATE][API_ELEMENT_UPDATE]);
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
}
catch
(
\
Exception
$e
)
{
$answer
[
API_MESSAGE
]
=
"Generic Exception: "
.
$e
->
getMessage
();
}
...
...
extension/qfq/api/save.php
View file @
7891900a
...
...
@@ -54,41 +54,43 @@ $answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
$answer
[
API_MESSAGE
]
=
''
;
try
{
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
""
]);
$data
=
$qfq
->
saveForm
();
$arr
=
$qfq
->
getForwardMode
();
$answer
[
API_REDIRECT
]
=
$arr
[
API_REDIRECT
];
$answer
[
API_REDIRECT_URL
]
=
$arr
[
API_REDIRECT_URL
];
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_SUCCESS
;
$answer
[
API_MESSAGE
]
=
'Saved'
;
if
(
isset
(
$data
[
API_ELEMENT_UPDATE
]))
{
$answer
[
API_ELEMENT_UPDATE
]
=
$data
[
API_ELEMENT_UPDATE
];
try
{
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
""
]);
$data
=
$qfq
->
saveForm
();
$arr
=
$qfq
->
getForwardMode
();
$answer
[
API_REDIRECT
]
=
$arr
[
API_REDIRECT
];
$answer
[
API_REDIRECT_URL
]
=
$arr
[
API_REDIRECT_URL
];
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_SUCCESS
;
$answer
[
API_MESSAGE
]
=
'Saved'
;
if
(
isset
(
$data
[
API_ELEMENT_UPDATE
]))
{
$answer
[
API_ELEMENT_UPDATE
]
=
$data
[
API_ELEMENT_UPDATE
];
}
if
(
isset
(
$data
[
API_FORM_UPDATE
]))
{
$answer
[
API_FORM_UPDATE
]
=
$data
[
API_FORM_UPDATE
];
}
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT
,
STORE_SYSTEM
);
if
(
$val
!==
false
)
{
$answer
[
API_FIELD_NAME
]
=
$val
;
}
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT_MESSAGE
,
STORE_SYSTEM
);
if
(
$val
!==
false
)
{
$answer
[
API_FIELD_MESSAGE
]
=
$val
;
}
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
if
(
isset
(
$data
[
API_FORM_UPDATE
]))
{
$answer
[
API_FORM_UPDATE
]
=
$data
[
API_FORM_UPDATE
];
}
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT
,
STORE_SYSTEM
);
if
(
$val
!==
false
)
{
$answer
[
API_FIELD_NAME
]
=
$val
;
}
$val
=
Store
::
getVar
(
SYSTEM_FORM_ELEMENT_MESSAGE
,
STORE_SYSTEM
);
if
(
$val
!==
false
)
{
$answer
[
API_FIELD_MESSAGE
]
=
$val
;
}
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
\
Exception
$e
)
{
$answer
[
API_MESSAGE
]
=
"Generic Exception: "
.
$e
->
getMessage
();
}
...
...
extension/qfq/external/AutoCron.php
View file @
7891900a
...
...
@@ -54,7 +54,9 @@ class AutoCron {
* @param bool $verbose
* @param bool $phpUnit
* @throws CodeException
* @throws DbException
* @throws UserFormException
* @throws UserReportException
*/
public
function
__construct
(
$verbose
=
false
,
$phpUnit
=
false
)
{
...
...
@@ -81,6 +83,7 @@ class AutoCron {
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
private
function
checkForOldJobs
(
$ageMaxMinutes
)
{
...
...
@@ -100,6 +103,7 @@ class AutoCron {
* @return array
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
private
function
calcNextRun
(
array
$job
)
{
...
...
@@ -227,6 +231,7 @@ class AutoCron {
* @return array $job, updated with AUTOCRON_LAST_STATUS
* @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws UserFormException
* @throws UserReportException
*/
...
...
@@ -277,8 +282,10 @@ class AutoCron {
*
* @throws CodeException
* @throws DbException
* @throws DownloadException
* @throws ShellException
* @throws UserFormException
* @throws UserReportException
*/
public
function
process
()
{
...
...
extension/qfq/external/autocron.php
View file @
7891900a
...
...
@@ -11,21 +11,23 @@ require_once(__DIR__ . '/AutoCron.php');
global
$argv
;
try
{
$verbose
=
false
;
if
(
isset
(
$argv
[
1
])
&&
$argv
[
1
]
==
'-v'
)
{
$verbose
=
true
;
try
{
$verbose
=
false
;
if
(
isset
(
$argv
[
1
])
&&
$argv
[
1
]
==
'-v'
)
{
$verbose
=
true
;
}
$autocron
=
new
\
qfq\AutoCron
(
$verbose
);
$autocron
->
process
();
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
$autocron
=
new
\
qfq\AutoCron
(
$verbose
);
$autocron
->
process
();
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
\
Exception
$e
)
{
$answer
[
API_MESSAGE
]
=
"Generic Exception: "
.
$e
->
getMessage
();
}
...
...
extension/qfq/qfq/Constants.php
View file @
7891900a
...
...
@@ -311,7 +311,7 @@ const STORE_FORM = "F"; // form, still not saved in database
const
STORE_SIP
=
"S"
;
// SIP
const
STORE_RECORD
=
"R"
;
// selected record from primary table.
const
STORE_BEFORE
=
"B"
;
// selected record from primary table before any modifcations.
const
STORE_PARENT_RECORD
=
"P"
;
// on multi forms the recent record of the outer query (multi).
const
STORE_PARENT_RECORD
=
"P"
;
// on
autoCron, copy/paste &
multi forms the recent record of the outer query (multi).
const
STORE_TABLE_DEFAULT
=
"D"
;
// definition of primary table.
const
STORE_TABLE_COLUMN_TYPES
=
"M"
;
// column types of primary table.
const
STORE_CLIENT
=
"C"
;
// Client: POST variable, if not found: GET variable
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment