pimcore / customer-data-framework

Customer Data Framework community bundle adds capability for management of customer data to Pimcore.
https://pimcore.com/docs/platform/Customer_Management_Framework/
Other
81 stars 93 forks source link

[Bug]: Error in SQL Syntax on GET /activities with modifiedSinceTimestamp parameter #496

Closed webdev-dp closed 1 year ago

webdev-dp commented 1 year ago

Expected behavior

When making a GET request to the /activities endpoint with the modifiedSinceTimestamp parameter, the API should return the relevant activities that have been modified since the provided timestamp. The SQL query should execute without any syntax errors, and the response should be accurate based on the specified timestamp.

Actual behavior

Currently, when making a GET request to the /activities endpoint with the modifiedSinceTimestamp parameter, the API returns a syntax error related to SQL execution. The error message displayed is as follows:

Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?) AND (1676560666)) dbal_count_tbl' at line 1

Steps to reproduce

To reproduce the issue, follow these steps:

Proposed Solution: The issue arises from incorrect parameter binding in the SQL query. To fix this issue, the suggested solution is as follows:

Update the code implementation from:

if ($ts = $params->getModifiedSinceTimestamp()) {
    $select->where('modificationDate >= ?', $ts);
}

TO:

if ($ts = $params->getModifiedSinceTimestamp()) {
      $select->where('modificationDate >= ?');
      $select->setParameters([$ts]);
}

By implementing the correct parameter binding, the SQL query will execute properly, and the error message will be resolved.

aryaantony92 commented 1 year ago

Fixed by https://github.com/pimcore/customer-data-framework/pull/498