Skip to content

PDO doesn't recognise mysql string (SYNC_DB) #2

Description

@irreleph4nt

Trying to move to mysql and away from sqlite, I found that the current implementation doesn't work. The constructor in lib/KopaanoSyncStates.php does not recognise the PDO string, causing php-fpm to crashdump and webbrowsers to display a HTTP 500 / page not operational error.

The journal shows this when you try to access kdav:

Mai 19 02:14:01 mx1 systemd[1]: Started A high performance web server and a reverse proxy server.
Mai 19 02:14:16 mx1 nginx[1997]: 2019/05/19 02:14:16 [error] 1999#1999: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  date(): Invalid date.timezone value 'Europe\Berlin', we selected the timezone 'UTC' for now. in /usr/share/webapps/kopano-kdav/vendor/apache/log4php/src/main/php/pattern/LoggerPatternConverterDate.php on line 74PHP message: PHP Warning:  date(): Invalid date.timezone value 'Europe\Berlin', we selected the timezone 'UTC' for now. in /usr/share/webapps/kopano-kdav/vendor/apache/log4php/src/main/php/pattern/LoggerPatternConverterDate.php on line 74PHP message: PHP Warning:  date(): Invalid date.timezone value 'Europe\Berlin', we selected the timezone 'UTC' for now. in /usr/share/webapps/kopano-kdav/vendor/apache/log4php/src/main/php/pattern/LoggerPatternConverterDate.php on line 74PHP message: PHP Warning:  date(): Invalid date.timezone value 'Europe\Berlin', we selected the timezone 'UTC' for now. in /usr/share/webapps/kopano-kdav/vendor/apache/log4php/src/main/php/pattern/LoggerPatternConverterDate.php on line 74PHP message: PHP Warning:  date(): Invalid date.timezone value 'Europe\Berlin', we selected the timezone 'UTC' for now. in /usr/share/webapps/kopano-kdav/vendor/apache/log4php/src/main/php/pattern/LoggerPatternConverterDate.php on line 74PHP message: PHP Fatal error:  Uncaught PDOException: could not find driver in /usr/share/webapps/kopano-kdav/lib/KopanoSyncState.php:45
Mai 19 02:14:16 mx1 nginx[1997]: Stack trace:
Mai 19 02:14:16 mx1 nginx[1997]: #0 /usr/share/webapps/kopano-kdav/lib/KopanoSyncState.php(45): PDO->__construct('"mysql:dbname=s...')
Mai 19 02:14:16 mx1 nginx[1997]: #1 /usr/share/webapps/kopano-kdav/lib/KopanoDavBackend.php(48): Kopano\DAV\KopanoSyncState->__construct(Object(Kopano\DAV\KLogger), '"mysql:dbname=s...')
Mai 19 02:14:16 mx1 nginx[1997]: #2 /usr/share/webapps/kopano-kdav/server.php(54): Kopano\DAV\KopanoDavBackend->__construct(Object(Kopano\DAV\KLogger))
Mai 19 02:14:16 mx1 nginx[1997]: #3 {main}
Mai 19 02:14:16 mx1 nginx[1997]:   thrown in /usr/share/webapps/kopano-kdav/lib/KopanoSyncState.php on line 45" while reading response header from upstream, client: 78.94.14.198, server: dav.maerz.cc, request: "GET /server.php HTTP/2.0", upstream: "fastcgi://unix:/run/php-fpm/webapp.sock

When the error is thrown, config.php reads this:

define('SYNC_DB', '"mysql:dbname=sabredav","user","pass"');

I have also tried this with the same result:

define('SYNC_DB', "'mysql:dbname=sabredav;host=localhost', 'user', 'pass'");
define('SYNC_DB', "mysql:dbname=sabredav;unix_socket=/run/mysqld/mysqld.sock");

The ugly workaround is to hard-code $dbstring in lib/KopanoSyncState.php with the same string as shown above - working perfectly fine:

    public function __construct($logger, $dbstring) {
        $this->logger = $logger;
        $this->logger->trace("Using db %s", $dbstring);
        // $this->db = new \PDO($dbstring);
        $this->db = new \PDO('mysql:dbname=sabredav','user','pass');

Which is also documented upstream in the official sabredav documentation found at:
http://sabre.io/dav/authentication/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions