Let for all database drivers the module name default to the driver name

Created on 29 May 2024, 7 months ago

Problem/Motivation

For the mysql, pgsql and sqlite database drivers do not have to set the module name setting. Those database drivers have their module name setting default to their driver name. Lets do that for all database drivers.

Proposed resolution

Let the database driver module setting when not set, default to the driver name.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

TBD

📌 Task
Status

Active

Version

11.0 🔥

Component
Database 

Last updated 33 minutes ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇳🇱Netherlands daffie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @daffie
  • Pipeline finished with Failed
    7 months ago
    Total: 1321s
    #185299
  • Pipeline finished with Success
    7 months ago
    Total: 540s
    #185787
  • Status changed to Needs review 3 months ago
  • 🇺🇸United States smustgrave

    Can MR be updated for 11.x vs 11.0.x

  • 🇳🇱Netherlands daffie

    The MR is changed to 11.x as requested.

  • Pipeline finished with Canceled
    3 months ago
    Total: 1367s
    #291433
  • 🇺🇸United States smustgrave

    Mind rebasing? 11.x branch is 400+ commits behind.

  • Pipeline finished with Success
    3 months ago
    Total: 520s
    #291460
  • 🇳🇱Netherlands daffie

    Rebased as requested.

  • Pipeline finished with Success
    3 months ago
    Total: 1952s
    #291490
  • 🇺🇸United States smustgrave

    Thanks! Test-only feature was able to run now

    1) Drupal\Tests\Core\Database\UrlConversionTest::testNoModuleIsSpecifiedExceptionIsRemoved
    Failed asserting that exception of type "InvalidArgumentException" matches expected exception "Drupal\Core\Extension\Exception\UnknownExtensionException". Message was: "Can not convert 'mongodb://test_user:test_pass@test_host/test_database' to a database connection, the module providing the driver 'mongodb' is not specified" at
    /builds/issue/drupal-3450706/core/lib/Drupal/Core/Database/Database.php:530
    /builds/issue/drupal-3450706/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php:316
    .
    FAILURES!

    Applied a nitpicky change for a void return.

    Changing to the driver name didn't seem to break mysql or the other tests so believe it's a fine update.

  • Pipeline finished with Success
    3 months ago
    Total: 398s
    #291530
  • 🇳🇿New Zealand quietone

    Left a question in the MR

  • Pipeline finished with Failed
    2 months ago
    Total: 139s
    #307930
  • Pipeline finished with Success
    2 months ago
    #307931
  • 🇳🇱Netherlands daffie

    @quietone: You are right, it is better to use another name for the database then "mongodb". I have changed it to "dummydb". I thought that I had an option to add "mongodb" to the Drupal core code. :)

  • 🇺🇸United States smustgrave

    smustgrave changed the visibility of the branch 3450706-let-for-all to hidden.

  • 🇺🇸United States smustgrave

    Hiding MR 8220

    Feedback for 9592 has been addressed.

  • Status changed to Needs work 5 days ago
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    This seems like a good idea. Less special casing core FTW.

    Added some comments to the MR to address.

  • Pipeline finished with Failed
    3 days ago
    Total: 444s
    #369530
  • Pipeline finished with Failed
    3 days ago
    Total: 140s
    #369610
  • Pipeline finished with Failed
    3 days ago
    Total: 205s
    #369613
  • Pipeline finished with Failed
    3 days ago
    Total: 119s
    #369633
  • Pipeline finished with Failed
    3 days ago
    Total: 891s
    #369643
  • Pipeline finished with Canceled
    3 days ago
    Total: 569s
    #369662
  • Pipeline finished with Failed
    3 days ago
    Total: 130s
    #369670
  • Pipeline finished with Failed
    3 days ago
    Total: 820s
    #369675
  • Pipeline finished with Canceled
    3 days ago
    Total: 400s
    #369689
  • Pipeline finished with Success
    3 days ago
    Total: 387s
    #369706
  • 🇳🇱Netherlands daffie

    Addressed the remarks and suggestions of @alexpott.
    Back to NR.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    I think we should be fixing the PHPStan errors in the new class we're adding - I can't see why we'd add these errors to the baseline.

  • Pipeline finished with Failed
    3 days ago
    Total: 205s
    #369893
  • Pipeline finished with Failed
    3 days ago
    Total: 221s
    #369897
  • Pipeline finished with Failed
    3 days ago
    Total: 157s
    #369902
  • Pipeline finished with Canceled
    3 days ago
    Total: 126s
    #369932
  • Pipeline finished with Failed
    3 days ago
    Total: 123s
    #369935
  • Pipeline finished with Success
    3 days ago
    Total: 717s
    #369936
  • 🇳🇱Netherlands daffie

    Removed the added style guide violations from the base line file.
    Back to NR.

  • 🇮🇹Italy mondrake 🇮🇹

    Question: can't we use something from Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses instead of adding a completely new dummy db and all of its minimal implementations?

    Anyway, the above should not hold this. RTBC

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    I think #21 is worth considering before we add yet more test code to maintain.

  • 🇳🇱Netherlands daffie

    We cannot use Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses for testing with this MR, because of the fact that the module name and the driver name are not the same.
    Back to RTBC.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    How about adding a driver_test driver to core/modules/system/tests/modules/driver_test can be a copy of system/tests/modules/driver_test/src/Driver/Database/DriverTestMysql with the driver name changed to driver_test... less to maintain but the same amount of code coverage.

  • 🇳🇱Netherlands daffie

    How about adding a driver_test driver to core/modules/system/tests/modules/driver_test can be a copy of system/tests/modules/driver_test/src/Driver/Database/DriverTestMysql with the driver name changed to driver_test... less to maintain but the same amount of code coverage.

    That sounds like a good idea, only it does not work. For that to work the $url need to change to: 'driver_test://test_user:test_pass@test_host/test_database'. That url gets parsed into components and the result will be:

    array (
      "path" => "driver_test://test_user:test_pass@test_host/test_database"
    );
    

    No schema and host values are set and a \InvalidArgumentException wiil be thrown with the message: "The database connection URL 'driver_test://test_user:test_pass@test_host/test_database' is invalid. The minimum requirement is: 'driver://host/database'" The function parse_url does not accept schema's with an underscore character in it. To me, we have 2 options: the first is to change the module name "driver_test" to "drivertest". That will result in a lot of code changes. The other is to leave it like it is and go with the new test module called "dummydb". Putting the issue back to RTBC for the core committers decision.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Okay let's keep on with dummydb but instead of extending the abstract connection class lets extend another db driver so we don't have to think about / maintain so much stuff we're not using here.

  • 🇳🇱Netherlands daffie

    The dummydb database driver is now dependent on the one for MySQL.
    Back to NR.

  • 🇮🇹Italy mondrake 🇮🇹

    Looks great to me, thanks for hearing my question. I triggered Sqlite and PgSql pipelines for safety, even though I do not think they are relevant here. RTBC

  • Pipeline finished with Success
    2 days ago
    Total: 1647s
    #370978
  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    Committed 8fd18fe and pushed to 11.x. Thanks!

    • alexpott committed 8fd18feb on 11.x
      Issue #3450706 by daffie, smustgrave, alexpott, quietone, mondrake: Let...
Production build 0.71.5 2024