Avatar

MLF and PHP 8: it will come contemporary (Bugs)

by Auge ⌂, Thursday, April 28, 2022, 19:22 (20 days ago) @ Auge

Hello

… we are ready to release a first PHP-8-aware version of MLF2. The code in the master branch (currently the development branch for version 2.5) is in general well tested …

I performed the last tests of the forum with activated PHP 8.1 and fell into a few traps. I overhauled the installation script some time ago, tested it at that time with PHP 7.2 or 7.3 and it worked. Now, with PHP 8.1 I had to rework the first attempt to connect to the database because the placeholders ("localhost" and the empty strings for user, database and password) caused a PHP error with a blank page.

So I changed the code, beginning with line #52 from


// try to connect to the database …
if ($connid = mysqli_connect($db_settings['host'], $db_settings['user'], $db_settings['password'])) {
 if (mysqli_select_db($connid, $db_settings['database'])) {
  mysqli_query($connid, 'SET NAMES utf8');
  if (table_exists($db_settings['forum_table'])) {
   // the forum seems to be installed
   header('Location: ../');
   exit;
  }
 }
}

to

// try to connect to the database …
if (!empty($db_settings['database']) && $connid = mysqli_connect($db_settings['host'], $db_settings['user'], $db_settings['password'])) {
 if (mysqli_select_db($connid, $db_settings['database'])) {
  mysqli_query($connid, 'SET NAMES utf8');
  if (table_exists($db_settings['forum_table'])) {
   // the forum seems to be installed
   header('Location: ../');
   exit;
  }
 }
}

because to provide the database name is mandatory and when installing the forum it is not part of the data in config/db_settings.php.

When this was solved, the creation of the database tables failed because in the userdata table the column user_name should get an index of the same name what ended in an error message about the double use of the name user_name. This could possibly be an issue of the database configuration of my webspace. Anyway, I solved it with renaming the index/key from user_name to k_user_name.

After solving this problem, the installation script run without further errors, created all tables, inserted the default settings and updated the settings, provided in the installation form and last but not least, created the administrator user with the data from the installation form. Afterwards it followed the last instruction to redirect to the main view if the array $errors was empty.

I expected to see the main page but I got only a blank page. Even with reloading the page it remained blank. This can be an indication of a syntax error like a not closed bracket (or something similar). So I updated the files in another testing installation and this installation works! At the moment I have no clue how to solve this issue so the release have to wait a bit.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!


Complete thread:

 RSS Feed of thread