Escape reserved SQL keyword when notifying expired credentials.

The CronService fails to send notifications for expired credentials
due to the SQL query containing as a column name the word 'rows',
which is a reserved keyword. This is the cause of issue #490.

This patch fixes the issue simply by quoting the offending keyword.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
This commit is contained in:
Damien Goutte-Gattat 2019-10-01 20:14:41 +01:00
parent 27cbb8271c
commit 4a1878ef0c
No known key found for this signature in database
GPG key ID: 6F7F0F91D138FC7B

View file

@ -52,7 +52,7 @@ class CronService {
foreach($expired_credentials as $credential){
$link = ''; // @TODO create direct link to credential
$sql = 'SELECT count(*) as rows from `*PREFIX*notifications` WHERE `subject`= \'credential_expired\' AND object_id=?';
$sql = 'SELECT count(*) as `rows` from `*PREFIX*notifications` WHERE `subject`= \'credential_expired\' AND object_id=?';
$id = $credential->getId();
$result = $this->db->executeQuery($sql, array($id));
$this->logger->debug($credential->getLabel() .' is expired, checking notifications!', array('app' => 'passman'));