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
1ed25e87
Commit
1ed25e87
authored
Aug 27, 2020
by
Carsten Rose
Browse files
Fixes #11075
parent
b452306e
Pipeline
#3726
passed with stages
in 4 minutes and 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Classes/Core/Database/Database.php
View file @
1ed25e87
...
@@ -175,13 +175,13 @@ class Database {
...
@@ -175,13 +175,13 @@ class Database {
* Else an exception. ROW_EXPECT_GE_1: Like 'ROW_REGULAR'. Throws an exception if there is an empty resultset.
* Else an exception. ROW_EXPECT_GE_1: Like 'ROW_REGULAR'. Throws an exception if there is an empty resultset.
* ROW_KEYS: Return 2-dimensional num(!) array. Every query row is one array row. $keys are the column names.
* ROW_KEYS: Return 2-dimensional num(!) array. Every query row is one array row. $keys are the column names.
*
*
* @param
$sql
* @param
string
$sql
* @param string $mode
* @param string $mode
* @param array $parameterArray
* @param array $parameterArray
* @param string $specificMessage
* @param string $specificMessage
* @param array $keys
* @param array $keys
* @param array $stat DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
* @param array $stat DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
* @param array $skipErrno
* @param array $skipErrno
Array of ERRNO numbers, which should be skipped and not throw an error.
*
*
* @return array|int
* @return array|int
* SELECT | SHOW | DESCRIBE | EXPLAIN: see $mode
* SELECT | SHOW | DESCRIBE | EXPLAIN: see $mode
...
@@ -349,7 +349,7 @@ class Database {
...
@@ -349,7 +349,7 @@ class Database {
* the query.
* the query.
* @param array $stat DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
* @param array $stat DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
* @param string $specificMessage
* @param string $specificMessage
* @param array $skipErrno
* @param array $skipErrno
Array of ERRNO numbers, which should be skipped and not throw an error.
*
*
* @return int|mixed
* @return int|mixed
* @throws \CodeException
* @throws \CodeException
...
@@ -360,8 +360,6 @@ class Database {
...
@@ -360,8 +360,6 @@ class Database {
$sqlLogMode
=
$this
->
isSqlModify
(
$sql
)
?
SQL_LOG_MODE_MODIFY
:
SQL_LOG_MODE_ALL
;
$sqlLogMode
=
$this
->
isSqlModify
(
$sql
)
?
SQL_LOG_MODE_MODIFY
:
SQL_LOG_MODE_ALL
;
$errno
=
0
;
$errno
=
0
;
$result
=
0
;
$stat
=
array
();
$stat
=
array
();
$errorMsg
[
ERROR_MESSAGE_TO_USER
]
=
empty
(
$specificMessage
)
?
'SQL error'
:
$specificMessage
;
$errorMsg
[
ERROR_MESSAGE_TO_USER
]
=
empty
(
$specificMessage
)
?
'SQL error'
:
$specificMessage
;
...
@@ -370,53 +368,44 @@ class Database {
...
@@ -370,53 +368,44 @@ class Database {
$this
->
store
->
setVar
(
SYSTEM_SQL_PARAM_ARRAY
,
$parameterArray
,
STORE_SYSTEM
);
$this
->
store
->
setVar
(
SYSTEM_SQL_PARAM_ARRAY
,
$parameterArray
,
STORE_SYSTEM
);
}
}
// if ($specificMessage !== '') {
// $specificMessage = ' - ' . $specificMessage;
// }
// Logfile
// Logfile
$this
->
dbLog
(
$sqlLogMode
,
$sql
,
$parameterArray
);
$this
->
dbLog
(
$sqlLogMode
,
$sql
,
$parameterArray
);
if
(
false
===
(
$this
->
mysqli_stmt
=
$this
->
mysqli
->
prepare
(
$sql
)))
{
if
(
false
===
(
$this
->
mysqli_stmt
=
$this
->
mysqli
->
prepare
(
$sql
)))
{
$errno
=
$this
->
mysqli
->
errno
;
if
(
$skipErrno
===
array
()
&&
false
===
array_search
(
$
this
->
mysqli
->
errno
,
$skipErrno
))
{
if
(
$skipErrno
===
array
()
&&
false
===
array_search
(
$errno
,
$skipErrno
))
{
$this
->
dbLog
(
SQL_LOG_MODE_ERROR
,
$sql
,
$parameterArray
);
$this
->
dbLog
(
SQL_LOG_MODE_ERROR
,
$sql
,
$parameterArray
);
$errorMsg
[
ERROR_MESSAGE_TO_DEVELOPER
]
=
$this
->
getSqlHint
(
$sql
,
$this
->
mysqli
->
error
);
$errorMsg
[
ERROR_MESSAGE_TO_DEVELOPER
]
=
$this
->
getSqlHint
(
$sql
,
$this
->
mysqli
->
error
);
$errorMsg
[
ERROR_MESSAGE_OS
]
=
'[ mysqli: '
.
$
this
->
mysqli
->
errno
.
' ] '
.
$this
->
mysqli
->
error
;
$errorMsg
[
ERROR_MESSAGE_OS
]
=
'[ mysqli: '
.
$errno
.
' ] '
.
$this
->
mysqli
->
error
;
throw
new
\
DbException
(
json_encode
(
$errorMsg
),
ERROR_DB_PREPARE
);
throw
new
\
DbException
(
json_encode
(
$errorMsg
),
ERROR_DB_PREPARE
);
}
else
{
$errno
=
$this
->
mysqli
->
errno
;
}
}
}
}
if
(
count
(
$parameterArray
)
>
0
)
{
if
(
count
(
$parameterArray
)
>
0
)
{
if
(
false
===
$this
->
prepareBindParam
(
$parameterArray
))
{
if
(
false
===
$this
->
prepareBindParam
(
$parameterArray
))
{
if
(
$skipErrno
!==
array
()
&&
false
===
array_search
(
$this
->
mysqli
->
errno
,
$skipErrno
))
{
$errno
=
$this
->
mysqli_stmt
->
errno
;
if
(
$skipErrno
===
array
()
&&
false
===
array_search
(
$errno
,
$skipErrno
))
{
$this
->
dbLog
(
SQL_LOG_MODE_ERROR
,
$sql
,
$parameterArray
);
$this
->
dbLog
(
SQL_LOG_MODE_ERROR
,
$sql
,
$parameterArray
);
$errorMsg
[
ERROR_MESSAGE_TO_DEVELOPER
]
=
$this
->
getSqlHint
(
$sql
,
$this
->
mysqli
->
error
);
$errorMsg
[
ERROR_MESSAGE_TO_DEVELOPER
]
=
$this
->
getSqlHint
(
$sql
,
$this
->
mysqli
->
error
);
$errorMsg
[
ERROR_MESSAGE_OS
]
=
'[ mysqli: '
.
$
this
->
mysqli_stmt
->
errno
.
' ] '
.
$this
->
mysqli_stmt
->
error
;
$errorMsg
[
ERROR_MESSAGE_OS
]
=
'[ mysqli: '
.
$errno
.
' ] '
.
$this
->
mysqli_stmt
->
error
;
throw
new
\
DbException
(
json_encode
(
$errorMsg
),
ERROR_DB_BIND
);
throw
new
\
DbException
(
json_encode
(
$errorMsg
),
ERROR_DB_BIND
);
}
else
{
$errno
=
$this
->
mysqli
->
errno
;
}
}
}
}
}
}
if
(
false
===
$this
->
mysqli_stmt
->
execute
())
{
if
(
false
===
$this
->
mysqli_stmt
->
execute
())
{
if
(
$skipErrno
!==
array
()
&&
false
===
array_search
(
$this
->
mysqli
->
errno
,
$skipErrno
))
{
$errno
=
$this
->
mysqli
->
errno
;
if
(
$skipErrno
===
array
()
||
false
===
array_search
(
$errno
,
$skipErrno
))
{
$this
->
dbLog
(
SQL_LOG_MODE_ERROR
,
$sql
,
$parameterArray
);
$this
->
dbLog
(
SQL_LOG_MODE_ERROR
,
$sql
,
$parameterArray
);
$errorMsg
[
ERROR_MESSAGE_TO_DEVELOPER
]
=
$this
->
getSqlHint
(
$sql
,
$this
->
mysqli
->
error
);
$errorMsg
[
ERROR_MESSAGE_TO_DEVELOPER
]
=
$this
->
getSqlHint
(
$sql
,
$this
->
mysqli
->
error
);
$errorMsg
[
ERROR_MESSAGE_OS
]
=
'[ mysqli: '
.
$this
->
mysqli_stmt
->
errno
.
' ] '
.
$this
->
mysqli_stmt
->
error
;
$errorMsg
[
ERROR_MESSAGE_OS
]
=
'[ mysqli: '
.
$this
->
mysqli_stmt
->
errno
.
' ] '
.
$this
->
mysqli_stmt
->
error
;
throw
new
\
DbException
(
json_encode
(
$errorMsg
),
ERROR_DB_EXECUTE
);
throw
new
\
DbException
(
json_encode
(
$errorMsg
),
ERROR_DB_EXECUTE
);
}
else
{
$errno
=
$this
->
mysqli
->
errno
;
}
}
}
}
$msg
=
''
;
$count
=
0
;
if
(
$errno
===
0
)
{
if
(
$errno
===
0
)
{
$command
=
strtoupper
(
explode
(
' '
,
$sql
,
2
)[
0
]);
$command
=
strtoupper
(
explode
(
' '
,
$sql
,
2
)[
0
]);
}
else
{
}
else
{
...
...
extension/Tests/Unit/Core/Database/DatabaseTest.php
View file @
1ed25e87
...
@@ -242,6 +242,17 @@ class DatabaseTest extends AbstractDatabaseTest {
...
@@ -242,6 +242,17 @@ class DatabaseTest extends AbstractDatabaseTest {
$this
->
dbArray
[
DB_INDEX_DEFAULT
]
->
sql
(
'some garbage'
);
$this
->
dbArray
[
DB_INDEX_DEFAULT
]
->
sql
(
'some garbage'
);
}
}
/**
* @expectedException DbException
*
* @throws \CodeException
* @throws \DbException
* @throws \UserFormException
*/
public
function
testReportException
()
{
$this
->
dbArray
[
DB_INDEX_DEFAULT
]
->
sql
(
"INSERT INTO Person (`id`,`name`) VALUES (1,'test')"
);
}
/**
/**
* Check to skip mysqli errno 1060
* Check to skip mysqli errno 1060
*
*
...
...
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