oerdnj / deb.sury.org

Public bugreports for anything ppa:ondrej/*
801 stars 26 forks source link

Compatibility issues with phpmyadmin. #2054

Closed AphidGit closed 7 months ago

AphidGit commented 7 months ago

Frequently asked questions

Description

Navigating to phpmyadmin will result in a blank screen. I expect this to simply function when installed via apt.

To Reproduce Steps to reproduce the behavior:

  1. Install debian linux 12 on a server reachable over ports 80,443.
  2. Configure your repository by adding it to /etc/apt, before the default repositories (I'm currently just doing it in sources.list to keep the reproduction simpler, but best method is to use a separate config file).
  3. Install the LAMP stack packages apache2, php7.4-fpm, mariadb, phpmyadmin
  4. Systemctl enable and start the services (apache, mysql, php7.4-fpm)
  5. Install and configure a certificate for the domain of the server.
  6. Configure the domain to use php-fpm (see further).
  7. Edit the hosts file on a client computer
  8. Navigate to https://mywebsite.com/phpmyadmin

The result is a blank screen.

Your understanding of what is happening

There seems to be going something wrong with phpmyadmin and its dependencies. It seems to not follow the right code path and crash if installed without specifically using php version 8.2. If that's not installed I encounter crashes. More specifically, this applies to the <Directory /usr/share/phpmyadmin>, which I guess makes sense, the SetHandler directive on the other two directories, templates and libraries, is likely ignored as these are not entry points for the application and only called in by scripts in the main directory.

For example, when installing and using version 7.4, the following error crashes php:

AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function Symfony\\Component\\DependencyInjection\\array_is_list() in /usr/share/php/Symfony/Component/DependencyInjection/ContainerBuilder.php:1092\nStack trace:\n#0 /usr/share/php/Symfony/Component/DependencyInjection/ContainerBuilder.php(608): Symfony\\Component\\DependencyInjection\\ContainerBuilder->createService()\n#1 /usr/share/php/Symfony/Component/DependencyInjection/ContainerBuilder.php(553): Symfony\\Component\\DependencyInjection\\ContainerBuilder->doGet()\n#2 /usr/share/phpmyadmin/libraries/classes/Common.php(96): Symfony\\Component\\DependencyInjection\\ContainerBuilder->get()\n#3 /usr/share/phpmyadmin/index.php(40): PhpMyAdmin\\Common::run()\n#4 {main}\n  thrown in /usr/share/php/Symfony/Component/DependencyInjection/ContainerBuilder.php on line 1092'

It tries to use function array_is_list(). Checking the php documentation for this function at https://www.php.net/manual/en/function.array-is-list.php shows that this function is only available from php version >=8.1.0 onwards. As 7.4 < 8.1, the function is undefined. Version 7.3 results in the same bug.

When using php version 8.1, the following error crashes php:

Got error 'PHP message: PHP Fatal error:  Uncaught TypeError: PhpMyAdmin\\Menu::__construct(): Argument #1 ($dbi) must be of type PhpMyAdmin\\DatabaseInterface, null given, called in /usr/share/phpmyadmin/libraries/classes/Header.php on line 114 and defined in /usr/share/phpmyadmin/libraries/classes/Menu.php:57\nStack trace:\n#0 /usr/share/phpmyadmin/libraries/classes/Header.php(114): PhpMyAdmin\\Menu->__construct()\n#1 /usr/share/phpmyadmin/libraries/classes/ResponseRenderer.php(168): PhpMyAdmin\\Header->__construct()\n#2 /usr/share/phpmyadmin/libraries/classes/ResponseRenderer.php(199): PhpMyAdmin\\ResponseRenderer->__construct()\n#3 /usr/share/phpmyadmin/libraries/classes/ErrorHandler.php(379): PhpMyAdmin\\ResponseRenderer::getInstance()\n#4 /usr/share/phpmyadmin/libraries/classes/ErrorHandler.php(337): PhpMyAdmin\\ErrorHandler->dispPageStart()\n#5 /usr/share/phpmyadmin/libraries/classes/ErrorHandler.php(308): PhpMyAdmin\\ErrorHandler->dispFatalError()\n#6 /usr/share/phpmyadmin/libraries/classes/ErrorHandler.php(242): Ph...PHP message: PHP Fatal error:  Uncaught Error: Call to a member function getDisplay() on null in /usr/share/phpmyadmin/libraries/classes/ResponseRenderer.php:293\nStack trace:\n#0 /usr/share/phpmyadmin/libraries/classes/ResponseRenderer.php(411): PhpMyAdmin\\ResponseRenderer->getDisplay()\n#1 [internal function]: PhpMyAdmin\\ResponseRenderer->response()\n#2 {main}\n  thrown in /usr/share/phpmyadmin/libraries/classes/ResponseRenderer.php on line 293'

I haven't managed to look more deeply into this as trying to understand this in the phpmyadmin code base took me too much time. I suspect it's another compatibility issue, albeit a far more complicated one, as the crash is happening completely differently from where the problem first occurs. It's an initialization error of the most-used variable in the whole program, with thousands of references to it. Phpmyadmin's "$dbi" variable is a global variable., which is a bit of a programming snafu, as this makes it very difficult to locate exactly where it should be initialized, but isn't.

What steps did you take to resolve issue yourself before reporting it here

Installing php8.2, using php-fpm to point to that version even though the site itself uses a different php version resolves the issue. It's kind of tricky to configure. In this example the site uses php7.4 and php8.2 as its phpmyadmin.

apt-get -y install php8.2-fpm php7.4-fpm phpmyadmin

Then, set X,Y to the right values here in the site and phpmyadmin.

    <FilesMatch \.php>
        SetHandler "proxy:unix:/var/run/php/phpX.Y-fpm.sock|fcgi://localhost/"
    </FilesMatch>

(When set to any version but the latest, things crash).

Expected behavior

The problem is: This shouldn't be necessary; phpmyadmin should be compatible with php versions 7.2 and up as reported on their site at https://www.phpmyadmin.net/news/2022/5/10/phpmyadmin-520-released/ . The version installed with the package manager is reported to be 5.2.1. As indicated by dpkg -l | grep phpmyadmin

ii  phpmyadmin                        4:5.2.1+dfsg-1                                                             all          MySQL web administration tool

Distribution (please complete the following information):

Debian 12, amd64, packages.sury.org.

Package(s) infodump:

See steps to reproduce. The versions of the relevant packages;

ii  apache2                           2.4.57-2                                                                   amd64        Apache HTTP Server
ii  mariadb-server                    1:10.11.3-1                                                                amd64        MariaDB database server binaries
ii  php7.4-fpm                        1:7.4.33-8+0~20230904.88+debian12~1.gbp87c414                              amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  phpmyadmin                        4:5.2.1+dfsg-1                                                             all          MySQL web administration tool

See the attached file for the complete list of packages on the system.

dpkg.txt

Other information

I have no idea whose fault it really is. Is it sury, debian, a config error, or phpmyadmin's code, I can't really tell from the complexity. If it turns out to be an actual packaging issue, but needs to be solved somewhere else, please report it there.

What I can say is that as a user I find this unexpected; I should be able to install any version of php >= 7.2, then phpmyadmin, then have it 'just work', with phpmyadmin from debian's main repository, and php from yours, as sury.org makes it easier to install multiple versions of php for compatibility reasons (mostly php deprecating things and breaking stuff very often).

oerdnj commented 7 months ago

This is not a packaging issue, moving to discussions.