Problem/Motivation
In #3221065: Field check out of memory, the dynamic database query in the Field check was rewritten as a constructed static query like so:
$query = $this->database()->query("SELECT `$id`, `$column_name` FROM {$table} t");
Unfortunately, this syntax is invalid if the site is using PostgreSQL for its database and generates the following error:
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near ","
LINE 1: SELECT `entity_id`, `body_value` FROM block_content__body t
^: SELECT `entity_id`, `body_value` FROM block_content__body t; Array
(
)
in Drupal\security_review\Checks\Field->run() (line 107 of modules/contrib/security_review/src/Checks/Field.php).Steps to reproduce
- Set up a site that uses PostgreSQL and install Drupal. (If using ddev, run
ddev config --database=postgres:14to switch the database.) - Install security_review module.
- Log in as admin.
- Go to /admin/reports/security-review and click Run > Run checklist.
Proposed resolution
Revert to constructing the query dynamically so the database abstraction layer handles the syntax correctly, but do it in a way that doesn't reintroduce the memory problem in the original issue. The fix should still be able to pass the test procedure proposed in #3221065-10: Field check out of memory.
Issue fork security_review-3386865
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
muriqui commentedComment #4
magnarmartinsen commentedI can confirm that this MR also works with Postgresql 12, locally.
Comment #7
smustgrave commentedStill ran fine for me.