Problem/Motivation
At the moment there are a lot of problems when you are the developer/maintainer of a contrib database driver. Normally when you are working on a contrib module and you have a problem, you look at how something similar is solved by the by core supported modules and use that solution for you contrib module. The problem for contrib database driver developers/maintainers is that solution does not work for them. In Drupal core there are a lot of specific for a database driver exceptions. Contrib database drivers are not allowed (for good reasons) to have the same exception added in core. That makes solving some problems almost impossible for contrib database drivers.
Proposed resolution
Move the by core supported database drivers to their own module (this issue). In following issues the specific exceptions in core for the by core supported database driver will be moved to the module part of the database drivers. When doing so we need to solve how to have those exception in a module instead of in regular core code. When do this for the by core supported database driver, the contrib database drivers can use the same solution.
Remaining tasks
TBD
User interface changes
None
API changes
The Database API and the Schema API are part of the public API. The implementation of those API's by the by core supported database drivers (MySQL, PostgreSQL and SQLite) are however NOT part of the public API. Therefor this patch does not contain any API changes.
Data model changes
None
Release notes snippet
The core supported database drivers, MySQL, PostgreSQL and SQLite, have been moved to their own modules. The modules are installed when the 9.4.0 update is run. Code that uses core supplied database classes will continue to work but these classes are deprecated and will be removed in Drupal 11. Custom and contrib drivers will need to supply a module parameter when encoding database connections as URLs.
| Comment | File | Size | Author |
|---|---|---|---|
| #149 | 3129043-10.0.x.patch | 340.9 KB | alexpott |
Issue fork drupal-3129043
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3129043-move-core-database
changes, plain diff MR !1147
Comments
Comment #2
daffie commentedComment #3
daffie commentedFixed a couple of tests.
The problem why there test failing is that when we moved the by core supported database drivers to a module, they now need the variable
$rootfor the loading of the PSR-4 namespace.Some tests result into errors like: "Error: Call to undefined function Drupal\Core\drupal_valid_test_ua()".
Comment #4
daffie commentedComment #5
daffie commentedComment #6
daffie commentedMake the 3 new database driver modules hidden. It should now pass Drupal\Tests\system\Functional\Module\InstallUninstallTest.
Comment #7
alexpottThere's some interesting conceptual things we need to work out.
I think I'm happy for it to be a special case that database drivers are something from a module that does not need to be installed. But we certainly need to document that. So +1 to the code db driver modules being hidden as installing them makes no sense. Some db drivers have provided extra module like functionality and service replacements. They need installing.
What is the use-case? This doesn't feel at all like something a user should ever configure. And also out-of-scope for this change.
Comment #8
mondrake#7 OTOH a non-core driver, in the current order, must implement at least a service to support date management functions via a backend overridable service. So another option would be for forcing at install time the installation of the ‘module’ that the driver resides in, and locking it as non-uninstallable.
Comment #9
mondrakeComment #10
mondrakealso see #3128699-6: Testing issue for pgsql_fallback
Comment #11
daffie commentedSome more test fixes.
Comment #12
mondrakeComment #13
daffie commentedComment #14
daffie commentedThere are problems getting to pass the test Drupal\Tests\Scripts\TestSiteApplicationTest. Maybe the work in #2962157: TestSiteApplicationTest requires a database despite being a unit test helps.
Comment #15
daffie commentedThis should fix Drupal\Tests\Scripts\TestSiteApplicationTest. It should fix the failure: "PHP Fatal error: Uncaught Error: Call to undefined function Drupal\Core\drupal_valid_test_ua() in /var/www/html/core/lib/Drupal/Core/DrupalKernel.php:378"
Comment #16
alexpottSo this is where I have some issues. I think we need a proviso that drivers should be completely self contained and not rely on any module code. The way the container and therefore the autoloader is affected by the way we boot mandates this. The only reason the drivers in driver_test could extend the core drivers is because code in Drupal\Core is always autoloadable. Now it's in a place where it's not.
Comment #17
daffie commentedRemoving:
I had added that to fix the installer tests. There was never a use-case for. My apologies for the confusion.
Comment #18
daffie commentedGreat idea. And how do I do that?
Comment #19
alexpott@daffie well we need to document it. It's enforced by the way db driver autoloading works. If you extend the core mysql connection class everything we jsut break because the system won't be able to autoload the core mysql connection class when it's in a module.
Comment #20
daffie commentedI get that. What I do not understand is how I can extend the by core supported database driver for PostgreSQL in my https://www.drupal.org/project/pgsql_fallback without directly extending the driver classes of the by core supported driver? What is the technical solution? I get the we in the end need to document the solution, but what is the solution???
Comment #22
daffie commentedChanged the test TestSetupTraitTest back to being a UnitTest.
Comment #24
alexpottYou don't. You copy the classes and change what you need to. The classes shouldn't be viewed as API. They are an implementation of an API. If you copy the classes we can change core's implementation without ever having to worry about the impacts on contrib and custom. Which for something as low level as a db driver that's a very good thing.
Comment #26
daffie commentedI have got all tests fixed with the exception of Drupal\FunctionalTests\Installer\InstallerNonDefaultDatabaseDriverTest. It fails with the following error:
That is because the database driver for
Drupal\mysql\Driver\Database\mysqldoes not get autoloaded. I see 2 possible solutions:1. We autoload every database driver in the code base.
2. We enable the module that is the provider of the current database driver and all modules that it is dependent on.
I prefer option 2, because the module that is providing the database driver needs to be enabled to have driver specific tests, plugins and stuff like that. Originally I was hoping that we could do that in a followup issue.
Comment #27
alexpott@daffie
As I've been trying to point out we shouldn't do this. Either the driver_test classes have a hard wired include to get around the autolaoding. Or we do not allow drivers to extend each other. And therefore driver_test classes need to have the driver specific classes too. #3124354: Remove unnecessary classes from the database drivers makes this a bit more palatable.
Comment #28
daffie commentedAdded a fix for the Drupal\FunctionalTests\Installer\InstallerNonDefaultDatabaseDriverTest. The solution has come from @alexpott. Thank you for that.
Comment #29
alexpottneat... not seen the second arg to dirname - ah it was added in PHP 7 - nice and only quite recently possible for us to adopt.... we should tidy up all the dirname(dirname( in core :) and we definitely need #3124354: Remove unnecessary classes from the database drivers -
Comment #30
daffie commentedAdded extra testing for this piece of code.
Comment #31
daffie commentedAdded a change record.
Comment #32
daffie commentedForgot to update default.settings.php
Comment #33
daffie commentedNice to see that the learning stuff between @alexpott and me is not always a one way street. :) Followup created in #3129508: Change multiple dirname()'s into a single dirname() with the use of the second parameter of dirname().
Comment #34
daffie commentedComment #35
daffie commentedStraight reroll, because #3129508: Change multiple dirname()'s into a single dirname() with the use of the second parameter of dirname() has landed.
Comment #36
alexpottHmmm it is a shame to lose this optimisation to class loading.
There's a big breaking change here - we moving classes out of core - and we're not deprecating them. That makes this change disruptive. The only way I can think of making this less disruptive is if the new modules provided aliases for the old classes. But even this is problematic because these aliases would only be available much later than the old classes would be. The other problem is that we can't leave the old classes there because then the drivers will be discovered.
Comment #37
daffie commented@alexpott: Does it help when we change the patch as above? Or are we then still losing the class loading optimalisation?
For making this change less disruptive: In #3124354-36: Remove unnecessary classes from the database drivers @catch said: "The inability to properly deprecate them is not great, and we also can't do that for class_alias." I do not see how we can make this patch less disruptive.
Rerolling the patch, because #3124354: Remove unnecessary classes from the database drivers has landed. New patch is 14 KB smaller!
Comment #38
alexpottIf I apply this patch to an existing site it breaks because in settings.php I have
So I see lots of
We need a BC layer to account for this.
Also we need to make the chosen database driver module required. The easiest way to do this will be in system_system_info_alter(). I think this might mean you can make the modules visible again since they won't be uninstallable if they are being used.
Comment #39
daffie commented@alexpott: Great find in comment #38.
Added BC layer for comment #38.
Comment #41
daffie commented1. My original plan was to automatically enable the module that is providing the current database driver in a followup. See: #3129534: Automatically enable the module that is providing the current database driver. We can also do it in this issue, only the current patch is almost 90 KB and it is also not necessary for moving the by core supported database drivers to their own module.
2. If we do it the way you are suggestion, when in the installation process will that module then be enabled. Is it going to be enabled right after the when the system module is enabled or much later? I would like that module to be able to override every possible backend service, plugin and the EntityStorage.
Comment #42
daffie commentedTalked to @alexpott on Slack and he was adamant that the module that is providing the current database driver must be enabled, "because explaining that we have code loading from a module that is not installed is hard".
His suggestion is to do #3129534: Automatically enable the module that is providing the current database driver for the contrib and test database drivers first.
He also said that: "I think we need to enable the module and I think we need to install it prior to system" module, because "the system module declares schema and therefore depends on the database driver".
Comment #43
daffie commentedThis issue is blocked by #2664322: key_value table is only used by a core service but it depends on system install and #3129534: Automatically enable the module that is providing the current database driver.
Comment #44
daffie commented#2664322: key_value table is only used by a core service but it depends on system install has landed.
Comment #45
daffie commentedThe added patch contains the move the by core supported database drivers to their own module and automatically enable the module when the module is providing the current database driver. There are a number of reasons to that in a single patch:
1. In the validator Drupal/Core/Extension/ModuleRequiredByDatabaseDriverUninstallValidator is a workaround in the method validate() necessary for the two issue solution. The workaround is added in #3129534: Automatically enable the module that is providing the current database driver and removed in this issue.
2. The added testing in #3129534: Automatically enable the module that is providing the current database driver is all changed. It can now be done far more simple.
3. Doing it in 1 patch fixes the problem as described by @Beakerboy in #3129534-29: Automatically enable the module that is providing the current database driver. The testbot results for contrib database drivers will not become in a state where a lot of tests will fail when #3129534: Automatically enable the module that is providing the current database driver has landed and this issue has not.
Unfortunately, I was not able to create an interdiff file.
Comment #47
mondrakeJust a couple of comments, skimming at the latest patch:
1. I think we should provide BC, cannot just move the classes. Maybe we can move the classes and still have an alias to them in place of current ones.
2. Why not to move all three drivers to a single module (even to the system module, maybe?) instead of one module per driver?
Comment #48
catch#3129534: Automatically enable the module that is providing the current database driver is in.
Comment #49
daffie commentedComment #50
mondrakeNot a native speaker, but I think this title is simpler :)
Comment #51
daffie commentedDifference with the previous patch:
hidden: true;system_post_update_enable_provider_database_driver()for enabling the module that is providing the current database driver;Drupal\Tests\system\Functional\Update\UpdateEnableProviderDatabaseDriverTestto check the post update hooksystem_post_update_enable_provider_database_driver();Comment #52
daffie commentedMy response to @mondrake questions from comment #47:
I have had the same question myself and @alexpott answed that the Database API is public, however the drivers are not and therefore can be moved without leaving an alias behind.
I would very much like to create a level playing field for all database drivers (core and contrib). And yes, putting all 3 by core supported database drivers in a single module is an option. For putting them in the system module, I would like the by core supported database driver module(s) to be an example for the contrib ones and putting them in the system module will make in confusing which parts are for the database drivers and which are not. There is already a lot of stuff in the system module.
Comment #53
mondrakeThank you for answering my questions in #47, @daffie. That all makes sense.
The patch is great. The one thing that makes me wonder is updating existing sites - I see that an update function for instaling the driver module exists which is great, still the settings.php content for the database settings for new sites will be different from the one of existing sites. How do we go for that? do we keep a BC layer forever or are we going to inform the site admins that their setup is outdated at some point?
A few points, many nits, in detail:
it is purposeless to initalise $files to emtpy array, just make
$files =instead of$files +=two lines belowsee initial comment - shall we add a todo to remove this when we'll be able to assume that the module key is always set? or, can we somehow tamper with connection_info so that the key is always set when initialising?
same comment as above
Drupal 7 syntax still a problem?
I'd use mymodule mydriver instead of oracle to make it clear in the example what's what
see above
no need to sort expected and actual values for assertEquals, you can use assertEqualsCanonicalising (I think)
I'd find more readable to associate
new Extension(...)to a, say, $expected_extension local variable and use that in the assertEqualsComment #54
daffie commented@mondrake: Thank you for your review.
I think that making site owners change the settings in settings.php will result that a small percentage of site owners do something wrong and that will result in their website will loose the connection to the database. And there are about a million Drupal website out there, so even a small percentage is still a big number. To me this can be avoided by adding a BC layer and keeping that until Drupal gets rid of the settings.php file. It is only a very small BC layer. We shall have to check that in settings.php the namespace and the autoload settings are not always set. For me, that is something I can live with.
For #53.1: Fixed!
For #53.2: See above. I talked about a year ago with @alexpott about database connection urls and would like to get rid of them and replace them with something else. I only cannot remember with what. For me, just keep it working until then.
For #53.3: This comment is for Drupal 8 style custom drivers. The ones that live in the directory /drivers/lib/Drupal/Driver/Database/. They are already deprecated and can be removed in D10. We need to keep it working until then.
For #53.4: Fixed.
For #53.5: Fixed.
For #53.6: See above.
For #53.7: Fixed. I did not know that that assetion existed. Learned something new.
For #53.8: Fixed.
Comment #55
mondrakethis can be removed
Comment #56
mondrake#54.3 then I think we should have a @todo for removal in D10
Comment #57
daffie commented@mondrake: When we do what you are suggesting, then when the if-statement is false, the variable $files will not be set. Is that ok for the following foreach loop?
Comment #58
mondrake#57 I missed that, sorry, OK then.
Comment #59
daffie commentedRerolled and added the @todo for #54.3.
Comment #60
fgmAny reason these would need to be "modules", especially as they have these weird properties of being hidden and not having to be installed. We already have multiple extension types, maybe a "dbdriver" type along with module, themes and profiles would be a cleaner way, not breaking module semantics about visibility and enabling/installing ?
Comment #61
daffie commented@fgm: In the current patch will the modules, who are providing the by core supported database drivers, be visible. As it should be able to do a migration from a different type of database then the one that is used by Drupal to store its data. At the moment only the module that is providing the current database driver will be enabled by default. The module that is providing the database driver for the migration source will not be enabled by default when the databases are of different types (for instance MySQL and PostgreSQL). When the migration is finished can the module with the database driver for the migration source be disabled.
For using a different extension type for storing database drivers: the core committers decided that fixed location inside a module would be the best way to solve it. See: #3120096: Support contrib database driver directories in a fixed location in a module.
Comment #62
mondrakeI went through again and I think there could be a few more changes to be done; added in a diff file not break the patches flow and so they can be discussed. It's close to RTBC from me.
Comment #63
mondrakeI think we can remove those given the changes in Settings
Comment #64
mondrakeActually, #62 does not work... :)
Will post again when I have a working diff
Comment #65
mondrakeSo, made some changes, mainly to ensure that
Database::convertDbUrlToConnectionInfo()andDatabase::getConnectionInfoAsUrl()manage the 'module' addition both.Had to take the patch from #2992274-18: Installer tests fail if contrib driver hides database credentials form fields to get this working.
At this stage, in a pure looking forward context, the 'namespace' key would be optional, only for BC, since any new db driver will be part of a module and therefore you can build the namespace with the 'module' and the 'driver' keys only. Maybe we can deprecate it?
Comment #67
mondrakeworking on some cleanup, @daffie hope you do not mind
Comment #68
daffie commentedFine by me. ;-)
A couple of points about the latest patch:
When we have connection info array and we change it to a connection url, it should work without the 'module' and/or 'namespace' keys set.
The problem is that we have sites that started as a D7 site and upgraded to a D9.1 site. They do not have those keys set and now are we going to expects those keys to be set. That will result in a BC break.
All I would like to do in this issue is to move the by core supported database drivers to their own module and change as little as possible. In D9 we still have to support the database drivers that have to be copied to the 'drivers' directory. Those are deprecated and will be removed before D10. Lets wait for D10 to start changing the 'module', 'namespace' and 'autoload' keys. Then are all database drivers provided by a module and we will have only one namespace formula. It will then be a lot easier to get the 'best' solution.
Comment #69
mondrakeoh I missed that. And your approach makes sense to me.
So I suppose my changes should be limited to the attached. No need for #2992274: Installer tests fail if contrib driver hides database credentials form fields since we are not adding the module key in
createConnectionOptionsFromUrl.Interdiff vs #59. Please disregard #62 and #65.
Comment #70
mondrakeComment #71
daffie commentedThe changes that @mondrake made on the patch in comment #69 are for me RTBC. Thank you for your help on this issue!
Comment #72
mondrakeI think I can RTBC this, this patch is 99% @daffie's and I just made some minor changes.
Comment #73
catchProfiles aren't a genuine third extension type, they're an extension of modules, issues like #820054: Add support for recommends[] and fix install profile dependency special casing, #3053521: Allow core.extension.yml to have empty profile on install site from existing configuration, #1676196: Install profiles are registered as modules are dealing with some of these inconsistencies.
If we made database drivers into a third extension type, then they'd still need to be able to register services on the container etc. (this is the reason they're being made modules at all) - and we'd still need them to be installable/uninstallable to be able to do this. So issues around running code when uninstalled, having them installable/uninstallable but hidden etc. would still be there - just a bit more siphoned into a different extension type. But that extension type would need to re-implement a lot of module functionality so it may not end up being any cleaner.
There's an old (won't fix) issue to allow themes to register services #2002606: Allow themes to provide services.yml. We ended up allowing themes to depend on modules instead #2937955: Themes can declare dependencies on modules.
Short version is I agree that them being modules adds some complexity/special casing to the module system, but I'm not sure trying to make them an independent extension type will remove any complexity overall - it's as likely to push it up into the extension system in general.
We might want a meta issue to look again at profiles vs. themes vs. modules (and now database drivers) though since those discussions are quite scattered and some are a decade old now.
Comment #74
alexpottDo we need a follow-up to discuss how to deprecate this code and help people change their settings.php?
We're moving these classes with no BC layer. That's a break.
Is there any discussion of this on the issue? I think we need to leave a class here that extends the new class and is deprecated. In #24 I wrote...
which is true for the new module module classes but unfortunately I don't think is true for the existing classes which are part of the Drupal\Core namespace.
Comment #75
daffie commentedFor #74.1: I think we have 2 options. The first one is not having site owners change their settings.php file. That is very easy for them and for Core a little bit more difficult. We will now have 2 different types of connection info array's: the ones with the settings "autoload" and "namespace" set an the older ones without those settings set. To me it looks very easy for Core to support both connection info array's. The overhead is very minimal in code as in execution time. The other option is to have site owners update their settings.php file. For the sites hosted on Acquia and similar companies, will it be easy. Only for site owners with little knowledge of Drupal and cheaper hosting will have more problems. We shall have to tell them which keys to add and where. Also that the namespace key value needs to be done with double backslashes. We also have to hope that they will not change anything else in the settings.php file what way cause problems. If we make this required in D10, will those who do not have the added settings loose their database connection? It will also need a big communication effort from the Drupal community to inform all site owners to add those keys. And when something goes wrong, who will get the blame? Yes, it will be Drupal's fault. For me it is easy, lets go with the first option.
I have added 3 patch files with this comment. The problem is that when I do it all in one patch file, the driver files will be deleted and created instead of renamed. Their git links will get broken and the patch file size will be 500kb. That is not reviewable any more. When you do the same only with 2 patch files the git links will not get broken and the combined patch file size will be 150kb. The first patch file is the rerolled version from comment #69, which moves the driver classes to their own modules. The second patch file will create the BC layer as requested by @alexpott in comment #74.2. The other problem with a single patch file is that when anything changes in one of the database driver classes, the single patch file needs to be rerolled. Not so for the double patch files.
Comment #76
alexpott@daffie I think if you have
in your .gitconfig file you'll get a more reasonable overall patch size - when I recreate the patch it comes out at 339K - still big but I think better then maintaining multiple patches.
Comment #77
daffie commentedI already had the setting "renames = copies" and I added the second setting. Now the patch file is much smaller.
@alexpott: Thanks!
Comment #78
daffie commentedComment #79
mondrakehow about just using class_alias?
Comment #80
daffie commented@mondrake: Good idea. Only the testbot does not like your solution. I am getting PHPCBF errors, like:
Comment #81
alexpott#79 doesn't work unfortunately. I'd love to add a parameter to class_alias to trigger a user deprecation and then we could have file will class_aliases loaded as part of the static file map. See https://www.schmengler-se.de/en/2016/09/php-using-class_alias-to-maintai...
Comment #82
daffie commentedIt all sounds great, and after reading the linked page twice, do I have no idea how to do that and I get the impression that is a lot more code then the current solution. If you @alexpott, think you have a better idea how to do it, could you post some code examples or create a patch?
Comment #83
mondrakeAh sorry @daffie, thanks @alexpott. So it's not possible to alias at the same time as loading the potential class.. I missed that. IIUC #81 means that we could put the aliases in a deprecated class loading php file to be loaded by composer, but as things stand that would not allow for triggering deprecation errors. So the only option seems inheritance like #77 which implements that and adds tests.
I think this can go back to RTBC; #74.1 is for a followup I believe.
Comment #84
mondrakeComment #85
daffie commentedRerolled.
Comment #86
mondrakeComment #87
ankithashettyRe-rolled the patch in #85, thanks!
Comment #88
daffie commented@mondrake: Thank you for posting that the patch needed a reroll.
@ankithashetty: Thank you for the reroll.
The reroll was needed, because #2510438: Remove 'all' index from {key_value_expire} - serves no purpose and negatively impacts performance has landed.
The reroll look good to me. Back to RTBC.
Comment #89
mondrakeAlas, I am quite sure that commit of #3186934: Introduce an ExceptionHandler class in the database API, deprecate Connection::handleQueryException requires another reroll.
Comment #90
ravi.shankar commentedAdded reroll of patch #87.
Comment #91
ankithashettyFixed custom command errors in #90, thanks!
Comment #93
mondrakeIt'd probably be easier to move this issue to MR workflow.
Comment #95
mondrakeI wonder whether #3214234: Add core/class_aliases.php could now make the class aliasing for BC simpler.
Comment #97
mondrakeRerolled and changed to MR workflow.
Comment #98
daffie commentedI have rerolled the first part of the main patch (it passes the testbot for all 3 databases #3215116-40: [IGNORE] Testing). The second part is for adding the BC layer. The second patch can be found in my comment #75.
@mondrake: If you want to do it a bit different, that is fine too.
Comment #99
mondrakeThanks @daffie, I think the MR should be up to a working reroll of #93 now, with BC and deprecation tests included.
Comment #100
daffie commented@mondrake The MR looks good, just some minor stuff that needs to be fixed.
Comment #101
mondrakeAll fixed.
Comment #102
daffie commented@mondrake: You forgot to change the deprecation message for the class Drupal\Core\Database\Driver\pgsql\Install\Tasks. All the other changes look good.
Comment #103
mondrakeOps.
Comment #104
daffie commentedThe reroll now looks good to me.
Back to RTBC.
Comment #105
daffie commentedThis issue is a major change for the database drivers as they are moved to their own modules. This issue is blocking the moving of database specific code to the database module where it belongs. Just like contrib database drivers must do. As the by core supported database driver are or better should be the example for contrib database drivers. Therefor changing the priority of the issue to major.
Comment #106
mondrakeRerolled. This one is a pretty nasty one to reroll if there are changes to drivers' code in HEAD.
Comment #107
daffie commented@mondrake: Do you still think that rerolling is easier with a MR than with a patch? By the way, that you for the reroll.
Comment #108
mondrake#107 I do, generally speaking. With this issue, the problem is that some classes are copied in a different directory structure AND changed at the source to keep the deprecation triggers. This does not work well with git on the repo, apparently: the changes to the 'old' sources are not tracked to the 'new' locations.
Comment #109
mondrakeFiled #3231950: Split Database tests in 'core' ones and 'driver specific' ones as a D10 follow-up.
Comment #110
mondrakeRerolled
Comment #111
mondrakeFixing
ComposerIntegrationTest::testComposerLockHashis a moving target, especially close to new releases when dependencies are updated frequently. I'd rather wait for a 'go' by core committers on the patch overall, and then do the final fix (along with any deprecation message update for versions).Comment #112
mondrakeReroll after #3232699: SQLite schema introspection implementation struggles with NULL default values.
Comment #113
mondrakeRerolled
Comment #114
mondrakeRerolled
Comment #115
mondrakeRerolled
Comment #116
mondrakeRerolled
Comment #117
mondrakeChanged target branch to 9.4.x.
Comment #118
mondrakeComment #119
mondrakeReroll
Comment #120
mondrakeUpdating deprecation messages.
Comment #121
mondrakeChanged deprecation messages for deprecating in 9.4 and removing in 11.
Comment #122
daffie commentedUpdated the CR with how the use statement to database driver specific classes should be replaced. As requested by @alexpott.
Comment #123
daffie commentedComment #124
daffie commentedAll the deprecations has changed to 9.4.0 and will be removed before 11.0.0.
The testbot is happy again.
Back to RTBC.
Comment #125
mondrakeRerolled
Comment #126
mondrakeRerolled.
Comment #127
mondrakeRerolled
Comment #128
mondrakeSQLite failure on PHP 8.1 is unrelated.
Comment #129
beakerboyShould each core database’s DateSqlInterface implementations get moved into the respective modules as well?
For example:
core/modules/views/src/Plugin/views/query/SqliteDateSql.php
Comment #130
beakerboyRunning this branch with sqlsrv, I receive the following failure:
Drupal\FunctionalTests\Installer\InstallerTest::testInstalled
The file specified by the given app root, relative path and file name (/opt/drupal/core/modules/sqlsrv/sqlsrv.info.yml) do not exist. in /opt/drupal/core/lib/Drupal/Core/Extension/Extension.php:67
/opt/drupal/vendor/phpunit/phpunit/src/Framework/TestResult.php:737
Line 137 of InstallerTest.php is assuming that database drivers under test are in the core modules.
Comment #131
mondrake#129 yes! But I’d leave that to a follow-up, there will be lots of stuff to do after this gets committed. See for example #3231950: Split Database tests in 'core' ones and 'driver specific' ones.
Also, see #2657888: Add Date function support in DBTNG for an alternative approach.
Comment #132
mondrakeTests are now back green on all DBs in 9.4.
Comment #133
alexpott#130 looks like a problem that this patch needs to address - this should not be causing us to look in core for contrib database drivers.
Comment #134
daffie commentedFixed the InstallerTest for making it work with contrib database drivers.
Comment #135
beakerboyMy #130 issue has been resolved, so back to RTBC. Thanks for all the hard work!
Comment #136
alexpottAdded a review with some actions to the MR.
The other thing I'm wondering about is migrations. How does this affect migrating from a different database provider eg. sqlite to mysql? This is mentioned in #61 but I can't glean the ramifications of this change on that.
Comment #137
daffie commentedWorking on this.
Comment #138
daffie commentedAdded 3 followup issues:
EDIT: @alexpott: Thank you very much for the review!
Comment #139
mondrakeNeeds another reroll, unfortunately.
Also a requested comment in the code is missing, plus answer to #136, which I cannot answer.
Do not know if it's the same thing, but was wondering what would happen if a site had multiple database entries on different database types in settings.php. Would the update function need to enable ALL the modules affected?
Comment #140
daffie commentedReplied to the remarks of @mondrake.
Comment #141
mondrakeThis addresses #139, howeevr now I realise that probably calling
\Database::getConnection()with key and target is possibly not a good idea, since there could be stale entries in $databases, and those would fail.Comment #142
mondrakeAddressed my own concern in #141, by avoiding actually opening connections.
Comment #143
daffie commentedI can remember that we (@alexpott and myself) have discused this on Slack a long time ago. I can remember that the problem was not only for migrations, but also for other modules that can add database connections, like Drush and others. One problem was that those second modules stay enabled by default and that was something that @alexpott did not like at the time. Therefor he did not what those second modules enabled by default. Another point was that this would hardly ever happen. If he has changed his mind then we need to auto enabled the module that is providing the source database connection for migrations.
My description from comment #61 is still valid. The change to
system_post_update_enable_provider_database_driver()makes this all database connections that are active have their modules enabled when the update is run. For all database connections that are added after that moment, this is not the case.All the changes in the MR look good to me.
All the threads are solved.
Back to RTBC.
@mondrake: Thank you again for the rebase.
Comment #144
mondrakeI tested a slightly modified version of the MR with the DruDbal experimental db driver module, and it works correctly.
The change is in adding a couple of dump watches in
UpdateEnableProviderDatabaseDriverTest, to inspect provider and list of installed modules before/after the post_update execution:The test run result indicates that the contrib module gets installed too as part of the post_update:
Before:
After:
you can see the 'drudbal' module got installed.
Now, the test will probably not work with contrib drivers that are NOT encapsulated into a module yet, but to me this is more a benefit than not.
Comment #145
mondrakeComment #146
mondrakeViceversa,
ExistingDrupal8StyleDatabaseConnectionInSettingsPhpTestcan only reasonably work with mysql, pgsql or sqlite drivers.Comment #147
mondrakeFixed #146.
Comment #148
daffie commentedLooks good to me.
Back to RTBC.
Comment #149
alexpottHere's a patch for 10.0.x - there are conflicts in composer.lock and core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php
Comment #150
alexpottCommitted 934f42a and pushed to 10.0.x. Thanks!
Committed c18f8d6 and pushed to 9.4.x. Thanks!
Comment #155
effulgentsia commentedA lot of great work here! But:
This is too aggressive because it also autoloads to this directory for the
Drupal\Drivernamespace which is not sensible and creates errors for https://www.drupal.org/project/mysql56.I opened #3284502: [regression] Drupal 9.4 breaks BC via incorrect autoloading of \Drupal\Driver\* overrides of core db drivers to fix that.
Comment #156
greg boggsAfter installing the latest version of Drupal 9 for the security release today, I get this error on config import
The following reasons prevent the modules from being uninstalled: The module 'MySQL' is providing the database driver 'mysql'.
When I view my config differences, it shows that I'm removing mysql: 0 in core extensions. If I add mysql: 0 to my core extensions file, everything works normally.
Comment #157
daffie commentedCreated #3285200: Importing older config without the mysql/pgsql module enabled will generate error for the bug from comment #156. Thanks @Greg Boggs.
Comment #158
nicholassJust to document this for others, this change has broken our sites on our hosting company Acquia due to them having some include logic that was including the old core DB drivers, I have a ticket with them to work on the issue. But other hosting companies may have similar problems.
After 9.4 were getting
Error: Class "Drupal\mysql\Driver\Database\mysql\Connection" not foundeven with the new mysql module enabled.Note: This isn't a bug with 9.4 but just an unexpected side effect of this update having moved the location of mysql drivers
Comment #159
rajab natshahAfter a new build and new
drush site:installfor a new site ( not on update )Trying to do any other drush commands like
../vendor/drush/drush/drush user-create newuser --mail="person@example.com" --password="dD.123123ddd"Facing issues with a number of contrib modules
But the
Drupal\Core\Database\Driver\mysql\Connectionis used not theDrupal\mysql\Driver\Database\mysql\ConnectionAnd the message from the Mysql Driver Legacy Test
The MySQL module
What is the next move for this change? Have that fixed in all used modules?
Change from
Drupal\Core\Database\Driver\mysql\ConnectiontoDrupal\mysql\Driver\Database\mysql\ConnectionComment #160
xjm@Greg Boggs, @Rajab Natshah, @NicholasS, commenting on a closed issue won't help much because we don't receive notifications of updates for closed issues. Any time you encounter a regression from a change, you are better off opening a new critical or major bug report about it.
See these issues:
If none of those address the problems you're encountering, open new issues referencing this one, and add the "9.4.0 update" issue tag to help us find it among regressions for this release.
Thanks for your reports!
Comment #161
effulgentsia commentedI opened #3290924: [regression] With Drupal 9.4, can no longer call Database::getConnection() from within settings.php due to driver classes not yet in autoloader for #158. #159 might be a different issue though.
Comment #162
effulgentsia commentedI opened #3290936: Argument #1 ($database) must be of type Drupal\Core\Database\Driver\mysql\Connection, Drupal\mysql\Driver\Database\mysql\Connection given for #159.
@Rajab Natshah: please comment there with any additional info you find about it. Also see my suggestion there to see if appending
?module=mysqlfixes the site:install for you. E.g.,--db-url="mysql://root:rootpw@127.0.0.1/dev_d940x1?module=mysql".Comment #163
xjmThis is kind of the definition of a potentially disruptive change, and should have had a release note. We've added links to the related regressions to the release note, but we should also have one that explains the change itself, what will happen as a result, etc. A release note for it has also been requested in #3291224: Issues missing and broken link in 9.4.0 release notes.
Thanks!
Comment #164
alexpottAdded a release note.
Comment #165
xjmLinking the CR.
Comment #166
xjmComment #167
joegl commentedPer xjm's comment I've created a new issue: https://www.drupal.org/project/drupal/issues/3292510
Comment #168
larowlanIn default.settings.php we have this comment:
Note the use of
[]for replicas.But it looks like the new code in
\Drupal\Core\Site\Settings::initializethat adds in the namespaces, doesn't handle the array formatComment #170
bkosborneFor some reason, sites in Acquia Site Factory (maybe Acquia Cloud Enterprise as well, not sure), this database update hook does not enable the MySQL module. It also doesn't get enabled when new sites are installed. It doesn't appear to be causing any problems, as I guess like I read in this issue, it's not technically required to have the module that provides a DB driver to be enabled. The status report page also doesn't show the error message indicating that the MySQL module needs to be installed.
This is because in Acquia, the 'autoload' key in the database connection string is not set. I don't know why, or how important that is. I opened a support ticket w/ Acquia just in case, because it seems like this might be problematic in the future.
Comment #171
daffie commentedHi @bkosborne, sorry to hear have problems related to this issue. Technically the mysql module does not have to be installed at the current time, but that shall change. Therefor the mysql module should already be enabled. Or any other database driver module you may use.
As your problem are related with the Acquia site factory, my suggestion to you is to contact Acquia and let them fix the problem.