PluginProbe
User Access Manager / trunk
User Access Manager vtrunk
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Database/Database.php +15 -1 2.3.18trunk View file →
@@ -146,8 +146,22 @@
146 146 }
147 147
148 148 public function getCharset(): string
149 149 {
150 + return $this->getCharsetCollate('DEFAULT ');
151 + }
152 +
153 + /**
154 + * The charset clause for a column definition. It carries no DEFAULT, because that
155 + * makes it a table option, which a column definition does not accept.
156 + */
157 + public function getColumnCharset(): string
158 + {
159 + return $this->getCharsetCollate('');
160 + }
161 +
162 + private function getCharsetCollate(string $charsetPrefix): string
163 + {
150 164 $mySqlVersion = (string) $this->getVariable('SELECT VERSION() as mysql_version');
151 165
152 166 if (version_compare($mySqlVersion, '4.1.0', '<')) {
153 167 return '';
@@ -155,9 +169,9 @@
155 169
156 170 $charsetCollate = '';
157 171
158 172 if (!empty($this->wpDatabase->charset)) {
159 - $charsetCollate = "DEFAULT CHARACTER SET {$this->wpDatabase->charset}";
173 + $charsetCollate = "{$charsetPrefix}CHARACTER SET {$this->wpDatabase->charset}";
160 174 }
161 175
162 176 if (!empty($this->wpDatabase->collate)) {
163 177 $charsetCollate .= " COLLATE {$this->wpDatabase->collate}";