Closed (fixed)
Project:
Drupal core
Version:
9.1.x-dev
Component:
database system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
30 Mar 2020 at 12:10 UTC
Updated:
17 Aug 2020 at 16:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
daffie commentedComment #3
daffie commentedA CR has been added.
Comment #5
daffie commentedFixed the failing test
Drupal\Tests\Core\Database\ConditionTest::testContribCondition(). Changed the used namespace from the deprecated D8 style to the new D9 style.Comment #6
daffie commentedRerolled the patch for #3126658: Support enclosing reserved words with brackets..
Comment #7
kristen polThanks for the patch.
a) Is it intentional that the comment and trigger error are using double backslashes but the code uses:
'Drupal\Driver\Database\\'?
Seems like it's missing two backslashes or the last double backslash should be a single backslash, but then I would expect the test to fail.UPDATE: Ok, I see how this is correct (// signifies the end of the namespace). I wonder if it's worth updating the comment to make this more clear.
b) "Not by Drupal core supported database drivers"
Not sure what this means.
Nitpick: Wrap at 80 chars.
Nitpick: Wrap at 80 chars? Maybe not for expectedDeprecation message.UPDATE: I looked at a few @expectedDeprecation messages and see they are all on one line.
core/tests/Drupal/Tests/Core/Database/DatabaseTest.php
and
(Sidenote: Code refers to "D8").
core/tests/Drupal/Tests/Core/Database/ConditionTest.php
This one is updated in the patch.
core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php
core/tests/fixtures/database_drivers/core/corefake/Connection.php
core/tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefake/Connection.php
core/tests/fixtures/database_drivers/custom/corefake/Connection.php
core/tests/fixtures/database_drivers/custom/fake/Install/Tasks.php
Comment #8
kristen polBack to "Needs work" for at least item 5 in #7.
Comment #9
daffie commented@Kristen Pol: Thank you for your review.
For #7.1.a: Yes, it is intentional. In the settings.php file you have the database connection array and for contrib/custom database drivers you have the namespace key. The value for that key is something like "Drupal\\Driver\\Database\\oracle". For PHP the backslash character is a special character. In PHP it is used as the escape character. See: https://www.php.net/language.types.string. In the if-statement I made the comparison to
'Drupal\Driver\Database\\'. For PHP this will become the string:Drupal\Driver\Database\. In PHP we have the backslash character as the string escape character and we use it in namespaces. When you then start working with namespaces as strings it will become a bit confusing. I have changed the if-statement so that it will be less confusing?For #7.1.b: Updated the test to: Contributed and custom database drivers have to use the namespace "Drupal\\MODULE_NAME\\Driver\\Database\\DRIVER_NAME"
For #7.2: Fixed.
For #7.3: That is how it works.
For #7.4: Unfortunately we are only allowed to deprecate the functionality not removing it. We shall have to wait for Drupal 10.0 before we can remove all that stuff.
For #7.5: This patch is for 9.1. We are not allowed to deprecate stuff in 9.0. The patch does not have to apply to 9.0 (
mac:kristen:drupal-9.0.x-dev).Comment #10
kristen polThanks for the speedy response and great comments. Let me take a look!
Comment #11
kristen polNice!
Looks good!
Looks good.
For #7.1.a: Understood. Looks good. Thanks for the changes.
For #7.1.b: Wording change looks good.
For #7.2: Truncation looks good.
For #7.3: Thanks.
For #7.4: Gotcha.
For #7.5: Whoops. Ok, applied cleanly against 9.1 branch!
Ok, this looks RTBC to me but is there a way for me to manually test this?
Comment #12
kristen polComment #13
daffie commented@Kristen Pol: To manual test this, you have to take the database driver for OracleDB (https://www.drupal.org/project/oracle) or the one for Microsoft SQL Server (https://www.drupal.org/project/sqlsrv) and install a Drupal site. You need of course a running OracleDB or Microsoft SQL Server to do so.
Comment #14
kristen polAh. Not sure I can do that as I'm on a Mac and maybe those cost money to install. Will someone need to manually test before this can be RTBCed?
Comment #15
daffie commentedWould be great is somebody did, but for me no it can be RTBC'd without. There are only a couple of contrib database drivers out there: OracleDB, MS SQL Server, MemSQL and DruDBAL. The last one is from @mondrake and he has already moved his module over to using #3120096: Support contrib database driver directories in a fixed location in a module. When this issue lands I will create an issue on all their modules issue queues informing them that they shall have to move over to using #3120096: Support contrib database driver directories in a fixed location in a module.
@Kristen Pol: By the way: Oracle has a free version for everybody: https://www.oracle.com/database/technologies/appdev/xe.html. And Microsoft has also a free version: https://www.microsoft.com/en-us/sql-server/sql-server-downloads.
Comment #16
alexpottSupport is deprecated... so
are deprecatedneeds changing. This could beThere's no need for the \\\\ stuff - https://3v4l.org/b3ja9
Also... I think it's more helpful to say that support for database drivers in the drivers/lib/Drupal/Driver/Database directory is deprecated. So this changes the message somewhat.
Comment #17
catchI'm not sure this is a case where deprecation is enough. Drupal 8 style contrib database drivers don't get included in update status reports, so for someone who's installed one, there is no notification that a new version is available. In other words the deprecation message helps the driver authors, but not the people that need to update.
There are not loads of options, but maybe a hook_requirements() to detect when a driver is being used in the deprecated location?
Comment #18
alexpott@catch I'm not sure about a requirements message. The situation you're getting at is only contrib - if you maintain a custom driver then you're 100% responsible for it and can update it. If you're using a D8 contrib driver you need the contrib driver author to update their code before you can do anything. There's nothing you can do till they do - so we'd be putting something non-actionable on the status report which never goes down well. We could file an issue against drupal-check to look in a sites drivers/lib/Drupal/Driver/Database a report that drivers placed there are deprecated. But I'm not convinced that's worth it. Contrib drivers are rare and doing this deprecation early in the D9 cycle plus having support for module provided drivers in D8.9 means they've got plenty of time to do a new release. And regardless of deprecations being on the most up-to-date module versions is recommended when you update from D9 to D10.
Comment #19
daffie commentedUpdated the patch for the comment #16.
Comment #20
catchThis is true, but database drivers aren't modules, they don't even ship with version information.
Maybe add it to 9.2, or whatever 9.LAST is in a follow-up?
Comment #21
kristen pol1) I reviewed the patch in #19 and compared the
@trigger_errorand@expectedDeprecationmessages against the suggestion in #16 and they match except for the quotes. The double quotes used in the patch seem like the correct approach rather than the single quotes in the suggested text based on usage in other core code.2) One minor thing that I didn't comment on before is there is a new line added in an unrelated section that technically shouldn't be added but it doesn't seem like a big deal.
3) The patch applied cleanly:
Based on this, #15, and the discussion between @alexpott and @catch, it doesn't appear like anything else needs to happen in this patch, so marking this RTBC.
Comment #22
catchTagging for needs follow-up, for some kind of site-admin facing message even if we do that in a later release.
Also is there an already an issue open for converting the core database drivers to extensions?
Comment #23
alexpottThis needs a reroll.
Namespace is now always set. So this can change a bit.
Comment #24
daffie commentedComment #25
daffie commentedComment #26
daffie commentedRemoved the
isset($connection_options['namespace'])from the if-statement.Moved the added deprecation part to after when no namespace set that add one.
Comment #27
daffie commentedWaiting for doing that until #3124354: Remove unnecessary classes from the database drivers has landed.
Comment #28
alexpottFrom https://www.php.net/manual/en/function.strstr.php
So lets change this to
if (strpos($connection_options['namespace'], 'Drupal\Driver\Database') === 0) {Comment #29
daffie commentedFixed for comment #28.
Comment #30
daffie commentedComment #31
kristen polThanks for the update.
1) I have confirmed that the change in #29 addresses the requested change from #28.
2) The patch applies cleanly:
3) All other requested changes above have been addressed, so marking RTBC.
Comment #32
daffie commentedYes, @catch there is now #3129043: Move core database drivers to modules of their own.
Comment #33
catchComment #34
xjmNW for the release note, and also since the patch no longer applies. Thanks!
Comment #35
xjmOh we also still need a followup for "some kind of site-admin-facing message" per #22.
Comment #36
daffie commentedComment #37
daffie commentedFollowup created for "some kind of site-admin-facing message". See: #3153443: A site-admin-facing message for the deprecation of database drivers in DRUPAL_ROOT/drivers.
Comment #38
daffie commentedStraight reroll.
Comment #39
daffie commentedThe only thing left is the "NW for the release note" from @xjm in comment #34.
Comment #40
daffie commentedComment #41
daffie commentedRelease note added.
Back to RTBC.
Comment #42
xjmComment #44
daffie commentedBack to RTBC.
Comment #46
catchCommitted 5730ee6 and pushed to 9.1.x. Thanks!