Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-11-07 12:48:56 +0300
committerGitHub <noreply@github.com>2020-11-07 12:48:56 +0300
commit8c384b8856246239b64d2b5445976464e0f7dcf5 (patch)
tree7437cc3b28d9705ba71e0522fea9804e949e94a9
parent80399bd8907abaca622bbd84fa543050c2ca3917 (diff)
parentce718ebd7bbf9b4356f62fbb253970b7372e2ed2 (diff)
Merge pull request #23952 from nextcloud/backport/23922/stable19
[stable19] Improve query type detection
-rw-r--r--lib/private/legacy/OC_DB.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/private/legacy/OC_DB.php b/lib/private/legacy/OC_DB.php
index 1d2e9bd1429..390b2d3b1ea 100644
--- a/lib/private/legacy/OC_DB.php
+++ b/lib/private/legacy/OC_DB.php
@@ -73,8 +73,7 @@ class OC_DB {
throw new \OC\DatabaseException($e->getMessage());
}
// differentiate between query and manipulation
- $result = new OC_DB_StatementWrapper($result, $isManipulation);
- return $result;
+ return new OC_DB_StatementWrapper($result, $isManipulation);
}
/**
@@ -85,22 +84,26 @@ class OC_DB {
* @return bool
*/
public static function isManipulation($sql) {
+ $sql = trim($sql);
$selectOccurrence = stripos($sql, 'SELECT');
- if ($selectOccurrence !== false && $selectOccurrence < 10) {
+ if ($selectOccurrence === 0) {
return false;
}
$insertOccurrence = stripos($sql, 'INSERT');
- if ($insertOccurrence !== false && $insertOccurrence < 10) {
+ if ($insertOccurrence === 0) {
return true;
}
$updateOccurrence = stripos($sql, 'UPDATE');
- if ($updateOccurrence !== false && $updateOccurrence < 10) {
+ if ($updateOccurrence === 0) {
return true;
}
$deleteOccurrence = stripos($sql, 'DELETE');
- if ($deleteOccurrence !== false && $deleteOccurrence < 10) {
+ if ($deleteOccurrence === 0) {
return true;
}
+
+ \OC::$server->getLogger()->logException(new \Exception('Can not detect if query is manipulating: ' . $sql));
+
return false;
}