Closed (fixed)
Project:
Drupal core
Version:
9.4.x-dev
Component:
sqlite db driver
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Jan 2021 at 08:45 UTC
Updated:
3 Feb 2022 at 10:44 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
catchI'm going to move this back to 9.2.x - I think we can implement the requirements test in Drupal 9, and show a warning in hook_requirements() to tell people if they don't have the extension configured and that it will be required in Drupal 10.
Then in Drupal 10 we'd just change the warning to an error and possibly update some wording.
Comment #3
gábor hojtsyMake title clearer.
Comment #4
gábor hojtsyAlso opened #3203193: Fail install if JSON is not supported by the database in Drupal 10 for Drupal 10.
Comment #5
gábor hojtsyHere is a patch that works fine for me. Not sure how to do automated test for this at all.
Comment #6
catchWe could have a test that checks the pass case - just add it to system_requirements() testing.
No idea with the fail case, seems like it could be prohibitively complex.
Comment #7
gábor hojtsyHm, which test would that be. I could not find it. https://api.drupal.org/api/drupal/9.1.x/search/requirementstest
Comment #8
catchhmm I thought we had a generic status report test, but it looks like tests/src/Functional/UpdateSystem/UpdateScriptTest.php might be the closest thing, which isn't really appropriate here.
Comment #9
pobster commentedWe shouldn't have the translated string split up as it is, this won't work across all languages (for like, RTL languages but maybe others too).
There's no harm in duplicating the $requirements lines.
Comment #10
gábor hojtsy@pobster: How does two individual full sentences cause that problem?
Comment #11
pobster commentedRight-to-left languages.
'value' => $json_message . ' ' . t('Currently not required, however it will be required from Drupal 10.'),You can't guarantee the order of these sentences. Like this, they can only go in one order.
Comment #12
gábor hojtsyDrupal is full of composition of larger text from full translated sentences. See system_help(). Why is this case different?
Comment #13
pobster commentedThat's different as each part is separate? Nearly every line is either a dynamic list item or a heading. I mean ... it's not SO different, this is true - but using the argument "we do it badly elsewhere, so we can do it badly here" isn't the best of reasons to make translating content difficult. Someone will end up having to patch this later as part of an i18n initiative - let's just give whoever that is one less thing to do?
Comment #14
gábor hojtsyI did not say we do it badly elsewhere, we did the breakup of those strings as part of an i18n initiative. Either way, I will nor be the one to decide whether this is good for commit or not, and it still requires a test to be considered for inclusion (which I don't have capacity currently to add).
Comment #15
andypostComment #17
gábor hojtsyNote that #3190641: [policy] Require SQLite 3.26 for Drupal 10 (same as Drupal 9) with the json1 extension required (new requirement for Drupal 10) does not yet specify the json1 extension as a requirement, so that would be important to document / propose there, so we don't put the cart before the horse writing code for it :D
Comment #19
andypostcleaned a bit, gonna extend
\Drupal\Tests\system\Functional\System\StatusTestComment #20
avpadernoInstead of using
t('Not supported. Currently not required, however it will be required from Drupal 10.')andt('Supported. Currently not required, however it will be required from Drupal 10.')for the value key, it should uset('Not supported')andt('Supported')for value andt('It is currently not required, but it will be required from Drupal 10.')for description.Comment #21
gábor hojtsyHm, good suggestion!
Comment #22
andypostAddressed #20 - good idea
Comment #23
andypostAdded basic test and refactored code a bit
Comment #24
catchI think we could shorten this to something like:
'Database JSON support will be required from Drupal 10.'
The 'not required, however it will be required' is a bit tricky to scan.
Comment #25
avpadernoJust a nitpick: Currently not required, however it will be required from Drupal 10. is an example of comma-splice sentence.
It should be either It's currently not required. However, it will be required from Drupal 10. or It's currently not required, but it will be required from Drupal 10.
Comment #26
andypostI find it kinda tautology - database support... supported
So description could also prevent duplicating words
Also I wonder if we should display description if supported, probably it useful only when not supported
Comment #27
avpadernoAvailable is probably better. I suggested Supported to avoid using a phrase for which there wasn't a translation.
As for showing a description only when the support isn't available, Drupal core shows the description even when an extension is available. I would do the same here.
As for shortening the description, that could simple be It will be required from Drupal 10. The title is Database support for JSON, which means it's clear to what it will be required is referring to.
Comment #28
andypostHere's updated patch - using Available and shorter description as 10.0 (like other deprecations using to, check with
git grep 'is required in')Comment #29
daffie commentedThe testbot is failing for PostgreSQL, it needs it own special version query.
My suggestion would be to create a new method, something like Drupal\Core\Database\Schema::hasJson().
The pgsql module can then override the method with its own implementation.
Comment #30
murilohp commentedI think it's a good idea @daffie, I created a new function at
core/lib/Drupal/Core/Database/Connection.php::hasJsonand override it atcore/modules/pgsql/src/Driver/Database/pgsql/Connection.php. Let's see if the tests can pass now.Comment #31
murilohp commentedComment #32
daffie commentedMy guess is that it will fail for PostgreSQL. The new method needs to do something else to make it work for PostgreSQL.
Comment #33
murilohp commentedLooks like it's passing @daffie, searching at the documentation, since postgres 9.5, we have some new functions to process json values.
Do you think we should use something else to validate json datatype on postgres?
FYI: https://www.postgresql.org/docs/9.5/functions-json.html#FUNCTIONS-JSON-P...
Comment #34
daffie commented@murilohp: You are right. I did a quick look and missed that the method implementations are different.
Can we add a return typehint for a boolean value.
Can we remove these exceptions and add a try and catch statement.
Comment #35
murilohp commentedThanks for the review @daffie! Here's a patch addressing #34.
Comment #36
murilohp commentedDo you guys have any idea of what happened with the tests from #35? At the first moment I thought it could be an infrastructure error, but I think that's not the case.
Comment #37
cilefen commentedPHP Parse error: syntax error, unexpected ')', expecting '|' or variable (T_VARIABLE) in /var/www/html/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php on line 378
Comment #38
murilohp commentedThanks @cilefen! Let's see the tests now.
Comment #39
daffie commentedAll code changes look good to me.
The testbot is happy for all 3 supported databases.
There is a test added.
For me it is RTBC.
Comment #41
catchCommitted 206d6ee and pushed to 10.0.x. Thanks!
Realised there wasn't a change record for this while committing it, so added one.
Comment #42
niklanIs that correct that this change is states for Drupal 9.4.0 here and in change records, but only pushed in 10.0.x branch.
It will be cherry-picked to 9.4.x, or it's Drupal 10 feature?
Comment #43
catch@Niklan - not correct, I failed to push the cherry-pick successfully. Back to RTBC until that happens.
Comment #44
daffie commentedThe patch has been committed to the D10.0 branch. Now we need one for the D9.4 branch.
Comment #46
catchIt's a clean cherry-pick to 10.x, I just didn't do it properly (but have now).
We'll need a follow-up to make this a requirement error in 10.x though.
Comment #47
daffie commented@catch: We have #3203193: Fail install if JSON is not supported by the database in Drupal 10 for that.
Comment #48
gábor hojtsyOpened #3259311: Fix database JSON detection for PostgreSQL to fix this in Upgrade Status, it would break the same way for PostgreSQL.
Comment #49
mondrakeIf a contrib driver has not implemented the
::hasJson()method, the status report will be WSOD. I think we should also check that the method exists before calling it, at least in D9.4.Comment #50
mondrakeAlso, we are missing a test here, maybe in ConnectionTest.
Comment #51
daffie commentedWe have added the method to the class Drupal\Core\Database\Connection. Every database driver extends that class, therefor the new method should exists.
@mondrake: If you have an example of a contrib database driver that already has the method
hasJson()then please show us.Comment #52
mondrake@daffie you're right, the method will be there but failing if the syntax is not appropriate. Sorry for the noise, thanks. (A KernelTest would still be helpful, but can be followup).
Comment #53
daffie commented@mondrake: If you create the issue and the patch, then I will review it. :)
Comment #54
mondrakeRe. #53 I filed #3259532: Add a kernel test for Connection::hasJson.