s9y / Serendipity

A PHP blog software
https://s9y.org
BSD 3-Clause "New" or "Revised" License
203 stars 86 forks source link

Impossible installation with mysql cause of "Unknown system variable 'storage_engine'" #818

Open Flip1 opened 9 months ago

Flip1 commented 9 months ago

The following error makes a install of s9y impossible: Unknown system variable 'storage_engine'

The use of "storage-engine" is maybe deprecated and leads to this error. This should be changed to "default_storage_engine". See here

The following changes will fix this issue: File: include/db/mysqli.inc.php Line: 296 and 300

Replace: serendipity_db_query("SET storage_engine= with: serendipity_db_query("SET default_storage_engine=

This happens with s9y version 2.4.0 and 2.5beta1. Version of MySQL or MariaDB is: 8.0.34-26

garvinhicking commented 9 months ago

Thanks for reporting! Since we also support older sql versions, we'll need to add a switch here. We don't have specific mysql version checking, so maybe the easier way is to let the query fail, catch the failure, and then issue the other engine command.

We should use the mysql8 syntax as default and only fall back to the "old" variant.

Thoughts? @onli ?

onli commented 9 months ago

Thoughts? @onli ?

I thought we already had the storage_engine bug fixed in the beta. Have a look at https://github.com/s9y/Serendipity/blob/2ef0afd7bb85d2c00ebb1c5b64f32caeef68b637/include/db/mysqli.inc.php#L295-L305

The idea there was to solve the MySQL bug by not setting the storage_engine at all in MySQL >= 5.8. But it seems my assumption was wrong how MariaDB behaves. Was discussed (and tested) in https://board.s9y.org/viewtopic.php?t=26120.

I'd probably would have added a second version check:

 if (serendipity_utf8mb4_ready()) {
       # InnoDB enables us to use utf8mb4 with the higher max index size
     if (version_compare($mysql_version, '5.7', '>')) {
        # We know we use MariaDB here, and versions after 5.7 prefer default_storage_engine.
        serendipity_db_query("SET default_storage_engine=INNODB");
     } else {
        serendipity_db_query("SET storage_engine=INNODB");
     }
} else {
     # Before 5.6.4/10.0.5 InnoDB did not support fulltext indexes, which we use,
     # thus we stay with MyISAM here
    if (version_compare($mysql_version, '5.7', '>')) {
        # We know we use MariaDB here, and versions after 5.7 prefer default_storage_engine.
        serendipity_db_query("SET default_storage_engine=MYISAM");
     } else {
        serendipity_db_query("SET storage_engine=MYISAM");
     }
}

But that's a version check after a version check and a lot of ifs. Probably not a good idea. To use the default_storage_engine by default and catch the error for old versions is probably smarter, then we can put the old code into the rescue/catch as-is.

onli commented 6 months ago

I just checked upon this code, since we just released 2.5.0, but I think this bug here was missed. Someone available to run the code as shown in https://github.com/s9y/Serendipity/issues/818#issuecomment-1826760259 on mariadb?

Flip1 commented 6 months ago

I wanted to try it out, but a new installation failed somewhere else: [#822]

The automatic update from 2.5beta to 2.5 doesn't work, but with FTP-Upload everything works fine.

Flip1 commented 6 months ago

The installation of unchanged 2.5 is now running smoothly. So, I have not tested the above code and I think this issue can be closed. Or should I test something special?

onli commented 6 months ago

It worked without you having to change anything, while you were trying to use MariaDB?

Flip1 commented 6 months ago

When I created this error I wasn't entirely sure, now I know that Limacity is running MySQL 8.0.34-26. This error occurred here with 2.4.0 and 2.5beta1. But now I was able to install 2.5 without changes and without any problems. Seems like this bug has been fixed. I haven't tested it with MariaDB, but I could test it locally. But maybe next week.

onli commented 6 months ago

Awesome :) If you want to test it we can keep this open, if not we can close here (or we can close and then re-open, as you prefer)

Flip1 commented 6 months ago

Okay, I have now set up a test environment on Debian Bookworm (stable):

Serendipity seems to run fine with MariaDB, the installation went smoothly. However, there seems to be a problem with PHP 8.2, which is why the blog cannot load. Apparently the built-in library for 8.1 does not work with PHP 8.2.

PHP Fatal error: Uncaught Error: Class "IntlDateFormatter" not found in /var/www/s9y/bundled-libs/php81_bc/strftime/src/php-8.1-strftime.php:60\nStack trace:

0 /var/www/s9y/bundled-libs/php81_bc/strftime/src/php-8.1-strftime.php(201): PHP81_BC\{closure}()

1 [internal function]: PHP81_BC\{closure}()

2 /var/www/s9y/bundled-libs/php81_bc/strftime/src/php-8.1-strftime.php(180): preg_replace_callback()

3 /var/www/s9y/include/functions.inc.php(143): PHP81_BC\strftime()

4 /var/www/s9y/include/functions.inc.php(191): serendipity_strftime()

5 /var/www/s9y/plugins/serendipity_plugin_archives/serendipity_plugin_archives.php(105): serendipity_formatTime()

6 /var/www/s9y/include/plugin_api.inc.php(971): serendipity_plugin_archives->generate_content()

7 /var/www/s9y/include/functions_smarty.inc.php(645): serendipity_plugin_api::generate_plugins()

8 /var/www/s9y/templates_c/2k11/a3/7e/d1/a37ed1f6570390f01a8643f6fef38d367196cfb9_0.file.index.tpl.php(163): serendipity_smarty_printSidebar()

9 /var/www/s9y/bundled-libs/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_65e72b4f6c5326_76947008()

10 /var/www/s9y/bundled-libs/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode()

11 /var/www/s9y/bundled-libs/smarty/smarty/libs/sysplugins/smarty_internal_template.php(217): Smarty_Template_Compiled->render()

12 /var/www/s9y/bundled-libs/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render()

13 /var/www/s9y/bundled-libs/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute()

14 /var/www/s9y/index.php(124): Smarty_Internal_TemplateBase->display()

15 {main}

thrown in /var/www/s9y/bundled-libs/php81_bc/strftime/src/php-8.1-strftime.php on line 60, referer: http://localhost//serendipity_admin.php?

garvinhicking commented 6 months ago

It seems you are missing the Debian package "php8-intl"?

Flip1 commented 6 months ago

Yeah that's it! php8.2-intl was not installed. Now I can confirm that Serendipity 2.5 runs smoothly with MariaDB and PHP 8.2. At least in my test environment!

The only thing that could possibly be improved is a test during installation to see whether php8.2-intl is available.