Skip to content

Commit 8c5ffa1

Browse files
authored
Warn about db name wildcards (#5390)
2 parents 8345993 + 122ac8f commit 8c5ffa1

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

application/forms/MigrationForm.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ protected function assemble(): void
133133
. ' that has the appropriate credentials to resolve this issue.'
134134
),
135135
implode(', ', $mm->getRequiredDatabasePrivileges())
136+
))),
137+
new HtmlElement('br'),
138+
new HtmlElement('br'),
139+
new HtmlElement('span', null, Text::create(sprintf(
140+
$this->translate(
141+
'The database name may contain either an underscore or a percent sign.'
142+
. ' In MySQL these characters represent a wildcard. If part of a database name,'
143+
. ' they might not have been escaped when manually granting privileges.'
144+
. ' Privileges might not be detected in this case. Check the documentation and'
145+
. ' update your grants accordingly: %s'
146+
),
147+
'https://dev.mysql.com/doc/refman/8.0/en/grant.html#grant-quoting'
136148
)))
137149
)
138150
);

modules/setup/application/forms/DatabaseCreationPage.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ public function setDatabaseUsagePrivileges(array $privileges)
9191
*/
9292
public function createElements(array $formData)
9393
{
94+
if ($this->config['db'] === 'mysql' && preg_match('/[_%]/', $this->config['dbname'])) {
95+
$this->warning(sprintf(
96+
$this->translate(
97+
'The database name may contain either an underscore or a percent sign.'
98+
. ' In MySQL these characters represent a wildcard. If part of a database name,'
99+
. ' they might not have been escaped when manually granting privileges.'
100+
. ' Privileges might not be detected in this case. Check the documentation and'
101+
. ' update your grants accordingly: %s'
102+
),
103+
'https://dev.mysql.com/doc/refman/8.0/en/grant.html#grant-quoting'
104+
));
105+
}
106+
94107
$skipValidation = isset($formData['skip_validation']) && $formData['skip_validation'];
95108
$this->addElement(
96109
'text',

0 commit comments

Comments
 (0)