We're running VarBase on PostgreSQL, and get a consistent 500 return when trying to create a custom block. Clicking on a block type on the "Add custom block" page returns a 500, with this error in the Apache logs:

[Mon Apr 24 17:18:15.526889 2017] [proxy_fcgi:error] [pid 8511:tid 139929712387840] [client 2001:4978:312:1:76de:2bff:fef7:1074:60285] AH01071: Got error 'PHP message: TypeError: Argument 1 passed to Drupal\\content_lock\\ContentLock\\ContentLock::__construct() must be an instance of Drupal\\Core\\Database\\Driver\\mysql\\Connection, instance of Drupal\\Core\\Database\\Driver\\pgsql\\Connection given, called in /home/bsafecprehs/public_html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 288 in /home/bsafecprehs/public_html/docroot/modules/contrib/content_lock/src/ContentLock/ContentLock.php on line 88 #0 /home/bsafecprehs/public_html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(288): Drupal\\content_lock\\ContentLock\\ContentLock->__construct(Object(Drupal\\Core\\Database\\Driver\\pgsql\\Connection), Object(Drupal\\Core\\Extension\\ModuleHandler), Object(Drupal\\Core\\Access\\CsrfTokenGenerator), Object(Drupal\\Core\\Datetime\\DateFormatter), Object(Drupal\\Core\\Session\\AccountProxy), Object(Drupal\\Core\\Config\\ConfigFactory))\n#1 /home/bsafecprehs/public_html/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php(177): Drupa...\n', referer: https://bsafecprehs.com/block/add?destination=/admin/structure/block/blo...

The issue looks to be passing a PostgreSQL connection where a MySQL connection is expected. Why would a MySQL connection be expected when on a site installed on PostgreSQL? This looks to be happening in the Content Lock module, but I see no database-specific settings in the Content Lock configuration.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ben Coleman created an issue. See original summary.

Rajab Natshah’s picture

Content locking module
https://www.drupal.org/project/content_lock
From the error back track you posted

Please have a look at the list of issues for Content locking
https://www.drupal.org/project/issues/content_lock?categories=All
or report the issue for them.

Ben Coleman’s picture

Project: Varbase - The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) » Content locking (anti-concurrent editing)
Version: 8.x-4.02 » 7.x-3.x-dev

Moving this to Content Locking

Ben Coleman’s picture

Version: 7.x-3.x-dev » 8.x-1.0-alpha1

Correcting version

Ben Coleman’s picture

Title: 500 return on trying to create custom block » 500 return on trying to create custom block on PostgreSQL
Ben Coleman’s picture

Looking over the code a bit, I note that the issue is that Drupal\content_lock\ContentLock defines the connection variable ($database) as a Drupal\Core\Database\Driver\mysql\Connection. I have not yet dug into this part of Drupal, but I wonder if instead using Drupal\Core\Database\Driver\mysql\Connection, it should use the abstract Drupal\Core\Database\Connection, so that the type will match whichever connection type is is use?

Ben Coleman’s picture

Title: 500 return on trying to create custom block on PostgreSQL » MySQL-specific Connection code in ContentLock
Status: Active » Needs review
FileSize
1.4 KB

This patch fixes the above issue. Instead of treating the database connection as a Drupal\Core\Database\Driver\mysql\Connection, it treats it as a Drupal\Core\Database\Connection. This works on PostgreSQL. Someone probably should verify that it still works on MySQL, but I think it should.

Ben Coleman’s picture

Issue tags: +PostgreSQL
Rajab Natshah’s picture

Good, I will use it.

Thank you Ben.
I think better to add PostgreSQL to the automated functional testing robot.

chr.fritsch’s picture

Status: Needs review » Fixed

Thanks for the patch, Ben!

Status: Fixed » Closed (fixed)

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