Problem/Motivation

Background context for Drupal 8

  • Drupal 8.0 was released in Nov. 2015. At that time, for people who wanted to install it on SQLite, the stated minimum required SQLite version was 3.6.8. If this were true, then this would have meant that all still-supported versions at that time of Debian (6, 7, 8), Ubuntu (12.04, 14.04), and RHEL/CentOS (6, 7), shipped with a compatible SQLite version. Debian 6 shipped with 3.7.3. Ubuntu 12.04 shipped with 3.7.9. And RHEL/CentOS 6 shipped with 3.6.20.
  • However, DrupalCI did not test on SQLite 3.6.8. It only tested on 3.8.2. So after releasing Drupal 8.0, we learned that Drupal could not in fact install on anything less than 3.7.11, at which point we raised the stated minimum to that, and have not raised it since.
  • Per above, this raised the minimum above what shipped with Debian 6, Ubuntu 12.04, and RHEL 6.
  • In other words, in reality, instead of Drupal 8.0 working with the SQLite version on all supported versions of the major Linux distros, it only worked on the latest versions of Ubuntu and RHEL/CentOS and with the latest and latest-1 of Debian.
  • This was mitigated by the fact that by default PHP was compiled with its own private copy of SQLite, whose version was above 3.7.11 since PHP 5.5.11. In other words, the only people who would have encountered a problem on Debian 6, Ubuntu 12.04, or RHEL/CentOS 6, were people who custom compiled PHP to link against their system's SQLite instead of PHP's bundled copy. This might explain why we didn't get many reports of the problem other than #2605594: Change minimum required sqlite version to 3.7.11.

Considerations for Drupal 9

  • PHP 7.3 continues to be compiled by default with its own bundled copy of SQLite (presently at version 3.28 since PHP 7.3.8).
  • However, PHP 7.4 removed its bundled copy and now compiles against whatever SQLite version is on the operating system.
  • If we want Drupal 9.0 to work on SQLite with all still-supported versions of Debian, Ubuntu, and RHEL/CentOS, then that would include RHEL/CentOS 7, which would only let us raise our minimum to 3.7.17.
  • However, then we'd lose out on some very helpful features, such as json support (since 3.9) and UPSERT support (since 3.25).
  • Alternatively, if we're willing to restrict SQLite support to the version that's shipped with the latest version of Debian, Ubuntu, RHEL/CentOS, and MacOS then we can raise the minimum to 3.26 and benefit from UPSERT support, because RHEL/CentOS 8 ships with SQLite 3.26, Debian 10 ships with SQLite 3.27, Mac Catalina ships with 3.28, and Ubuntu 20.04 will ship with 3.30 or higher.

