From 81d9568d004947c9ffbadf4543c61a8035bb674d Mon Sep 17 00:00:00 2001 From: Thorsten Rinne Date: Thu, 16 Jan 2025 19:58:28 +0100 Subject: [PATCH 1/5] fix: corrected column length in faqforms table --- .../src/phpMyFAQ/Instance/Database/Mysqli.php | 2 +- .../src/phpMyFAQ/Instance/Database/Pgsql.php | 2 +- .../phpMyFAQ/Instance/Database/Sqlite3.php | 2 +- .../src/phpMyFAQ/Instance/Database/Sqlsrv.php | 2 +- phpmyfaq/src/phpMyFAQ/Setup/Update.php | 62 +++++++++++++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/phpmyfaq/src/phpMyFAQ/Instance/Database/Mysqli.php b/phpmyfaq/src/phpMyFAQ/Instance/Database/Mysqli.php index 77ad35fa80..bf76a6e96e 100644 --- a/phpmyfaq/src/phpMyFAQ/Instance/Database/Mysqli.php +++ b/phpmyfaq/src/phpMyFAQ/Instance/Database/Mysqli.php @@ -208,7 +208,7 @@ class Mysqli extends Database implements Driver form_id INT(1) NOT NULL, input_id INT(11) NOT NULL, input_type VARCHAR(1000) NOT NULL, - input_label VARCHAR(100) NOT NULL, + input_label VARCHAR(500) NOT NULL, input_active INT(1) NOT NULL, input_required INT(1) NOT NULL, input_lang VARCHAR(11) NOT NULL)', diff --git a/phpmyfaq/src/phpMyFAQ/Instance/Database/Pgsql.php b/phpmyfaq/src/phpMyFAQ/Instance/Database/Pgsql.php index f66bb26b00..19ce01eb53 100644 --- a/phpmyfaq/src/phpMyFAQ/Instance/Database/Pgsql.php +++ b/phpmyfaq/src/phpMyFAQ/Instance/Database/Pgsql.php @@ -208,7 +208,7 @@ class Pgsql extends Database implements Driver form_id INTEGER NOT NULL, input_id INTEGER NOT NULL, input_type VARCHAR(1000) NOT NULL, - input_label VARCHAR(100) NOT NULL, + input_label VARCHAR(500) NOT NULL, input_active INTEGER NOT NULL, input_required INTEGER NOT NULL, input_lang VARCHAR(11) NOT NULL)', diff --git a/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlite3.php b/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlite3.php index 495b06d0cf..178b9d0e5a 100644 --- a/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlite3.php +++ b/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlite3.php @@ -204,7 +204,7 @@ class Sqlite3 extends Database implements Driver form_id INTEGER NOT NULL, input_id INTEGER NOT NULL, input_type VARCHAR(1000) NOT NULL, - input_label VARCHAR(100) NOT NULL, + input_label VARCHAR(500) NOT NULL, input_active INTEGER NOT NULL, input_required INTEGER NOT NULL, input_lang VARCHAR(11) NOT NULL)', diff --git a/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlsrv.php b/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlsrv.php index f4368fdf93..da6fdd4558 100644 --- a/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlsrv.php +++ b/phpmyfaq/src/phpMyFAQ/Instance/Database/Sqlsrv.php @@ -204,7 +204,7 @@ class Sqlsrv extends Database implements Driver form_id INTEGER NOT NULL, input_id INTEGER NOT NULL, input_type NVARCHAR(1000) NOT NULL, - input_label NVARCHAR(100) NOT NULL, + input_label NVARCHAR(500) NOT NULL, input_active INTEGER NOT NULL, input_required INTEGER NOT NULL, input_lang NVARCHAR(11) NOT NULL)', diff --git a/phpmyfaq/src/phpMyFAQ/Setup/Update.php b/phpmyfaq/src/phpMyFAQ/Setup/Update.php index f5cf1e3cbd..789ed8df25 100644 --- a/phpmyfaq/src/phpMyFAQ/Setup/Update.php +++ b/phpmyfaq/src/phpMyFAQ/Setup/Update.php @@ -165,6 +165,7 @@ public function applyUpdates(): bool $this->applyUpdates400Alpha2(); $this->applyUpdates400Alpha3(); $this->applyUpdates400Beta2(); + $this->applyUpdates405(); // Optimize the tables $this->optimizeTables(); @@ -860,6 +861,67 @@ private function applyUpdates400Beta2(): void } } + private function applyUpdates405(): void + { + if (version_compare($this->version, '4.0.5', '<')) { + switch (Database::getType()) { + case 'mysqli': + $this->queries[] = sprintf( + 'ALTER TABLE %sfaqforms CHANGE input_label input_label VARCHAR(500) NOT NULL', + Database::getTablePrefix() + ); + break; + case 'pgsql': + $this->queries[] = sprintf( + 'ALTER TABLE %sfaqforms ALTER COLUMN input_label TYPE VARCHAR(500)', + Database::getTablePrefix() + ); + $this->queries[] = sprintf( + 'ALTER TABLE %sfaqforms ALTER COLUMN input_label SET NOT NULL', + Database::getTablePrefix() + ); + break; + case 'sqlite3': + $this->queries[] = sprintf( + 'ALTER TABLE %sfaqforms RENAME TO %sfaqforms_old', + Database::getTablePrefix(), + Database::getTablePrefix() + ); + $this->queries[] = sprintf( + 'CREATE TABLE %sfaqforms ( + form_id INTEGER NOT NULL, + input_id INTEGER NOT NULL, + input_type VARCHAR(1000) NOT NULL, + input_label VARCHAR(500) NOT NULL, + input_active INTEGER NOT NULL, + input_required INTEGER NOT NULL, + input_lang VARCHAR(11) NOT NULL + )', + Database::getTablePrefix() + ); + $this->queries[] = sprintf( + 'INSERT INTO %sfaqforms + SELECT + form_id, input_id, input_type, input_label, input_active, input_required, input_lang + FROM %sfaqforms_old', + Database::getTablePrefix(), + Database::getTablePrefix() + ); + $this->queries[] = sprintf( + 'DROP TABLE %sfaqforms_old;', + Database::getTablePrefix() + ); + break; + case 'sqlsrv': + $this->queries[] = sprintf( + 'ALTER TABLE %sfaqforms ALTER COLUMN input_label NVARCHAR(500) NOT NULL', + Database::getTablePrefix() + ); + break; + } + } + } + private function updateVersion(): void { $this->configuration->update(['main.currentApiVersion' => System::getApiVersion()]); From 793877b9bd6f358c36a65612d2fba307b4fad165 Mon Sep 17 00:00:00 2001 From: Thorsten Rinne Date: Fri, 17 Jan 2025 17:10:59 +0100 Subject: [PATCH 2/5] fix: corrected check on captcha after displaying smart answer --- phpmyfaq/assets/src/search/question.js | 4 +++ phpmyfaq/assets/templates/default/ask.twig | 19 +++++++----- .../Frontend/QuestionController.php | 31 +++++++++---------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/phpmyfaq/assets/src/search/question.js b/phpmyfaq/assets/src/search/question.js index 0bc7d76ac0..985fae3e85 100644 --- a/phpmyfaq/assets/src/search/question.js +++ b/phpmyfaq/assets/src/search/question.js @@ -47,6 +47,10 @@ export const handleQuestion = () => { message.insertAdjacentElement('afterend', addElement('div', { classList: '', innerHTML: resultMessage })); // Add hidden input form.insertAdjacentElement('afterbegin', addElement('input', { type: 'hidden', name: 'save', value: 1 })); + form.insertAdjacentElement( + 'afterbegin', + addElement('input', { type: 'hidden', name: 'store', value: 'now' }) + ); } // Final result diff --git a/phpmyfaq/assets/templates/default/ask.twig b/phpmyfaq/assets/templates/default/ask.twig index 5f5a567236..5dc714bda9 100644 --- a/phpmyfaq/assets/templates/default/ask.twig +++ b/phpmyfaq/assets/templates/default/ask.twig @@ -31,16 +31,18 @@
- +
- +
@@ -48,8 +50,8 @@ {% if id5_label is defined %}
-