Fatal error: Uncaught RuntimeException: Cannot read PHP configuration: pdo_mysql.default_socket in ...

Hallo zusammen,

nachdem ich auf eine neue MariaDB/PHP Version updaten musste, wollte ich testweise auch mal die neue 2.2.4 installieren. Ich scheitere aber schon mit dem Fehler (Fatal error: Uncaught RuntimeException: Cannot read PHP configuration: pdo_mysql.default_socket in ...) nachdem ich Datenbanktyp MySQL ausgewählt und auf weiter geklickt habe.

Windows 11, Apache, MariaDB 11.8.3, PHP 8.4.5

In der php.ini steht:
[Pdo_mysql]
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
pdo_mysql.default_socket=

In der alten php.ini stand:
[Pdo]
pdo_mysql.default_socket="MySQL"
[Pdo_mysql]
pdo_mysql.default_socket=

Hat auch nicht funktioniert. Dann habe ich nochmal mit nur
[Pdo_mysql]
pdo_mysql.default_socket="MySQL"
probiert, aber das hat auch nichts gebracht.

Bei der Installation der 2.1.16 vor ein paar Jahren gab es keine Probleme. Ist vielleicht noch jemand anderes auf diesen Fehler gestoßen und hat eine Lösung parat? (Im github habe ich nichts gefunden.) Was muss man tun, um webtrees 2.2.4 unter Windows zum Laufen zu kriegen?

Gruß
Martina (Klein)

Hallo zusammen,

heureka, ich hab's. Nach etwas schlaflosen Nächten, jede Menge wühlen in Dokus, im Forum und im Code (was ohne Entwicklungsumgebung ziemlich mühsam ist), habe ich es wohl rausgefunden.

In der PhpService.php gibt es die Funktion

     public function iniGet(string $option): string
     {
         $value = ini_get(option: $option);

         if ($value === false) {
             throw new RuntimeException(message: 'Cannot read PHP configuration: ' . $option);
         }

         return $value;
     }

Die wird an zwei Stellen in der SetupWizard.php aufgerufen (vielleicht auch woanders, aber das weiß sicher Greg):

    private function step4DatabaseConnection(array $data): ResponseInterface
     private function step5Administrator(array $data): ResponseInterface

als
         $data['mysql_local'] = 'localhost:' . $this->php_service->iniGet(option: 'pdo_mysql.default_socket');

Das Problem: die php_Funktion ini_get liefert für pdo_mysql.default_socket immer false zurück, egal was da drin steht (zumindest bei mir).

php.ini: pdo_mysql.default_socket=
var_dump(ini_get('pdo_mysql.default_socket')) => bool(false)

Bei
cli_server.color=On
  string(16) "cli_server.color" bool(false)
müsste eigentlich 1 zurückgegeben werden, es kommt aber false.

Sieht mir nach einem Bug im php aus, aber das sollte sich besser ein (richtiger) Entwickler / Greg mal anschauen.

Die Lösung bei mir:
     public function iniGet(string $option): string
     {
         $value = ini_get(option: $option);
         if ($option === 'pdo_mysql.default_socket') {
             $value = '';
         }

         if ($value === false) {
             throw new RuntimeException(message: 'Cannot read PHP configuration: ' . $option);
         }

         return $value;
     }

Besser wäre wohl sogar, auf if ($option === 'pdo_mysql.default_socket' && $value === false) abzufragen, falls auf einem System ini_get tatsächlich was sinnvolles zurückliefert.

Möge es anderen helfen. Und vielleicht kann das ja jemand an die webtrees Entwickler weitergeben. Es scheinen ja noch andere das Problem bei einem Neusetup mit der 2.2.4 zu haben.

Gruß
Martina (Klein)