Problem/Motivation

Because of #2296557: [policy] Require PHP 5.5 I switched the PostgreSQL/SQLite bots at *.erwanderbar.de to test on PHP-5.5. This exposes a new fail in:
Drupal\system\Tests\Database\ConnectionTest 24 passes 1 fails
I never see this fail when on PHP-5.4.

Proposed resolution

Identify and fix the fail for both, PostgreSQL and SQLite.

Remaining tasks

Write Patch

User interface changes

None

API changes

?

Data model changes

CommentFileSizeAuthor
#4 2508777-4.patch806 bytesdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

daffie’s picture

The fail has to do with the not throwing of an exception when there are multiple statements in the executing of a single query.

Fail      Other      ConnectionTest.php  132 Drupal\system\Tests\Database\ConnectionTest.php
    NO PDO exception thrown for multiple statements.
bzrudi71’s picture

daffie’s picture

Priority: Major » Critical

Because this issue is causing the SQLite database testbot to fail. And of what xjm said in #2454513-34: [meta] Make Drupal 8 work with SQLite:

And then for any SQLite regressions between now and release:
  • If a new failure is introduced by a non-critical issue, we revert the issue that introduced it as soon as possible, and ensure SQLite passes before committing an updated patch.
  • If a critical introduces an SQLite failure, we can decide whether to make fixing the SQLite failure a critical followup.
  • In general, any SQLite failure is individually critical

I am setting the priority to critical.

dawehner’s picture

Status: Active » Needs review
FileSize
806 bytes

Meh, so yes this test should be just targeted against msyql.

I was wondering though whether sqlite and pgsql has similar kind of protection, see http://stackoverflow.com/questions/19253673/pdosqlite-does-not-run-multi... for example

@daffie
Do you have any information about that?

Crell’s picture

Status: Needs review » Reviewed & tested by the community

It took me a moment to realize why this is needed, but it makes sense. The constant is defined regardless of whether the active DB is MySQL, so if using PGSQL or SQLite the constant is defined, we try to run a MySQL-specific test, and things break.

The change seems reasonable to me, given that it's a Simpletest class. We should still have someone confirm that it fixes things on SQLite/Postgres, though.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
      // Prepared statements are most effective for performance when queries
      // are recycled (used several times). However, if they are not re-used,
      // prepared statements become inefficient. Since most of Drupal's
      // prepared queries are not re-used, it should be faster to emulate
      // the preparation than to actually ready statements for re-use. If in
      // doubt, reset to FALSE and measure performance.
      \PDO::ATTR_EMULATE_PREPARES => TRUE,

Because we connect to Postgres and set this flag postgres can run mulitple queries in a single statement. See #2348931: Use native MySQL statement preparation via PDO. What is interesting about that issue is it asserts:

Postgres PDO Driver uses native statement preparation by default. PDO MySQL uses emulated prepares by default. Native prepares are much more robust against SQL injection, so should be used if at all possible.

... and it has been this way since D7.

Anyhow this fix looks good for now. Committed bf44bc0 and pushed to 8.0.x. Thanks!

  • alexpott committed bf44bc0 on 8.0.x
    Issue #2508777 by dawehner: Database Connection test fails on PHP-5.5
    
bzrudi71’s picture

Wooho! I think we need a follow up here, created #2509296: PostgreSQL: Re-think current PDO::ATTR_EMULATE_PREPARES setting.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.