aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-05-10 12:35:14 +0200
committerJoas Schilling <coding@schilljs.com>2017-05-16 16:16:12 +0200
commit1951c88bdcc201078968613743229e4d97204855 (patch)
tree568223b74923e7c469f866c2dc4a3b3a9a91761c
parent8e757b343d92da5b53725f4574f8a222710a8864 (diff)
downloadnextcloud-server-1951c88bdcc201078968613743229e4d97204855.tar.gz
nextcloud-server-1951c88bdcc201078968613743229e4d97204855.zip
We don't use the prefix on index names
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/private/App/CodeChecker/DatabaseSchemaChecker.php10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/private/App/CodeChecker/DatabaseSchemaChecker.php b/lib/private/App/CodeChecker/DatabaseSchemaChecker.php
index 30226139b19..1255dec25c1 100644
--- a/lib/private/App/CodeChecker/DatabaseSchemaChecker.php
+++ b/lib/private/App/CodeChecker/DatabaseSchemaChecker.php
@@ -88,14 +88,12 @@ class DatabaseSchemaChecker {
// Index names
foreach ($table->declaration->index as $index) {
- if (strpos($index->name, '*dbprefix*') !== 0) {
- $warnings[] = 'Database schema warning: name of index ' . $index->name . ' on table ' . $table->name . ' does not start with *dbprefix*';
- }
- $indexName = substr($index->name, strlen('*dbprefix*'));
- if (strpos($indexName, '*dbprefix*') !== false) {
- $warnings[] = 'Database schema warning: *dbprefix* should only appear once in name of index ' . $index->name . ' on table ' . $table->name;
+ $hasPrefix = strpos($index->name, '*dbprefix*');
+ if ($hasPrefix !== false && $hasPrefix !== 0) {
+ $warnings[] = 'Database schema warning: *dbprefix* should only appear at the beginning in name of index ' . $index->name . ' on table ' . $table->name;
}
+ $indexName = $hasPrefix === 0 ? substr($index->name, strlen('*dbprefix*')) : $index->name;
if (strlen($indexName) > 27) {
$errors[] = 'Database schema error: Name of index ' . $index->name . ' on table ' . $table->name . ' is too long (' . strlen($tableName) . '), max. 27 characters + *dbprefix* allowed';
}