munkireport / munkireport-php

A reporting tool for munki
MIT License
394 stars 138 forks source link

Migration to 5.8.0: 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found #1513

Closed doits closed 1 year ago

doits commented 1 year ago

When upgrading I git this error running the migrations:

$ ./please migrate
Migrating: 2023_02_28_000000_inventory_bigint_id
PHP Fatal error:  Uncaught Error: Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found in /var/www/munkireport-php/vendor/illuminate/database/MySqlConnection.php:64
Stack trace:
#0 /var/www/munkireport-php/vendor/illuminate/database/Connection.php(894): Illuminate\Database\MySqlConnection->getDoctrineDriver()
#1 /var/www/munkireport-php/vendor/illuminate/database/Schema/Grammars/ChangeColumn.php(36): Illuminate\Database\Connection->getDoctrineSchemaManager()
#2 /var/www/munkireport-php/vendor/illuminate/database/Schema/Grammars/Grammar.php(55): Illuminate\Database\Schema\Grammars\ChangeColumn::compile()
#3 /var/www/munkireport-php/vendor/illuminate/database/Schema/Blueprint.php(128): Illuminate\Database\Schema\Grammars\Grammar->compileChange()
#4 /var/www/munkireport-php/vendor/illuminate/database/Schema/Blueprint.php(101): Illuminate\Database\Schema\Blueprint->toSql()
#5 /var/www/munkireport-php/vendor/illuminate/database/Schema/Builder.php(290): Illuminate\Database\Schema\Blueprint->build()
#6 /var/www/munkireport-php/vend in /var/www/munkireport-php/vendor/illuminate/database/MySqlConnection.php on line 64

Changing composer.json to require an older doctrine/dbal fixes it:

diff --git a/composer.json b/composer.json
index 311764a3..fa31fd10 100644
--- a/composer.json
+++ b/composer.json
@@ -77,7 +77,7 @@
     "fakerphp/faker": "^1.13",
     "guzzlehttp/guzzle": "~7.0",
     "munkireport/usb": "^3.0",
-    "doctrine/dbal": "~3.6",
+    "doctrine/dbal": "~2.3",
     "munkireport/sentinelone": "^3.0",
     "munkireport/inventory": "^7.0",
     "adldap2/adldap2": "^10",

Looks like the migration is not compatible with newer dbal?

I reverted the change after the migrations completed, but I'm not sure what should be the correct version in the end.

bochoven commented 1 year ago

Is your server running php 8.x?

doits commented 1 year ago

Thanks for your help. It is indeed running v7.4.3. Can this be the cause of the error?

bochoven commented 1 year ago

Yes, that is probably the reason. Composer will install a newer version of DBAL when PHP is upgraded

bochoven commented 1 year ago

Make sure to run composer update after you update the PHP version on the server

doits commented 1 year ago

I run composer update before running the migrations, so it should be up to date.

I just checked it installs doctrine/dbal 3.6.3 (latest version) even with my php 7 version, and with this version the migration failed.

According to https://stackoverflow.com/a/65075035 the downgrade fixes the error about the missing class (which it did for me). Looks like the class does not exist in dbal 3, see https://github.com/doctrine/dbal/issues/4439? For me it looks like there might be an error using Doctrine\DBAL\Driver\PDOMySql\Driver with dbal 3, but this is just a guess.

I will update to php 8 soon to be on the supported version – for now everything seems to work even with php 7 after the migration completed with the old dbal 2 version.

doits commented 1 year ago

Aah probably it is because illumniate/database is incompatible with dbal 3 ... it installs v7.30.6 for me, probably the later versions are not compatible with php 7.

doits commented 1 year ago

Seems to be only supported from v8.15.0 onwards, see https://github.com/laravel/framework/releases/tag/v8.15.0

Added Support DBAL v3.0 (https://github.com/laravel/framework/pull/35236)

bochoven commented 1 year ago

I don't think we want to keep supporting EOL versions of PHP, so I'm closing this issue. I think we need to update the docs so it's clear that PHP 7 is not supported anymore in MunkiReport 5.8