Selaa lähdekoodia

Update Admin\Instal page

Add additional check for PDO driver and DB permissions.
Visman 2 vuotta sitten
vanhempi
commit
db2d89168d

+ 25 - 0
app/Models/Pages/Admin/Install.php

@@ -623,6 +623,31 @@ class Install extends Admin
             $v->addError(['Bad database encoding', 'UTF-8']);
         }
 
+        // тест типа возвращаемого результата
+        $table  = '::tmp' . time();
+        $schema = [
+            'FIELDS' => [
+                'test_field' => ['INT(10) UNSIGNED', false, 0],
+            ],
+            'ENGINE' => $this->DBEngine,
+        ];
+
+        if (! $this->c->DB->createTable($table, $schema)) {
+            $v->addError('Failed to create table');
+        } else {
+            $this->c->DB->exec("INSERT INTO {$table} (test_field) VALUES (?i)", [123]);
+
+            $value = $this->c->DB->query("SELECT test_field FROM {$table} WHERE test_field=123")->fetchColumn();
+
+            if (123 !== $value) {
+                $v->addError('Wrong data type for numeric fields');
+            }
+
+            if (! $this->c->DB->dropTable($table)) {
+                $v->addError('Failed to drop table');
+            }
+        }
+
         return $dbhost;
     }
 

+ 9 - 0
app/lang/en/admin_install.po

@@ -248,3 +248,12 @@ msgstr "Cookie Secure"
 
 msgid "Cookie Secure info"
 msgstr "Indicates that the cookie should only be transmitted over a secure <b>HTTPS</b> connection from the client. When set to <b>YES</b>, the cookie will only be set if a secure connection exists."
+
+msgid "Failed to create table"
+msgstr "Failed to create table in selected database."
+
+msgid "Wrong data type for numeric fields"
+msgstr "The PDO driver returns the wrong data type for numeric fields, most likely strings. For MySQL, the most likely reason is that the pdo_mysql extension uses the libmysql library and not mysqlnd. Change the php configuration (among the php extensions in the control panel there may be nd_pdo_mysql, select it instead of pdo_mysql)."
+
+msgid "Failed to drop table"
+msgstr "Failed to drop a table in the selected database."

+ 9 - 0
app/lang/ru/admin_install.po

@@ -248,3 +248,12 @@ msgstr "Cookie Secure"
 
 msgid "Cookie Secure info"
 msgstr "Указывает на то, что значение cookie должно передаваться от клиента по защищённому соединению <b>HTTPS</b>. Если задано <b>ДА</b>, cookie от клиента будет передано на сервер, только если установлено защищённое соединение."
+
+msgid "Failed to create table"
+msgstr "Не удалось создать таблицу в выбранной БД."
+
+msgid "Wrong data type for numeric fields"
+msgstr "PDO драйвер возвращает неверный тип данных для числовых полей, вероятнее всего строки. Для MySQL вероятнее всего причина может быть в том, что расширение pdo_mysql использует библиотеку libmysql, а не mysqlnd. Измените конфигурацию php (среди расширений php в панели управления возможно есть nd_pdo_mysql, выберите его вместо pdo_mysql)."
+
+msgid "Failed to drop table"
+msgstr "Не удалось удалить таблицу в выбранной БД."