@@ -165,6 +165,7 @@ public function applyUpdates(): bool
165165 $ this ->applyUpdates400Alpha2 ();
166166 $ this ->applyUpdates400Alpha3 ();
167167 $ this ->applyUpdates400Beta2 ();
168+ $ this ->applyUpdates405 ();
168169
169170 // 4.1 updates
170171 $ this ->applyUpdates410Alpha ();
@@ -863,6 +864,90 @@ private function applyUpdates400Beta2(): void
863864 }
864865 }
865866
867+ private function applyUpdates405 (): void
868+ {
869+ if (version_compare ($ this ->version , '4.0.5 ' , '< ' )) {
870+ // Delete old permissions
871+ $ this ->queries [] = sprintf (
872+ 'DELETE FROM %sfaqright WHERE name = \'view_sections \'' ,
873+ Database::getTablePrefix ()
874+ );
875+ $ this ->queries [] = sprintf (
876+ 'DELETE FROM %sfaqright WHERE name = \'add_section \'' ,
877+ Database::getTablePrefix ()
878+ );
879+ $ this ->queries [] = sprintf (
880+ 'DELETE FROM %sfaqright WHERE name = \'edit_section \'' ,
881+ Database::getTablePrefix ()
882+ );
883+ $ this ->queries [] = sprintf (
884+ 'DELETE FROM %sfaqright WHERE name = \'delete_section \'' ,
885+ Database::getTablePrefix ()
886+ );
887+ $ this ->queries [] = sprintf (
888+ 'DELETE FROM %sfaqright WHERE name = \'delete_section \'' ,
889+ Database::getTablePrefix ()
890+ );
891+
892+ // Update faqforms table
893+ switch (Database::getType ()) {
894+ case 'mysqli ' :
895+ $ this ->queries [] = sprintf (
896+ 'ALTER TABLE %sfaqforms CHANGE input_label input_label VARCHAR(500) NOT NULL ' ,
897+ Database::getTablePrefix ()
898+ );
899+ break ;
900+ case 'pgsql ' :
901+ $ this ->queries [] = sprintf (
902+ 'ALTER TABLE %sfaqforms ALTER COLUMN input_label TYPE VARCHAR(500) ' ,
903+ Database::getTablePrefix ()
904+ );
905+ $ this ->queries [] = sprintf (
906+ 'ALTER TABLE %sfaqforms ALTER COLUMN input_label SET NOT NULL ' ,
907+ Database::getTablePrefix ()
908+ );
909+ break ;
910+ case 'sqlite3 ' :
911+ $ this ->queries [] = sprintf (
912+ 'ALTER TABLE %sfaqforms RENAME TO %sfaqforms_old ' ,
913+ Database::getTablePrefix (),
914+ Database::getTablePrefix ()
915+ );
916+ $ this ->queries [] = sprintf (
917+ 'CREATE TABLE %sfaqforms (
918+ form_id INTEGER NOT NULL,
919+ input_id INTEGER NOT NULL,
920+ input_type VARCHAR(1000) NOT NULL,
921+ input_label VARCHAR(500) NOT NULL,
922+ input_active INTEGER NOT NULL,
923+ input_required INTEGER NOT NULL,
924+ input_lang VARCHAR(11) NOT NULL
925+ ) ' ,
926+ Database::getTablePrefix ()
927+ );
928+ $ this ->queries [] = sprintf (
929+ 'INSERT INTO %sfaqforms
930+ SELECT
931+ form_id, input_id, input_type, input_label, input_active, input_required, input_lang
932+ FROM %sfaqforms_old ' ,
933+ Database::getTablePrefix (),
934+ Database::getTablePrefix ()
935+ );
936+ $ this ->queries [] = sprintf (
937+ 'DROP TABLE %sfaqforms_old; ' ,
938+ Database::getTablePrefix ()
939+ );
940+ break ;
941+ case 'sqlsrv ' :
942+ $ this ->queries [] = sprintf (
943+ 'ALTER TABLE %sfaqforms ALTER COLUMN input_label NVARCHAR(500) NOT NULL ' ,
944+ Database::getTablePrefix ()
945+ );
946+ break ;
947+ }
948+ }
949+ }
950+
866951 private function applyUpdates410Alpha (): void
867952 {
868953 if (version_compare ($ this ->version , '4.1.0-alpha ' , '< ' )) {
0 commit comments