Proposed resolution

  • For Drupal 9, raise the SQLite minimum to 3.26.
  • PHP 7.3 users will be fine, since they'll be using PHP's bundled copy that's at 3.28.
  • PHP 7.4 users will only be able to use SQLite if they're on the latest version of their respective operating system, or if they install SQLite from a different package repository than what's on their operating system. This includes Mac Mojave users who will need to either upgrade to Catalina or use PHP 7.3 or find some other way to install a higher SQLite version.
  • Ubuntu 18.04 users (including users of downstream distros like Mint and ElementaryOS) will be particularly impacted during the next few months, because Ubuntu 20.04 won't be released until April and the downstream distros will lag another few months after that. However, they too can use PHP 7.3 until they're able to upgrade their OS.
  • People with Drupal codebases (modules, distributions, or sites) on GitHub that they test with TravisCI will be affected, since TravisCI provides Ubuntu 18.04 but not yet 20.04. However, as above, they can run those tests on PHP 7.3. Or, if they must test with PHP 7.4, they can add the following to their .travis.yml:
    dist: bionic
    
    before_install:
      - sudo echo "deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse" >> /etc/apt/sources.list
      - sudo apt-get update
      - sudo apt-get -y install sqlite3/focal
    

    I tested the above on TravisCI and it works (it successfully installs Ubuntu 20.04 (focal)'s SQLite version on Ubuntu 18.04 (bionic)), but I don't know if it has any unwanted side effects.

  • Note that all of the above only affects people wanting to use SQLite. People affected by the above can also simply choose to use MySQL or PostgreSQL. However, SQLite is convenient for running tests and installing a site with Quick Start.

Remaining tasks

Release notes snippet

Raised the minimum SQLite version to 3.26 in Drupal 9.

CommentFileSizeAuthor
#80 3107155-80.patch3.99 KBandypost
#80 interdiff.txt2.67 KBandypost
#77 3107155-77.patch3.71 KBcatch
#76 3107155-76.patch1.55 KBcatch
#76 3107155-interdiff.txt1.55 KBcatch
#69 3107155-interdiff.txt2.5 KBcatch
#69 3107155-69.patch3.14 KBcatch
#66 3107155-66.patch3.46 KBcatch
#62 3107155-61-install-tasks.patch2.01 KBcatch
#62 3107155-61.patch1.77 KBcatch
#56 3107155-56.patch2.33 KBcatch
#39 3107155.patch1.09 KBcatch
#23 sqlite-min-version-3107155-23-3.26.patch475 byteseffulgentsia
#23 sqlite-min-version-3107155-23-3.22.patch475 byteseffulgentsia
#14 test.php_.txt369 byteseffulgentsia
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

daffie created an issue. See original summary.

andypost’s picture

Another dimension to check is state of -DSQLITE_MAX_VARIABLE_NUMBER=250000

daffie’s picture

Another dimension to check is state of -DSQLITE_MAX_VARIABLE_NUMBER=250000

@andypost: Good idea!
We need to add that as an requirement. If we go for higher minimum version for SQLite, we shall properly get that, but we need to check for it.

daffie’s picture

Issue summary: View changes
daffie’s picture

The newest versions of Debian 10 and Red Hat Enterprice Linux (RHEL) 8 are gong to be almost a full year old when Drupal 9 will be released. For me that is long enough to be used as a base distribution for Drupal 9. Ubuntu 18.04 LTS will be by then 2 years old. All 3 of those distribions support at least SQLite 3.22.0. SQLite 3.22.0 is by the time of the release of Drupal 9 over 2 years out. Which implies that it should be very stable.

According to @Dries: "Drupal is for ambitious digital experiences". Supporting only modern databases helps with that goal.

For me the minimum supported version for SQLite should be 3.22.0.

andypost’s picture

daffie’s picture

@andypost: Thanks for the info!

New release is out https://sqlite.org/releaselog/3_31_0.html

I think that that will have to wait for after the release of Drupal 10.

andypost’s picture

effulgentsia’s picture

It does, but starting with PHP 7.4, it links against the sqlite library that's on the system, which could be 3.11 for Ubuntu 16.04 or 3.22 for Ubuntu 18.04.

I agree with #5 that 3.22 is a reasonable minimum. I think it's fine for Debian 9, Ubuntu 16.04, and RHEL 7 users to either not be able to use SQLite with Drupal 9 or else to upgrade their sqlite library.

Orthogonal to the version question, I opened #3109340: [policy] Decide whether to require json support for all database drivers for Drupal 10 to discuss whether we can require that json1 be compiled in. There's also #2, which is a separate question, but might overlap slightly in terms of whether there's any correlation between builds (either the distribution's build, or PHP 7.3's internal build) that include json1 and ones that set DSQLITE_MAX_VARIABLE_NUMBER to a large enough number.

daffie’s picture

I have asked the same question on #3109340: [policy] Decide whether to require json support for all database drivers for Drupal 10. The question that I have is: How easy is it for Windows and Mac users to get SQLite on their systems with the json1 extension? (and also with the DSQLITE_MAX_VARIABLE_NUMBER setting being higher then/equal 250000?)
Does anybody have any idea how many people on Windows and Mac use SQLite as a database for Drupal to test it out?

andypost’s picture

@daffie I bet windows will use WSL in d9 era, so some Linux-distro, on MacOS this limit is higher iirc

daffie’s picture

@effulgentsia said in #3109340-12: [policy] Decide whether to require json support for all database drivers for Drupal 10:

And here's where it was added to PHP 7.3 prior to becoming unbundled (and therefore using however it was compiled on the system) in PHP 7.4.

So the summary is, SQLite json support is ON by default in all of:

PHP 7.3, regardless of system
PHP 7.4 if the SQLite on the system is 3.24 or higher
PHP 7.4 if the SQLite on the system is the 3.22 that's shipped with Ubuntu 18.04
Possibly others too, though I don't know if we care about any others, since I think all other systems that we care about for D9, including MacOS Mojave and Catalina, come with SQLite 3.24 or higher.

Lets then set the minimum supported version for SQLite at 3.22 with json1 module enabled and the variable DSQLITE_MAX_VARIABLE_NUMBER having a value of 250000 or higher.

@effulgentsia: Thank you for your effort in the fact finding mission.

effulgentsia’s picture

FileSize
369 bytes

and the variable DSQLITE_MAX_VARIABLE_NUMBER having a value of 250000 or higher

This one is problematic. The default for DSQLITE_MAX_VARIABLE_NUMBER is 999. I don't see anything in either SQLite's configure.ac or PHP 7.3's config0.m4 that sets that compiler flag to anything else.

I think this means that all or most PHP 7.3 builds will have the 999 limit. And, for PHP 7.4, it will depend on whether the operating system explicitly added that compiler flag. Debian and Ubuntu add it, but it doesn't look like CentOS does, unless it does it elsewhere than that line.

I tested on my MacOS Catalina, and found that as expected, on PHP 7.3, it's limited to 999. On PHP 7.4, I'm getting 500000, so MacOS is setting that compiler flag somewhere (I don't know where since AFAIK, MacOS source code isn't public).

So unless we're willing to restrict Drupal 9 SQLite use to only PHP 7.4+, and only on MacOS, Debian, and Ubuntu, I don't think we can require DSQLITE_MAX_VARIABLE_NUMBER higher than 999.

For anyone who wants to find out the limit on systems they have access to, here's a PHP script that tests it. It's a copy of the example in https://www.php.net/manual/en/sqlite3stmt.bindparam.php, but with :bar replaced with ?$num where $num is set in the first code line. If that number is below the limit, the script will output what https://www.php.net/manual/en/sqlite3stmt.bindparam.php says it should. If it's above the limit it, it will output nothing.

effulgentsia’s picture

One more thing to consider here. SQLite added a real UPSERT in 3.24. As in, INSERT ... ON CONFLICT UPDATE, rather than what Drupal\Core\Database\Driver\sqlite\Upsert currently relies on, which is INSERT OR REPLACE INTO. A difference between the two is that REPLACE deletes and re-creates the entire row, so any field values not specified are reset to NULL or their default value.

I don't think that difference matters in core yet, where ->upsert() is used only by Drupal\Core\Cache\DatabaseBackend, which sets all of the field values. But maybe it could matter in contrib or in future Drupal 9 minors?

So the decision we need to make is... do we want to require 3.24 in order to be able to rely on INSERT ... ON CONFLICT UPDATE, but at the cost of leaving Ubuntu 18.04 users on PHP 7.4+ unable to use SQLite? Those users would then have to choose between not using SQLite, or using PHP 7.3, or updating to 20.04 once it's out, or manually installing a newer sqlite.

If it were MySQL or PostgreSQL, I would say that no way can we abandon Ubuntu 18.04 users, but for SQLite, since it's primarily for development and testing, maybe it's less of a big deal for developers/testers to get onto Ubuntu 20.04 or manually upgrade their sqlite installation? Tagging for release manager review of this question in particular.

daffie’s picture

I think we have two questions for the release/product managers:

  1. Whether or not to require that the variable DSQLITE_MAX_VARIABLE_NUMBER has a minimum value of 250000. In a number of cases Drupal likes to use queries with a lot of variables, mainly migration and import of configuration/content. See: #2031261: Make SQLite faster by combining multiple inserts and updates in a single query and #3049948: SQLSTATE[HY000]: General error: 1 too many SQL variables: INSERT OR REPLACE INTO {cache_content} (cid, expire, created, tags, checksum, data, serialized). WE have fixed the problem a bit, but that goes only so far. By setting variable to the suggested minimum those problem will be solved. The value can only be changed by recompiling SQLite. Not all distribution have set that variable high enough and if we are going to require that then those distribution cannot be used to run Drupal on SQLite. See comment #14 in this issue from @effulgentsia for more info.
  2. Wether or not to require support native UPSERT queries on SQLite. For that we need SQLite 3.25. UPSERT was originally introduced in SQLite 3.24 and a major bug for UPSERTS was fixed in 3.25 (See: https://sqlite.org/changes.html). The downside of setting the minimum version of SQLite of 3.25 is explained very well by @effulgentsia in comment #15. Everything he states about 3.24 also applies to 3.25.

Add the tag "Needs product maintainers review", because they can make the best judgment call about what the users of Drupal on SQLite want/need. In short support on more distributions vs. a better experience with working/using Drupal on SQLite. As somebody who works on the driver software, I would go for the better experience, but it is not my call to make.

effulgentsia’s picture

And, for PHP 7.4, it will depend on whether the operating system explicitly added that compiler flag. Debian and Ubuntu add it, but it doesn't look like CentOS does

I decided to test this instead of just inferring from CentOS source code. I spun up a droplet on Digital Ocean using a base CentOS 8.1 image. I then followed the instructions on https://blog.remirepo.net/post/2019/12/03/Install-PHP-7.4-on-CentOS-RHEL... to install PHP 7.4:

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf module reset php
dnf module install php:remi-7.4

To get sqlite into PHP, you also need to install the php-pdo package, so I did that:

dnf install php-pdo

Then, to test #14, I did:

dnf install wget
wget https://www.drupal.org/files/issues/2020-01-31/test.php_.txt
php test.php_.txt

Sure enough, it error'd out:

PHP Warning:  SQLite3::prepare(): Unable to prepare statement: 1, variable number must be between ?1 and ?999 in /tmp/test.php_.txt on line 7

While I only tried this on CentOS 8.1, I suspect it would yield the same result on RHEL 8.1 and Fedora 31.

Gábor Hojtsy’s picture

@daffie: as per https://www.drupal.org/contribute/core/maintainers the questions you are asking belong to framework managers. @effulgentsia is already a framework manager, so you got the attention of a great person :) I swapped the tag, framework managers can remove it when they believe they provided adequate feedback.

Gábor Hojtsy’s picture

catch’s picture

Whether or not to require that the variable DSQLITE_MAX_VARIABLE_NUMBER has a minimum value of 250000

I'd prefer to move this to two follow-up issues:

Follow-up 1. Warn people in system_requirements() if the value is too low, this should be non-controversial and easy to commit more or less immediately, also backportable to 8.9.x and maybe 8.8.x

Folllow-up 2. Decide whether to make it a hard requirement in 9.0.x or 10.0.x

On 3.25: For me personally I think requiring 3.25 at the expense of Ubuntu 18.04 users is OK. The release date for Ubuntu 20.04 is April 2020, and that is definitely going to happen before Drupal 9.0.0. Since we are mainly talking about people's development environments here rather than site hosting, needing to be on the latest Ubuntu LTS (or getting a higher version of sqlite via some other route) is pretty reasonable and a good trade-off for being able to fix otherwise-unfixable bugs in the driver (although sounds like not the end of the world if we delayed that fix to 10.0.x either).

Gábor Hojtsy’s picture

@catch: I was looking to open the first followup but apparently #2031261: Make SQLite faster by combining multiple inserts and updates in a single query provides a sensible workaround even for lower numbers. I think that may be the issue to add a warning, given that the workaround makes things work but is not the optimal behaviour. It also does not look like raising SQLite version requirements raises that number.

catch’s picture

OK great let's continue the variable limit work in #2031261: Make SQLite faster by combining multiple inserts and updates in a single query and can ignore it here.

effulgentsia’s picture

Uploading 2 patches: one that sets the minimum version to 3.22 and one that sets it to 3.26. I'm curious whether DrupalCI will pass the first and fail the second.

effulgentsia’s picture

For me personally I think requiring 3.25 ... is OK

If we're ok with 3.25, then I recommend going to 3.26, because I don't think there's any operating system distribution that ships with 3.25. Therefore, it'll be easier for DrupalCI to test on 3.26 as that's the one that comes with RHEL/CentOS 8. Also, it means that that'll continue to have secure builds available (provided by CentOS) until 2024.

I posted #23 because I was concerned that DrupalCI currently tests on Ubuntu, so I thought it would allow us to go as high as 3.22 but no higher. However, looks like that's not true. The "PHP 7.4 & SQLite 3.8" test is actually testing on Debian 8, which is the OS that ships with SQLite 3.8, so it's failing both patches. But if DrupalCI can run a docker image with Debian 8, then presumably it can also run a Docker image with CentOS 8, in which case it can test SQLite 3.26. But I think this means that to actually bump the minimum to 3.26 that we need to add that image to DrupalCI. If someone knows where to file an issue to request that change/addition to DrupalCI, please do. Otherwise, I'll figure it out and do it tomorrow.

daffie’s picture

f we're ok with 3.25, then I recommend going to 3.26, because I don't think there's any operating system distribution that ships with 3.25.

I fully agree with this statement.

The "PHP 7.4 & SQLite 3.8" test is actually testing on Debian 8

Yes, that is correct. SQLite does not have its own database docker container image. SQLite 3.8 is the version that comes with Debian 8. If we now set the minimum version to 3.26 all PHP containers need to be based on CentOS 8. The easiest upgrade would be to use Debian 10 as the base image for the PHP containers, then we would however get SQLite 3.27.2 instead of 3.26. @mixologic is the maintainer of the testbot, lets ask him what he thinks is the best solution, before we create an issue for it.

catch’s picture

So the queue is https://www.drupal.org/project/issues/drupalci_environments. I went ahead and opened an issue at #3112396: DrupalCI environment needed with PHP 7.4 and SQLite >= 3.26 making it clear we're not 100% finalized here yet.

To be able to commit a core patch, we just need to be able to run tests on a supported version of sqlite, min/max environments can come later.

effulgentsia’s picture

Issue summary: View changes

I reworked the issue summary. I hope it's helpful for whoever else is needed to make the decision.

effulgentsia’s picture

Issue summary: View changes
effulgentsia’s picture

Issue summary: View changes
effulgentsia’s picture

Issue summary: View changes
effulgentsia’s picture

I'm +1 to raising the minimum version to 3.26, so removing the "Needs framework manager review" tag.

As noted in the issue summary, I think the key to that being acceptable is that people on the non-latest OS version can use PHP 7.3. However, those people will be running with a SQLITE_MAX_VARIABLE_NUMBER at its default of 999, so I don't think we should require anything higher than that, and instead get the workaround in #2031261: Make SQLite faster by combining multiple inserts and updates in a single query to a committable state.

effulgentsia’s picture

Issue summary: View changes
Gábor Hojtsy’s picture

@effulgentsia: re who needs to decide IMHO that would be framework and release managers. Thanks for the framework manager signoff. What we usually did before is we opened an actual issue to raise the requirement once the technical possibilities were there (in this case the sqlite environment for PHP 7.4 and #2031261: Make SQLite faster by combining multiple inserts and updates in a single query would IMHO be considered a requirement). We can also convert this issue to a not-policy issue, if we think 3.26 is it for Drupal 9 and continue as an implementation issue that is postponed on those two things. In that case #3112396: DrupalCI environment needed with PHP 7.4 and SQLite >= 3.26 should be informed to go ahead :)

Gábor Hojtsy’s picture

Title: [policy] Decide on SQLite 3.x support status » Raise SQLite version requirement to 3.26 in Drupal 9
Issue tags: +Needs release manager review

Ok converted to an implementation issue since it does not seem like we would raise it further later (ie. we don't need the policy issues after the implementation issue) :)

xjm’s picture

FWIW I'm also +1 on requiring 3.26 given the IS writeup and the available distro support.

I can't find anything from SQLite themselves about their support policy for minor versions; does anyone have a reference?

xjm’s picture

Per @effulgentsia their release history is the best indicator he found either (and it doesn't seem to include any backports of security patches or whatnot). OTOH they also don't seem to have a fixed schedule at all. So I think setting the requirement based on "all distros have a version that has support for it" and "has useful technical features/bug fixes" is good. Edit: Said release history is at: https://www.sqlite.org/changes.html

xjm’s picture

Confirmed @catch is also alright with increasing the requirement to 3.26 for D9.

Gábor Hojtsy’s picture

Updated #3112396: DrupalCI environment needed with PHP 7.4 and SQLite >= 3.26 following the above decision. Looks like #2031261: Make SQLite faster by combining multiple inserts and updates in a single query should not be a beta requirement then? (It is honestly not clear to me at all from the above if we are loosing on the max variable numbers by upgrading SQLite requirements or just not gaining anything?)

catch’s picture

Gábor Hojtsy’s picture

Re #38 I since got confirmation from @xjm et. al. that #2031261: Make SQLite faster by combining multiple inserts and updates in a single query is a pre-existing condition that is not made better or worse here. So that is not blocking.

Looks like this cannot get to RTBC without #3112396: DrupalCI environment needed with PHP 7.4 and SQLite >= 3.26 first being rolled out. That said, I don't believe this is considered a beta must-have ATM.

effulgentsia’s picture

Note that #39 passes on PHP 7.3, because PHP 7.3 bundles its own SQLite with a high enough version. Given that, would it make sense to commit it while we wait for #3112396: DrupalCI environment needed with PHP 7.4 and SQLite >= 3.26, or is it not acceptable for HEAD to be in an interim state where we can't test a PHP 7.4 + SQLite combination?

catch’s picture

IMO we can commit and add the combination later.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 19cf46c and pushed to 9.0.x. Thanks!

#3112396: DrupalCI environment needed with PHP 7.4 and SQLite >= 3.26 is a shame but I agree with @catch I don't think that should stop us going forward.

  • alexpott committed 19cf46c on 9.0.x
    Issue #3107155 by effulgentsia, catch, daffie, Gábor Hojtsy, andypost,...
xjm’s picture

How can it not stop us going forward? We literally cannot test SQLite on D9 at all now that this has been committed.

My suggestion in the previous meeting was for this to be a beta target if the CI environments did not support it, since it's only a minor version update. I think this needs to be reverted, but can be allowed during beta.

xjm’s picture

xjm’s picture

According to @Mixologic the UI label might be lying and it additionally looks like #3109534: Raise the minimum MySQL version to 5.7.8 and MariaDB version to 10.2.7 in Drupal 9 might have actually been the thing that broke SQLite (as well as postgres), which is... counterintuitive. Reverting that now to verify.

catch’s picture

Just to confirm the UI label is lying #3107155-38: Discuss lowering SQLite version requirement from 3.26 to 3.22 in Drupal 9 properly passed on PHP 7.3

The one thing we can't do is test PHP 7.4 and sqlite.

effulgentsia’s picture

The UI label is semi-true. Version 3.8 is the version that's on the operating system. It's just that PHP 7.3 ignores what's on the operating system and uses its own bundled copy of SQLite 3.28.

mondrake’s picture

Priority: Normal » Critical
Status: Fixed » Needs work

I am afraid this needs to be reverted as this fails tests on PHP 7.4 DrupalCI testbot

The database server version 3.8.7.1 is less than the minimum required version 3.26.

We should have PHP 7.4 containers upgraded to a newer sqlite3 library

Gábor Hojtsy’s picture

Note that this was found via #3109534-76: Raise the minimum MySQL version to 5.7.8 and MariaDB version to 10.2.7 in Drupal 9.

Not sure fixing the test environments would be enough, given that people could encounter the same mismatch of versions locally in which case it would still fail, so we to fix the db layer in Drupal to not freak out about invalid combinations of DB backends if at least a valid one is available probably.

catch’s picture

Could we make the quickstart test only run on sqlite environments?

  • catch committed fc9d6ce on 9.0.x
    Revert "Issue #3107155 by effulgentsia, catch, daffie, Gábor Hojtsy,...
catch’s picture

Reverted for now to get the PHP 7.4 environment back to green.

catch’s picture

Status: Needs review » Needs work

The last submitted patch, 56: 3107155-56.patch, failed testing. View results

alexpott’s picture

+++ b/core/tests/Drupal/KernelTests/Core/Command/QuickStartTest.php
@@ -21,7 +21,7 @@
-class QuickStartTest extends TestCase {
+class QuickStartTest extends KernelTestBase {

@@ -88,6 +88,10 @@ public function testQuickStartCommand() {
+    if ($this->testDb::getConnection()->driver() !== 'sqlite') {
+      $this->markTestSkipped();
+    }

QucikStartTest can't be a kernel test - it can't have any Drupal environment stuff like this. If we want to skip the test then we need to skip on PHP version because this quick start site being installed and tested is always using SQLite.

xjm’s picture

Could we use a non-Drupal API to check the SQLite version? Skipping on PHP version would be super fragile because the relationship between the environment and the SQLite version could change at any time.

alexpott’s picture

It looks at though https://www.php.net/manual/en/sqlite3.version.php will do the trick. For me locally on PHP 7.3 this returns

Array
(
    [versionString] => 3.31.1
    [versionNumber] => 3031001
)

It's the same on PHP 7.4 for me too but my locally PHP is built against the same sqlite.

xjm’s picture

@TravisCarden is going to work on implementing #60.

catch’s picture

SQLite3::version() is a good find.

Uploading two patches. One hard-codes 3.26 in the test. The other instantiates Drupal\Database\Driver\sqlite\Install\Tasks and gets the minimum version from there.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Unfortunately this did not skip the test on MySQL :(

xjm’s picture

The second version didn't, at least. The first version didn't get run against an environment with old SQLite. I queued the first version against the additional environments.

xjm’s picture

Status: Needs work » Needs review

(NR because the first version might still work?)

catch’s picture

It's because two more test methods needed to be skipped.

I think using the version from install tasks is going to be the way to go here, so updated version for that. Tiny patch so not bothering with an interdiff.

xjm’s picture

If #66 passes -- we should probably add a a comment explaining why we have to skip the tests followed by a @todo referencing #3112396: DrupalCI environment needed with PHP 7.4 and SQLite >= 3.26.

catch’s picture

I'm not sure we should add the @todo to that issue. The problem here is that we have a test with a dependency on sqlite, that runs when we're only supposed to be running MySQL tests. So skipping it seems the right thing in general, it's just that it's happened to pass until now.

If you don't have the sqlite extension at all, the test will fail too (either because the SQLite3 class doesn't exist with the patch so you'll get a fatal error, or in HEAD because it can't install Drupal without sqlite being available).

In #3107155-56: Discuss lowering SQLite version requirement from 3.26 to 3.22 in Drupal 9 I was trying to detect whether we're in an sqlite or mysql environment, but using a Kernel test was a no go.

I'm wondering if we could rely on SIMPLETEST_DB - then we could determine whether we're trying to run MySQL or sqlite tests and skip based on that rather than the version.

catch’s picture

mondrake’s picture

xjm’s picture

Status: Needs review » Reviewed & tested by the community

This seems fine to me for the purposes of the 9.0.x beta.

alexpott’s picture

I'm not sure about #68. Quickstart command tests should be test database independent. Quickstart uses sqlite. The test database is irrelevant. #66 failed on PHP 7.4 for a known random fail - #3115000: Random fail in \Drupal\Tests\node\Functional\PagePreviewTest::testPagePreviewWithRevisions on PHP 7.4. I think #66 is the correct stopgap because the moment PHP7.4 containers are updated then it'll work.

catch’s picture

We allow sites (and by extension development environments) to run without sqlite available, so therefore our tests should also pass without it available - so we should not assume that it's always there.

#3107155-66: Discuss lowering SQLite version requirement from 3.26 to 3.22 in Drupal 9 with a class_exists() in addition to the version check might be fine though?

xjm’s picture

We allow sites (and by extension development environments) to run without sqlite available, so therefore our tests should also pass without it available - so we should not assume that it's always there.

Agreed with this either way.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

We allow sites (and by extension development environments) to run without sqlite available,

Sure but that's not our test coverage. What our test environments have installed is up to us. I don't think we're promising our tests will run successfully in any environment Drupal supports. There would be many many more fails than just this.

The InstallCommand has the following code

    if (!extension_loaded('pdo_sqlite')) {
      $io->getErrorStyle()->error('You must have the pdo_sqlite PHP extension installed. See core/INSTALL.sqlite.txt for instructions.');
      return 1;
    }

So I think you're right we can use #66 plus a @requires extension pdo_sqlite on the test classes.

catch’s picture

Status: Needs work » Needs review
FileSize
1.55 KB
1.55 KB

Re-rolled for the MySQL issue landing - conflicts in INSTALL.txt - and updating for #75.

catch’s picture

alexpott’s picture

+++ b/core/tests/Drupal/BuildTests/Framework/Tests/HtRouterTest.php
@@ -14,6 +16,11 @@ class HtRouterTest extends QuickStartTestBase {
+   $tasks = new Tasks();
+    if (version_compare(\SQLite3::version()['versionString'], $tasks->minimumVersion()) < 0) {
+      $this->markTestSkipped();
+    }

V minor nit. Indentation of $tasks.

Also tempting to add this as a constant to \Drupal\Core\Database\Driver\sqlite\Install\Tasks - like we have \Drupal\Core\Database\Driver\mysql\Install\Tasks::MYSQL_MINIMUM_VERSION. So we don't to construct an object here.

xjm’s picture

Status: Needs review » Needs work

WidgetUploadTest bit us, so requeueing.

NW for #78.

andypost’s picture

Status: Needs work » Needs review
Related issues: +#3109340: [policy] Decide whether to require json support for all database drivers for Drupal 10
FileSize
2.67 KB
3.99 KB

Fix #78 and mentioned json support as we already added the same to mysql (solves #10-13 comments)

xjm’s picture

Status: Needs review » Reviewed & tested by the community

That looks correct to me. Nice and clean. It also addresses previous feedback, fails on expected databases, and passes on the rest.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 27987af and pushed to 9.0.x. Thanks!

All looks good. The containers have already been updated so actually this is now passing and running the tests on all supported environments. But it's still a good change to make. It'd be great to fix #2905007: Allow run-tests.sh to report skipped/risky/incomplete PHPUnit-based tests so we can confirm whether a test is skipped or passed on DrupalCI but I've confirmed locally that these tests are running when the requirements are met.

  • alexpott committed 27987af on 9.0.x
    Issue #3107155 by catch, effulgentsia, andypost, xjm, daffie, Gábor...
xjm’s picture

This is missing a change record. It should also be mentioned in the release notes.

xjm’s picture

Status: Fixed » Needs work
alexpott’s picture

Issue summary: View changes
Status: Needs work » Fixed

Created change record and published it - plus added release note.

alexpott’s picture

Issue tags: -Needs change record
samuel.mortenson’s picture

Has anyone tested SQLite+PHP 7.3+Drupal 9 with Ubuntu 18.04? I can't get it to work - there's no official package for SQLite newer than 3.22, so I think the only way to get this working is to compile SQLite and PHP. IMO Drupal 9 and SQLite should work on 18.04 since it's the newest LTS release.

catch’s picture

Ubuntu 20.04 is due for release April 23rd, several weeks before Drupal 9.0.0 will come out. So we are incompatible for the next month (at least without some fiddling), but then compatible with the LTS again.

Note this is also documented in the issue summary.

samuel.mortenson’s picture

@catch This statement from the issue summary is incorrect then "However, they too can use PHP 7.3 until they're able to upgrade their OS"

Edit: Also worth noting that 18.04 is supported until Apr 2023

xjm’s picture

We could consider a contrib driver to intermediately support older versions of SQLite, like we've added for MySQL 5.6?

daffie’s picture

I have absolutely no problem with adding a fallback driver for SQLite. Drupal 9.0 does not have any code other then the setting for the minimum version for SQLite that prevents such a driver and creating one is easy. The problem is getting it to work with core #3120096: Support contrib database driver directories in a fixed location in a module and having a testbot that runs all core tests.

effulgentsia’s picture

Has anyone tested SQLite+PHP 7.3 with Ubuntu 18.04?

I thought I did, but when I tried it again just now, you're right that if you use ppa:ondrej/php to get PHP 7.3, then SQLite is at version 3.22. In other words, that package compiles against the sqlite that's on the system, rather than PHP 7.3's default of its own copy of sqlite 3.28. And when I check what's on a fresh install of Debian 10, then its PHP 7.3 has SQLite 3.27, which also means it's using the one on the system rather than PHP 7.3's copy of 3.28.

Note that TravisCI on Ubuntu 18.04 uses a PHP 7.3 build that uses PHP 7.3's default SQLite 3.28 copy, which might be related to it using phpenv to manage its PHP versions.

IMO Drupal 9 and SQLite should work on 18.04 since it's the newest LTS release.

I agree. I think we should lower the SQLite minimum in core to 3.22. I think it's fine to lower requirements between beta and RC. My rationale for thinking 3.26 was ok was based on an assumption that the most common ways to have PHP 7.3 on Ubuntu 18.04 used PHP's default of compiling with its copy of SQLite 3.28. But if the most official PHP 7.3 package for Ubuntu 18.04 compiles in SQLite 3.22, then I think that's what core should support.

It's a shame, because UPSERTs would have been nice, but I think we can continue to work around not having that.

catch’s picture

@effulgentsia is that really necessary when Ubuntu 20.04 will be out in 3-4 weeks?

amateescu’s picture

Another option would be to try and fix this upstream in ppa:ondrej/php, if anyone has experience with building debian packages :)

catch’s picture

Status: Fixed » Active

Re-opening while we discuss.

effulgentsia’s picture

Another option would be to try and fix this upstream in ppa:ondrej/php, if anyone has experience with building debian packages :)

I doubt they'd accept it. I suspect it's intentional on their part to use the sqlite that's on the system.

Has anyone tested SQLite+PHP 7.3+Drupal 9 with Ubuntu 18.04? I can't get it to work - there's no official package for SQLite newer than 3.22, so I think the only way to get this working is to compile SQLite and PHP.

@samuel.mortenson: Well, Ubuntu 20.04 (focal) is a pretty official package repository, so does this work for you:

sudo echo "deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get -y install sqlite3/focal

In my testing, it does, and does not require recompiling PHP. However, I don't know enough about Ubuntu to know if the above is a legitimate thing to ask Ubuntu users to do. Anyone know if having an Ubuntu focal repository as an additional item in sources.list on a Ubuntu bionic system will mess anything up? For example, unintentionally pulling other packages in that you don't want? I would hope that it wouldn't without you explicitly asking for "/focal" like in the last line of the above.

xjm’s picture

I'm OK with lowering the SQLite version requirement to 3.22 in principle, although that means we'll have to figure out what to do with the CI environments all over again.

xjm’s picture

Title: Raise SQLite version requirement to 3.26 in Drupal 9 » Discuss lowering SQLite version requirement from 3.26 to 3.22 in Drupal 9
samuel.mortenson’s picture

@effulgentsia After you ran that, did you confirm that the SQLite version used by PHP (using something like php -i) was correct? AFAIK you'd also need to update the SQLite PHP extension, not just the SQLite package.

Edit: Re-read your comment, re-writing mine.

effulgentsia’s picture

did you confirm that the SQLite version used by PHP (using something like php -i) was correct?

Yes. Starting from a brand new Ubuntu 18.04.3 droplet on Digital Ocean, here's what I get:

(output from commands is indented for clarity)

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt install php7.3 php7.3-common php7.3-sqlite

php --version
  PHP 7.3.16-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 20 2020 13:51:46) ( NTS )
  ...

php -i | grep "SQLite Library"
  SQLite Library => 3.22.0
  SQLite Library => 3.22.0
  
sudo echo "deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get -y install sqlite3/focal

php --version
  PHP 7.3.16-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 20 2020 13:51:46) ( NTS )
  ...
  
php -i | grep "SQLite Library"
  SQLite Library => 3.31.1
  SQLite Library => 3.31.1
AFAIK you'd also need to update the SQLite PHP extension, not just the SQLite package.

The reason I think the above works is that the whole point of compiling/building PHP to use the SQLite that's on the system rather than PHP's default bundled copy of SQLite 3.28 is, you know, to actually use the SQLite that's on the system, so I'm guessing it links to that dynamically, and does not require recompilation when what's on the system changes. Alternatively, maybe Ubuntu's package manager is smart enough to rebuild all dependents automatically, though I see no indication that it's doing that in this case.

samuel.mortenson’s picture

@effulgentsia Great, thanks for testing again - if that's documented and safe on 18.04 I don't think there's as much pressure to lower the requirement.

andypost’s picture

Maybe just update change record with this workaround?

effulgentsia’s picture

Issue summary: View changes
effulgentsia’s picture

if that's documented and safe on 18.04

I really can't vouch for its safety. I asked some co-workers, and they expressed unease about mixing Bionic and Focal repositories in sources.list. I think those commands are probably safe enough for something like DrupalCI or TravisCI, but without understanding the repercussions more, I'd be hesitant to recommend them for someone's personal computer.

@effulgentsia is that really necessary when Ubuntu 20.04 will be out in 3-4 weeks?

That's only for new installs. People already on 18.04 won't be prompted to upgrade until July. People on downstream distros like Mint and ElementaryOS will need to wait until those have upgrades.

I have absolutely no problem with adding a fallback driver for SQLite.

Thanks for offering! I think this might be an acceptable solution. The only caveat here though is that in this case, the driver has to be named 'sqlite', because that's hard-coded in InstallCommand::install(), unless we fix that to not hard-code it.

We'll also need to update the docs page for Quick Start, where instead of:

mkdir drupal && cd drupal && curl -sSL https://www.drupal.org/download-latest/tar.gz | tar -xz --strip-components=1
php ./core/scripts/drupal quick-start demo_umami

We'll need to add a line in between those two for Ubuntu 18.04 users for the command to run to get the contrib sqlite driver into their codebase.

catch’s picture

People already on 18.04 won't be prompted to upgrade until July.

That's still only a month from Drupal 9.0.0's release, for an issue that is only really going to impact local development.

heddn’s picture

Its a dev dependency. That means the community for this is already somewhat techie. I don't see any concern leaving the sqlite version as-is.

ressa’s picture

As an Ubuntu 18.04 user, I just got this error message after trying to install with Quick Start:

$ mkdir drupal && cd drupal && curl -sSL https://www.drupal.org/download-latest/tar.gz | tar -xz --strip-components=1
$ php ./core/scripts/drupal quick-start demo_umami
 0/17 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]
Installing Drupal

In install.core.inc line 964:
Resolve all issues below to continue the installation. For help configuring your database server, see the installation handbook, or contact your hosting provider.
  • The database server version 3.22.0 is less than the minimum required version 3.26.
quick-start [--langcode [LANGCODE]] [--site-name [SITE-NAME]] [--host [HOST]] [--port [PORT]] [-s|--suppress-login] [--] [<install-profile>]

$ php -v
PHP 7.3.19-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jun 12 2020 07:48:30) ( NTS )

$ php -i | grep "SQLite Library"
SQLite Library => 3.22.0
SQLite Library => 3.22.0
[...] you're right that if you use ppa:ondrej/php to get PHP 7.3, then SQLite is at version 3.22

I have upgraded to PHP 7.3 with ppa:ondrej/php, and do seem to have SQLite 3.22.

Usually, I don't install the latest LTS Ubuntu release (16.04, 18.04, 20.04, etc.) right after it is released, but wait up to half a year, for all the bugs to get fixed and a few service packs are released to fix them. So I vote for lowering the SQLite requirement to 3.22, if it is possible.

catch’s picture

Priority: Critical » Major

Downgrading from critical - this is a developer-facing issue only, and becomes less of an issue as time passes due to Ubuntu 20.04 having been out longer.

While I still don't think it's necessary to make this change, I don't think there's a particular problem if we do so.

ressa’s picture

It is of course possible for Ubuntu 18.04 users to upgrade to 20.04 at any point now, but it is technically not required until 2023:

An Ubuntu LTS is a commitment from Canonical to support and maintain a version of Ubuntu for five years.

What is an Ubuntu LTS release?

So as if @catch write "I don't think there's a particular problem if we do so" I still vote for it.

andypost’s picture

Good option is #105 - update instructions for quickstart command.

Moreover for quickstart there's official docker images!

When someone using LTS version it's really strange to see that external repositories used...
Why you're sticking to LTS when your system has non-lts components?

amateescu’s picture

ressa’s picture

@andypost: I stick to Ubuntu LTS for stability, and only upgraded to PHP 7.3 to bypass Composer issues with un-resolvable PHP version requirements (Your requirements could not be resolved [...] drupal/core 9.0.2 requires php >=7.3 -> your PHP version (7.2.32) does not satisfy that requirement.) since Composer is checking against the host PHP version, not Lando, when I initially run composer create-project drupal/recommended-project.

There is a chicken/egg situation, since I need to be in the Drupal folder, fire up lando init, and start Lando before I can use lando composer, which will use Lando's PHP version (7.3). Supposedly you can override Composer PHP version by defining it in the .composer/config.json file, but it doesn't seem to get picked up ... I also know of the --ignore-platform-reqs flag, but it doesn't seem ideal.

Like I wrote, I usually wait for the first point release of Ubuntu (in this case Ubuntu 20.04.1 LTS) before I consider upgrading, or do a fresh install, which should be released August 6th 2020.

Version: 9.0.x-dev » 9.1.x-dev

Drupal 9.0.10 was released on December 3, 2020 and is the final full bugfix release for the Drupal 9.0.x series. Drupal 9.0.x will not receive any further development aside from security fixes. Sites should update to Drupal 9.1.0 to continue receiving regular bugfixes.

Drupal-9-only bug reports should be targeted for the 9.1.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.2.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

daffie’s picture

The problem with lowering the minimal supported version of SQLite is that we cannot fix #2755831: [PP-1] Make K/V store for database faster by using upsert OR get() before set(). That issue will provide a significant perfomance increasement when writing to the key_value tables. We are now using a merge query to write to the key_value tables and I would like to change that to an upsert query. Merge queries use first a select query to determine whether to use an insert query or an update query. Upsert queries do the same in one query. Therefore for me the choose between lowering the minimum supported version of SQLite and a significant perfomance increasement when writing to the key_value tables is for me an easy choose. Making this issue as closed with a "won't fix". If you do not agree then please reopen this issue.

heddn’s picture

+1, good call here IMO. I ran into this issue once with github's action in the past few weeks, using their default ubuntu runner. But that "latest" version is about to jump from 18.04 => 20.04 soon. And many other toolings in the marketplace have also made that jump too.